浏览代码

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
 
802
 
803
   #if ENABLED(SHOW_BOOTSCREEN)
803
   #if ENABLED(SHOW_BOOTSCREEN)
804
     lcd_bootscreen();
804
     lcd_bootscreen();
805
-    #if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
806
-        lcd_init();
807
-    #endif
808
   #endif
805
   #endif
809
 
806
 
810
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
807
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1

+ 12
- 14
Marlin/src/lcd/ultralcd.cpp 查看文件

522
       lcd_implementation_clear();
522
       lcd_implementation_clear();
523
       // Re-initialize custom characters that may be re-used
523
       // Re-initialize custom characters that may be re-used
524
       #if DISABLED(DOGLCD) && ENABLED(AUTO_BED_LEVELING_UBL)
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
       #elif ENABLED(LCD_PROGRESS_BAR)
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
       #endif
534
       #endif
533
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
535
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
534
       screen_changed = true;
536
       screen_changed = true;
670
       #endif
672
       #endif
671
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
673
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
672
         #if ENABLED(LCD_PROGRESS_BAR)
674
         #if ENABLED(LCD_PROGRESS_BAR)
673
-          false
675
+          CHARSET_MENU
674
         #endif
676
         #endif
675
       );
677
       );
676
       lcd_goto_screen(lcd_main_menu);
678
       lcd_goto_screen(lcd_main_menu);
849
       static int8_t bar_percent = 0;
851
       static int8_t bar_percent = 0;
850
       if (lcd_clicked) {
852
       if (lcd_clicked) {
851
         lcd_goto_previous_menu();
853
         lcd_goto_previous_menu();
852
-        lcd_set_custom_characters(false);
854
+        lcd_set_custom_characters(CHARSET_MENU);
853
         return;
855
         return;
854
       }
856
       }
855
       bar_percent += (int8_t)encoderPosition;
857
       bar_percent += (int8_t)encoderPosition;
4458
 
4460
 
4459
 void lcd_init() {
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
   #if ENABLED(NEWPANEL)
4465
   #if ENABLED(NEWPANEL)
4468
 
4466
 
4636
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
4634
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
4637
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
4635
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
4638
         #if ENABLED(LCD_PROGRESS_BAR)
4636
         #if ENABLED(LCD_PROGRESS_BAR)
4639
-          currentScreen == lcd_status_screen
4637
+          currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
4640
         #endif
4638
         #endif
4641
       );
4639
       );
4642
     }
4640
     }

+ 99
- 31
Marlin/src/lcd/ultralcd_impl_HD44780.h 查看文件

221
   lcd.createChar(c, temp);
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
 static void lcd_set_custom_characters(
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
   #endif
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
   const static PROGMEM byte bedTemp[8] = {
275
   const static PROGMEM byte bedTemp[8] = {
230
     B00000,
276
     B00000,
231
     B11111,
277
     B11111,
293
   };
339
   };
294
 
340
 
295
   #if ENABLED(SDSUPPORT)
341
   #if ENABLED(SDSUPPORT)
342
+
343
+    // CHARSET_MENU
296
     const static PROGMEM byte refresh[8] = {
344
     const static PROGMEM byte refresh[8] = {
297
       B00000,
345
       B00000,
298
       B00110,
346
       B00110,
315
     };
363
     };
316
 
364
 
317
     #if ENABLED(LCD_PROGRESS_BAR)
365
     #if ENABLED(LCD_PROGRESS_BAR)
366
+
367
+      // CHARSET_INFO
318
       const static PROGMEM byte progress[3][8] = { {
368
       const static PROGMEM byte progress[3][8] = { {
319
         B00000,
369
         B00000,
320
         B10000,
370
         B10000,
343
         B10101,
393
         B10101,
344
         B00000
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
   #else
404
   #else
376
-    createChar_P(LCD_UPLEVEL_CHAR, uplevel);
405
+    #define CHAR_COND true
377
   #endif
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
 static void lcd_implementation_init(
448
 static void lcd_implementation_init(
381
   #if ENABLED(LCD_PROGRESS_BAR)
449
   #if ENABLED(LCD_PROGRESS_BAR)
382
-    const bool info_screen_charset = true
450
+    const uint8_t screen_charset=CHARSET_INFO
383
   #endif
451
   #endif
384
 ) {
452
 ) {
385
 
453
 
409
 
477
 
410
   lcd_set_custom_characters(
478
   lcd_set_custom_characters(
411
     #if ENABLED(LCD_PROGRESS_BAR)
479
     #if ENABLED(LCD_PROGRESS_BAR)
412
-      info_screen_charset
480
+      screen_charset
413
     #endif
481
     #endif
414
   );
482
   );
415
 
483
 

正在加载...
取消
保存