Browse Source

Add Debug Menu with LCD_PROGRESS_BAR_TEST as an example

Scott Lahteine 7 years ago
parent
commit
18ba31e9b5

+ 2
- 0
Marlin/Conditionals_LCD.h View File

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

+ 2
- 0
Marlin/Configuration_adv.h View File

454
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
467
     #define PROGRESS_MSG_EXPIRE   0
468
     // Enable this to show messages for MSG_TIME then hide them
468
     // Enable this to show messages for MSG_TIME then hide them
469
     //#define PROGRESS_MSG_ONCE
469
     //#define PROGRESS_MSG_ONCE
470
+    // Add a menu item to test the progress bar:
471
+    //#define LCD_PROGRESS_BAR_TEST
470
   #endif
472
   #endif
471
 
473
 
472
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
462
     #define PROGRESS_MSG_EXPIRE   0
463
     // Enable this to show messages for MSG_TIME then hide them
463
     // Enable this to show messages for MSG_TIME then hide them
464
     //#define PROGRESS_MSG_ONCE
464
     //#define PROGRESS_MSG_ONCE
465
+    // Add a menu item to test the progress bar:
466
+    //#define LCD_PROGRESS_BAR_TEST
465
   #endif
467
   #endif
466
 
468
 
467
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
456
     #define PROGRESS_MSG_EXPIRE   0
457
     // Enable this to show messages for MSG_TIME then hide them
457
     // Enable this to show messages for MSG_TIME then hide them
458
     //#define PROGRESS_MSG_ONCE
458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459
   #endif
461
   #endif
460
 
462
 
461
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
456
     #define PROGRESS_MSG_EXPIRE   0
457
     // Enable this to show messages for MSG_TIME then hide them
457
     // Enable this to show messages for MSG_TIME then hide them
458
     //#define PROGRESS_MSG_ONCE
458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459
   #endif
461
   #endif
460
 
462
 
461
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
456
     #define PROGRESS_MSG_EXPIRE   0
457
     // Enable this to show messages for MSG_TIME then hide them
457
     // Enable this to show messages for MSG_TIME then hide them
458
     //#define PROGRESS_MSG_ONCE
458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459
   #endif
461
   #endif
460
 
462
 
461
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
461
     #define PROGRESS_MSG_EXPIRE   0
462
     // Enable this to show messages for MSG_TIME then hide them
462
     // Enable this to show messages for MSG_TIME then hide them
463
     //#define PROGRESS_MSG_ONCE
463
     //#define PROGRESS_MSG_ONCE
464
+    // Add a menu item to test the progress bar:
465
+    //#define LCD_PROGRESS_BAR_TEST
464
   #endif
466
   #endif
465
 
467
 
466
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
456
     #define PROGRESS_MSG_EXPIRE   0
457
     // Enable this to show messages for MSG_TIME then hide them
457
     // Enable this to show messages for MSG_TIME then hide them
458
     //#define PROGRESS_MSG_ONCE
458
     //#define PROGRESS_MSG_ONCE
459
+    // Add a menu item to test the progress bar:
460
+    //#define LCD_PROGRESS_BAR_TEST
459
   #endif
461
   #endif
460
 
462
 
461
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
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
     #define PROGRESS_MSG_EXPIRE   0
454
     #define PROGRESS_MSG_EXPIRE   0
455
     // Enable this to show messages for MSG_TIME then hide them
455
     // Enable this to show messages for MSG_TIME then hide them
456
     //#define PROGRESS_MSG_ONCE
456
     //#define PROGRESS_MSG_ONCE
457
+    // Add a menu item to test the progress bar:
458
+    //#define LCD_PROGRESS_BAR_TEST
457
   #endif
459
   #endif
458
 
460
 
459
   // This allows hosts to request long names for files and folders with M33
461
   // This allows hosts to request long names for files and folders with M33

+ 6
- 0
Marlin/language_en.h View File

51
 #ifndef MSG_DISABLE_STEPPERS
51
 #ifndef MSG_DISABLE_STEPPERS
52
   #define MSG_DISABLE_STEPPERS                _UxGT("Disable steppers")
52
   #define MSG_DISABLE_STEPPERS                _UxGT("Disable steppers")
53
 #endif
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
 #ifndef MSG_AUTO_HOME
60
 #ifndef MSG_AUTO_HOME
55
   #define MSG_AUTO_HOME                       _UxGT("Auto home")
61
   #define MSG_AUTO_HOME                       _UxGT("Auto home")
56
 #endif
62
 #endif

+ 49
- 0
Marlin/ultralcd.cpp View File

316
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
316
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
317
 
317
 
318
   // Used to print static text with no visible cursor.
318
   // Used to print static text with no visible cursor.
319
+  // Parameters: label [, bool center [, bool invert [, char *value] ] ]
319
   #define STATIC_ITEM(LABEL, ...) \
320
   #define STATIC_ITEM(LABEL, ...) \
320
     if (_menuLineNr == _thisItemNr) { \
321
     if (_menuLineNr == _thisItemNr) { \
321
       if (_skipStatic && encoderLine <= _thisItemNr) { \
322
       if (_skipStatic && encoderLine <= _thisItemNr) { \
623
 
624
 
624
   #endif // MENU_ITEM_CASE_LIGHT
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
    * "Main" menu
670
    * "Main" menu
634
     MENU_BACK(MSG_WATCH);
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
     // Switch case light on/off
686
     // Switch case light on/off
638
     //
687
     //
639
     #if ENABLED(MENU_ITEM_CASE_LIGHT)
688
     #if ENABLED(MENU_ITEM_CASE_LIGHT)

+ 21
- 15
Marlin/ultralcd_impl_HD44780.h View File

573
   }
573
   }
574
 }
574
 }
575
 
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
+
576
 /**
595
 /**
577
 Possible status screens:
596
 Possible status screens:
578
 16x2   |000/000 B000/000|
597
 16x2   |000/000 B000/000|
759
     if (card.isFileOpen()) {
778
     if (card.isFileOpen()) {
760
       // Draw the progress bar if the message has shown long enough
779
       // Draw the progress bar if the message has shown long enough
761
       // or if there is no message set.
780
       // or if there is no message set.
762
-      if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]) {
763
-        int tix = (int)(card.percentDone() * (LCD_WIDTH) * 3) / 100,
764
-          cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
765
-        char msg[LCD_WIDTH + 1], b = ' ';
766
-        msg[i] = '\0';
767
-        while (i--) {
768
-          if (i == cel - 1)
769
-            b = LCD_STR_PROGRESS[2];
770
-          else if (i == cel && rem != 0)
771
-            b = LCD_STR_PROGRESS[rem - 1];
772
-          msg[i] = b;
773
-        }
774
-        lcd.print(msg);
775
-        return;
776
-      }
781
+      if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0])
782
+        return lcd_draw_progress_bar(card.percentDone());
777
     } //card.isFileOpen
783
     } //card.isFileOpen
778
 
784
 
779
   #elif ENABLED(FILAMENT_LCD_DISPLAY)
785
   #elif ENABLED(FILAMENT_LCD_DISPLAY)

Loading…
Cancel
Save