Browse Source

Support 4.3" (480x272) Color UI display (#20334)

Victor Oliveira 4 years ago
parent
commit
41e4124af9
No account linked to committer's email address

+ 1
- 0
Marlin/Configuration.h View File

2438
   //#define TOUCH_CALIBRATION_Y -8981
2438
   //#define TOUCH_CALIBRATION_Y -8981
2439
   //#define TOUCH_OFFSET_X        -43
2439
   //#define TOUCH_OFFSET_X        -43
2440
   //#define TOUCH_OFFSET_Y        257
2440
   //#define TOUCH_OFFSET_Y        257
2441
+  //#define TOUCH_ORIENTATION   TOUCH_LANDSCAPE
2441
 
2442
 
2442
   #if ENABLED(TFT_COLOR_UI)
2443
   #if ENABLED(TFT_COLOR_UI)
2443
     //#define SINGLE_TOUCH_NAVIGATION
2444
     //#define SINGLE_TOUCH_NAVIGATION

+ 9
- 0
Marlin/src/inc/Conditionals_LCD.h View File

1169
   #elif ENABLED(TFT_INTERFACE_FSMC)
1169
   #elif ENABLED(TFT_INTERFACE_FSMC)
1170
     #define TFT_480x320
1170
     #define TFT_480x320
1171
   #endif
1171
   #endif
1172
+#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 272
1173
+  #if ENABLED(TFT_INTERFACE_SPI)
1174
+    #define TFT_480x272_SPI
1175
+  #elif ENABLED(TFT_INTERFACE_FSMC)
1176
+    #define TFT_480x272
1177
+  #endif
1172
 #endif
1178
 #endif
1173
 
1179
 
1174
 // Fewer lines with touch buttons on-screen
1180
 // Fewer lines with touch buttons on-screen
1178
 #elif EITHER(TFT_480x320, TFT_480x320_SPI)
1184
 #elif EITHER(TFT_480x320, TFT_480x320_SPI)
1179
   #define HAS_UI_480x320 1
1185
   #define HAS_UI_480x320 1
1180
   #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
1186
   #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
1187
+#elif EITHER(TFT_480x272, TFT_480x272_SPI)
1188
+  #define HAS_UI_480x272 1
1189
+  #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
1181
 #endif
1190
 #endif
1182
 
1191
 
1183
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
1192
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'

+ 3
- 0
Marlin/src/lcd/tft/tft.h View File

43
 #elif HAS_UI_480x320
43
 #elif HAS_UI_480x320
44
   #define TFT_WIDTH         480
44
   #define TFT_WIDTH         480
45
   #define TFT_HEIGHT        320
45
   #define TFT_HEIGHT        320
46
+#elif HAS_UI_480x272
47
+  #define TFT_WIDTH         480
48
+  #define TFT_HEIGHT        272
46
 #else
49
 #else
47
   #error "Unsupported display resolution!"
50
   #error "Unsupported display resolution!"
48
 #endif
51
 #endif

+ 36
- 31
Marlin/src/lcd/tft/ui_480x320.cpp View File

22
 
22
 
23
 #include "../../inc/MarlinConfigPre.h"
23
 #include "../../inc/MarlinConfigPre.h"
24
 
24
 
25
-#if HAS_UI_480x320
25
+#if HAS_UI_480x320 || HAS_UI_480x272
26
 
26
 
27
 #include "ui_480x320.h"
27
 #include "ui_480x320.h"
28
 
28
 
56
 void MarlinUI::tft_idle() {
56
 void MarlinUI::tft_idle() {
57
   #if ENABLED(TOUCH_SCREEN)
57
   #if ENABLED(TOUCH_SCREEN)
58
     if (draw_menu_navigation) {
58
     if (draw_menu_navigation) {
59
-      add_control(104, 286, PAGE_UP, imgPageUp, encoderTopLine > 0);
60
-      add_control(344, 286, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
61
-      add_control(224, 286, BACK, imgBack);
59
+      add_control(104, TFT_HEIGHT - 34, PAGE_UP, imgPageUp, encoderTopLine > 0);
60
+      add_control(344, TFT_HEIGHT - 34, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
61
+      add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
62
       draw_menu_navigation = false;
62
       draw_menu_navigation = false;
63
     }
63
     }
64
   #endif
64
   #endif
259
     }
259
     }
260
   }
260
   }
261
 
261
 
