Browse Source

Merge pull request #5562 from thinkyhead/rc_char_lcd_tweaks

Fix various LCD-related issues
Scott Lahteine 8 years ago
parent
commit
4213330d22

+ 2
- 0
Marlin/Conditionals_LCD.h View File

@@ -278,6 +278,8 @@
278 278
     #define BOOTSCREEN_TIMEOUT 2500
279 279
   #endif
280 280
 
281
+  #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
282
+
281 283
   /**
282 284
    * Extruders have some combination of stepper motors and hotends
283 285
    * so we separate these concepts into the defines:

+ 2
- 0
Marlin/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -467,6 +467,8 @@
467 467
     #define PROGRESS_MSG_EXPIRE   0
468 468
     // Enable this to show messages for MSG_TIME then hide them
469 469
     //#define PROGRESS_MSG_ONCE
470
+    // Add a menu item to test the progress bar:
471
+    //#define LCD_PROGRESS_BAR_TEST
470 472
   #endif
471 473
 
472 474
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -462,6 +462,8 @@
462 462
     #define PROGRESS_MSG_EXPIRE   0
463 463
     // Enable this to show messages for MSG_TIME then hide them
464 464
     //#define PROGRESS_MSG_ONCE
465
+    // Add a menu item to test the progress bar:
466
+    //#define LCD_PROGRESS_BAR_TEST
465 467
   #endif
466 468
 
467 469
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

@@ -456,6 +456,8 @@
456 456
     #define PROGRESS_MSG_EXPIRE   0
457 457
     // Enable this to show messages for MSG_TIME then hide them
458 458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459 461
   #endif
460 462
 
461 463
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -456,6 +456,8 @@
456 456
     #define PROGRESS_MSG_EXPIRE   0
457 457
     // Enable this to show messages for MSG_TIME then hide them
458 458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459 461
   #endif
460 462
 
461 463
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -456,6 +456,8 @@
456 456
     #define PROGRESS_MSG_EXPIRE   0
457 457
     // Enable this to show messages for MSG_TIME then hide them
458 458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459 461
   #endif
460 462
 
461 463
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -461,6 +461,8 @@
461 461
     #define PROGRESS_MSG_EXPIRE   0
462 462
     // Enable this to show messages for MSG_TIME then hide them
463 463
     //#define PROGRESS_MSG_ONCE
464
+    // Add a menu item to test the progress bar:
465
+    //#define LCD_PROGRESS_BAR_TEST
464 466
   #endif
465 467
 
466 468
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -456,6 +456,8 @@
456 456
     #define PROGRESS_MSG_EXPIRE   0
457 457
     // Enable this to show messages for MSG_TIME then hide them
458 458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459 461
   #endif
460 462
 
461 463
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 2
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -454,6 +454,8 @@
454 454
     #define PROGRESS_MSG_EXPIRE   0
455 455
     // Enable this to show messages for MSG_TIME then hide them
456 456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457 459
   #endif
458 460
 
459 461
   // This allows hosts to request long names for files and folders with M33

+ 8
- 2
Marlin/language_en.h View File

@@ -51,6 +51,12 @@
51 51
 #ifndef MSG_DISABLE_STEPPERS
52 52
   #define MSG_DISABLE_STEPPERS                _UxGT("Disable steppers")
53 53
 #endif
54
+#ifndef MSG_DEBUG_MENU
55
+  #define MSG_DEBUG_MENU                      _UxGT("Debug Menu")
56
+#endif
57
+#ifndef MSG_PROGRESS_BAR_TEST
58
+  #define MSG_PROGRESS_BAR_TEST               _UxGT("Progress Bar Test")
59
+#endif
54 60
 #ifndef MSG_AUTO_HOME
55 61
   #define MSG_AUTO_HOME                       _UxGT("Auto home")
56 62
 #endif
@@ -139,10 +145,10 @@
139 145
   #define MSG_LEVEL_BED                       _UxGT("Level bed")
140 146
 #endif
141 147
 #ifndef MSG_MOVING
142
-  #define MSG_MOVING                          "Moving..."
148
+  #define MSG_MOVING                          _UxGT("Moving...")
143 149
 #endif
144 150
 #ifndef MSG_FREE_XY
145
-  #define MSG_FREE_XY                         "Free XY"
151
+  #define MSG_FREE_XY                         _UxGT("Free XY")
146 152
 #endif
147 153
 #ifndef MSG_MOVE_X
148 154
   #define MSG_MOVE_X                          _UxGT("Move X")

+ 70
- 13
Marlin/ultralcd.cpp View File

@@ -316,6 +316,7 @@ uint16_t max_display_update_time = 0;
316 316
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
317 317
 
318 318
   // Used to print static text with no visible cursor.
319
+  // Parameters: label [, bool center [, bool invert [, char *value] ] ]
319 320
   #define STATIC_ITEM(LABEL, ...) \
320 321
     if (_menuLineNr == _thisItemNr) { \
321 322
       if (_skipStatic && encoderLine <= _thisItemNr) { \
@@ -623,6 +624,47 @@ void kill_screen(const char* lcd_msg) {
623 624
 
624 625
   #endif // MENU_ITEM_CASE_LIGHT
625 626
 
627
+  #if ENABLED(LCD_PROGRESS_BAR_TEST)
628
+
629
+    static void progress_bar_test() {
630
+      static int8_t bar_percent = 0;
631
+      if (lcd_clicked) {
632
+        lcd_goto_previous_menu();
633
+        lcd_set_custom_characters(false);
634
+        return;
635
+      }
636
+      bar_percent += (int8_t)encoderPosition;
637
+      bar_percent = constrain(bar_percent, 0, 100);
638
+      encoderPosition = 0;
639
+      lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
640
+      lcd.setCursor((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
641
+      lcd.print(itostr3(bar_percent)); lcd.print('%');
642
+      lcd.setCursor(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
643
+    }
644
+
645
+    void _progress_bar_test() {
646
+      lcd_goto_screen(progress_bar_test);
647
+      lcd_set_custom_characters();
648
+    }
649
+
650
+  #endif // LCD_PROGRESS_BAR_TEST
651
+
652
+  #if HAS_DEBUG_MENU
653
+
654
+    void lcd_debug_menu() {
655
+      START_MENU();
656
+
657
+      MENU_BACK(MSG_MAIN); // ^ Main
658
+
659
+      #if ENABLED(LCD_PROGRESS_BAR_TEST)
660
+        MENU_ITEM(submenu, MSG_PROGRESS_BAR_TEST, _progress_bar_test);
661
+      #endif
662
+
663
+      END_MENU();
664
+    }
665
+
666
+  #endif // HAS_DEBUG_MENU
667
+
626 668
   /**
627 669
    *
628 670
    * "Main" menu
@@ -634,6 +676,13 @@ void kill_screen(const char* lcd_msg) {
634 676
     MENU_BACK(MSG_WATCH);
635 677
 
636 678
     //
679
+    // Debug Menu when certain options are enabled
680
+    //
681
+    #if HAS_DEBUG_MENU
682
+      MENU_ITEM(submenu, MSG_DEBUG_MENU, lcd_debug_menu);
683
+    #endif
684
+
685
+    //
637 686
     // Switch case light on/off
638 687
     //
639 688
     #if ENABLED(MENU_ITEM_CASE_LIGHT)
@@ -1303,12 +1352,6 @@ KeepDrawing:
1303 1352
     #endif
1304 1353
 
1305 1354
     //
1306
-    // Set Home Offsets
1307
-    //
1308
-    MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
1309
-    //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
1310
-
1311
-    //
1312 1355
     // Level Bed
1313 1356
     //
1314 1357
     #if HAS_ABL
@@ -1320,6 +1363,12 @@ KeepDrawing:
1320 1363
     #endif
1321 1364
 
1322 1365
     //
1366
+    // Set Home Offsets
1367
+    //
1368
+    MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
1369
+    //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
1370
+
1371
+    //
1323 1372
     // Disable Steppers
1324 1373
     //
1325 1374
     MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
@@ -1341,7 +1390,12 @@ KeepDrawing:
1341 1390
     //
1342 1391
     // Cooldown
1343 1392
     //
1344
-    MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
1393
+    bool has_heat = false;
1394
+    HOTEND_LOOP() if (thermalManager.target_temperature[e]) { has_heat = true; break; }
1395
+    #if HAS_TEMP_BED
1396
+      if (thermalManager.target_temperature_bed) has_heat = true;
1397
+    #endif
1398
+    if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
1345 1399
 
1346 1400
     //
1347 1401
     // BLTouch Self-Test and Reset
@@ -2698,7 +2752,7 @@ KeepDrawing:
2698 2752
 
2699 2753
   #endif //SDSUPPORT
2700 2754
 
2701
-  void menu_action_setting_edit_bool(const char* pstr, bool* ptr) {UNUSED(pstr); *ptr = !(*ptr); }
2755
+  void menu_action_setting_edit_bool(const char* pstr, bool* ptr) {UNUSED(pstr); *ptr = !(*ptr); lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; }
2702 2756
   void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, screenFunc_t callback) {
2703 2757
     menu_action_setting_edit_bool(pstr, ptr);
2704 2758
     (*callback)();
@@ -2838,7 +2892,7 @@ bool lcd_blink() {
2838 2892
  *     - Before exiting the handler set lcdDrawUpdate to:
2839 2893
  *       - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
2840 2894
  *       - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE to keep drawingm but only in this loop.
2841
- *       - LCDVIEW_REDRAW_NEXT to keep drawing and draw on the next loop also.
2895
+ *       - LCDVIEW_CALL_REDRAW_NEXT to keep drawing and draw on the next loop also.
2842 2896
  *       - LCDVIEW_CALL_NO_REDRAW to keep drawing (or start drawing) with no redraw on the next loop.
2843 2897
  *     - NOTE: For graphical displays menu handlers may be called 2 or more times per loop,
2844 2898
  *             so don't change lcdDrawUpdate without considering this.
@@ -2951,12 +3005,15 @@ void lcd_update() {
2951 3005
 
2952 3006
           encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
2953 3007
           encoderDiff = 0;
2954
-          #if ENABLED(DOGLCD)
2955
-            drawing_screen = false;  // refresh the complete screen for a encoder change (different menu-item/value)
2956
-          #endif
2957 3008
         }
2958 3009
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
2959
-        lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
3010
+        lcdDrawUpdate =
3011
+          #if ENABLED(DOGLCD)
3012
+            LCDVIEW_CALL_REDRAW_NEXT
3013
+          #else
3014
+            LCDVIEW_REDRAW_NOW
3015
+          #endif
3016
+        ;
2960 3017
       }
2961 3018
     #endif // ULTIPANEL
2962 3019
 

+ 25
- 15
Marlin/ultralcd_impl_HD44780.h View File

@@ -530,11 +530,15 @@ void lcd_print(char c) { charset_mapper(c); }
530 530
       safe_delay(2000);
531 531
     #endif
532 532
 
533
+    /*
534
+    lcd.clear();
535
+
533 536
     lcd_set_custom_characters(
534 537
       #if ENABLED(LCD_PROGRESS_BAR)
535 538
         false
536 539
       #endif
537 540
     );
541
+    //*/
538 542
   }
