Browse Source

TFT 3x upscale followup (#18256)

Victor 4 years ago
parent
commit
0a49ad1ccf
No account linked to committer's email address

+ 9
- 3
Marlin/src/feature/touch/xpt2046.cpp View File

@@ -25,9 +25,15 @@
25 25
 #include "../../inc/MarlinConfig.h"
26 26
 #include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
27 27
 
28
+// Touch screen resolution independent of display resolution
29
+#define TOUCH_SCREEN_HEIGHT 240
30
+#define TOUCH_SCREEN_WIDTH 320
31
+
32
+// Coordinates in terms of touch area
28 33
 #define BUTTON_AREA_TOP 175
29 34
 #define BUTTON_AREA_BOT 234
30
-#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * 240 / (LCD_FULL_PIXEL_HEIGHT))
35
+
36
+#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
31 37
 #define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP))
32 38
 
33 39
 #ifndef TOUCH_INT_PIN
@@ -92,10 +98,10 @@ uint8_t XPT2046::read_buttons() {
92 98
          : WITHIN(x, 242, 305) ? EN_C
93 99
          : 0;
94 100
 
95
-  if (x > LCD_FULL_PIXEL_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0;
101
+  if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0;
96 102
 
97 103
   // Column and row above BUTTON_AREA_TOP
98
-  int8_t col = x * (LCD_WIDTH) / (LCD_FULL_PIXEL_WIDTH),
104
+  int8_t col = x * (LCD_WIDTH) / (TOUCH_SCREEN_WIDTH),
99 105
          row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
100 106
 
101 107
   // Send the touch to the UI (which will simulate the encoder wheel)

+ 7
- 4
Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp View File

@@ -546,12 +546,15 @@ static const uint16_t ili9341_init[] = {
546 546
   #define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
547 547
   #define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
548 548
 
549
-  #define BUTTON_Y_LO (184 / 2) * (FSMC_UPSCALE)
549
+  #define BUTTON_Y_LO (140 / 2) * (FSMC_UPSCALE) + 44 //184 2x, 254 3x
550 550
   #define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
551 551
 
552 552
   void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
553 553
     uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
554 554
 
555
+    //NOTE: the buffer are sized for max 32 lenght! If you need draw bigger things with this function, we need increase the buffer
556
+    if (length > BUTTON_SIZE_X) return;
557
+
555 558
     for (uint16_t i = 0; i < height; i++) {
556 559
       uint16_t k = 0;
557 560
       for (uint16_t j = 0; j < length; j++) {
@@ -567,7 +570,7 @@ static const uint16_t ili9341_init[] = {
567 570
           for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
568 571
             buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l];
569 572
 
570
-        LCD_IO_WriteSequence(buffer, COUNT(buffer));
573
+        LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE));
571 574
       #else
572 575
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
573 576
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
@@ -657,9 +660,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
657 660
       // bottom line and buttons
658 661
       #if ENABLED(TOUCH_BUTTONS)
659 662
 
660
-        setWindow(u8g, dev, 10, 170, 309, 171);
663
+        setWindow(u8g, dev, BUTTOND_X_LO - 4, BUTTON_Y_LO - 5, BUTTONC_X_HI + BUFSIZE + 4, BUTTON_Y_LO - 4);
661 664
         #ifdef LCD_USE_DMA_FSMC
662
-          LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 600);
665
+          LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 600 / 2 * FSMC_UPSCALE);
663 666
         #else
664 667
           memset2(buffer, TFT_DISABLED_COLOR, 150);
665 668
           for (uint8_t i = 8; i--;)

+ 1
- 0
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h View File

@@ -115,6 +115,7 @@
115 115
   #define LCD_FULL_PIXEL_WIDTH 480
116 116
   #define LCD_PIXEL_OFFSET_X 48
117 117
   #define LCD_FULL_PIXEL_HEIGHT 320
118
+  #define LCD_PIXEL_OFFSET_Y 48
118 119
 
119 120
   #define LCD_RESET_PIN                     PF11
120 121
   #define NO_LCD_REINIT

+ 1
- 0
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h View File

@@ -120,6 +120,7 @@
120 120
   #define LCD_FULL_PIXEL_WIDTH 480
121 121
   #define LCD_PIXEL_OFFSET_X 48
122 122
   #define LCD_FULL_PIXEL_HEIGHT 320
123
+  #define LCD_PIXEL_OFFSET_Y 48
123 124
 
124 125
   #define LCD_RESET_PIN                     PF11
125 126
   #define NO_LCD_REINIT

Loading…
Cancel
Save