262
+  y += TERN(HAS_UI_480x272, 118, 128);
263
+
262
   // coordinates
264
   // coordinates
263
-  tft.canvas(4, 132, TFT_WIDTH - 8, 34);
265
+  tft.canvas(4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT);
264
   tft.set_background(COLOR_BACKGROUND);
266
   tft.set_background(COLOR_BACKGROUND);
265
-  tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);
267
+  tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
266
 
268
 
267
   tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
269
   tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
268
   tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
270
   tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
290
     offset -= tft_string.width();
292
     offset -= tft_string.width();
291
   }
293
   }
292
   tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
294
   tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
293
-  TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));
295
+  TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
294
 
296
 
297
+  y += TERN(HAS_UI_480x272, 38, 48);
295
   // feed rate
298
   // feed rate
296
-  tft.canvas(96, 180, 100, 32);
299
+  tft.canvas(96, y, 100, 32);
297
   tft.set_background(COLOR_BACKGROUND);
300
   tft.set_background(COLOR_BACKGROUND);
298
   uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
301
   uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
299
   tft.add_image(0, 0, imgFeedRate, color);
302
   tft.add_image(0, 0, imgFeedRate, color);
303
   TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
306
   TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
304
 
307
 
305
   // flow rate
308
   // flow rate
306
-  tft.canvas(284, 180, 100, 32);
309
+  tft.canvas(284, y, 100, 32);
307
   tft.set_background(COLOR_BACKGROUND);
310
   tft.set_background(COLOR_BACKGROUND);
308
   color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
311
   color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
309
   tft.add_image(0, 0, imgFlowRate, color);
312
   tft.add_image(0, 0, imgFlowRate, color);
312
   tft.add_text(36, 1, color , tft_string);
315
   tft.add_text(36, 1, color , tft_string);
313
   TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
316
   TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
314
 
317
 
318
+  #if ENABLED(TOUCH_SCREEN)
319
+    add_control(404, y, menu_main, imgSettings);
320
+    TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
321
+  #endif
322
+
323
+  y += TERN(HAS_UI_480x272, 36, 44);
315
   // print duration
324
   // print duration
316
   char buffer[14];
325
   char buffer[14];
317
   duration_t elapsed = print_job_timer.duration();
326
   duration_t elapsed = print_job_timer.duration();
318
   elapsed.toDigital(buffer);
327
   elapsed.toDigital(buffer);
319
 
328
 
320
-  tft.canvas((TFT_WIDTH - 128) / 2, 224, 128, 29);
329
+  tft.canvas((TFT_WIDTH - 128) / 2, y, 128, 29);
321
   tft.set_background(COLOR_BACKGROUND);
330
   tft.set_background(COLOR_BACKGROUND);
322
   tft_string.set(buffer);
331
   tft_string.set(buffer);
323
   tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
332
   tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
324
 
333
 
334
+  y += TERN(HAS_UI_480x272, 28, 36);
325
   // progress bar
335
   // progress bar
326
   const uint8_t progress = ui.get_progress_percent();
336
   const uint8_t progress = ui.get_progress_percent();
327
-  tft.canvas(4, 260, TFT_WIDTH - 8, 9);
337
+  tft.canvas(4, y, TFT_WIDTH - 8, 9);
328
   tft.set_background(COLOR_PROGRESS_BG);
338
   tft.set_background(COLOR_PROGRESS_BG);
329
   tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
339
   tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
330
   if (progress)
340
   if (progress)
331
     tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
341
     tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
332
 
342
 
343
+  y += 20;
333
   // status message
344
   // status message
334
-  tft.canvas(0, 280, TFT_WIDTH, 29);
345
+  tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT - 5);
335
   tft.set_background(COLOR_BACKGROUND);
346
   tft.set_background(COLOR_BACKGROUND);
336
   tft_string.set(status_message);
347
   tft_string.set(status_message);
337
   tft_string.trim();
348
   tft_string.trim();
338
   tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
349
   tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
339
-
340
-
341
-  #if ENABLED(TOUCH_SCREEN)
342
-    add_control(404, 180, menu_main, imgSettings);
343
-    TERN_(SDSUPPORT, add_control(12, 180, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
344
-  #endif
345
 }
350
 }
346
 
351
 
347
 // Draw a static item with no left-right margin required. Centered by default.
352
 // Draw a static item with no left-right margin required. Centered by default.