539 543
 
540 544
 #endif // SHOW_BOOTSCREEN
@@ -569,6 +573,25 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr,
569 573
   }
570 574
 }
571 575
 
576
+#if ENABLED(LCD_PROGRESS_BAR)
577
+
578
+  inline void lcd_draw_progress_bar(const uint8_t percent) {
579
+    int tix = (int)(percent * (LCD_WIDTH) * 3) / 100,
580
+      cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
581
+    char msg[LCD_WIDTH + 1], b = ' ';
582
+    msg[i] = '\0';
583
+    while (i--) {
584
+      if (i == cel - 1)
585
+        b = LCD_STR_PROGRESS[2];
586
+      else if (i == cel && rem != 0)
587
+        b = LCD_STR_PROGRESS[rem - 1];
588
+      msg[i] = b;
589
+    }
590
+    lcd.print(msg);
591
+  }
592
+
593
+#endif // LCD_PROGRESS_BAR
594
+
572 595
 /**
573 596
 Possible status screens:
574 597
 16x2   |000/000 B000/000|
@@ -755,21 +778,8 @@ static void lcd_implementation_status_screen() {
755 778
     if (card.isFileOpen()) {
756 779
       // Draw the progress bar if the message has shown long enough
757 780
       // or if there is no message set.
758
-      if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]) {
759
-        int tix = (int)(card.percentDone() * (LCD_WIDTH) * 3) / 100,
760
-          cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
761
-        char msg[LCD_WIDTH + 1], b = ' ';
762
-        msg[i] = '\0';
763
-        while (i--) {
764
-          if (i == cel - 1)
765
-            b = LCD_STR_PROGRESS[2];
766
-          else if (i == cel && rem != 0)
767
-            b = LCD_STR_PROGRESS[rem - 1];
768
-          msg[i] = b;
769
-        }
770
-        lcd.print(msg);
771
-        return;
772
-      }
781
+      if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0])
782
+        return lcd_draw_progress_bar(card.percentDone());
773 783
     } //card.isFileOpen
774 784
 
775 785
   #elif ENABLED(FILAMENT_LCD_DISPLAY)

+ 1
- 1
Marlin/watchdog.cpp View File

@@ -43,7 +43,7 @@ void watchdog_init() {
43 43
 //=================================== ISR ===================================
44 44
 //===========================================================================
45 45
 
46
-// Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
46
+// Watchdog timer interrupt, called if main program blocks >4sec and manual reset is enabled.
47 47
 #if ENABLED(WATCHDOG_RESET_MANUAL)
48 48
   ISR(WDT_vect) {
49 49
     SERIAL_ERROR_START;

Loading…
Cancel
Save