|
|
@ -61,9 +61,9 @@ |
|
|
|
|
|
|
|
#include "HAL_LCD_com_defines.h" |
|
|
|
|
|
|
|
#define WIDTH 128 |
|
|
|
#define HEIGHT 64 |
|
|
|
#define PAGE_HEIGHT 8 |
|
|
|
#define LCD_PIXEL_WIDTH 128 |
|
|
|
#define LCD_PIXEL_HEIGHT 64 |
|
|
|
#define PAGE_HEIGHT 8 |
|
|
|
|
|
|
|
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */ |
|
|
|
static const uint8_t u8g_dev_st7920_128x64_HAL_init_seq[] PROGMEM = { |
|
|
@ -91,11 +91,11 @@ void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev) { |
|
|
|
u8g_SetAddress(u8g, dev, 0); // cmd mode
|
|
|
|
u8g_WriteByte(u8g, dev, 0x08); //display off, cursor+blink off
|
|
|
|
u8g_WriteByte(u8g, dev, 0x3E); //extended mode + GDRAM active
|
|
|
|
for (uint8_t y = 0; y < (HEIGHT) / 2; y++) { //clear GDRAM
|
|
|
|
for (uint8_t y = 0; y < (LCD_PIXEL_HEIGHT) / 2; y++) { //clear GDRAM
|
|
|
|
u8g_WriteByte(u8g, dev, 0x80 | y); //set y
|
|
|
|
u8g_WriteByte(u8g, dev, 0x80); //set x = 0
|
|
|
|
u8g_SetAddress(u8g, dev, 1); /* data mode */ |
|
|
|
for (uint8_t i = 0; i < 2 * (WIDTH) / 8; i++) //2x width clears both segments
|
|
|
|
for (uint8_t i = 0; i < 2 * (LCD_PIXEL_WIDTH) / 8; i++) //2x width clears both segments
|
|
|
|
u8g_WriteByte(u8g, dev, 0); |
|
|
|
u8g_SetAddress(u8g, dev, 0); /* cmd mode */ |
|
|
|
} |
|
|
@ -137,8 +137,8 @@ uint8_t u8g_dev_st7920_128x64_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo |
|
|
|
} |
|
|
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); /* data mode */ |
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr); |
|
|
|
ptr += WIDTH/8; |
|
|
|
u8g_WriteSequence(u8g, dev, (LCD_PIXEL_WIDTH) / 8, ptr); |
|
|
|
ptr += (LCD_PIXEL_WIDTH) / 8; |
|
|
|
y++; |
|
|
|
} |
|
|
|
u8g_SetChipSelect(u8g, dev, 0); |
|
|
@ -182,8 +182,8 @@ uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, |
|
|
|
} |
|
|
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); /* data mode */ |
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr); |
|
|
|
ptr += WIDTH/8; |
|
|
|
u8g_WriteSequence(u8g, dev, (LCD_PIXEL_WIDTH) / 8, ptr); |
|
|
|
ptr += (LCD_PIXEL_WIDTH) / 8; |
|
|
|
y++; |
|
|
|
} |
|
|
|
u8g_SetChipSelect(u8g, dev, 0); |
|
|
@ -193,14 +193,14 @@ uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, |
|
|
|
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg); |
|
|
|
} |
|
|
|
|
|
|
|
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_SW_SPI); |
|
|
|
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_sw_spi, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_SW_SPI); |
|
|
|
|
|
|
|
#define QWIDTH (WIDTH*4) |
|
|
|
#define QWIDTH ((LCD_PIXEL_WIDTH) * 4) |
|
|
|
uint8_t u8g_dev_st7920_128x64_HAL_4x_buf[QWIDTH] U8G_NOCOMMON ; |
|
|
|
u8g_pb_t u8g_dev_st7920_128x64_HAL_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_128x64_HAL_4x_buf}; |
|
|
|
u8g_pb_t u8g_dev_st7920_128x64_HAL_4x_pb = { { 32, LCD_PIXEL_HEIGHT, 0, 0, 0 }, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_HAL_4x_buf}; |
|
|
|
u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_SW_SPI }; |
|
|
|
|
|
|
|
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_HW_SPI); |
|
|
|
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_hw_spi, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_HW_SPI); |
|
|
|
u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_HW_SPI }; |
|
|
|
|
|
|
|
#if defined(U8G_HAL_LINKS) || defined(__SAM3X8E__) |
|
|
|