450
 
455
 
451
 void TFT::draw_edit_screen_buttons() {
456
 void TFT::draw_edit_screen_buttons() {
452
   #if ENABLED(TOUCH_SCREEN)
457
   #if ENABLED(TOUCH_SCREEN)
453
-    add_control(64, 256, DECREASE, imgDecrease);
454
-    add_control(352, 256, INCREASE, imgIncrease);
455
-    add_control(208, 256, CLICK, imgConfirm);
458
+    add_control(64, TFT_HEIGHT - 64, DECREASE, imgDecrease);
459
+    add_control(352, TFT_HEIGHT - 64, INCREASE, imgIncrease);
460
+    add_control(208, TFT_HEIGHT - 64, CLICK, imgConfirm);
456
   #endif
461
   #endif
457
 }
462
 }
458
 
463
 
481
     tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
486
     tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
482
   }
487
   }
483
   #if ENABLED(TOUCH_SCREEN)
488
   #if ENABLED(TOUCH_SCREEN)
484
-    add_control(88, 256, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
485
-    add_control(328, 256, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
489
+    add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
490
+    add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
486
   #endif
491
   #endif
487
 }
492
 }
488
 
493
 
541
     const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
546
     const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
542
                    lpos = pos.asLogical();
547
                    lpos = pos.asLogical();
543
 
548
 
544
-    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 - 43, 120, 43);
549
+    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
545
     tft.set_background(COLOR_BACKGROUND);
550
     tft.set_background(COLOR_BACKGROUND);
546
     tft_string.set(X_LBL);
551
     tft_string.set(X_LBL);
547
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
552
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
549
     tft_string.trim();
554
     tft_string.trim();
550
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
555
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
551
 
556
 
552
-    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 120, 43);
557
+    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 120, MENU_ITEM_HEIGHT);
553
     tft.set_background(COLOR_BACKGROUND);
558
     tft.set_background(COLOR_BACKGROUND);
554
     tft_string.set(Y_LBL);
559
     tft_string.set(Y_LBL);
555
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
560
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
557
     tft_string.trim();
562
     tft_string.trim();
558
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
563
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
559
 
564
 
560
-    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 + 43, 120, 43);
565
+    tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
561
     tft.set_background(COLOR_BACKGROUND);
566
     tft.set_background(COLOR_BACKGROUND);
562
     tft_string.set(Z_LBL);
567
     tft_string.set(Z_LBL);
563
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
568
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
566
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
571
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
567
 
572
 
568
 
573
 
569
-    tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - 48) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, 48, 43);
574
+    tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - 48) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, 48, MENU_ITEM_HEIGHT);
570
     tft.set_background(COLOR_BACKGROUND);
575
     tft.set_background(COLOR_BACKGROUND);
571
     tft_string.set(ui8tostr3rj(x_plot));
576
     tft_string.set(ui8tostr3rj(x_plot));
572
     tft_string.trim();
577
     tft_string.trim();
573
     tft.add_text(tft_string.center(48), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
578
     tft.add_text(tft_string.center(48), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
574
 
579
 
575
-    tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 48, 43);
580
+    tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 48, MENU_ITEM_HEIGHT);
576
     tft.set_background(COLOR_BACKGROUND);
581
     tft.set_background(COLOR_BACKGROUND);
577
     tft_string.set(ui8tostr3rj(y_plot));
582
     tft_string.set(ui8tostr3rj(y_plot));
578
     tft_string.trim();
583
     tft_string.trim();
586
       add_control(GRID_OFFSET_X + CONTROL_OFFSET,                   GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET,      UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
591
       add_control(GRID_OFFSET_X + CONTROL_OFFSET,                   GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET,      UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
587
       add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET,      UBL,   ENCODER_STEPS_PER_MENU_ITEM, imgRight);
592
       add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET,      UBL,   ENCODER_STEPS_PER_MENU_ITEM, imgRight);
588
       add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
593
       add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
589
-      add_control(224, 286, BACK, imgBack);
594
+      add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
590
     #endif
595
     #endif
591
   }
596
   }
592
 #endif // AUTO_BED_LEVELING_UBL
597
 #endif // AUTO_BED_LEVELING_UBL
644
 #endif // TOUCH_SCREEN_CALIBRATION
649
 #endif // TOUCH_SCREEN_CALIBRATION
645
 
650
 
