Browse Source

🐛 Fix MarlinUI on Ender 3 S1 (#23949)

InsanityAutomation 3 years ago
parent
commit
49539463b8
No account linked to committer's email address

+ 1
- 1
Marlin/src/inc/SanityCheck.h View File

853
 /**
853
 /**
854
  * Custom Boot and Status screens
854
  * Custom Boot and Status screens
855
  */
855
  */
856
-#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE)
856
+#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI)
857
   #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE."
857
   #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE."
858
 #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN)
858
 #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN)
859
   #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN."
859
   #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN."

+ 42
- 0
Marlin/src/lcd/e3v2/common/dwin_api.cpp View File

25
 
25
 
26
 #include "dwin_api.h"
26
 #include "dwin_api.h"
27
 #include "dwin_set.h"
27
 #include "dwin_set.h"
28
+#include "dwin_font.h"
28
 
29
 
29
 #include "../../../inc/MarlinConfig.h"
30
 #include "../../../inc/MarlinConfig.h"
30
 
31
 
89
   }
90
   }
90
 #endif
91
 #endif
91
 
92
 
93
+// Get font character width
94
+uint8_t fontWidth(uint8_t cfont) {
95
+  switch (cfont) {
96
+    case font6x12 : return 6;
97
+    case font8x16 : return 8;
98
+    case font10x20: return 10;
99
+    case font12x24: return 12;
100
+    case font14x28: return 14;
101
+    case font16x32: return 16;
102
+    case font20x40: return 20;
103
+    case font24x48: return 24;
104
+    case font28x56: return 28;
105
+    case font32x64: return 32;
106
+    default: return 0;
107
+  }
108
+}
109
+
110
+// Get font character height
111
+uint8_t fontHeight(uint8_t cfont) {
112
+  switch (cfont) {
113
+    case font6x12 : return 12;
114
+    case font8x16 : return 16;
115
+    case font10x20: return 20;
116
+    case font12x24: return 24;
117
+    case font14x28: return 28;
118
+    case font16x32: return 32;
119
+    case font20x40: return 40;
120
+    case font24x48: return 48;
121
+    case font28x56: return 56;
122
+    case font32x64: return 64;
123
+    default: return 0;
124
+  }
125
+}
126
+
92
 // Set screen display direction
127
 // Set screen display direction
93
 //  dir: 0=0°, 1=90°, 2=180°, 3=270°
128
 //  dir: 0=0°, 1=90°, 2=180°, 3=270°
94
 void DWIN_Frame_SetDir(uint8_t dir) {
129
 void DWIN_Frame_SetDir(uint8_t dir) {
199
 //  *string: The string
234
 //  *string: The string
200
 //  rlimit: To limit the drawn string length
235
 //  rlimit: To limit the drawn string length
201
 void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
236
 void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
237
+  DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size));
238
+  DWIN_UpdateLCD();
202
   constexpr uint8_t widthAdjust = 0;
239
   constexpr uint8_t widthAdjust = 0;
203
   size_t i = 0;
240
   size_t i = 0;
204
   DWIN_Byte(i, 0x11);
241
   DWIN_Byte(i, 0x11);
213
   DWIN_Word(i, y);
250
   DWIN_Word(i, y);
214
   DWIN_Text(i, string, rlimit);
251
   DWIN_Text(i, string, rlimit);
215
   DWIN_Send(i);
252
   DWIN_Send(i);
253
+  DWIN_UpdateLCD();
216
 }
254
 }
217
 
255
 
218
 // Draw a positive integer
256
 // Draw a positive integer
228
 void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
266
 void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
229
                           uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
267
                           uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
230
   size_t i = 0;
268
   size_t i = 0;
269
+  DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
231
   DWIN_Byte(i, 0x14);
270
   DWIN_Byte(i, 0x14);
232
   // Bit 7: bshow
271
   // Bit 7: bshow
233
   // Bit 6: 1 = signed; 0 = unsigned number;
272
   // Bit 6: 1 = signed; 0 = unsigned number;
258
   #endif
297
   #endif
259
 
298
 
260
   DWIN_Send(i);
299
   DWIN_Send(i);
300
+  DWIN_UpdateLCD();
261
 }
301
 }
262
 
302
 
263
 // Draw a floating point number
303
 // Draw a floating point number
275
                           uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
315
                           uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
276
   //uint8_t *fvalue = (uint8_t*)&value;
316
   //uint8_t *fvalue = (uint8_t*)&value;
277
   size_t i = 0;
317
   size_t i = 0;
318
+  DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
278
   DWIN_Byte(i, 0x14);
319
   DWIN_Byte(i, 0x14);
279
   DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
320
   DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
280
   DWIN_Word(i, color);
321
   DWIN_Word(i, color);
291
   DWIN_Byte(i, fvalue[0]);
332
   DWIN_Byte(i, fvalue[0]);
292
   */
333
   */
293
   DWIN_Send(i);
334
   DWIN_Send(i);
335
+  DWIN_UpdateLCD();
294
 }
336
 }
295
 
337
 
296
 // Draw a floating point number
338
 // Draw a floating point number

+ 1
- 1
Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp View File

45
   const bool success = DWIN_Handshake();
45
   const bool success = DWIN_Handshake();
46
   if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
46
   if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
47
   DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1));
