Browse Source

Move scaled TFT / touch defines (#18915)

Scott Lahteine 5 years ago
parent
commit
ca0ebf10d1
No account linked to committer's email address

+ 2
- 2
Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp View File

20
 
20
 
21
 #include "../../../inc/MarlinConfig.h"
21
 #include "../../../inc/MarlinConfig.h"
22
 
22
 
23
-#if BOTH(HAS_GRAPHICAL_LCD, SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI)
23
+#if ENABLED(SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI)
24
 
24
 
25
 #include "../HAL.h"
25
 #include "../HAL.h"
26
 #include <U8glib.h>
26
 #include <U8glib.h>
232
   return 1;
232
   return 1;
233
 }
233
 }
234
 
234
 
235
-#endif // HAS_GRAPHICAL_LCD
235
+#endif // SPI_GRAPHICAL_TFT && !FORCE_SOFT_SPI
236
 #endif // STM32F1
236
 #endif // STM32F1

+ 19
- 12
Marlin/src/MarlinCore.cpp View File

39
 #include <math.h>
39
 #include <math.h>
40
 
40
 
41
 #include "core/utility.h"
41
 #include "core/utility.h"
42
-#include "lcd/ultralcd.h"
43
 #include "module/motion.h"
42
 #include "module/motion.h"
44
 #include "module/planner.h"
43
 #include "module/planner.h"
45
-#include "module/stepper.h"
46
 #include "module/endstops.h"
44
 #include "module/endstops.h"
47
-#include "module/probe.h"
48
 #include "module/temperature.h"
45
 #include "module/temperature.h"
49
-#include "sd/cardreader.h"
50
 #include "module/configuration_store.h"
46
 #include "module/configuration_store.h"
51
 #include "module/printcounter.h" // PrintCounter or Stopwatch
47
 #include "module/printcounter.h" // PrintCounter or Stopwatch
52
-#include "feature/closedloop.h"
53
 
48
 
49
+#include "module/stepper.h"
54
 #include "module/stepper/indirection.h"
50
 #include "module/stepper/indirection.h"
55
 
51
 
56
-#include "libs/nozzle.h"
57
-
58
 #include "gcode/gcode.h"
52
 #include "gcode/gcode.h"
59
 #include "gcode/parser.h"
53
 #include "gcode/parser.h"
60
 #include "gcode/queue.h"
54
 #include "gcode/queue.h"
61
 
55
 
56
+#include "sd/cardreader.h"
57
+
58
+#include "lcd/ultralcd.h"
59
+#if HAS_TOUCH_XPT2046
60
+  #include "lcd/touch/xpt2046.h"
61
+#endif
62
+
62
 #if HAS_TFT_LVGL_UI
63
 #if HAS_TFT_LVGL_UI
63
   #include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
64
   #include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
64
   #include "lcd/extui/lib/mks_ui/draw_ui.h"
65
   #include "lcd/extui/lib/mks_ui/draw_ui.h"
80
   #include "feature/direct_stepping.h"
81
   #include "feature/direct_stepping.h"
81
 #endif
82
 #endif
82
 
83
 
83
-#if HAS_TOUCH_XPT2046
84
-  #include "feature/touch/xpt2046.h"
85
-#endif
86
-
87
 #if ENABLED(HOST_ACTION_COMMANDS)
84
 #if ENABLED(HOST_ACTION_COMMANDS)
88
   #include "feature/host_actions.h"
85
   #include "feature/host_actions.h"
89
 #endif
86
 #endif
92
   #include "libs/buzzer.h"
89
   #include "libs/buzzer.h"
93
 #endif
90
 #endif
94
 
91
 
92
+#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
93
+  #include "feature/closedloop.h"
94
+#endif
95
+
95
 #if HAS_I2C_DIGIPOT
96
 #if HAS_I2C_DIGIPOT
96
   #include "feature/digipot/digipot.h"
97
   #include "feature/digipot/digipot.h"
97
 #endif
98
 #endif
176
   #include "feature/runout.h"
177
   #include "feature/runout.h"
177
 #endif
178
 #endif
178
 
179
 
180
+#if HAS_Z_SERVO_PROBE
181
+  #include "module/probe.h"
182
+#endif
183
+
179
 #if ENABLED(HOTEND_IDLE_TIMEOUT)
184
 #if ENABLED(HOTEND_IDLE_TIMEOUT)
180
   #include "feature/hotend_idle.h"
185
   #include "feature/hotend_idle.h"
181
 #endif
186
 #endif
1194
   #endif
1199
   #endif
1195
 
1200
 
1196
   #if HAS_TFT_LVGL_UI
1201
   #if HAS_TFT_LVGL_UI
1197
-    if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
1202
+    #if ENABLED(SDSUPPORT)
1203
+      if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
1204
+    #endif
1198
     SETUP_RUN(tft_lvgl_init());
1205
     SETUP_RUN(tft_lvgl_init());
1199
   #endif
1206
   #endif
1200
 
1207
 