646
 void menu_line(const uint8_t row, uint16_t color) {
651
 void menu_line(const uint8_t row, uint16_t color) {
647
-  tft.canvas(0, 4 + 45 * row, TFT_WIDTH, 43);
652
+  tft.canvas(0, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH, MENU_ITEM_HEIGHT);
648
   tft.set_background(color);
653
   tft.set_background(color);
649
 }
654
 }
650
 
655
 
661
   menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
666
   menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
662
   #if ENABLED(TOUCH_SCREEN)
667
   #if ENABLED(TOUCH_SCREEN)
663
     const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? MENU_CLICK : MENU_ITEM;
668
     const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? MENU_CLICK : MENU_ITEM;
664
-    touch.add_control(tct, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row);
669
+    touch.add_control(tct, 0, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH, MENU_ITEM_HEIGHT, encoderTopLine + row);
665
   #endif
670
   #endif
666
 }
671
 }
667
 
672
 

+ 11
- 2
Marlin/src/lcd/tft/ui_480x320.h View File

38
 void menu_line(const uint8_t row, uint16_t color = COLOR_BACKGROUND);
38
 void menu_line(const uint8_t row, uint16_t color = COLOR_BACKGROUND);
39
 void menu_item(const uint8_t row, bool sel = false);
39
 void menu_item(const uint8_t row, bool sel = false);
40
 
40
 
41
-#define MENU_FONT_NAME    Helvetica18
42
-#define SYMBOLS_FONT_NAME Helvetica18_symbols
41
+#if HAS_UI_480x320
42
+  #define MENU_FONT_NAME    Helvetica18
43
+  #define SYMBOLS_FONT_NAME Helvetica18_symbols
44
+  #define MENU_ITEM_HEIGHT  43
45
+  #define FONT_LINE_HEIGHT  34
46
+#elif HAS_UI_480x272
47
+  #define MENU_FONT_NAME    Helvetica14
48
+  #define SYMBOLS_FONT_NAME Helvetica14_symbols
49
+  #define MENU_ITEM_HEIGHT  36
50
+  #define FONT_LINE_HEIGHT  24
51
+#endif
43
 
52
 
44
 #define ABSOLUTE_ZERO     -273.15
53
 #define ABSOLUTE_ZERO     -273.15
45
 
54
 

+ 3
- 3
Marlin/src/lcd/tft_io/ssd1963.h View File

39
                             IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    SSD1963_MADCTL_FH) | \
39
                             IF_0((TFT_ORIENTATION) & TFT_INVERT_X,    SSD1963_MADCTL_FH) | \
40
                             IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    SSD1963_MADCTL_FV)
40
                             IF_0((TFT_ORIENTATION) & TFT_INVERT_Y,    SSD1963_MADCTL_FV)
41
 
41
 
42
-#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
43
-  #define SSD1963_COLOR SSD1963_MADCTL_BGR
44
-#elif TFT_COLOR == TFT_COLOR_RGB
42
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
45
   #define SSD1963_COLOR SSD1963_MADCTL_RGB
43
   #define SSD1963_COLOR SSD1963_MADCTL_RGB
44
+#elif TFT_COLOR == TFT_COLOR_BGR
45
+  #define SSD1963_COLOR  SSD1963_MADCTL_BGR
46
 #endif
46
 #endif
47
 
47
 
48
 #define SSD1963_MADCTL_DATA       (SSD1963_ORIENTATION) | (SSD1963_COLOR)
48
 #define SSD1963_MADCTL_DATA       (SSD1963_ORIENTATION) | (SSD1963_COLOR)

+ 34
- 11
Marlin/src/lcd/tft_io/touch_calibration.cpp View File

23
 
23
 
24
 #include "touch_calibration.h"
24
 #include "touch_calibration.h"
25
 
25
 
26
+#define TOUCH_CALIBRATION_MAX_RETRIES 5
27
+
28
+#define DEBUG_OUT ENABLED(DEBUG_TOUCH_CALIBRATION)
29
+#include "../../core/debug_out.h"
30
+
26
 TouchCalibration touch_calibration;
31
 TouchCalibration touch_calibration;
27
 
32
 
28
 touch_calibration_t TouchCalibration::calibration;
33
 touch_calibration_t TouchCalibration::calibration;
31
 uint8_t TouchCalibration::failed_count;
36
 uint8_t TouchCalibration::failed_count;
32
 
