Browse Source

Merge pull request #8526 from thinkyhead/bf1_lcd_init_charset

[1.1.x] Fix up LCD init / charset
Scott Lahteine 7 years ago
parent
commit
3958ff8627
No account linked to committer's email address
8 changed files with 135 additions and 109 deletions
  1. 2
    5
      Marlin/Marlin_main.cpp
  2. 5
    5
      Marlin/stepper.cpp
  3. 4
    0
      Marlin/ubl.cpp
  4. 7
    3
      Marlin/ubl.h
  5. 2
    2
      Marlin/ubl_G29.cpp
  6. 14
    17
      Marlin/ultralcd.cpp
  7. 0
    1
      Marlin/ultralcd.h
  8. 101
    76
      Marlin/ultralcd_impl_HD44780.h

+ 2
- 5
Marlin/Marlin_main.cpp View File

@@ -8414,7 +8414,7 @@ inline void gcode_M18_M84() {
8414 8414
     }
8415 8415
 
8416 8416
     #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD)  // Only needed with an LCD
8417
-      ubl_lcd_map_control = defer_return_to_status = false;
8417
+      ubl.lcd_map_control = defer_return_to_status = false;
8418 8418
     #endif
8419 8419
   }
8420 8420
 }
@@ -13483,7 +13483,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
13483 13483
       disable_e_steppers();
13484 13484
     #endif
13485 13485
     #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD)  // Only needed with an LCD
13486
-      ubl_lcd_map_control = defer_return_to_status = false;
13486
+      ubl.lcd_map_control = defer_return_to_status = false;
13487 13487
     #endif
13488 13488
   }
13489 13489
 
@@ -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

+ 5
- 5
Marlin/stepper.cpp View File

@@ -54,6 +54,10 @@
54 54
 #include "cardreader.h"
55 55
 #include "speed_lookuptable.h"
56 56
 
57
+#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTIPANEL)
58
+  #include "ubl.h"
59
+#endif
60
+
57 61
 #if HAS_DIGIPOTSS
58 62
   #include <SPI.h>
59 63
 #endif
@@ -62,10 +66,6 @@ Stepper stepper; // Singleton
62 66
 
63 67
 // public:
64 68
 
65
-#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTIPANEL)
66
-  extern bool ubl_lcd_map_control;
67
-#endif
68
-
69 69
 block_t* Stepper::current_block = NULL;  // A pointer to the block currently being traced
70 70
 
71 71
 #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
@@ -1224,7 +1224,7 @@ void Stepper::finish_and_disable() {
1224 1224
 
1225 1225
 void Stepper::quick_stop() {
1226 1226
   #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTIPANEL)
1227
-    if (!ubl_lcd_map_control)
1227
+    if (!ubl.lcd_map_control)
1228 1228
       cleaning_buffer_counter = 5000;
1229 1229
   #else
1230 1230
     cleaning_buffer_counter = 5000;

+ 4
- 0
Marlin/ubl.cpp View File

@@ -73,6 +73,10 @@
73 73
   bool unified_bed_leveling::g26_debug_flag = false,
74 74
        unified_bed_leveling::has_control_of_lcd_panel = false;
75 75
 
76
+  #if ENABLED(ULTIPANEL)
77
+    bool unified_bed_leveling::lcd_map_control = false;
78
+  #endif
79
+
76 80
   volatile int unified_bed_leveling::encoder_diff;
77 81
 
78 82
   unified_bed_leveling::unified_bed_leveling() {

+ 7
- 3
Marlin/ubl.h View File

@@ -46,9 +46,9 @@
46 46
 
47 47
   // ubl.cpp
48 48
 
49
-void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y);
50
-void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
51
-bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
49
+  void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y);
50
+  void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
51
+  bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
52 52
 
53 53
   // ubl_motion.cpp
54 54
 
@@ -191,6 +191,10 @@ bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
191 191
 
192 192
       static bool g26_debug_flag, has_control_of_lcd_panel;
193 193
 
194
+      #if ENABLED(ULTIPANEL)
195
+        static bool lcd_map_control;
196
+      #endif
197
+
194 198
       static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
195 199
 
196 200
       unified_bed_leveling();

+ 2
- 2
Marlin/ubl_G29.cpp View File

@@ -1526,7 +1526,7 @@
1526 1526
           idle();
1527 1527
         } while (!ubl_lcd_clicked());
1528 1528
 
1529
-        if (!ubl_lcd_map_control) lcd_return_to_status();
1529
+        if (!lcd_map_control) lcd_return_to_status();
1530 1530
 
