|
|
|
@ -91,6 +91,10 @@
|
|
|
|
|
#define COLOR_BLUE 0x21DD
|
|
|
|
|
#define COLOR_RED 0xF800
|
|
|
|
|
#define COLOR_DARK 0x0003 // Some dark color
|
|
|
|
|
#define COLOR_GREY 0x39E7
|
|
|
|
|
#define COLOR_YELLOW 0xEFC0
|
|
|
|
|
#define COLOR_ORANGE 0xFC00
|
|
|
|
|
#define COLOR_GREEN 0x77E0
|
|
|
|
|
|
|
|
|
|
#ifndef TFT_MARLINUI_COLOR
|
|
|
|
|
#define TFT_MARLINUI_COLOR COLOR_WHITE
|
|
|
|
@ -101,11 +105,14 @@
|
|
|
|
|
#ifndef TFT_DISABLED_COLOR
|
|
|
|
|
#define TFT_DISABLED_COLOR COLOR_DARK
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TFT_BTSLEFT_COLOR
|
|
|
|
|
#define TFT_BTSLEFT_COLOR COLOR_BLUE
|
|
|
|
|
#ifndef TFT_BTCANCEL_COLOR
|
|
|
|
|
#define TFT_BTCANCEL_COLOR COLOR_RED
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TFT_BTRIGHT_COLOR
|
|
|
|
|
#define TFT_BTRIGHT_COLOR COLOR_RED
|
|
|
|
|
#ifndef TFT_BTARROWS_COLOR
|
|
|
|
|
#define TFT_BTARROWS_COLOR COLOR_BLUE
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TFT_BTOKMENU_COLOR
|
|
|
|
|
#define TFT_BTOKMENU_COLOR COLOR_RED
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static uint32_t lcd_id = 0;
|
|
|
|
@ -142,22 +149,29 @@ static const uint8_t clear_screen_sequence[] = {
|
|
|
|
|
U8G_ESC_END
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const uint8_t button0_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(20), U8G_ESC_DATA(99),
|
|
|
|
|
static const uint8_t buttonD_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(14), U8G_ESC_DATA(77),
|
|
|
|
|
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 buttonA_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(90), U8G_ESC_DATA(153),
|
|
|
|
|
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 button1_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(120), U8G_ESC_DATA(199),
|
|
|
|
|
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 button2_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(220), U8G_ESC_DATA(299),
|
|
|
|
|
static const uint8_t buttonC_sequence[] = {
|
|
|
|
|
U8G_ESC_ADR(0), LCD_COLUMN, U8G_ESC_ADR(1), U8G_ESC_DATA(242), U8G_ESC_DATA(305),
|
|
|
|
|
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
|
|
|
|
@ -214,77 +228,100 @@ static const uint8_t ili9341_init_sequence[] = { // 0x9341 - ILI9341
|
|
|
|
|
|
|
|
|
|
#if ENABLED(TOUCH_BUTTONS)
|
|
|
|
|
|
|
|
|
|
static const uint8_t button0[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B01000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000001,B11110000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000011,B11111000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000111,B11111100,B00010000,B11111111,B11100001,
|
|
|
|
|
B10000000,B11100000,B00010000,B11111111,B11100001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
static const uint8_t buttonD[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00011000,B00110000,B00000001,
|
|
|
|
|
B10000000,B00001100,B01100000,B00000001,
|
|
|
|
|
B10000000,B00000110,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000011,B10000000,B00000001,
|
|
|
|
|
B10000000,B00000011,B10000000,B00000001,
|
|
|
|
|
B10000000,B00000110,B11000000,B00000001,
|
|
|
|
|
B10000000,B00001100,B01100000,B00000001,
|
|
|
|
|
B10000000,B00011000,B00110000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const uint8_t buttonA[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B01000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00000000,B00000001,
|
|
|
|
|
B10000001,B11110000,B00000000,B00000001,
|
|
|
|
|
B10000011,B11111000,B00000000,B00000001,
|
|
|
|
|
B10000111,B11111100,B00111111,B11100001,
|
|
|
|
|
B10000000,B11100000,B00111111,B11100001,
|
|
|
|
|
B10000000,B11100000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00000000,B00000001,
|
|
|
|
|
B10000000,B11100000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const uint8_t button1[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B11111111,B11110001,
|
|
|
|
|
B10000111,B11111100,B00010000,B11111111,B11110001,
|
|
|
|
|
B10000011,B11111000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000001,B11110000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B11100000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B01000000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000110,B00000001,
|
|
|
|
|
B10000000,B00000000,B00010000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
static const uint8_t buttonB[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B01100000,B00000111,B00000001,
|
|
|
|
|
B10000000,B01100000,B00000111,B00000001,
|
|
|
|
|
B10000000,B01100000,B00000111,B00000001,
|
|
|
|
|
B10000000,B01100000,B00000111,B00000001,
|
|
|
|
|
B10000111,B11111110,B00000111,B00000001,
|
|
|
|
|
B10000111,B11111110,B00111111,B11100001,
|
|
|
|
|
B10000000,B01100000,B00011111,B11000001,
|
|
|
|
|
B10000000,B01100000,B00001111,B10000001,
|
|
|
|
|
B10000000,B01100000,B00000111,B00000001,
|
|
|
|
|
B10000000,B01100000,B00000010,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const uint8_t button2[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000001,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B01000001,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B11000001,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000001,B11111111,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000011,B11111111,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000001,B11111111,B11000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B11000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B01000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111111,B11111110,
|
|
|
|
|
static const uint8_t buttonC[] = {
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00011100,B00000001,
|
|
|
|
|
B10000000,B00000100,B00011100,B00000001,
|
|
|
|
|
B10000000,B00001100,B00011100,B00000001,
|
|
|
|
|
B10000000,B00011111,B11111100,B00000001,
|
|
|
|
|
B10000000,B00111111,B11111100,B00000001,
|
|
|
|
|
B10000000,B00011111,B11111100,B00000001,
|
|
|
|
|
B10000000,B00001100,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000100,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B10000000,B00000000,B00000000,B00000001,
|
|
|
|
|
B01111111,B11111111,B11111111,B11111110,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
|
|
|
|
|
uint16_t buffer[160];
|
|
|
|
|
uint16_t buffer[128];
|
|
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < height; i++) {
|
|
|
|
|
uint16_t k = 0;
|
|
|
|
@ -333,7 +370,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
|
|
|
|
uint16_t* buffer = &bufferA[0];
|
|
|
|
|
bool allow_async = true;
|
|
|
|
|
#else
|
|
|
|
|
uint16_t buffer[256]; // 16-bit RGB 565 pixel line buffer
|
|
|
|
|
uint16_t buffer[WIDTH*2]; // 16-bit RGB 565 pixel line buffer
|
|
|
|
|
#endif
|
|
|
|
|
switch (msg) {
|
|
|
|
|
case U8G_DEV_MSG_INIT:
|
|
|
|
@ -351,6 +388,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
|
|
|
|
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear Screen Sequence
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, clear_screen_sequence);
|
|
|
|
|
#ifdef LCD_USE_DMA_FSMC
|
|
|
|
|
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (320*240));
|
|
|
|
@ -378,15 +416,17 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 150, (uint8_t *)buffer);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, button0_sequence);
|
|
|
|
|
drawImage(button0, u8g, dev, 40, 20, TFT_BTSLEFT_COLOR);
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonD_sequence);
|
|
|
|
|
drawImage(buttonD, u8g, dev, 32, 20, TFT_BTCANCEL_COLOR);
|
|
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, button1_sequence);
|
|
|
|
|
drawImage(button1, u8g, dev, 40, 20, TFT_BTSLEFT_COLOR);
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonA_sequence);
|
|
|
|
|
drawImage(buttonA, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
|
|
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, button2_sequence);
|
|
|
|
|
drawImage(button2, u8g, dev, 40, 20, TFT_BTRIGHT_COLOR);
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonB_sequence);
|
|
|
|
|
drawImage(buttonB, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
|
|
|
|
|
|
|
|
|
|
u8g_WriteEscSeqP(u8g, dev, buttonC_sequence);
|
|
|
|
|
drawImage(buttonC, u8g, dev, 32, 20, TFT_BTOKMENU_COLOR);
|
|
|
|
|
#endif // TOUCH_BUTTONS
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
@ -399,9 +439,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case U8G_DEV_MSG_PAGE_NEXT:
|
|
|
|
|
if (++page > 8) return 1;
|
|
|
|
|
if (++page > (HEIGHT / PAGE_HEIGHT)) return 1;
|
|
|
|
|
|
|
|
|
|
for (uint8_t y = 0; y < 8; y++) {
|
|
|
|
|
for (uint8_t y = 0; y < PAGE_HEIGHT; y++) {
|
|
|
|
|
uint32_t k = 0;
|
|
|
|
|
#ifdef LCD_USE_DMA_FSMC
|
|
|
|
|
buffer = (y & 1) ? bufferB : bufferA;
|
|
|
|
@ -423,11 +463,12 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
|
|
|
|
else
|
|
|
|
|
LCD_IO_WriteSequence(buffer, 512);
|
|
|
|
|
#else
|
|
|
|
|
uint8_t* bufptr = (uint8_t*) buffer;
|
|
|
|
|
for (uint8_t i = 2; i--;) {
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 128, (uint8_t*)buffer);
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 128, (uint8_t*)&(buffer[64]));
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 128, (uint8_t*)&(buffer[128]));
|
|
|
|
|
u8g_WriteSequence(u8g, dev, 128, (uint8_t*)&(buffer[192]));
|
|
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[0]);
|
|
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[WIDTH]);
|
|
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[WIDTH*2]);
|
|
|
|
|
u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[WIDTH*3]);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|