Browse Source

Fix up LCD init / charset

Scott Lahteine 7 years ago
parent
commit
73ddc762c8
3 changed files with 113 additions and 93 deletions
  1. 0
    3
      Marlin/Marlin_main.cpp
  2. 12
    14
      Marlin/ultralcd.cpp
  3. 101
    76
      Marlin/ultralcd_impl_HD44780.h

+ 0
- 3
Marlin/Marlin_main.cpp View File

@@ -13904,9 +13904,6 @@ void setup() {
13904 13904
 
13905 13905
   #if ENABLED(SHOW_BOOTSCREEN)
13906 13906
     lcd_bootscreen();
13907
-    #if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
13908
-      lcd_init();
13909
-    #endif
13910 13907
   #endif
13911 13908
 
13912 13909
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1

+ 12
- 14
Marlin/ultralcd.cpp View File

@@ -521,13 +521,15 @@ uint16_t max_display_update_time = 0;
521 521
       lcd_implementation_clear();
522 522
       // Re-initialize custom characters that may be re-used
523 523
       #if DISABLED(DOGLCD) && ENABLED(AUTO_BED_LEVELING_UBL)
524
-        if (!ubl_lcd_map_control) lcd_set_custom_characters(
525
-          #if ENABLED(LCD_PROGRESS_BAR)
526
-            screen == lcd_status_screen
527
-          #endif
528
-        );
524
+        if (!ubl_lcd_map_control) {
525
+          lcd_set_custom_characters(
526
+            #if ENABLED(LCD_PROGRESS_BAR)
527
+              screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
528
+            #endif
529
+          );
530
+        }
529 531
       #elif ENABLED(LCD_PROGRESS_BAR)
530
-        lcd_set_custom_characters(screen == lcd_status_screen);
532
+        lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
531 533
       #endif
532 534
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
533 535
       screen_changed = true;
@@ -669,7 +671,7 @@ void lcd_status_screen() {
669 671
       #endif
670 672
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
671 673
         #if ENABLED(LCD_PROGRESS_BAR)
672
-          false
674
+          CHARSET_MENU
673 675
         #endif
674 676
       );
675 677
       lcd_goto_screen(lcd_main_menu);
@@ -850,7 +852,7 @@ void kill_screen(const char* lcd_msg) {
850 852
       static int8_t bar_percent = 0;
851 853
       if (lcd_clicked) {
852 854
         lcd_goto_previous_menu();
853
-        lcd_set_custom_characters(false);
855
+        lcd_set_custom_characters(CHARSET_MENU);
854 856
         return;
855 857
       }
856 858
       bar_percent += (int8_t)encoderPosition;
@@ -4469,11 +4471,7 @@ void kill_screen(const char* lcd_msg) {
4469 4471
 
4470 4472
 void lcd_init() {
4471 4473
 
4472
-  lcd_implementation_init(
4473
-    #if ENABLED(LCD_PROGRESS_BAR)
4474
-      true
4475
-    #endif
4476
-  );
4474
+  lcd_implementation_init();
4477 4475
 
4478 4476
   #if ENABLED(NEWPANEL)
4479 4477
     #if BUTTON_EXISTS(EN1)
@@ -4642,7 +4640,7 @@ void lcd_update() {
4642 4640
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
4643 4641
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
4644 4642
         #if ENABLED(LCD_PROGRESS_BAR)
4645
-          currentScreen == lcd_status_screen
4643
+          currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
4646 4644
         #endif
4647 4645
       );
4648 4646
     }

+ 101
- 76
Marlin/ultralcd_impl_HD44780.h View File

@@ -218,11 +218,57 @@ static void createChar_P(const char c, const byte * const ptr) {
218 218
   lcd.createChar(c, temp);
219 219
 }
220 220
 
221
+#define CHARSET_MENU 0
222
+#define CHARSET_INFO 1
223
+#define CHARSET_BOOT 2
224
+
221 225
 static void lcd_set_custom_characters(
222
-  #if ENABLED(LCD_PROGRESS_BAR)
223
-    const bool info_screen_charset = true
226
+  #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
227
+    const uint8_t screen_charset=CHARSET_INFO
224 228
   #endif
225 229
 ) {
230
+  // CHARSET_BOOT
231
+  #if ENABLED(SHOW_BOOTSCREEN)
232
+    const static PROGMEM byte corner[4][8] = { {
233
+      B00000,
234
+      B00000,
235
+      B00000,
236
+      B00000,
237
+      B00001,
238
+      B00010,
239
+      B00100,
240
+      B00100
241
+    }, {
242
+      B00000,
243
+      B00000,
244
+      B00000,
245
+      B11100,
246
+      B11100,
247
+      B01100,
248
+      B00100,
249
+      B00100
250
+    }, {
251
+      B00100,
252
+      B00010,
253
+      B00001,
254
+      B00000,
255
+      B00000,
256
+      B00000,
257
+      B00000,
258
+      B00000
259
+    }, {
260
+      B00100,
261
+      B01000,
262
+      B10000,
263
+      B00000,
264
+      B00000,
265
+      B00000,
266
+      B00000,
267
+      B00000
268
+    } };
269
+  #endif // SHOW_BOOTSCREEN
270
+
271
+  // CHARSET_INFO
226 272
   const static PROGMEM byte bedTemp[8] = {
227 273
     B00000,
228 274
     B11111,
@@ -290,6 +336,8 @@ static void lcd_set_custom_characters(
290 336
   };
291 337
 
292 338
   #if ENABLED(SDSUPPORT)
339
+
340
+    // CHARSET_MENU
293 341
     const static PROGMEM byte refresh[8] = {
294 342
       B00000,
295 343
       B00110,
@@ -312,6 +360,8 @@ static void lcd_set_custom_characters(
312 360
     };
313 361
 
314 362
     #if ENABLED(LCD_PROGRESS_BAR)
363
+
364
+      // CHARSET_INFO
315 365
       const static PROGMEM byte progress[3][8] = { {
316 366
         B00000,
317 367
         B10000,
@@ -340,43 +390,61 @@ static void lcd_set_custom_characters(
340 390
         B10101,
341 391
         B00000
342 392
       } };
343
-    #endif
344
-  #endif
345 393
 
346
-  createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
347
-  createChar_P(LCD_DEGREE_CHAR, degree);
348
-  createChar_P(LCD_STR_THERMOMETER[0], thermometer);
349
-  createChar_P(LCD_FEEDRATE_CHAR, feedrate);
350
-  createChar_P(LCD_CLOCK_CHAR, clock);
394
+    #endif // LCD_PROGRESS_BAR
351 395
 
352
-  #if ENABLED(SDSUPPORT)
353
-    #if ENABLED(LCD_PROGRESS_BAR)
354
-      static bool char_mode = false;
355
-      if (info_screen_charset != char_mode) {
356
-        char_mode = info_screen_charset;
357
-        if (info_screen_charset) { // Progress bar characters for info screen
358
-          for (int16_t i = 3; i--;) createChar_P(LCD_STR_PROGRESS[i], progress[i]);
359
-        }
360
-        else { // Custom characters for submenus
361
-          createChar_P(LCD_UPLEVEL_CHAR, uplevel);
362
-          createChar_P(LCD_STR_REFRESH[0], refresh);
363
-          createChar_P(LCD_STR_FOLDER[0], folder);
364
-        }
365
-      }
366
-    #else
367
-      createChar_P(LCD_UPLEVEL_CHAR, uplevel);
368
-      createChar_P(LCD_STR_REFRESH[0], refresh);
369
-      createChar_P(LCD_STR_FOLDER[0], folder);
370
-    #endif
396
+  #endif // SDSUPPORT
371 397
 
398
+  #if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
399
+    static uint8_t char_mode = 0;
400
+    #define CHAR_COND (screen_charset != char_mode)
372 401
   #else
373
-    createChar_P(LCD_UPLEVEL_CHAR, uplevel);
402
+    #define CHAR_COND true
374 403
   #endif
404
+
405
+  if (CHAR_COND) {
406
+    #if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
407
+      char_mode = screen_charset;
408
+      #if ENABLED(SHOW_BOOTSCREEN)
409
+        // Set boot screen corner characters
410
+        if (screen_charset == CHARSET_BOOT) {
411
+          for (uint8_t i = 4; i--;)
412
+            createChar_P(i, corner[i]);
413
+        }
414
+        else
415
+      #endif
416
+    #endif
417
+        { // Info Screen uses 5 special characters
418
+          createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
419
+          createChar_P(LCD_DEGREE_CHAR, degree);
420
+          createChar_P(LCD_STR_THERMOMETER[0], thermometer);
421
+          createChar_P(LCD_FEEDRATE_CHAR, feedrate);
422
+          createChar_P(LCD_CLOCK_CHAR, clock);
423
+
424
+          #if ENABLED(SDSUPPORT)
425
+            #if ENABLED(LCD_PROGRESS_BAR)
426
+              if (screen_charset == CHARSET_INFO) { // 3 Progress bar characters for info screen
427
+                for (int16_t i = 3; i--;)
428
+                  createChar_P(LCD_STR_PROGRESS[i], progress[i]);
429
+              }
430
+              else
431
+            #endif
432
+              { // SD Card sub-menu special characters
433
+                createChar_P(LCD_UPLEVEL_CHAR, uplevel);
434
+                createChar_P(LCD_STR_REFRESH[0], refresh);
435
+                createChar_P(LCD_STR_FOLDER[0], folder);
436
+              }
437
+          #else
438
+            // With no SD support, only need the uplevel character
439
+            createChar_P(LCD_UPLEVEL_CHAR, uplevel);
440
+          #endif
441
+        }
442
+  }
375 443
 }
376 444
 
377 445
 static void lcd_implementation_init(
378 446
   #if ENABLED(LCD_PROGRESS_BAR)
379
-    const bool info_screen_charset = true
447
+    const uint8_t screen_charset=CHARSET_INFO
380 448
   #endif
381 449
 ) {
382 450
 
@@ -406,7 +474,7 @@ static void lcd_implementation_init(
406 474
 
407 475
   lcd_set_custom_characters(
408 476
     #if ENABLED(LCD_PROGRESS_BAR)
409
-      info_screen_charset
477
+      screen_charset
410 478
     #endif
411 479
   );
412 480
 
@@ -458,46 +526,7 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
458 526
   }
459 527
 
460 528
   void lcd_bootscreen() {
461
-    const static PROGMEM byte corner[4][8] = { {
462
-      B00000,
463
-      B00000,
464
-      B00000,
465
-      B00000,
466
-      B00001,
467
-      B00010,
468
-      B00100,
469
-      B00100
470
-    }, {
471
-      B00000,
472
-      B00000,
473
-      B00000,
474
-      B11100,
475
-      B11100,
476
-      B01100,
477
-      B00100,
478
-      B00100
479
-    }, {
480
-      B00100,
481
-      B00010,
482
-      B00001,
483
-      B00000,
484
-      B00000,
485
-      B00000,
486
-      B00000,
487
-      B00000
488
-    }, {
489
-      B00100,
490
-      B01000,
491
-      B10000,
492
-      B00000,
493
-      B00000,
494
-      B00000,
495
-      B00000,
496
-      B00000
497
-    } };
498
-    for (uint8_t i = 0; i < 4; i++)
499
-      createChar_P(i, corner[i]);
500
-
529
+    lcd_set_custom_characters(CHARSET_BOOT);
501 530
     lcd.clear();
502 531
 
503 532
     #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
@@ -568,11 +597,7 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
568 597
 
569 598
     safe_delay(100);
570 599
 
571
-    lcd_set_custom_characters(
572
-      #if ENABLED(LCD_PROGRESS_BAR)
573
-        false
574
-      #endif
575
-    );
600
+    lcd_set_custom_characters();
576 601
   }
577 602
 
578 603
 #endif // SHOW_BOOTSCREEN

Loading…
Cancel
Save