1531 1531
         // The technique used here generates a race condition for the encoder click.
1532 1532
         // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
@@ -1571,7 +1571,7 @@
1571 1571
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1572 1572
       SERIAL_ECHOLNPGM("Done Editing Mesh");
1573 1573
 
1574
-      if (ubl_lcd_map_control)
1574
+      if (lcd_map_control)
1575 1575
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
1576 1576
       else
1577 1577
         lcd_return_to_status();

+ 14
- 17
Marlin/ultralcd.cpp View File

@@ -50,7 +50,6 @@
50 50
 
51 51
 #if ENABLED(AUTO_BED_LEVELING_UBL)
52 52
   #include "ubl.h"
53
-  bool ubl_lcd_map_control = false;
54 53
 #elif HAS_ABL
55 54
   #include "planner.h"
56 55
 #elif ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
@@ -514,20 +513,22 @@ uint16_t max_display_update_time = 0;
514 513
       if (screen == lcd_status_screen) {
515 514
         defer_return_to_status = false;
516 515
         #if ENABLED(AUTO_BED_LEVELING_UBL)
517
-          ubl_lcd_map_control = false;
516
+          ubl.lcd_map_control = false;
518 517
         #endif
519 518
         screen_history_depth = 0;
520 519
       }
521 520
       lcd_implementation_clear();
522 521
       // Re-initialize custom characters that may be re-used
523 522
       #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
-        );
523
+        if (!ubl.lcd_map_control) {
524
+          lcd_set_custom_characters(
525
+            #if ENABLED(LCD_PROGRESS_BAR)
526
+              screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
527
+            #endif
528
+          );
529
+        }
529 530
       #elif ENABLED(LCD_PROGRESS_BAR)
530
-        lcd_set_custom_characters(screen == lcd_status_screen);
531
+        lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
531 532
       #endif
532 533
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
533 534
       screen_changed = true;
@@ -669,7 +670,7 @@ void lcd_status_screen() {
669 670
       #endif
670 671
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
671 672
         #if ENABLED(LCD_PROGRESS_BAR)
672
-          false
673
+          CHARSET_MENU
673 674
         #endif
674 675
       );
675 676
       lcd_goto_screen(lcd_main_menu);
@@ -850,7 +851,7 @@ void kill_screen(const char* lcd_msg) {
850 851
       static int8_t bar_percent = 0;
851 852
       if (lcd_clicked) {
852 853
         lcd_goto_previous_menu();
853
-        lcd_set_custom_characters(false);
854
+        lcd_set_custom_characters(CHARSET_MENU);
854 855
         return;
855 856
       }
856 857
       bar_percent += (int8_t)encoderPosition;
@@ -2356,7 +2357,7 @@ void kill_screen(const char* lcd_msg) {
2356 2357
 
2357 2358
     void _lcd_ubl_map_homing() {
2358 2359
       defer_return_to_status = true;
2359
-      ubl_lcd_map_control = true; // Return to the map screen
2360
+      ubl.lcd_map_control = true; // Return to the map screen
2360 2361
       if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT < 3 ? 0 : (LCD_HEIGHT > 4 ? 2 : 1), PSTR(MSG_LEVEL_BED_HOMING));
2361 2362
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2362 2363
       if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
@@ -4469,11 +4470,7 @@ void kill_screen(const char* lcd_msg) {
4469 4470
 
4470 4471
 void lcd_init() {
4471 4472
 
4472
-  lcd_implementation_init(
4473
-    #if ENABLED(LCD_PROGRESS_BAR)
4474
-      true
4475
-    #endif
4476
-  );
4473
+  lcd_implementation_init();
4477 4474
 
4478 4475
   #if ENABLED(NEWPANEL)
4479 4476
     #if BUTTON_EXISTS(EN1)
@@ -4642,7 +4639,7 @@ void lcd_update() {
4642 4639
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
4643 4640
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
4644 4641
         #if ENABLED(LCD_PROGRESS_BAR)
4645
-          currentScreen == lcd_status_screen
4642
+          currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
4646 4643
         #endif
4647 4644
       );
4648 4645
     }

+ 0
- 1
Marlin/ultralcd.h View File

@@ -193,7 +193,6 @@
193 193
 void lcd_reset_status();
194 194
 
195 195
 #if ENABLED(AUTO_BED_LEVELING_UBL)
196
-  extern bool ubl_lcd_map_control;
197 196
   void lcd_mesh_edit_setup(float initial);
198 197
   float lcd_mesh_edit();
199 198
   void lcd_z_offset_edit_setup(float);

+ 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