47
   DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1));
48
-  DWIN_JPG_ShowAndCache(3);
49
   DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here
48
   DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here
49
+  DWIN_JPG_ShowAndCache(3);
50
   DWIN_UpdateLCD();
50
   DWIN_UpdateLCD();
51
 }
51
 }
52
 
52
 

+ 18
- 6
Marlin/src/lcd/e3v2/marlinui/ui_common.cpp View File

84
 // This LCD should clear where it will draw anew
84
 // This LCD should clear where it will draw anew
85
 void MarlinUI::clear_lcd() {
85
 void MarlinUI::clear_lcd() {
86
   DWIN_ICON_AnimationControl(0x0000); // disable all icon animations
86
   DWIN_ICON_AnimationControl(0x0000); // disable all icon animations
87
+  DWIN_JPG_ShowAndCache(3);
87
   DWIN_Frame_Clear(Color_Bg_Black);
88
   DWIN_Frame_Clear(Color_Bg_Black);
88
   DWIN_UpdateLCD();
89
   DWIN_UpdateLCD();
89
 
90
 
93
 #if ENABLED(SHOW_BOOTSCREEN)
94
 #if ENABLED(SHOW_BOOTSCREEN)
94
 
95
 
95
   void MarlinUI::show_bootscreen() {
96
   void MarlinUI::show_bootscreen() {
96
-    clear_lcd();
97
     dwin_string.set(F(SHORT_BUILD_VERSION));
97
     dwin_string.set(F(SHORT_BUILD_VERSION));
98
 
98
 
99
+    #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && !defined(CUSTOM_BOOTSCREEN_TIMEOUT)
100
+      #define CUSTOM_BOOTSCREEN_TIMEOUT 3000
101
+    #endif
102
+
99
     #if ENABLED(DWIN_MARLINUI_PORTRAIT)
103
     #if ENABLED(DWIN_MARLINUI_PORTRAIT)
100
       #define LOGO_CENTER ((LCD_PIXEL_WIDTH) / 2)
104
       #define LOGO_CENTER ((LCD_PIXEL_WIDTH) / 2)
101
       #define INFO_CENTER LOGO_CENTER
105
       #define INFO_CENTER LOGO_CENTER
102
       #define VERSION_Y   330
106
       #define VERSION_Y   330
103
-      DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2,  15);
107
+    #else
108
+      #define LOGO_CENTER (280 / 2)
109
+      #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2)
110
+      #define VERSION_Y   84
111
+    #endif
112
+
113
+    DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string()));
114
+    TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT));
115
+    clear_lcd();
116
+
117
+    DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2,  15);
118
+    #if ENABLED(DWIN_MARLINUI_PORTRAIT)
104
       DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, LOGO_CENTER - 174 / 2, 280);
119
       DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, LOGO_CENTER - 174 / 2, 280);
105
       DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL,  LOGO_CENTER - 180 / 2, 420);
120
       DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL,  LOGO_CENTER - 180 / 2, 420);
106
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL,  LOGO_CENTER - 100 / 2, 440);
121
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL,  LOGO_CENTER - 100 / 2, 440);
107
       DWIN_ICON_Show(BOOT_ICON, ICON_Copyright,  LOGO_CENTER - 126 / 2, 460);
122
       DWIN_ICON_Show(BOOT_ICON, ICON_Copyright,  LOGO_CENTER - 126 / 2, 460);
108
     #else
123
     #else
109
-      #define LOGO_CENTER (280 / 2)
110
-      #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2)
111
-      #define VERSION_Y   84
112
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2,  15);
124
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2,  15);
113
       DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, INFO_CENTER - 174 / 2,  60);
125
       DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, INFO_CENTER - 174 / 2,  60);
114
       DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL,  INFO_CENTER - 180 / 2, 130);
126
       DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL,  INFO_CENTER - 180 / 2, 130);
115
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL,  INFO_CENTER - 100 / 2, 152);
127
       DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL,  INFO_CENTER - 100 / 2, 152);
116
       DWIN_ICON_Show(BOOT_ICON, ICON_Copyright,  INFO_CENTER - 126 / 2, 200);
128
       DWIN_ICON_Show(BOOT_ICON, ICON_Copyright,  INFO_CENTER - 126 / 2, 200);
117
     #endif
129
     #endif
118
-
119
     DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string()));
130
     DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string()));
120
     DWIN_UpdateLCD();
131
     DWIN_UpdateLCD();
121
   }
132
   }
170
   dwin_font.solid = true;
181
   dwin_font.solid = true;
171
   dwin_font.fg = Color_White;
182
   dwin_font.fg = Color_White;
172
   dwin_font.bg = Color_Bg_Black;
183
   dwin_font.bg = Color_Bg_Black;
184
+  DWIN_Draw_Box(1, Color_Bg_Black, 0, (LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1), 272, STAT_FONT_HEIGHT + 1);
173
   lcd_moveto_xy(0, LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1);
185
   lcd_moveto_xy(0, LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1);
174
 
186
 
175
   constexpr uint8_t max_status_chars = (LCD_PIXEL_WIDTH) / (STAT_FONT_WIDTH);
187
   constexpr uint8_t max_status_chars = (LCD_PIXEL_WIDTH) / (STAT_FONT_WIDTH);

Loading…
Cancel
Save