ソースを参照

Merge pull request #8526 from thinkyhead/bf1_lcd_init_charset

[1.1.x] Fix up LCD init / charset
Scott Lahteine 6年前
コミット
3958ff8627
コミッターのメールアドレスに関連付けられたアカウントが存在しません
8個のファイルの変更135行の追加109行の削除
  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 ファイルの表示

8414
     }
8414
     }
8415
 
8415
 
8416
     #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD)  // Only needed with an LCD
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
     #endif
8418
     #endif
8419
   }
8419
   }
8420
 }
8420
 }
13483
       disable_e_steppers();
13483
       disable_e_steppers();
13484
     #endif
13484
     #endif
13485
     #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD)  // Only needed with an LCD
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
     #endif
13487
     #endif
13488
   }
13488
   }
13489
 
13489
 
13904
 
13904
 
13905
   #if ENABLED(SHOW_BOOTSCREEN)
13905
   #if ENABLED(SHOW_BOOTSCREEN)
13906
     lcd_bootscreen();
13906
     lcd_bootscreen();
13907
-    #if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
13908
-      lcd_init();
13909
-    #endif
13910
   #endif
13907
   #endif
13911
 
13908
 
13912
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
13909
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1

+ 5
- 5
Marlin/stepper.cpp ファイルの表示

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

+ 4
- 0
Marlin/ubl.cpp ファイルの表示

73
   bool unified_bed_leveling::g26_debug_flag = false,
73
   bool unified_bed_leveling::g26_debug_flag = false,
74
        unified_bed_leveling::has_control_of_lcd_panel = false;
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
   volatile int unified_bed_leveling::encoder_diff;
80
   volatile int unified_bed_leveling::encoder_diff;
77
 
81
 
78
   unified_bed_leveling::unified_bed_leveling() {
82
   unified_bed_leveling::unified_bed_leveling() {

+ 7
- 3
Marlin/ubl.h ファイルの表示

46
 
46
 
47
   // ubl.cpp
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
   // ubl_motion.cpp
53
   // ubl_motion.cpp
54
 
54
 
191
 
191
 
192
       static bool g26_debug_flag, has_control_of_lcd_panel;
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
       static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
198
       static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
195
 
199
 
196
       unified_bed_leveling();
200
       unified_bed_leveling();

+ 2
- 2
Marlin/ubl_G29.cpp ファイルの表示

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

+ 14
- 17
Marlin/ultralcd.cpp ファイルの表示

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

+ 0
- 1
Marlin/ultralcd.h ファイルの表示

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

+ 101
- 76
Marlin/ultralcd_impl_HD44780.h ファイルの表示

218
   lcd.createChar(c, temp);
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
 static void lcd_set_custom_characters(
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
   #endif
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
   const static PROGMEM byte bedTemp[8] = {
272
   const static PROGMEM byte bedTemp[8] = {
227
     B00000,
273
     B00000,
228
     B11111,
274
     B11111,
290
   };
336
   };
291
 
337
 
292
   #if ENABLED(SDSUPPORT)
338
   #if ENABLED(SDSUPPORT)
339
+
340
+    // CHARSET_MENU
293
     const static PROGMEM byte refresh[8] = {
341
     const static PROGMEM byte refresh[8] = {
294
       B00000,
342
       B00000,
295
       B00110,
343
       B00110,
312
     };
360
     };
313
 
361
 
314
     #if ENABLED(LCD_PROGRESS_BAR)
362
     #if ENABLED(LCD_PROGRESS_BAR)
363
+
364
+      // CHARSET_INFO
315
       const static PROGMEM byte progress[3][8] = { {
365
       const static PROGMEM byte progress[3][8] = { {
316
         B00000,
366
         B00000,
317
         B10000,
367
         B10000,
340
         B10101,
390
         B10101,
341
         B00000
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
   #else
401
   #else
373
-    createChar_P(LCD_UPLEVEL_CHAR, uplevel);
402
+    #define CHAR_COND true
374
   #endif
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
 static void lcd_implementation_init(
445
 static void lcd_implementation_init(
378
   #if ENABLED(LCD_PROGRESS_BAR)
446
   #if ENABLED(LCD_PROGRESS_BAR)
379
-    const bool info_screen_charset = true
447
+    const uint8_t screen_charset=CHARSET_INFO
380
   #endif
448
   #endif
381
 ) {
449
 ) {
382
 
450
 
406
 
474
 
407
   lcd_set_custom_characters(
475
   lcd_set_custom_characters(
408
     #if ENABLED(LCD_PROGRESS_BAR)
476
     #if ENABLED(LCD_PROGRESS_BAR)
409
-      info_screen_charset
477
+      screen_charset
410
     #endif
478
     #endif
411
   );
479
   );
412
 
480
 
458
   }
526
   }
459
 
527
 
460
   void lcd_bootscreen() {
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
     lcd.clear();
530
     lcd.clear();
502
 
531
 
503
     #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
532
     #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
568
 
597
 
569
     safe_delay(100);
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
 #endif // SHOW_BOOTSCREEN
603
 #endif // SHOW_BOOTSCREEN

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