|
@ -65,6 +65,8 @@ |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
#if ENABLED(LCD_USE_DMA_FSMC) |
|
|
#if ENABLED(LCD_USE_DMA_FSMC) |
|
|
|
|
|
extern void LCD_IO_WriteReg(uint16_t Reg); |
|
|
|
|
|
extern void LCD_IO_WriteData(uint16_t RegValue); |
|
|
extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); |
|
|
extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); |
|
|
extern void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length); |
|
|
extern void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length); |
|
|
extern void LCD_IO_WaitSequence_Async(); |
|
|
extern void LCD_IO_WaitSequence_Async(); |
|
@ -80,10 +82,6 @@ |
|
|
#define X_HI (X_LO + 2 * WIDTH - 1) |
|
|
#define X_HI (X_LO + 2 * WIDTH - 1) |
|
|
#define Y_HI (Y_LO + 2 * HEIGHT - 1) |
|
|
#define Y_HI (Y_LO + 2 * HEIGHT - 1) |
|
|
|
|
|
|
|
|
#define LCD_COLUMN 0x2A /* Colomn address register */ |
|
|
|
|
|
#define LCD_ROW 0x2B /* Row address register */ |
|
|
|
|
|
#define LCD_WRITE_RAM 0x2C |
|
|
|
|
|
|
|
|
|
|
|
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
|
|
|
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
|
|
|
|
|
|
|
|
|
#define COLOR_BLACK 0x0000 // #000000
|
|
|
#define COLOR_BLACK 0x0000 // #000000
|
|
@ -133,113 +131,254 @@ |
|
|
|
|
|
|
|
|
static uint32_t lcd_id = 0; |
|
|
static uint32_t lcd_id = 0; |
|
|
|
|
|
|
|
|
#define U8G_ESC_DATA(x) (uint8_t)(x >> 8), (uint8_t)(x & 0xFF) |
|
|
#define ST7789V_CASET 0x2A /* Column address register */ |
|
|
|
|
|
#define ST7789V_RASET 0x2B /* Row address register */ |
|
|
|
|
|
#define ST7789V_WRITE_RAM 0x2C /* Write data to GRAM */ |
|
|
|
|
|
|
|
|
static const uint8_t page_first_sequence[] = { |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(X_LO), U8G_ESC_DATA(X_HI), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(Y_LO), U8G_ESC_DATA(Y_HI), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
|
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const uint8_t clear_screen_sequence[] = { |
|
|
/* Mind the mess: with landscape screen orientation 'Horizontal' is Y and 'Vertical' is X */ |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), 0x00, 0x00, U8G_ESC_DATA(LCD_FULL_PIXEL_WIDTH), |
|
|
#define ILI9328_HASET 0x20 /* Horizontal GRAM address register (0-255) */ |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), 0x00, 0x00, U8G_ESC_DATA(LCD_FULL_PIXEL_HEIGHT), |
|
|
#define ILI9328_VASET 0x21 /* Vertical GRAM address register (0-511)*/ |
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
#define ILI9328_WRITE_RAM 0x22 /* Write data to GRAM */ |
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(TOUCH_BUTTONS) |
|
|
#define ILI9328_HASTART 0x50 /* Horizontal address start position (0-255) */ |
|
|
|
|
|
#define ILI9328_HAEND 0x51 /* Horizontal address end position (0-255) */ |
|
|
|
|
|
#define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */ |
|
|
|
|
|
#define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */ |
|
|
|
|
|
|
|
|
static const uint8_t separation_line_sequence_left[] = { |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(10), U8G_ESC_DATA(159), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(170), U8G_ESC_DATA(173), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
|
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const uint8_t separation_line_sequence_right[] = { |
|
|
static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(160), U8G_ESC_DATA(309), |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(170), U8G_ESC_DATA(173), |
|
|
LCD_IO_WriteReg(ILI9328_HASTART); |
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
LCD_IO_WriteData(Ymin); |
|
|
U8G_ESC_END |
|
|
LCD_IO_WriteReg(ILI9328_HAEND); |
|
|
}; |
|
|
LCD_IO_WriteData(Ymax); |
|
|
|
|
|
LCD_IO_WriteReg(ILI9328_VASTART); |
|
|
|
|
|
LCD_IO_WriteData(Xmin); |
|
|
|
|
|
LCD_IO_WriteReg(ILI9328_VAEND); |
|
|
|
|
|
LCD_IO_WriteData(Xmax); |
|
|
|
|
|
|
|
|
|
|
|
LCD_IO_WriteReg(ILI9328_HASET); |
|
|
|
|
|
LCD_IO_WriteData(Ymin); |
|
|
|
|
|
LCD_IO_WriteReg(ILI9328_VASET); |
|
|
|
|
|
LCD_IO_WriteData(Xmin); |
|
|
|
|
|
|
|
|
|
|
|
LCD_IO_WriteReg(ILI9328_WRITE_RAM); |
|
|
|
|
|
#else |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); |
|
|
|
|
|
|
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_HASTART); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Ymin); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_HAEND); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Ymax); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_VASTART); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Xmin); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_VAEND); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Xmax); |
|
|
|
|
|
|
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_HASET); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Ymin); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_VASET); |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&Xmin); |
|
|
|
|
|
|
|
|
|
|
|
u8g_WriteByte(u8g, dev, ILI9328_WRITE_RAM); |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static const uint8_t buttonD_sequence[] = { |
|
|
static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(14), U8G_ESC_DATA(77), |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(185), U8G_ESC_DATA(224), |
|
|
LCD_IO_WriteReg(ST7789V_CASET); |
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
LCD_IO_WriteData((Xmin >> 8) & 0xFF); |
|
|
U8G_ESC_END |
|
|
LCD_IO_WriteData(Xmin & 0xFF); |
|
|
}; |
|
|
LCD_IO_WriteData((Xmax >> 8) & 0xFF); |
|
|
|
|
|
LCD_IO_WriteData(Xmax & 0xFF); |
|
|
|
|
|
|
|
|
|
|
|
LCD_IO_WriteReg(ST7789V_RASET); |
|
|
|
|
|
LCD_IO_WriteData((Ymin >> 8) & 0xFF); |
|
|
|
|
|
LCD_IO_WriteData(Ymin & 0xFF); |
|
|
|
|
|
LCD_IO_WriteData((Ymax >> 8) & 0xFF); |
|
|
|
|
|
LCD_IO_WriteData(Ymax & 0xFF); |
|
|
|
|
|
|
|
|
|
|
|
LCD_IO_WriteReg(ST7789V_WRITE_RAM); |
|
|
|
|
|
#else |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_CASET); u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, (Xmin >> 8) & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, Xmin & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, (Xmax >> 8) & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, Xmax & 0xFF); |
|
|
|
|
|
|
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_RASET); u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, (Ymin >> 8) & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, Ymin & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, (Ymax >> 8) & 0xFF); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, Ymax & 0xFF); |
|
|
|
|
|
|
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); u8g_WriteByte(u8g, dev, ST7789V_WRITE_RAM); u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static const uint8_t buttonA_sequence[] = { |
|
|
static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {} |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(90), U8G_ESC_DATA(153), |
|
|
void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none; |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(185), U8G_ESC_DATA(224), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
|
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const uint8_t buttonB_sequence[] = { |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(166), U8G_ESC_DATA(229), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(185), U8G_ESC_DATA(224), |
|
|
|
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
|
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const uint8_t buttonC_sequence[] = { |
|
|
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(242), U8G_ESC_DATA(305), |
|
|
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), U8G_ESC_DATA(185), U8G_ESC_DATA(224), |
|
|
#define ESC_END 0xFFFF, 0x7FFF |
|
|
U8G_ESC_ADR(0), LCD_WRITE_RAM, U8G_ESC_ADR(1), |
|
|
#define ESC_FFFF 0xFFFF, 0xFFFF |
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
|
|
|
void writeEscSequence(const uint16_t *sequence) { |
|
|
|
|
|
uint16_t data; |
|
|
|
|
|
for (;;) { |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data != 0xFFFF) { |
|
|
|
|
|
LCD_IO_WriteData(data); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data == 0x7FFF) return; |
|
|
|
|
|
if (data == 0xFFFF) { |
|
|
|
|
|
LCD_IO_WriteData(data); |
|
|
|
|
|
} else if (data & 0x8000) { |
|
|
|
|
|
delay(data & 0x7FFF); |
|
|
|
|
|
} else if ((data & 0xFF00) == 0) { |
|
|
|
|
|
LCD_IO_WriteReg(data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
|
void writeEscSequence8(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) { |
|
|
|
|
|
uint16_t data; |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
for (;;) { |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data != 0xFFFF) { |
|
|
|
|
|
u8g_WriteByte(u8g, dev, data & 0xFF); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data == 0x7FFF) return; |
|
|
|
|
|
if (data == 0xFFFF) { |
|
|
|
|
|
u8g_WriteByte(u8g, dev, data & 0xFF); |
|
|
|
|
|
} else if (data & 0x8000) { |
|
|
|
|
|
delay(data & 0x7FFF); |
|
|
|
|
|
} else if ((data & 0xFF00) == 0) { |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); |
|
|
|
|
|
u8g_WriteByte(u8g, dev, data & 0xFF); |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void writeEscSequence16(u8g_t *u8g, u8g_dev_t *dev, const uint16_t *sequence) { |
|
|
|
|
|
uint16_t data; |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 0); |
|
|
|
|
|
for (;;) { |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data != 0xFFFF) { |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
data = *sequence++; |
|
|
|
|
|
if (data == 0x7FFF) return; |
|
|
|
|
|
if (data == 0xFFFF) { |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 2, (uint8_t *)&data); |
|
|
|
|
|
} else if (data & 0x8000) { |
|
|
|
|
|
delay(data & 0x7FFF); |
|
|
|
|
|
} else if ((data & 0xFF00) == 0) { |
|
|
|
|
|
u8g_WriteByte(u8g, dev, data & 0xFF); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
u8g_SetAddress(u8g, dev, 1); |
|
|
|
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
static const uint8_t st7789v_init_sequence[] = { // 0x8552 - ST7789V
|
|
|
static const uint16_t st7789v_init[] = { |
|
|
U8G_ESC_ADR(0), |
|
|
ESC_REG(0x0010), ESC_DELAY(10), |
|
|
0x10, |
|
|
ESC_REG(0x0001), ESC_DELAY(200), |
|
|
U8G_ESC_DLY(10), |
|
|
ESC_REG(0x0011), ESC_DELAY(120), |
|
|
0x01, |
|
|
ESC_REG(0x0036), 0x00A0, |
|
|
U8G_ESC_DLY(100), U8G_ESC_DLY(100), |
|
|
ESC_REG(0x003A), 0x0055, |
|
|
0x11, |
|
|
ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F, |
|
|
U8G_ESC_DLY(120), |
|
|
ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF, |
|
|
0x36, U8G_ESC_ADR(1), 0xA0, |
|
|
ESC_REG(0x00B2), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033, |
|
|
U8G_ESC_ADR(0), 0x3A, U8G_ESC_ADR(1), 0x05, |
|
|
ESC_REG(0x00B7), 0x0035, |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), 0x00, 0x00, 0x01, 0x3F, |
|
|
ESC_REG(0x00BB), 0x001F, |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), 0x00, 0x00, 0x00, 0xEF, |
|
|
ESC_REG(0x00C0), 0x002C, |
|
|
U8G_ESC_ADR(0), 0xB2, U8G_ESC_ADR(1), 0x0C, 0x0C, 0x00, 0x33, 0x33, |
|
|
ESC_REG(0x00C2), 0x0001, 0x00C3, |
|
|
U8G_ESC_ADR(0), 0xB7, U8G_ESC_ADR(1), 0x35, |
|
|
ESC_REG(0x00C4), 0x0020, |
|
|
U8G_ESC_ADR(0), 0xBB, U8G_ESC_ADR(1), 0x1F, |
|
|
ESC_REG(0x00C6), 0x000F, |
|
|
U8G_ESC_ADR(0), 0xC0, U8G_ESC_ADR(1), 0x2C, |
|
|
ESC_REG(0x00D0), 0x00A4, 0x00A1, |
|
|
U8G_ESC_ADR(0), 0xC2, U8G_ESC_ADR(1), 0x01, 0xC3, |
|
|
ESC_REG(0x0029), |
|
|
U8G_ESC_ADR(0), 0xC4, U8G_ESC_ADR(1), 0x20, |
|
|
ESC_REG(0x0011), |
|
|
U8G_ESC_ADR(0), 0xC6, U8G_ESC_ADR(1), 0x0F, |
|
|
ESC_END |
|
|
U8G_ESC_ADR(0), 0xD0, U8G_ESC_ADR(1), 0xA4, 0xA1, |
|
|
|
|
|
U8G_ESC_ADR(0), 0xE0, U8G_ESC_ADR(1), 0xD0, 0x08, 0x11, 0x08, 0x0C, 0x15, 0x39, 0x33, 0x50, 0x36, 0x13, 0x14, 0x29, 0x2D, |
|
|
|
|
|
U8G_ESC_ADR(0), 0xE1, U8G_ESC_ADR(1), 0xD0, 0x08, 0x10, 0x08, 0x06, 0x06, 0x39, 0x44, 0x51, 0x0B, 0x16, 0x14, 0x2F, 0x31, |
|
|
|
|
|
U8G_ESC_ADR(0), 0x29, 0x11, 0x35, U8G_ESC_ADR(1), 0x00, |
|
|
|
|
|
U8G_ESC_END |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
static const uint8_t ili9341_init_sequence[] = { // 0x9341 - ILI9341
|
|
|
static const uint16_t ili9328_init[] = { |
|
|
U8G_ESC_ADR(0), |
|
|
ESC_REG(0x0001), 0x0100, |
|
|
0x10, |
|
|
ESC_REG(0x0002), 0x0400, |
|
|
U8G_ESC_DLY(10), |
|
|
ESC_REG(0x0003), 0x1038, |
|
|
0x01, |
|
|
ESC_REG(0x0004), 0x0000, |
|
|
U8G_ESC_DLY(100), U8G_ESC_DLY(100), |
|
|
ESC_REG(0x0008), 0x0202, |
|
|
0x36, U8G_ESC_ADR(1), 0xE8, |
|
|
ESC_REG(0x0009), 0x0000, |
|
|
U8G_ESC_ADR(0), 0x3A, U8G_ESC_ADR(1), 0x55, |
|
|
ESC_REG(0x000A), 0x0000, |
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), 0x00, 0x00, 0x01, 0x3F, |
|
|
ESC_REG(0x000C), 0x0000, |
|
|
U8G_ESC_ADR(0), LCD_ROW, U8G_ESC_ADR(1), 0x00, 0x00, 0x00, 0xEF, |
|
|
ESC_REG(0x000D), 0x0000, |
|
|
U8G_ESC_ADR(0), 0xC5, U8G_ESC_ADR(1), 0x3E, 0x28, |
|
|
ESC_REG(0x000F), 0x0000, |
|
|
U8G_ESC_ADR(0), 0xC7, U8G_ESC_ADR(1), 0x86, |
|
|
ESC_REG(0x0010), 0x0000, |
|
|
U8G_ESC_ADR(0), 0xB1, U8G_ESC_ADR(1), 0x00, 0x18, |
|
|
ESC_REG(0x0011), 0x0007, |
|
|
U8G_ESC_ADR(0), 0xC0, U8G_ESC_ADR(1), 0x23, |
|
|
ESC_REG(0x0012), 0x0000, |
|
|
U8G_ESC_ADR(0), 0xC1, U8G_ESC_ADR(1), 0x10, |
|
|
ESC_REG(0x0013), 0x0000, |
|
|
U8G_ESC_ADR(0), 0x29, |
|
|
ESC_REG(0x0007), 0x0001, |
|
|
U8G_ESC_ADR(0), 0x11, |
|
|
ESC_DELAY(200), |
|
|
U8G_ESC_DLY(100), |
|
|
ESC_REG(0x0010), 0x1690, |
|
|
U8G_ESC_END |
|
|
ESC_REG(0x0011), 0x0227, |
|
|
|
|
|
ESC_DELAY(50), |
|
|
|
|
|
ESC_REG(0x0012), 0x008C, |
|
|
|
|
|
ESC_DELAY(50), |
|
|
|
|
|
ESC_REG(0x0013), 0x1500, |
|
|
|
|
|
ESC_REG(0x0029), 0x0004, |
|
|
|
|
|
ESC_REG(0x002B), 0x000D, |
|
|
|
|
|
ESC_DELAY(50), |
|
|
|
|
|
ESC_REG(0x0050), 0x0000, |
|
|
|
|
|
ESC_REG(0x0051), 0x00EF, |
|
|
|
|
|
ESC_REG(0x0052), 0x0000, |
|
|
|
|
|
ESC_REG(0x0053), 0x013F, |
|
|
|
|
|
ESC_REG(0x0020), 0x0000, |
|
|
|
|
|
ESC_REG(0x0021), 0x0000, |
|
|
|
|
|
ESC_REG(0x0060), 0x2700, |
|
|
|
|
|
ESC_REG(0x0061), 0x0001, |
|
|
|
|
|
ESC_REG(0x006A), 0x0000, |
|
|
|
|
|
ESC_REG(0x0080), 0x0000, |
|
|
|
|
|
ESC_REG(0x0081), 0x0000, |
|
|
|
|
|
ESC_REG(0x0082), 0x0000, |
|
|
|
|
|
ESC_REG(0x0083), 0x0000, |
|
|
|
|
|
ESC_REG(0x0084), 0x0000, |
|
|
|
|
|
ESC_REG(0x0085), 0x0000, |
|
|
|
|
|
ESC_REG(0x0090), 0x0010, |
|
|
|
|
|
ESC_REG(0x0092), 0x0600, |
|
|
|
|
|
ESC_REG(0x0007), 0x0133, |
|
|
|
|
|
ESC_REG(0x0022), |
|
|
|
|
|
ESC_END |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const uint16_t ili9341_init[] = { |
|
|
|
|
|
ESC_REG(0x0010), ESC_DELAY(10), |
|
|
|
|
|
ESC_REG(0x0001), ESC_DELAY(200), |
|
|
|
|
|
ESC_REG(0x0036), 0x00E8, |
|
|
|
|
|
ESC_REG(0x003A), 0x0055, |
|
|
|
|
|
ESC_REG(0x002A), 0x0000, 0x0000, 0x0001, 0x003F, |
|
|
|
|
|
ESC_REG(0x002B), 0x0000, 0x0000, 0x0000, 0x00EF, |
|
|
|
|
|
ESC_REG(0x00C5), 0x003E, 0x0028, |
|
|
|
|
|
ESC_REG(0x00C7), 0x0086, |
|
|
|
|
|
ESC_REG(0x00B1), 0x0000, 0x0018, |
|
|
|
|
|
ESC_REG(0x00C0), 0x0023, |
|
|
|
|
|
ESC_REG(0x00C1), 0x0010, |
|
|
|
|
|
ESC_REG(0x0029), |
|
|
|
|
|
ESC_REG(0x0011), |
|
|
|
|
|
ESC_DELAY(100), |
|
|
|
|
|
ESC_END |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#if ENABLED(TOUCH_BUTTONS) |
|
|
#if ENABLED(TOUCH_BUTTONS) |
|
@ -439,23 +578,55 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
switch (msg) { |
|
|
switch (msg) { |
|
|
case U8G_DEV_MSG_INIT: |
|
|
case U8G_DEV_MSG_INIT: |
|
|
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, &lcd_id); |
|
|
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, &lcd_id); |
|
|
if (lcd_id == 0x040404) return 0; // No connected display on FSMC
|
|
|
|
|
|
if (lcd_id == 0xFFFFFF) return 0; // No connected display on SPI
|
|
|
|
|
|
|
|
|
|
|
|
if ((lcd_id & 0xFFFF) == 0x8552) // ST7789V
|
|
|
switch(lcd_id & 0xFFFF) { |
|
|
u8g_WriteEscSeqP(u8g, dev, st7789v_init_sequence); |
|
|
case 0x8552: // ST7789V
|
|
|
if ((lcd_id & 0xFFFF) == 0x9341) // ILI9341
|
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
u8g_WriteEscSeqP(u8g, dev, ili9341_init_sequence); |
|
|
writeEscSequence(st7789v_init); |
|
|
|
|
|
#else |
|
|
|
|
|
writeEscSequence8(u8g, dev, st7789v_init); |
|
|
|
|
|
#endif |
|
|
|
|
|
setWindow = setWindow_st7789v; |
|
|
|
|
|
break; |
|
|
|
|
|
case 0x9328: // ILI9328
|
|
|
|
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
|
|
|
writeEscSequence(ili9328_init); |
|
|
|
|
|
#else |
|
|
|
|
|
writeEscSequence16(u8g, dev, ili9328_init); |
|
|
|
|
|
#endif |
|
|
|
|
|
setWindow = setWindow_ili9328; |
|
|
|
|
|
break; |
|
|
|
|
|
case 0x9341: // ILI9341
|
|
|
|
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
|
|
|
writeEscSequence(ili9341_init); |
|
|
|
|
|
#else |
|
|
|
|
|
writeEscSequence8(u8g, dev, ili9341_init); |
|
|
|
|
|
#endif |
|
|
|
|
|
setWindow = setWindow_st7789v; |
|
|
|
|
|
break; |
|
|
|
|
|
case 0x0404: // No connected display on FSMC
|
|
|
|
|
|
lcd_id = 0; |
|
|
|
|
|
return 0; |
|
|
|
|
|
case 0xFFFF: // No connected display on SPI
|
|
|
|
|
|
lcd_id = 0; |
|
|
|
|
|
return 0; |
|
|
|
|
|
default: |
|
|
|
|
|
if (lcd_id && 0xFF000000) |
|
|
|
|
|
setWindow = setWindow_st7789v; |
|
|
|
|
|
else |
|
|
|
|
|
setWindow = setWindow_ili9328; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (preinit) { |
|
|
if (preinit) { |
|
|
preinit = false; |
|
|
preinit = false; |
|
|
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); |
|
|
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Clear Screen Sequence
|
|
|
// Clear Screen
|
|
|
u8g_WriteEscSeqP(u8g, dev, clear_screen_sequence); |
|
|
setWindow(u8g, dev, 0, 0, LCD_FULL_PIXEL_WIDTH - 1, LCD_FULL_PIXEL_HEIGHT - 1); |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (320*240)); |
|
|
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT); |
|
|
#else |
|
|
#else |
|
|
memset2(buffer, TFT_MARLINBG_COLOR, 160); |
|
|
memset2(buffer, TFT_MARLINBG_COLOR, 160); |
|
|
for (uint16_t i = 0; i < 960; i++) |
|
|
for (uint16_t i = 0; i < 960; i++) |
|
@ -465,31 +636,25 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
// bottom line and buttons
|
|
|
// bottom line and buttons
|
|
|
#if ENABLED(TOUCH_BUTTONS) |
|
|
#if ENABLED(TOUCH_BUTTONS) |
|
|
|
|
|
|
|
|
|
|
|
setWindow(u8g, dev, 10, 170, 309, 171); |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
#ifdef LCD_USE_DMA_FSMC |
|
|
u8g_WriteEscSeqP(u8g, dev, separation_line_sequence_left); |
|
|
LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 600); |
|
|
LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 300); |
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, separation_line_sequence_right); |
|
|
|
|
|
LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 300); |
|
|
|
|
|
#else |
|
|
#else |
|
|
memset2(buffer, TFT_DISABLED_COLOR, 150); |
|
|
memset2(buffer, TFT_DISABLED_COLOR, 150); |
|
|
u8g_WriteEscSeqP(u8g, dev, separation_line_sequence_left); |
|
|
for (uint8_t i = 8; i--;) |
|
|
for (uint8_t i = 4; i--;) |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 150, (uint8_t *)buffer); |
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, separation_line_sequence_right); |
|
|
|
|
|
for (uint8_t i = 4; i--;) |
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 150, (uint8_t *)buffer); |
|
|
u8g_WriteSequence(u8g, dev, 150, (uint8_t *)buffer); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonD_sequence); |
|
|
setWindow(u8g, dev, 14, 185, 77, 224); |
|
|
drawImage(buttonD, u8g, dev, 32, 20, TFT_BTCANCEL_COLOR); |
|
|
drawImage(buttonD, u8g, dev, 32, 20, TFT_BTCANCEL_COLOR); |
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonA_sequence); |
|
|
setWindow(u8g, dev, 90, 185, 153, 224); |
|
|
drawImage(buttonA, u8g, dev, 32, 20, TFT_BTARROWS_COLOR); |
|
|
drawImage(buttonA, u8g, dev, 32, 20, TFT_BTARROWS_COLOR); |
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonB_sequence); |
|
|
setWindow(u8g, dev, 166, 185, 229, 224); |
|
|
drawImage(buttonB, u8g, dev, 32, 20, TFT_BTARROWS_COLOR); |
|
|
drawImage(buttonB, u8g, dev, 32, 20, TFT_BTARROWS_COLOR); |
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonC_sequence); |
|
|
setWindow(u8g, dev, 242, 185, 305, 224); |
|
|
drawImage(buttonC, u8g, dev, 32, 20, TFT_BTOKMENU_COLOR); |
|
|
drawImage(buttonC, u8g, dev, 32, 20, TFT_BTOKMENU_COLOR); |
|
|
#endif // TOUCH_BUTTONS
|
|
|
#endif // TOUCH_BUTTONS
|
|
|
|
|
|
|
|
@ -499,7 +664,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
|
|
|
|
|
|
case U8G_DEV_MSG_PAGE_FIRST: |
|
|
case U8G_DEV_MSG_PAGE_FIRST: |
|
|
page = 0; |
|
|
page = 0; |
|
|
u8g_WriteEscSeqP(u8g, dev, page_first_sequence); |
|
|
setWindow(u8g, dev, X_LO, Y_LO, X_HI, Y_HI); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case U8G_DEV_MSG_PAGE_NEXT: |
|
|
case U8G_DEV_MSG_PAGE_NEXT: |
|
|