37
 
33
 void TouchCalibration::validate_calibration() {
38
 void TouchCalibration::validate_calibration() {
34
-  const bool landscape = validate_precision_x(0, 1) && validate_precision_x(2, 3) && validate_precision_y(0, 2) && validate_precision_y(1, 3);
35
-  const bool portrait = validate_precision_y(0, 1) && validate_precision_y(2, 3) && validate_precision_x(0, 2) && validate_precision_x(1, 3);
39
+  #define VALIDATE_PRECISION(XY, A, B) validate_precision_##XY(CALIBRATION_##A, CALIBRATION_##B)
40
+  const bool landscape = VALIDATE_PRECISION(x, TOP_LEFT, BOTTOM_LEFT)
41
+                      && VALIDATE_PRECISION(x, TOP_RIGHT, BOTTOM_RIGHT)
42
+                      && VALIDATE_PRECISION(y, TOP_LEFT, TOP_RIGHT)
43
+                      && VALIDATE_PRECISION(y, BOTTOM_LEFT, BOTTOM_RIGHT);
44
+  const bool portrait = VALIDATE_PRECISION(y, TOP_LEFT, BOTTOM_LEFT)
45
+                     && VALIDATE_PRECISION(y, TOP_RIGHT, BOTTOM_RIGHT)
46
+                     && VALIDATE_PRECISION(x, TOP_LEFT, TOP_RIGHT)
47
+                     && VALIDATE_PRECISION(x, BOTTOM_LEFT, BOTTOM_RIGHT);
48
+  #undef VALIDATE_PRECISION
36
 
49
 
37
-  if (landscape || portrait) {
50
+  #define CAL_PTS(N) calibration_points[CALIBRATION_##N]
51
+  if (landscape) {
52
+    calibration_state = CALIBRATION_SUCCESS;
53
+    calibration.x = ((CAL_PTS(TOP_RIGHT).x - CAL_PTS(TOP_LEFT).x) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_x + CAL_PTS(TOP_RIGHT).raw_x - CAL_PTS(BOTTOM_LEFT).raw_x - CAL_PTS(TOP_LEFT).raw_x);
54
+    calibration.y = ((CAL_PTS(BOTTOM_LEFT).y - CAL_PTS(TOP_LEFT).y) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_y - CAL_PTS(TOP_RIGHT).raw_y + CAL_PTS(BOTTOM_LEFT).raw_y - CAL_PTS(TOP_LEFT).raw_y);
55
+    calibration.offset_x = CAL_PTS(TOP_LEFT).x - int16_t(((CAL_PTS(TOP_LEFT).raw_x + CAL_PTS(BOTTOM_LEFT).raw_x) * calibration.x) >> 17);
56
+    calibration.offset_y = CAL_PTS(TOP_LEFT).y - int16_t(((CAL_PTS(TOP_LEFT).raw_y + CAL_PTS(TOP_RIGHT).raw_y) * calibration.y) >> 17);
57
+    calibration.orientation = TOUCH_LANDSCAPE;
58
+  }
59
+  else if (portrait) {
38
     calibration_state = CALIBRATION_SUCCESS;
60
     calibration_state = CALIBRATION_SUCCESS;
39
-    calibration.x = ((calibration_points[2].x - calibration_points[0].x) << 17) / (calibration_points[3].raw_x + calibration_points[2].raw_x - calibration_points[1].raw_x - calibration_points[0].raw_x);
40
-    calibration.y = ((calibration_points[1].y - calibration_points[0].y) << 17) / (calibration_points[3].raw_y - calibration_points[2].raw_y + calibration_points[1].raw_y - calibration_points[0].raw_y);
41
-    calibration.offset_x = calibration_points[0].x - int16_t(((calibration_points[0].raw_x + calibration_points[1].raw_x) * calibration.x) >> 17);
42
-    calibration.offset_y = calibration_points[0].y - int16_t(((calibration_points[0].raw_y + calibration_points[2].raw_y) * calibration.y) >> 17);
43
-    calibration.orientation = landscape ? TOUCH_LANDSCAPE : TOUCH_PORTRAIT;
61
+    calibration.x = ((CAL_PTS(TOP_RIGHT).x - CAL_PTS(TOP_LEFT).x) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_y + CAL_PTS(TOP_RIGHT).raw_y - CAL_PTS(BOTTOM_LEFT).raw_y - CAL_PTS(TOP_LEFT).raw_y);
62
+    calibration.y = ((CAL_PTS(BOTTOM_LEFT).y - CAL_PTS(TOP_LEFT).y) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_x - CAL_PTS(TOP_RIGHT).raw_x + CAL_PTS(BOTTOM_LEFT).raw_x - CAL_PTS(TOP_LEFT).raw_x);
63
+    calibration.offset_x = CAL_PTS(TOP_LEFT).x - int16_t(((CAL_PTS(TOP_LEFT).raw_y + CAL_PTS(BOTTOM_LEFT).raw_y) * calibration.x) >> 17);
64
+    calibration.offset_y = CAL_PTS(TOP_LEFT).y - int16_t(((CAL_PTS(TOP_LEFT).raw_x + CAL_PTS(TOP_RIGHT).raw_x) * calibration.y) >> 17);
65
+    calibration.orientation = TOUCH_PORTRAIT;
44
   }
66
   }
45
   else {
67
   else {
46
     calibration_state = CALIBRATION_FAIL;
68
     calibration_state = CALIBRATION_FAIL;
47
     calibration_reset();
69
     calibration_reset();
48
-    // Retry up to 5 times before reporting the failure
49
-    if (need_calibration() && failed_count++ < 5) calibration_state = CALIBRATION_TOP_LEFT;
70
+    if (need_calibration() && failed_count++ < TOUCH_CALIBRATION_MAX_RETRIES) calibration_state = CALIBRATION_TOP_LEFT;
50
   }
71
   }
72
+  #undef CAL_PTS
51
 
73
 
52
   if (calibration_state == CALIBRATION_SUCCESS) {
74
   if (calibration_state == CALIBRATION_SUCCESS) {
53
     SERIAL_ECHOLNPGM("Touch screen calibration completed");
75
     SERIAL_ECHOLNPGM("Touch screen calibration completed");
55
     SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_Y ", calibration.y);
77
     SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_Y ", calibration.y);
56
     SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x);
78
     SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x);
57
     SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y);
79
     SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y);