+ 64
- 65
Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-/*
24
-
25
-  u8g_dev_tft_320x240_upscale_from_128x64.cpp
26
-
27
-  Universal 8bit Graphics Library
28
-
29
-  Copyright (c) 2011, olikraus@gmail.com
30
-  All rights reserved.
31
-
32
-  Redistribution and use in source and binary forms, with or without modification,
33
-  are permitted provided that the following conditions are met:
34
-
35
-  * Redistributions of source code must retain the above copyright notice, this list
36
-    of conditions and the following disclaimer.
37
-
38
-  * Redistributions in binary form must reproduce the above copyright notice, this
39
-    list of conditions and the following disclaimer in the documentation and/or other
40
-    materials provided with the distribution.
41
-
42
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
43
-  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
44
-  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
45
-  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46
-  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
47
-  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49
-  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50
-  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51
-  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52
-  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
-  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
54
-  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55
-
56
-*/
23
+/**
24
+ * u8g_dev_tft_320x240_upscale_from_128x64.cpp
25
+ *
26
+ * Universal 8bit Graphics Library
27
+ *
28
+ * Copyright (c) 2011, olikraus@gmail.com
29
+ * All rights reserved.
30
+ *
31
+ * Redistribution and use in source and binary forms, with or without modification,
32
+ * are permitted provided that the following conditions are met:
33
+ *
34
+ * Redistributions of source code must retain the above copyright notice, this list
35
+ * of conditions and the following disclaimer.
36
+ *
37
+ * Redistributions in binary form must reproduce the above copyright notice, this
38
+ * list of conditions and the following disclaimer in the documentation and/or other
39
+ * materials provided with the distribution.
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
42
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
43
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
46
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
53
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+ *
55
+ */
57
 
56
 
58
 #include "../../inc/MarlinConfig.h"
57
 #include "../../inc/MarlinConfig.h"
59
 
58
 
80
   extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count);
79
   extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count);
81
 #endif
80
 #endif
82
 
81
 
83
-#define WIDTH LCD_PIXEL_WIDTH
82
+#define WIDTH  LCD_PIXEL_WIDTH
84
 #define HEIGHT LCD_PIXEL_HEIGHT
83
 #define HEIGHT LCD_PIXEL_HEIGHT
85
 #define PAGE_HEIGHT 8
84
 #define PAGE_HEIGHT 8
86
 
85
 
87
-#define X_LO LCD_PIXEL_OFFSET_X
88
-#define Y_LO LCD_PIXEL_OFFSET_Y
89
-#define X_HI (X_LO + (FSMC_UPSCALE) * WIDTH  - 1)
90
-#define Y_HI (Y_LO + (FSMC_UPSCALE) * HEIGHT - 1)
86
+#include "../scaled_tft.h"
87
+
88
+#define UPSCALE0(M) ((M) * (FSMC_UPSCALE))
89
+#define UPSCALE(A,M) (UPSCALE0(M) + (A))
90
+#define X_HI (UPSCALE(LCD_PIXEL_OFFSET_X, WIDTH) - 1)
91
+#define Y_HI (UPSCALE(LCD_PIXEL_OFFSET_Y, HEIGHT) - 1)
91
 
92
 
92
 // see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
93
 // see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
93
 
94
 
153
 #define ILI9328_VASTART     0x52   /* Vertical address start position (0-511) */
154
 #define ILI9328_VASTART     0x52   /* Vertical address start position (0-511) */
154
 #define ILI9328_VAEND       0x53   /* Vertical address end position (0-511) */
155
 #define ILI9328_VAEND       0x53   /* Vertical address end position (0-511) */
155
 
156
 
156
-
157
 static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
157
 static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
158
   #if HAS_LCD_IO
158
   #if HAS_LCD_IO
159
     #define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0)
159
     #define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0)
216
 static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {}
216
 static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {}
217
 void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none;
217
 void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none;
218
 
218
 
219
-
220
 #define ESC_REG(x)      0xFFFF, 0x00FF & (uint16_t)x
219
 #define ESC_REG(x)      0xFFFF, 0x00FF & (uint16_t)x
221
 #define ESC_DELAY(x)    0xFFFF, 0x8000 | (x & 0x7FFF)
220
 #define ESC_DELAY(x)    0xFFFF, 0x8000 | (x & 0x7FFF)
222
 #define ESC_END         0xFFFF, 0x7FFF
221
 #define ESC_END         0xFFFF, 0x7FFF
552
   #define BUTTON_SIZE_Y 20
551
   #define BUTTON_SIZE_Y 20
553
 
552
 
554
   // 14, 90, 166, 242, 185 are the original values upscaled 2x.
553
   // 14, 90, 166, 242, 185 are the original values upscaled 2x.
555
-  #define BUTTOND_X_LO (14 / 2) * (FSMC_UPSCALE)
556
-  #define BUTTOND_X_HI (BUTTOND_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
554
+  #define BUTTOND_X_LO UPSCALE0(14 / 2)
555
+  #define BUTTOND_X_HI (UPSCALE(BUTTOND_X_LO, BUTTON_SIZE_X) - 1)
557
 
556
 
558
-  #define BUTTONA_X_LO (90 / 2) * (FSMC_UPSCALE)
559
-  #define BUTTONA_X_HI (BUTTONA_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
557
+  #define BUTTONA_X_LO UPSCALE0(90 / 2)
558
+  #define BUTTONA_X_HI (UPSCALE(BUTTONA_X_LO, BUTTON_SIZE_X) - 1)
560
 
559
 
561
-  #define BUTTONB_X_LO (166 / 2) * (FSMC_UPSCALE)
562
-  #define BUTTONB_X_HI (BUTTONB_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
560
+  #define BUTTONB_X_LO UPSCALE0(166 / 2)
561
+  #define BUTTONB_X_HI (UPSCALE(BUTTONB_X_LO, BUTTON_SIZE_X) - 1)
563
 
562
 
564
-  #define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
565
-  #define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
563
+  #define BUTTONC_X_LO UPSCALE0(242 / 2)
564
+  #define BUTTONC_X_HI (UPSCALE(BUTTONC_X_LO, BUTTON_SIZE_X) - 1)
566
 
565
 
567
-  #define BUTTON_Y_LO (140 / 2) * (FSMC_UPSCALE) + 44 //184 2x, 254 3x
568
-  #define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
566
+  #define BUTTON_Y_LO UPSCALE0(140 / 2) + 44 // 184 2x, 254 3x
567
+  #define BUTTON_Y_HI (UPSCALE(BUTTON_Y_LO, BUTTON_SIZE_Y) - 1)
569
 
568
 
570
   void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
