Browse Source

TFT 3x upscale followup (#18256)

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

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

25
 #include "../../inc/MarlinConfig.h"
25
 #include "../../inc/MarlinConfig.h"
26
 #include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
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
 #define BUTTON_AREA_TOP 175
33
 #define BUTTON_AREA_TOP 175
29
 #define BUTTON_AREA_BOT 234
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
 #define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP))
37
 #define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP))
32
 
38
 
33
 #ifndef TOUCH_INT_PIN
39
 #ifndef TOUCH_INT_PIN
92
          : WITHIN(x, 242, 305) ? EN_C
98
          : WITHIN(x, 242, 305) ? EN_C
93
          : 0;
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
   // Column and row above BUTTON_AREA_TOP
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
          row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
105
          row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
100
 
106
 
101
   // Send the touch to the UI (which will simulate the encoder wheel)
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
   #define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
546
   #define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
547
   #define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
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
   #define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
550
   #define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
551
 
551
 
552
   void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
552
   void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
553
     uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
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
     for (uint16_t i = 0; i < height; i++) {
558
     for (uint16_t i = 0; i < height; i++) {
556
       uint16_t k = 0;
559
       uint16_t k = 0;
557
       for (uint16_t j = 0; j < length; j++) {
560
       for (uint16_t j = 0; j < length; j++) {
567
           for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
570
           for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
568
             buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l];
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
       #else
574
       #else
572
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
575
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
573
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
576
         u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
657
       // bottom line and buttons
660
       // bottom line and buttons
658
       #if ENABLED(TOUCH_BUTTONS)
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
         #ifdef LCD_USE_DMA_FSMC
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
         #else
666
         #else
664
           memset2(buffer, TFT_DISABLED_COLOR, 150);
667
           memset2(buffer, TFT_DISABLED_COLOR, 150);
665
           for (uint8_t i = 8; i--;)
668
           for (uint8_t i = 8; i--;)

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

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

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

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

Loading…
Cancel
Save