58
-    SERIAL_ECHOPGM("TOUCH_ORIENTATION "); if (calibration.orientation == TOUCH_LANDSCAPE) SERIAL_ECHOLNPGM("TOUCH_LANDSCAPE"); else SERIAL_ECHOLNPGM("TOUCH_PORTRAIT");
80
+    SERIAL_ECHO_TERNARY(calibration.orientation == TOUCH_LANDSCAPE, "TOUCH_ORIENTATION ", "TOUCH_LANDSCAPE", "TOUCH_PORTRAIT", "\n");
59
   }
81
   }
60
 }
82
 }
61
 
83
 
68
   if (calibration_state < CALIBRATION_SUCCESS) {
90
   if (calibration_state < CALIBRATION_SUCCESS) {
69
     calibration_points[calibration_state].raw_x = x;
91
     calibration_points[calibration_state].raw_x = x;
70
     calibration_points[calibration_state].raw_y = y;
92
     calibration_points[calibration_state].raw_y = y;
93
+    DEBUG_ECHOLNPAIR("TouchCalibration - State: ", calibration_state, ", x: ", calibration_points[calibration_state].x, ", raw_x: ", x, ", y: ", calibration_points[calibration_state].y, ", raw_y: ", y);
71
   }
94
   }
72
 
95
 
73
   switch (calibration_state) {
96
   switch (calibration_state) {

+ 0
- 5
Marlin/src/pins/stm32f4/pins_ANET_ET4.h View File

155
   #define TOUCH_INT_PIN                     PB1
155
   #define TOUCH_INT_PIN                     PB1
156
 #endif
156
 #endif
157
 
157
 
158
-// Touchscreen calibration does not work correctly with ANET_ET5_TFT35 or ANET_ET4_TFT28
159
-#if ENABLED(TOUCH_SCREEN_CALIBRATION)
160
-  #undef TOUCH_SCREEN_CALIBRATION
161
-#endif
162
-
163
 #if ENABLED(ANET_ET5_TFT35)
158
 #if ENABLED(ANET_ET5_TFT35)
164
   #ifndef TOUCH_CALIBRATION_X
159
   #ifndef TOUCH_CALIBRATION_X
165
     #define TOUCH_CALIBRATION_X            17125
160
     #define TOUCH_CALIBRATION_X            17125

Loading…
Cancel
Save