569
   void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
571
     uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
570
     uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
584
       }
583
       }
585
       #if HAS_LCD_IO
584
       #if HAS_LCD_IO
586
         LOOP_S_L_N(n, 1, FSMC_UPSCALE)
585
         LOOP_S_L_N(n, 1, FSMC_UPSCALE)
587
-          for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
588
-            buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l];
586
+          for (uint16_t l = 0; l < UPSCALE0(length); l++)
587
+            buffer[l + n * UPSCALE0(length)] = buffer[l];
589
 
588
 
590
         LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE));
589
         LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE));
591
       #else
590
       #else
660
       }
659
       }
661
 
660
 
662
       // Clear Screen
661
       // Clear Screen
663
-      setWindow(u8g, dev, 0, 0, LCD_FULL_PIXEL_WIDTH - 1, LCD_FULL_PIXEL_HEIGHT - 1);
662
+      setWindow(u8g, dev, 0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1);
664
       #if HAS_LCD_IO
663
       #if HAS_LCD_IO
665
-        LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT);
664
+        LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
666
       #else
665
       #else
667
-        memset2(buffer, TFT_MARLINBG_COLOR, 160);
668
-        for (uint16_t i = 0; i < 960; i++)
669
-          u8g_WriteSequence(u8g, dev, 160, (uint8_t *)buffer);
666
+        memset2(buffer, TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) / 2);
667
+        for (uint16_t i = 0; i < (LCD_FULL_PIXEL_WIDTH) * 3; i++)
668
+          u8g_WriteSequence(u8g, dev, (LCD_FULL_PIXEL_WIDTH) / 2, (uint8_t *)buffer);
670
       #endif
669
       #endif
671
 
670
 
672
       // Bottom buttons
671
       // Bottom buttons
673
       #if HAS_TOUCH_XPT2046
672
       #if HAS_TOUCH_XPT2046
674
-        setWindow(u8g, dev, BUTTOND_X_LO, BUTTON_Y_LO,  BUTTOND_X_HI, BUTTON_Y_HI);
673
+        setWindow(u8g, dev, BUTTOND_X_LO, BUTTON_Y_LO, BUTTOND_X_HI, BUTTON_Y_HI);
675
         drawImage(buttonD, u8g, dev, 32, 20, TFT_BTCANCEL_COLOR);
674
         drawImage(buttonD, u8g, dev, 32, 20, TFT_BTCANCEL_COLOR);
676
 
675
 
