ソースを参照

Fix up LCD init / charset

Scott Lahteine 7年前
コミット
9406c87a97
3個のファイルの変更111行の追加48行の削除
  1. 0
    3
      Marlin/src/Marlin.cpp
  2. 12
    14
      Marlin/src/lcd/ultralcd.cpp
  3. 99
    31
      Marlin/src/lcd/ultralcd_impl_HD44780.h

+ 0
- 3
Marlin/src/Marlin.cpp ファイルの表示

@@ -802,9 +802,6 @@ void setup() {
802 802
 
803 803
   #if ENABLED(SHOW_BOOTSCREEN)
804 804
     lcd_bootscreen();
805
-    #if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
806
-        lcd_init();
807
-    #endif
808 805
   #endif
809 806
 
810 807
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1

+ 12
- 14
Marlin/src/lcd/ultralcd.cpp ファイルの表示

@@ -522,13 +522,15 @@ uint16_t max_display_update_time = 0;
522 522
       lcd_implementation_clear();
523 523
       // Re-initialize custom characters that may be re-used
524 524
       #if DISABLED(DOGLCD) && ENABLED(AUTO_BED_LEVELING_UBL)
525
-        if (!ubl.lcd_map_control) lcd_set_custom_characters(
526
-          #if ENABLED(LCD_PROGRESS_BAR)
527
-            screen == lcd_status_screen
528
-          #endif
529
-        );
525
+        if (!ubl.lcd_map_control) {
526
+          lcd_set_custom_characters(
527
+            #if ENABLED(LCD_PROGRESS_BAR)
528
+              screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
529
+            #endif
530
+          );
531
+        }
530 532
       #elif ENABLED(LCD_PROGRESS_BAR)
531
-        lcd_set_custom_characters(screen == lcd_status_screen);
533
+        lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
532 534
       #endif
533 535
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
534 536
       screen_changed = true;
@@ -670,7 +672,7 @@ void lcd_status_screen() {
670 672
       #endif
671 673
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
672 674
         #if ENABLED(LCD_PROGRESS_BAR)
673
-          false
675
+          CHARSET_MENU
674 676
         #endif
675 677
       );
676 678
       lcd_goto_screen(lcd_main_menu);
@@ -849,7 +851,7 @@ void kill_screen(const char* lcd_msg) {
849 851
       static int8_t bar_percent = 0;
850 852
       if (lcd_clicked) {
851 853
         lcd_goto_previous_menu();
852
-        lcd_set_custom_characters(false);
854
+        lcd_set_custom_characters(CHARSET_MENU);
853 855
         return;
854 856
       }
855 857
       bar_percent += (int8_t)encoderPosition;
@@ -4458,11 +4460,7 @@ void kill_screen(const char* lcd_msg) {
4458 4460
 
4459 4461
 void lcd_init() {
4460 4462
 
4461
-  lcd_implementation_init(
4462
-    #if ENABLED(LCD_PROGRESS_BAR)
4463
-      true
4464
-    #endif
4465
-  );
4463
+  lcd_implementation_init();
4466 4464
 
4467 4465
   #if ENABLED(NEWPANEL)
4468 4466
 
@@ -4636,7 +4634,7 @@ void lcd_update() {
4636 4634
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
4637 4635
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
4638 4636
         #if ENABLED(LCD_PROGRESS_BAR)
4639
-          currentScreen == lcd_status_screen
4637
+          currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
4640 4638
         #endif
4641 4639
       );
4642 4640
     }

+ 99
- 31
Marlin/src/lcd/ultralcd_impl_HD44780.h ファイルの表示

@@ -221,11 +221,57 @@ static void createChar_P(const char c, const byte * const ptr) {
221 221
   lcd.createChar(c, temp);
222 222
 }
223 223
 
224
+#define CHARSET_MENU 0
225
+#define CHARSET_INFO 1
226
+#define CHARSET_BOOT 2
227
+
224 228
 static void lcd_set_custom_characters(
225
-  #if ENABLED(LCD_PROGRESS_BAR)
226
-    const bool info_screen_charset = true
229
+  #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
230
+    const uint8_t screen_charset=CHARSET_INFO
227 231
   #endif
228 232
 ) {
233
+  // CHARSET_BOOT
234
+  #if ENABLED(SHOW_BOOTSCREEN)
235
+    const static PROGMEM byte corner[4][8] = { {
236
+      B00000,
237
+      B00000,
238
+      B00000,
239
+      B00000,
240
+      B00001,
241
+      B00010,
242
+      B00100,
243
+      B00100
244
+    }, {
245
+      B00000,
246
+      B00000,
247
+      B00000,
248
+      B11100,
249
+      B11100,
250
+      B01100,
251
+      B00100,
252
+      B00100
253
+    }, {
254
+      B00100,
255
+      B00010,
256
+      B00001,
257
+      B00000,
258
+      B00000,
259
+      B00000,
260
+      B00000,
261
+      B00000
262
+    }, {
263
+      B00100,
264
+      B01000,
265
+      B10000,
266
+      B00000,
267
+      B00000,
268
+      B00000,
269
+      B00000,
270
+      B00000
271
+    } };
272
+  #endif // SHOW_BOOTSCREEN
273
+
274
+  // CHARSET_INFO
229 275
   const static PROGMEM byte bedTemp[8] = {
230 276
     B00000,
231 277
     B11111,
@@ -293,6 +339,8 @@ static void lcd_set_custom_characters(
293 339
   };
294 340
 
295 341
   #if ENABLED(SDSUPPORT)
342
+
343
+    // CHARSET_MENU
296 344
     const static PROGMEM byte refresh[8] = {
297 345
       B00000,
298 346
       B00110,
@@ -315,6 +363,8 @@ static void lcd_set_custom_characters(
315 363
     };
316 364
 
317 365
     #if ENABLED(LCD_PROGRESS_BAR)
366
+
367
+      // CHARSET_INFO
318 368
       const static PROGMEM byte progress[3][8] = { {
319 369
         B00000,
320 370
         B10000,
@@ -343,43 +393,61 @@ static void lcd_set_custom_characters(
343 393
         B10101,
344 394
         B00000
345 395
       } };
346
-    #endif
347
-  #endif
348 396
 
349
-  createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
350
-  createChar_P(LCD_DEGREE_CHAR, degree);
351
-  createChar_P(LCD_STR_THERMOMETER[0], thermometer);
352
-  createChar_P(LCD_FEEDRATE_CHAR, feedrate);
353
-  createChar_P(LCD_CLOCK_CHAR, clock);
397
+    #endif // LCD_PROGRESS_BAR
354 398
 
355
-  #if ENABLED(SDSUPPORT)
356
-    #if ENABLED(LCD_PROGRESS_BAR)
357
-      static bool char_mode = false;
358
-      if (info_screen_charset != char_mode) {
359
-        char_mode = info_screen_charset;
360
-        if (info_screen_charset) { // Progress bar characters for info screen
361
-          for (int16_t i = 3; i--;) createChar_P(LCD_STR_PROGRESS[i], progress[i]);
362
-        }
363
-        else { // Custom characters for submenus
364
-          createChar_P(LCD_UPLEVEL_CHAR, uplevel);
365
-          createChar_P(LCD_STR_REFRESH[0], refresh);
366
-          createChar_P(LCD_STR_FOLDER[0], folder);
367
-        }
368
-      }
369
-    #else
370
-      createChar_P(LCD_UPLEVEL_CHAR, uplevel);
371
-      createChar_P(LCD_STR_REFRESH[0], refresh);
372
-      createChar_P(LCD_STR_FOLDER[0], folder);
373
-    #endif
399
+  #endif // SDSUPPORT
374 400
 
401
+  #if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
402
+    static uint8_t char_mode = 0;
403
+    #define CHAR_COND (screen_charset != char_mode)
375 404
   #else
376
-    createChar_P(LCD_UPLEVEL_CHAR, uplevel);
405
+    #define CHAR_COND true
377 406
   #endif
407
+
408
+  if (CHAR_COND) {
409
+    #if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
410
+      char_mode = screen_charset;
411
+      #if ENABLED(SHOW_BOOTSCREEN)
412
+        // Set boot screen corner characters
413
+        if (screen_charset == CHARSET_BOOT) {
414
+          for (uint8_t i = 4; i--;)
415
+            createChar_P(i, corner[i]);
416
+        }
417
+        else
418
+      #endif
419
+    #endif
420
+        { // Info Screen uses 5 special characters
421
+          createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
422
+          createChar_P(LCD_DEGREE_CHAR, degree);
423
+          createChar_P(LCD_STR_THERMOMETER[0], thermometer);
424
+          createChar_P(LCD_FEEDRATE_CHAR, feedrate);
425
+          createChar_P(LCD_CLOCK_CHAR, clock);
426
+
427
+          #if ENABLED(SDSUPPORT)
428
+            #if ENABLED(LCD_PROGRESS_BAR)
429
+              if (screen_charset == CHARSET_INFO) { // 3 Progress bar characters for info screen
430
+                for (int16_t i = 3; i--;)
431
+                  createChar_P(LCD_STR_PROGRESS[i], progress[i]);
432
+              }
433
+              else
434
+            #endif
435
+              { // SD Card sub-menu special characters
436
+                createChar_P(LCD_UPLEVEL_CHAR, uplevel);
437
+                createChar_P(LCD_STR_REFRESH[0], refresh);
438
+                createChar_P(LCD_STR_FOLDER[0], folder);
439
+              }
440
+          #else
441
+            // With no SD support, only need the uplevel character
442
+            createChar_P(LCD_UPLEVEL_CHAR, uplevel);
443
+          #endif
444
+        }
445
+  }
378 446
 }
379 447
 
380 448
 static void lcd_implementation_init(
381 449
   #if ENABLED(LCD_PROGRESS_BAR)
382
-    const bool info_screen_charset = true
450
+    const uint8_t screen_charset=CHARSET_INFO
383 451
   #endif
384 452
 ) {
385 453
 
@@ -409,7 +477,7 @@ static void lcd_implementation_init(
409 477
 
410 478
   lcd_set_custom_characters(
411 479
     #if ENABLED(LCD_PROGRESS_BAR)
412
-      info_screen_charset
480
+      screen_charset
413 481
     #endif
414 482
   );
415 483
 

読み込み中…
キャンセル
保存