677
-        setWindow(u8g, dev, BUTTONA_X_LO, BUTTON_Y_LO,  BUTTONA_X_HI, BUTTON_Y_HI);
676
+        setWindow(u8g, dev, BUTTONA_X_LO, BUTTON_Y_LO, BUTTONA_X_HI, BUTTON_Y_HI);
678
         drawImage(buttonA, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
677
         drawImage(buttonA, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
679
 
678
 
680
-        setWindow(u8g, dev, BUTTONB_X_LO, BUTTON_Y_LO,  BUTTONB_X_HI, BUTTON_Y_HI);
679
+        setWindow(u8g, dev, BUTTONB_X_LO, BUTTON_Y_LO, BUTTONB_X_HI, BUTTON_Y_HI);
681
         drawImage(buttonB, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
680
         drawImage(buttonB, u8g, dev, 32, 20, TFT_BTARROWS_COLOR);
682
 
681
 
683
-        setWindow(u8g, dev, BUTTONC_X_LO, BUTTON_Y_LO,  BUTTONC_X_HI, BUTTON_Y_HI);
682
+        setWindow(u8g, dev, BUTTONC_X_LO, BUTTON_Y_LO, BUTTONC_X_HI, BUTTON_Y_HI);
684
         drawImage(buttonC, u8g, dev, 32, 20, TFT_BTOKMENU_COLOR);
683
         drawImage(buttonC, u8g, dev, 32, 20, TFT_BTOKMENU_COLOR);
685
       #endif // HAS_TOUCH_XPT2046
684
       #endif // HAS_TOUCH_XPT2046
686
 
685
 
690
 
689
 
691
     case U8G_DEV_MSG_PAGE_FIRST:
690
     case U8G_DEV_MSG_PAGE_FIRST:
692
       page = 0;
691
       page = 0;
693
-      setWindow(u8g, dev, X_LO, Y_LO, X_HI, Y_HI);
692
+      setWindow(u8g, dev, LCD_PIXEL_OFFSET_X, LCD_PIXEL_OFFSET_Y, X_HI, Y_HI);
694
       break;
693
       break;
695
 
694
 
696
     case U8G_DEV_MSG_PAGE_NEXT:
695
     case U8G_DEV_MSG_PAGE_NEXT:
708
         }
707
         }
709
         #if HAS_LCD_IO
708
         #if HAS_LCD_IO
710
           LOOP_S_L_N(n, 1, FSMC_UPSCALE)
709
           LOOP_S_L_N(n, 1, FSMC_UPSCALE)
711
-            for (uint16_t l = 0; l < WIDTH * (FSMC_UPSCALE); l++)
712
-              buffer[l + WIDTH * (FSMC_UPSCALE) * n] = buffer[l];
710
+            for (uint16_t l = 0; l < UPSCALE0(WIDTH); l++)
711
+              buffer[l + n * UPSCALE0(WIDTH)] = buffer[l];
713
 
712
 
714
           if (allow_async) {
713
           if (allow_async) {
715
             if (y > 0 || page > 1) LCD_IO_WaitSequence_Async();
714
             if (y > 0 || page > 1) LCD_IO_WaitSequence_Async();

+ 0
- 21
Marlin/src/lcd/dogm/ultralcd_DOGM.h View File

212
   #endif
212
   #endif
213
 #endif
213
 #endif
214
 
214
 
215
-// LCD_FULL_PIXEL_WIDTH =
216
-// LCD_PIXEL_OFFSET_X + (LCD_PIXEL_WIDTH * 2) + LCD_PIXEL_OFFSET_X
217
-#if TFT_SCALED_DOGLCD
218
-  #ifndef LCD_FULL_PIXEL_WIDTH
219
-    #define LCD_FULL_PIXEL_WIDTH  320
220
-  #endif
221
-  #ifndef LCD_PIXEL_OFFSET_X
222
-    #define LCD_PIXEL_OFFSET_X     32
223
-  #endif
224
-  #ifndef LCD_FULL_PIXEL_HEIGHT
225
-    #define LCD_FULL_PIXEL_HEIGHT 240
226
-  #endif
227
-  #ifndef LCD_PIXEL_OFFSET_Y
228
-    #define LCD_PIXEL_OFFSET_Y     32
229
-  #endif
230
-#endif
231
-
232
 // For selective rendering within a Y range
215
 // For selective rendering within a Y range
233
 #define PAGE_OVER(ya)         ((ya) <= u8g.getU8g()->current_page.y1) // Does the current page follow a region top?
216
 #define PAGE_OVER(ya)         ((ya) <= u8g.getU8g()->current_page.y1) // Does the current page follow a region top?
234
 #define PAGE_UNDER(yb)        ((yb) >= u8g.getU8g()->current_page.y0) // Does the current page precede a region bottom?
217
 #define PAGE_UNDER(yb)        ((yb) >= u8g.getU8g()->current_page.y0) // Does the current page precede a region bottom?
235
 #define PAGE_CONTAINS(ya, yb) ((yb) >= u8g.getU8g()->current_page.y0 && (ya) <= u8g.getU8g()->current_page.y1) // Do two vertical regions overlap?
218
 #define PAGE_CONTAINS(ya, yb) ((yb) >= u8g.getU8g()->current_page.y0 && (ya) <= u8g.getU8g()->current_page.y1) // Do two vertical regions overlap?
236
 
219
 
237
-#ifndef FSMC_UPSCALE
238
-  #define FSMC_UPSCALE 2
239
-#endif
240
-
241
 extern U8G_CLASS u8g;
220
 extern U8G_CLASS u8g;

+ 2
- 1
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp View File

35
 #include "pic_manager.h"
35
 #include "pic_manager.h"
36
 #include <lvgl.h>
36
 #include <lvgl.h>
37
 
37
 
38
+#include "../../../touch/xpt2046.h"
39
+
38
 #include "../../../../MarlinCore.h"
40
 #include "../../../../MarlinCore.h"
39
 #include "../../../../module/temperature.h"
41
 #include "../../../../module/temperature.h"
40
-#include "../../../../feature/touch/xpt2046.h"
41
 #include "../../../../sd/cardreader.h"
42
 #include "../../../../sd/cardreader.h"
42
 
43
 
43
 uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;
44
 uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;

+ 24
- 16
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp View File

41
 #include "draw_ui.h"
41
 #include "draw_ui.h"
42
 #include <lvgl.h>
42
 #include <lvgl.h>
43
 
43
 
44
-#include "../../../../MarlinCore.h"
45
-#include "../../../../feature/touch/xpt2046.h"
44
+#include "../../../../inc/MarlinConfig.h"
45
+
46
+#if HAS_TOUCH_XPT2046
47
+  #include "../../../touch/xpt2046.h"
48
+#endif
46
 
49
 
47
 #if ENABLED(POWER_LOSS_RECOVERY)
50
 #if ENABLED(POWER_LOSS_RECOVERY)
48
   #include "../../../../feature/powerloss.h"
51
   #include "../../../../feature/powerloss.h"
50
 
53
 
51
 #include <SPI.h>
54
 #include <SPI.h>
52
 
55
 
56
+#ifndef LCD_FULL_PIXEL_WIDTH
57
+  #define LCD_FULL_PIXEL_WIDTH  480
58
+#endif
59
+#ifndef LCD_FULL_PIXEL_HEIGHT
60
+  #define LCD_FULL_PIXEL_HEIGHT 320
61
+#endif
62
+
53
 #if HAS_SPI_FLASH_FONT
63
 #if HAS_SPI_FLASH_FONT
54
   extern void init_gb2312_font();
64
   extern void init_gb2312_font();
55
 #endif
65
 #endif
127
 
137
 
128
 void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
138
 void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
129
   //if (DeviceCode == 0x9488) {
139
   //if (DeviceCode == 0x9488) {
130
-  if ((x > 480) || (y > 320)) return;
140
+  if (x > (LCD_FULL_PIXEL_WIDTH) || y > (LCD_FULL_PIXEL_HEIGHT)) return;
131
   //}
141
   //}
132
-  //**if ( (x>320)||(y>240) ) return;
133
   tft_set_cursor(x, y);
142
   tft_set_cursor(x, y);
134
 
143
 
135
   LCD_WriteRAM_Prepare();
144
   LCD_WriteRAM_Prepare();
187
      LCD_WriteReg(0x0052, StartY);
196
      LCD_WriteReg(0x0052, StartY);
188
      LCD_WriteReg(0x0051, xEnd);
197
      LCD_WriteReg(0x0051, xEnd);
189
      LCD_WriteReg(0x0053, yEnd);*/
198
      LCD_WriteReg(0x0053, yEnd);*/
190
-    LCD_WriteReg(0x0050, StartY);      //Specify the start/end positions of the window address in the horizontal direction by an address unit
191
-    LCD_WriteReg(0x0051, yEnd);      //Specify the start positions of the window address in the vertical direction by an address unit
199
+    LCD_WriteReg(0x0050, StartY);   // Specify the start/end positions of the window address in the horizontal direction by an address unit
200
+    LCD_WriteReg(0x0051, yEnd);     // Specify the start positions of the window address in the vertical direction by an address unit
192
     LCD_WriteReg(0x0052, 320 - xEnd);
201
     LCD_WriteReg(0x0052, 320 - xEnd);
193
-    LCD_WriteReg(0x0053, 320 - StartX - 1);      //Specify the end positions of the window address in the vertical direction by an address unit
202
+    LCD_WriteReg(0x0053, 320 - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit
194
 
203
 
195
   }
204
   }
196
   else {
205
   else {
224
 
233
 
225
   if (DeviceCode == 0x9488) {
234
   if (DeviceCode == 0x9488) {
226
     tft_set_cursor(0, 0);
235
     tft_set_cursor(0, 0);
227
-    ili9320_SetWindows(0, 0, 480, 320);
236
+    ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
228
     LCD_WriteRAM_Prepare();
237
     LCD_WriteRAM_Prepare();
229
     #ifdef LCD_USE_DMA_FSMC
238
     #ifdef LCD_USE_DMA_FSMC
230
-      LCD_IO_WriteMultiple(Color, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT);
239
+      LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
231
     #else
240
     #else
232
-    //index = (160*480);
233
-    for (index = 0; index < 320 * 480; index++)
234
-      LCD_IO_WriteData(Color);
241
+      //index = (LCD_FULL_PIXEL_HEIGHT) / 2 * (LCD_FULL_PIXEL_WIDTH);
242
+      for (index = 0; index < (LCD_FULL_PIXEL_HEIGHT) * (LCD_FULL_PIXEL_WIDTH); index++)
243
+        LCD_IO_WriteData(Color);
235
     #endif
244
     #endif
236
-    //LCD_IO_WriteMultiple(Color, (480*320));
245
+    //LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
237
     //while(index --) LCD_IO_WriteData(Color);
246
     //while(index --) LCD_IO_WriteData(Color);
238
   }
247
   }
239
   else if (DeviceCode == 0x5761) {
248
   else if (DeviceCode == 0x5761) {
262
 
271
 
263
 extern uint16_t ILI9488_ReadRAM();
272
 extern uint16_t ILI9488_ReadRAM();
264
 
273
 
265
-
266
 void init_tft() {
274
 void init_tft() {
267
   uint16_t i;
275
   uint16_t i;
268
   //************* Start Initial Sequence **********//
276
   //************* Start Initial Sequence **********//
393
     for (i = 0; i < 65535; i++);
401
     for (i = 0; i < 65535; i++);
394
     LCD_IO_WriteReg(0x0029);
402
     LCD_IO_WriteReg(0x0029);
395
 
403
 
396
-    ili9320_SetWindows(0, 0, 480, 320);
404
+    ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
397
     LCD_Clear(0x0000);
405
     LCD_Clear(0x0000);
398
 
406
 
399
     OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
407
     OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
486
   #if ENABLED(TFT_LVGL_UI_SPI)
494
   #if ENABLED(TFT_LVGL_UI_SPI)
487
     uint16_t i, width, height;
495
     uint16_t i, width, height;
488
     uint16_t clr_temp;
496
     uint16_t clr_temp;
489
-    uint8_t tbuf[480 * 2];
497
+    uint8_t tbuf[(LCD_FULL_PIXEL_WIDTH) * 2];
490
 
498
 
491
     SPI_TFT.spi_init(SPI_FULL_SPEED);
499
     SPI_TFT.spi_init(SPI_FULL_SPEED);
492
 
500
 

+ 22
- 0
Marlin/src/lcd/lcdprint.h View File

1
 /**
1
 /**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
2
  * @file    lcdprint.h
24
  * @file    lcdprint.h
3
  * @brief   LCD print api
25
  * @brief   LCD print api
4
  * @author  Yunhui Fu (yhfudev@gmail.com)
26
  * @author  Yunhui Fu (yhfudev@gmail.com)

+ 50
- 0
Marlin/src/lcd/scaled_tft.h View File

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../inc/MarlinConfig.h"
25
+
26
+#ifndef FSMC_UPSCALE
27
+  #define FSMC_UPSCALE 2
28
+#endif
29
+
30
+#ifndef LCD_FULL_PIXEL_WIDTH
31
+  #if FSMC_UPSCALE == 3
32
+    #define LCD_FULL_PIXEL_WIDTH 480
33
+  #else
34
+    #define LCD_FULL_PIXEL_WIDTH 320
35
+  #endif
36
+#endif
37
+#ifndef LCD_FULL_PIXEL_HEIGHT
38
+  #if FSMC_UPSCALE == 3
39
+    #define LCD_FULL_PIXEL_HEIGHT 320
40
+  #else
41
+    #define LCD_FULL_PIXEL_HEIGHT 240
42
+  #endif
43
+#endif
44
+
45
+#ifndef LCD_PIXEL_OFFSET_X
46
+  #define LCD_PIXEL_OFFSET_X 48
47
+#endif
48
+#ifndef LCD_PIXEL_OFFSET_Y
49
+  #define LCD_PIXEL_OFFSET_Y 48
50
+#endif

Marlin/src/feature/touch/xpt2046.cpp → Marlin/src/lcd/touch/xpt2046.cpp View File

21
 
21
 
22
 #if HAS_TOUCH_XPT2046
22
 #if HAS_TOUCH_XPT2046
23
 
23
 
24
-#if TFT_SCALED_DOGLCD
25
-  #include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
26
-#endif
27
-
28
 #include "xpt2046.h"
24
 #include "xpt2046.h"
25
+#include "../scaled_tft.h"
29
 
26
 
30
 #ifndef XPT2046_Z1_THRESHOLD
27
 #ifndef XPT2046_Z1_THRESHOLD
31
   #define XPT2046_Z1_THRESHOLD 10
28
   #define XPT2046_Z1_THRESHOLD 10
35
  * Draw and Touch processing
32
  * Draw and Touch processing
36
  *
33
  *
37
  *      LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution.
34
  *      LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution.
38
- *   TOUCH_SCREEN_WIDTH/HEIGHT (320x240) is the Touch Area resolution.
35
+ *   TOUCH_SENSOR_WIDTH/HEIGHT (320x240) is the Touch Area resolution.
39
  * LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution.
36
  * LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution.
40
  *
37
  *
41
  *  - All native (u8g) drawing is done in LCD_PIXEL_* (128x64)
38
  *  - All native (u8g) drawing is done in LCD_PIXEL_* (128x64)
42
  *  - The DOGM pixels are is upscaled 2-3x (as needed) for display.
39
  *  - The DOGM pixels are is upscaled 2-3x (as needed) for display.
43
- *  - Touch coordinates use TOUCH_SCREEN_* resolution and are converted to
40
+ *  - Touch coordinates use TOUCH_SENSOR_* resolution and are converted to
44
  *    click and scroll-wheel events (emulating of a common DOGM display).
41
  *    click and scroll-wheel events (emulating of a common DOGM display).
45
  *
42
  *
46
  *  TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made
43
  *  TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made
54
  * The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP)
51
  * The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP)
55
  * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT).
52
  * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT).
56
  */
53
  */
57
-// Touch screen resolution independent of display resolution
58
-#define TOUCH_SCREEN_HEIGHT 240
59
-#define TOUCH_SCREEN_WIDTH 320
60
 
54
 
61
 // Coordinates in terms of touch area
55
 // Coordinates in terms of touch area
62
 #define BUTTON_AREA_TOP 175
56
 #define BUTTON_AREA_TOP 175
63
 #define BUTTON_AREA_BOT 234
57
 #define BUTTON_AREA_BOT 234
64
 
58
 
65
-#define SCREEN_START_TOP  ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
66
-#define SCREEN_START_LEFT ((LCD_PIXEL_OFFSET_X) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
67
-#define SCREEN_HEIGHT     ((LCD_PIXEL_HEIGHT * FSMC_UPSCALE) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
68
-#define SCREEN_WIDTH      ((LCD_PIXEL_WIDTH * FSMC_UPSCALE) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
59
+// Touch sensor resolution independent of display resolution
60
+#define TOUCH_SENSOR_WIDTH  320
61
+#define TOUCH_SENSOR_HEIGHT 240
62
+
63
+#define SCREEN_WIDTH_PCT(X) ((X) * (TOUCH_SENSOR_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
64
+#define SCREEN_HEIGHT_PCT(Y) ((Y) * (TOUCH_SENSOR_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
65
+
66
+#define SCREEN_START_LEFT SCREEN_WIDTH_PCT(LCD_PIXEL_OFFSET_X)
67
+#define SCREEN_START_TOP  SCREEN_HEIGHT_PCT(LCD_PIXEL_OFFSET_Y)
68
+#define SCREEN_WIDTH      SCREEN_WIDTH_PCT((LCD_PIXEL_WIDTH) * (FSMC_UPSCALE))
69
+#define SCREEN_HEIGHT     SCREEN_HEIGHT_PCT((LCD_PIXEL_HEIGHT) * (FSMC_UPSCALE))
69
 
70
 
70
-#define TOUCHABLE_Y_HEIGHT  SCREEN_HEIGHT
71
 #define TOUCHABLE_X_WIDTH  SCREEN_WIDTH
71
 #define TOUCHABLE_X_WIDTH  SCREEN_WIDTH
72
+#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT
72
 
73
 
73
 #ifndef TOUCH_INT_PIN
74
 #ifndef TOUCH_INT_PIN
74
   #define TOUCH_INT_PIN  -1
75
   #define TOUCH_INT_PIN  -1
125
     if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
126
     if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
126
 
127
 
127
     #if ENABLED(GRAPHICAL_TFT_ROTATE_180)
128
     #if ENABLED(GRAPHICAL_TFT_ROTATE_180)
128
-      x = TOUCH_SCREEN_WIDTH - x;
129
-      y = TOUCH_SCREEN_HEIGHT - y;
129
+      x = TOUCH_SENSOR_WIDTH - x;
130
+      y = TOUCH_SENSOR_HEIGHT - y;
130
     #endif
131
     #endif
131
 
132
 
132
     // Touch within the button area simulates an encoder button
133
     // Touch within the button area simulates an encoder button
137
           : WITHIN(x, 242, 305) ? EN_C
138
           : WITHIN(x, 242, 305) ? EN_C
138
           : 0;
139
           : 0;
139
 
140
 
140
-    if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
141
+    if (x > TOUCH_SENSOR_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
141
 
142
 
142
     // Column and row above BUTTON_AREA_TOP
143
     // Column and row above BUTTON_AREA_TOP
143
     int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
144
     int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
144
-          row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
145
+           row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
145
 
146
 
146
     // Send the touch to the UI (which will simulate the encoder wheel)
147
     // Send the touch to the UI (which will simulate the encoder wheel)
147
     MarlinUI::screen_click(row, col, x, y);
148
     MarlinUI::screen_click(row, col, x, y);

Marlin/src/feature/touch/xpt2046.h → Marlin/src/lcd/touch/xpt2046.h View File


+ 1
- 1
Marlin/src/lcd/ultralcd.cpp View File

150
     volatile uint8_t MarlinUI::slow_buttons;
150
     volatile uint8_t MarlinUI::slow_buttons;
151
   #endif
151
   #endif
152
   #if HAS_TOUCH_XPT2046
152
   #if HAS_TOUCH_XPT2046
153
-    #include "../feature/touch/xpt2046.h"
153
+    #include "touch/xpt2046.h"
154
     bool MarlinUI::on_edit_screen = false;
154
     bool MarlinUI::on_edit_screen = false;
155
   #endif
155
   #endif
156
 #endif
156
 #endif

+ 19
- 22
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h View File

112
 
112
 
113
 #if ENABLED(FSMC_GRAPHICAL_TFT)
113
 #if ENABLED(FSMC_GRAPHICAL_TFT)
114
   #define FSMC_UPSCALE 3
114
   #define FSMC_UPSCALE 3
115
-  #define LCD_FULL_PIXEL_WIDTH               480
116
-  #define LCD_PIXEL_OFFSET_X                  48
117
-  #define LCD_FULL_PIXEL_HEIGHT              320
118
-  #define LCD_PIXEL_OFFSET_Y                  48
119
 
115
 
120
   #define LCD_RESET_PIN                     PF11
116
   #define LCD_RESET_PIN                     PF11
121
   #define LCD_BACKLIGHT_PIN                 PD13
117
   #define LCD_BACKLIGHT_PIN                 PD13
161
   #define HAS_BAK_VIEW_IN_FLASH 0
157
   #define HAS_BAK_VIEW_IN_FLASH 0
162
   #define HAS_LOGO_IN_FLASH 0
158
   #define HAS_LOGO_IN_FLASH 0
163
 
159
 
164
-  //SPI 2
160
+  // SPI 2
165
   #define W25QXX_CS_PIN                     PB12
161
   #define W25QXX_CS_PIN                     PB12
166
   #define W25QXX_MOSI_PIN                   PB15
162
   #define W25QXX_MOSI_PIN                   PB15
167
   #define W25QXX_MISO_PIN                   PB14
163
   #define W25QXX_MISO_PIN                   PB14
171
   #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
167
   #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
172
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
168
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
173
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
169
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
174
-  // #define TOUCH_INT_PIN                   PB6
175
-
176
-  #define SPI_TFT_CS_PIN            TOUCH_CS_PIN
177
-  #define SPI_TFT_SCK_PIN          TOUCH_SCK_PIN
178
-  #define SPI_TFT_MISO_PIN        TOUCH_MISO_PIN
179
-  #define SPI_TFT_MOSI_PIN        TOUCH_MOSI_PIN
180
-  #define SPI_TFT_DC_PIN                    PB6
181
-  #define SPI_TFT_RST_PIN                   PF11
170
+  //#define TOUCH_INT_PIN                   PB6
171
+
172
+  #if ENABLED(TFT_LVGL_UI_SPI)
173
+    #define SPI_TFT_CS_PIN          TOUCH_CS_PIN
174
+    #define SPI_TFT_SCK_PIN        TOUCH_SCK_PIN
175
+    #define SPI_TFT_MISO_PIN      TOUCH_MISO_PIN
176
+    #define SPI_TFT_MOSI_PIN      TOUCH_MOSI_PIN
177
+    #define SPI_TFT_DC_PIN                  PB6
178
+    #define SPI_TFT_RST_PIN                 PF11
179
+  #endif
182
 
180
 
183
   #define LCD_RESET_PIN                     PF11
181
   #define LCD_RESET_PIN                     PF11
184
   #define LCD_BACKLIGHT_PIN                 PD13
182
   #define LCD_BACKLIGHT_PIN                 PD13
185
-  #define FSMC_CS_PIN                       PD7
186
-  #define FSMC_RS_PIN                       PD11
187
 
183
 
188
   #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
184
   #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
185
+  #define FSMC_CS_PIN                       PD7
186
+  #define FSMC_RS_PIN                       PD11
189
   #define FSMC_DMA_DEV                      DMA2
187
   #define FSMC_DMA_DEV                      DMA2
190
   #define FSMC_DMA_CHANNEL               DMA_CH5
188
   #define FSMC_DMA_CHANNEL               DMA_CH5
191
 
189
 
192
-  #define LCD_FULL_PIXEL_WIDTH 480
193
-  #define LCD_PIXEL_OFFSET_X 48
194
-  #define LCD_FULL_PIXEL_HEIGHT 320
195
-  #define LCD_PIXEL_OFFSET_Y 48
196
-
197
-  #define LCD_PIXEL_HEIGHT 320
198
-  #define LCD_PIXEL_WIDTH 480
190
+  #define LCD_PIXEL_WIDTH       480
191
+  #define LCD_PIXEL_HEIGHT      320
192
+  #define LCD_FULL_PIXEL_WIDTH  LCD_PIXEL_WIDTH
193
+  #define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT
194
+  #define LCD_PIXEL_OFFSET_X     48
195
+  #define LCD_PIXEL_OFFSET_Y     48
199
 
196
 
200
   #define XPT2046_X_CALIBRATION  -12316
197
   #define XPT2046_X_CALIBRATION  -12316
201
   #define XPT2046_Y_CALIBRATION   8981
198
   #define XPT2046_Y_CALIBRATION   8981

+ 19
- 22
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h View File

118
 //
118
 //
119
 #if ENABLED(FSMC_GRAPHICAL_TFT)
119
 #if ENABLED(FSMC_GRAPHICAL_TFT)
120
   #define FSMC_UPSCALE 3
120
   #define FSMC_UPSCALE 3
121
-  #define LCD_FULL_PIXEL_WIDTH               480
122
-  #define LCD_PIXEL_OFFSET_X                  48
123
-  #define LCD_FULL_PIXEL_HEIGHT              320
124
-  #define LCD_PIXEL_OFFSET_Y                  48
125
 
121
 
126
   #define LCD_RESET_PIN                     PF11
122
   #define LCD_RESET_PIN                     PF11
127
   #define LCD_BACKLIGHT_PIN                 PD13
123
   #define LCD_BACKLIGHT_PIN                 PD13
166
   #define HAS_BAK_VIEW_IN_FLASH 0
162
   #define HAS_BAK_VIEW_IN_FLASH 0
167
   #define HAS_LOGO_IN_FLASH 0
163
   #define HAS_LOGO_IN_FLASH 0
168
 
164
 
169
-  //SPI 2
165
+  // SPI 2
170
   #define W25QXX_CS_PIN                     PB12
166
   #define W25QXX_CS_PIN                     PB12
171
   #define W25QXX_MOSI_PIN                   PB15
167
   #define W25QXX_MOSI_PIN                   PB15
172
   #define W25QXX_MISO_PIN                   PB14
168
   #define W25QXX_MISO_PIN                   PB14
176
   #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
172
   #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
177
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
173
   #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
178
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
174
   #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
179
-  // #define TOUCH_INT_PIN                   PB6
180
-
181
-  #define SPI_TFT_CS_PIN            TOUCH_CS_PIN
182
-  #define SPI_TFT_SCK_PIN          TOUCH_SCK_PIN
183
-  #define SPI_TFT_MISO_PIN        TOUCH_MISO_PIN
184
-  #define SPI_TFT_MOSI_PIN        TOUCH_MOSI_PIN
185
-  #define SPI_TFT_DC_PIN                    PB6
186
-  #define SPI_TFT_RST_PIN                   PF11
175
+  //#define TOUCH_INT_PIN                   PB6
176
+
177
+  #if ENABLED(TFT_LVGL_UI_SPI)
178
+    #define SPI_TFT_CS_PIN          TOUCH_CS_PIN
179
+    #define SPI_TFT_SCK_PIN        TOUCH_SCK_PIN
180
+    #define SPI_TFT_MISO_PIN      TOUCH_MISO_PIN
181
+    #define SPI_TFT_MOSI_PIN      TOUCH_MOSI_PIN
182
+    #define SPI_TFT_DC_PIN                  PB6
183
+    #define SPI_TFT_RST_PIN                 PF11
184
+  #endif
187
 
185
 
188
   #define LCD_RESET_PIN                     PF11
186
   #define LCD_RESET_PIN                     PF11
189
   #define LCD_BACKLIGHT_PIN                 PD13
187
   #define LCD_BACKLIGHT_PIN                 PD13
190
-  #define FSMC_CS_PIN                       PD7
191
-  #define FSMC_RS_PIN                       PD11
192
 
188
 
193
   #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
189
   #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
190
+  #define FSMC_CS_PIN                       PD7
191
+  #define FSMC_RS_PIN                       PD11
194
   #define FSMC_DMA_DEV                      DMA2
192
   #define FSMC_DMA_DEV                      DMA2
195
   #define FSMC_DMA_CHANNEL               DMA_CH5
193
   #define FSMC_DMA_CHANNEL               DMA_CH5
196
 
194
 
197
-  #define LCD_FULL_PIXEL_WIDTH 480
198
-  #define LCD_PIXEL_OFFSET_X 48
199
-  #define LCD_FULL_PIXEL_HEIGHT 320
200
-  #define LCD_PIXEL_OFFSET_Y 48
201
-
202
-  #define LCD_PIXEL_HEIGHT 320
203
-  #define LCD_PIXEL_WIDTH 480
195
+  #define LCD_PIXEL_WIDTH       480
196
+  #define LCD_PIXEL_HEIGHT      320
197
+  #define LCD_FULL_PIXEL_WIDTH  LCD_PIXEL_WIDTH
198
+  #define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT
199
+  #define LCD_PIXEL_OFFSET_X     48
200
+  #define LCD_PIXEL_OFFSET_Y     48
204
 
201
 
205
   #define XPT2046_X_CALIBRATION  -12316
202
   #define XPT2046_X_CALIBRATION  -12316
206
   #define XPT2046_Y_CALIBRATION   8981
203
   #define XPT2046_Y_CALIBRATION   8981

+ 1
- 10
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h View File

294
     #define TOUCH_BUTTONS_HW_SPI_DEVICE     1
294
     #define TOUCH_BUTTONS_HW_SPI_DEVICE     1
295
 
295
 
296
     //#define TOUCH_SCREEN
296
     //#define TOUCH_SCREEN
297
-    #if NEED_TOUCH_PINS
297
+    #if EITHER(TOUCH_SCREEN, NEED_TOUCH_PINS)
298
       #define TOUCH_CS_PIN                  PE14  // SPI1_NSS
298
       #define TOUCH_CS_PIN                  PE14  // SPI1_NSS
299
       #define TOUCH_SCK_PIN                 PA5   // SPI1_SCK
299
       #define TOUCH_SCK_PIN                 PA5   // SPI1_SCK
300
       #define TOUCH_MISO_PIN                PA6   // SPI1_MISO
300
       #define TOUCH_MISO_PIN                PA6   // SPI1_MISO
317
     #ifndef FSMC_UPSCALE
317
     #ifndef FSMC_UPSCALE
318
       #define FSMC_UPSCALE                     3
318
       #define FSMC_UPSCALE                     3
319
     #endif
319
     #endif
320
-    #ifndef LCD_FULL_PIXEL_WIDTH
321
-      #define LCD_FULL_PIXEL_WIDTH           480
322
-    #endif
323
-    #ifndef LCD_PIXEL_OFFSET_X
324
-      #define LCD_PIXEL_OFFSET_X              48
325
-    #endif
326
-    #ifndef LCD_FULL_PIXEL_HEIGHT
327
-      #define LCD_FULL_PIXEL_HEIGHT          320
328
-    #endif
329
     #ifndef LCD_PIXEL_OFFSET_Y
320
     #ifndef LCD_PIXEL_OFFSET_Y
330
       #define LCD_PIXEL_OFFSET_Y              32
321
       #define LCD_PIXEL_OFFSET_Y              32
331
     #endif
322
     #endif

Loading…
Cancel
Save