Ver código fonte

Encapsulate common display code in a singleton (#12395)

* Encapsulate common LCD code in a singleton
* Depend more UBL code on UBL_DEVEL_DEBUGGING
  - Since most users don't need the debugging on at all times, this helps reduce the default build size for UBL by over 2K, a little closer to fitting on 128K boards.
Scott Lahteine 5 anos atrás
pai
commit
a0c795b097
Nenhuma conta vinculada ao e-mail do autor do commit
65 arquivos alterados com 1885 adições e 2001 exclusões
  1. 7
    7
      Marlin/src/Marlin.cpp
  2. 1
    1
      Marlin/src/config/examples/Geeetech/GT2560/Configuration.h
  3. 1
    1
      Marlin/src/feature/bedlevel/bedlevel.cpp
  4. 9
    23
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  5. 7
    9
      Marlin/src/feature/bedlevel/ubl/ubl.h
  6. 336
    344
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  7. 1
    1
      Marlin/src/feature/pause.cpp
  8. 28
    29
      Marlin/src/gcode/bedlevel/G26.cpp
  9. 2
    2
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  10. 2
    2
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  11. 1
    1
      Marlin/src/gcode/calibrate/G28.cpp
  12. 4
    4
      Marlin/src/gcode/calibrate/G33.cpp
  13. 1
    1
      Marlin/src/gcode/control/M17_M18_M84.cpp
  14. 1
    1
      Marlin/src/gcode/control/M80_M81.cpp
  15. 1
    1
      Marlin/src/gcode/control/M999.cpp
  16. 3
    3
      Marlin/src/gcode/lcd/M0_M1.cpp
  17. 1
    1
      Marlin/src/gcode/lcd/M117.cpp
  18. 4
    4
      Marlin/src/gcode/lcd/M145.cpp
  19. 2
    4
      Marlin/src/gcode/lcd/M250.cpp
  20. 2
    4
      Marlin/src/gcode/lcd/M73.cpp
  21. 1
    1
      Marlin/src/gcode/motion/G4.cpp
  22. 1
    1
      Marlin/src/gcode/stats/M31.cpp
  23. 2
    2
      Marlin/src/gcode/temperature/M104_M109.cpp
  24. 1
    1
      Marlin/src/gcode/temperature/M140_M190.cpp
  25. 30
    55
      Marlin/src/inc/Conditionals_LCD.h
  26. 36
    0
      Marlin/src/inc/Conditionals_post.h
  27. 2
    0
      Marlin/src/inc/SanityCheck.h
  28. 1
    65
      Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h
  29. 99
    147
      Marlin/src/lcd/HD44780/ultralcd_impl_HD44780.cpp
  30. 35
    46
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  31. 102
    142
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  32. 2
    2
      Marlin/src/lcd/dogm/status_screen_lite_ST7920_class.h
  33. 28
    29
      Marlin/src/lcd/dogm/ultralcd_impl_DOGM.cpp
  34. 14
    14
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  35. 1
    1
      Marlin/src/lcd/language/language_es.h
  36. 1
    1
      Marlin/src/lcd/language/language_zh_CN.h
  37. 1
    1
      Marlin/src/lcd/language/language_zh_TW.h
  38. 3
    3
      Marlin/src/lcd/malyanlcd.cpp
  39. 60
    71
      Marlin/src/lcd/menu/menu.cpp
  40. 55
    96
      Marlin/src/lcd/menu/menu.h
  41. 6
    6
      Marlin/src/lcd/menu/menu_advanced.cpp
  42. 4
    4
      Marlin/src/lcd/menu/menu_bed_corners.cpp
  43. 30
    30
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  44. 11
    15
      Marlin/src/lcd/menu/menu_configuration.cpp
  45. 2
    2
      Marlin/src/lcd/menu/menu_custom.cpp
  46. 6
    6
      Marlin/src/lcd/menu/menu_delta_calibrate.cpp
  47. 8
    8
      Marlin/src/lcd/menu/menu_filament.cpp
  48. 4
    4
      Marlin/src/lcd/menu/menu_info.cpp
  49. 3
    3
      Marlin/src/lcd/menu/menu_job_recovery.cpp
  50. 4
    4
      Marlin/src/lcd/menu/menu_main.cpp
  51. 26
    32
      Marlin/src/lcd/menu/menu_motion.cpp
  52. 29
    28
      Marlin/src/lcd/menu/menu_sdcard.cpp
  53. 40
    40
      Marlin/src/lcd/menu/menu_temperature.cpp
  54. 11
    11
      Marlin/src/lcd/menu/menu_tune.cpp
  55. 31
    31
      Marlin/src/lcd/menu/menu_ubl.cpp
  56. 242
    295
      Marlin/src/lcd/ultralcd.cpp
  57. 382
    220
      Marlin/src/lcd/ultralcd.h
  58. 85
    84
      Marlin/src/libs/buzzer.h
  59. 50
    35
      Marlin/src/module/configuration_store.cpp
  60. 1
    1
      Marlin/src/module/endstops.cpp
  61. 2
    2
      Marlin/src/module/motion.cpp
  62. 4
    4
      Marlin/src/module/probe.cpp
  63. 10
    10
      Marlin/src/module/temperature.cpp
  64. 1
    1
      Marlin/src/module/tool_change.cpp
  65. 4
    4
      Marlin/src/sd/cardreader.cpp

+ 7
- 7
Marlin/src/Marlin.cpp Ver arquivo

@@ -371,7 +371,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
371 371
       #if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
372 372
         if (ubl.lcd_map_control) {
373 373
           ubl.lcd_map_control = false;
374
-          set_defer_return_to_status(false);
374
+          ui.defer_status_screen(false);
375 375
         }
376 376
       #endif
377 377
     }
@@ -549,7 +549,7 @@ void idle(
549 549
     max7219.idle_tasks();
550 550
   #endif
551 551
 
552
-  lcd_update();
552
+  ui.update();
553 553
 
554 554
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
555 555
     gcode.host_keepalive();
@@ -609,8 +609,8 @@ void kill(PGM_P const lcd_msg/*=NULL*/) {
609 609
   SERIAL_ERROR_START();
610 610
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
611 611
 
612
-  #if ENABLED(ULTRA_LCD) || ENABLED(EXTENSIBLE_UI)
613
-    kill_screen(lcd_msg ? lcd_msg : PSTR(MSG_KILLED));
612
+  #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
613
+    ui.kill_screen(lcd_msg ? lcd_msg : PSTR(MSG_KILLED));
614 614
   #else
615 615
     UNUSED(lcd_msg);
616 616
   #endif
@@ -899,11 +899,11 @@ void setup() {
899 899
     fanmux_init();
900 900
   #endif
901 901
 
902
-  lcd_init();
903
-  lcd_reset_status();
902
+  ui.init();
903
+  ui.reset_status();
904 904
 
905 905
   #if ENABLED(SHOW_BOOTSCREEN)
906
-    lcd_bootscreen();
906
+    ui.show_bootscreen();
907 907
   #endif
908 908
 
909 909
   #if ENABLED(MIXING_EXTRUDER)

+ 1
- 1
Marlin/src/config/examples/Geeetech/GT2560/Configuration.h Ver arquivo

@@ -2035,7 +2035,7 @@
2035 2035
  */
2036 2036
 #if ENABLED(ULTIMAKERCONTROLLER) || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL) || ENABLED(MKS_MINI_12864)
2037 2037
   #define SDSUPPORT   // Force SD Card support on for these displays
2038
-#else
2038
+#elif DISABLED(LIGHTWEIGHT_UI)
2039 2039
   #define LCD_WIDTH_OVERRIDE 20 // Default is 22. For this Geeetech use 20.
2040 2040
 #endif
2041 2041
 

+ 1
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Ver arquivo

@@ -233,7 +233,7 @@ void reset_bed_level() {
233 233
     current_position[Y_AXIS] = ry;
234 234
 
235 235
     #if ENABLED(LCD_BED_LEVELING)
236
-      lcd_wait_for_move = false;
236
+      ui.wait_for_bl_move = false;
237 237
     #endif
238 238
   }
239 239
 

+ 9
- 23
Marlin/src/feature/bedlevel/ubl/ubl.cpp Ver arquivo

@@ -34,8 +34,6 @@
34 34
 
35 35
   #include "math.h"
36 36
 
37
-  uint8_t ubl_cnt = 0;
38
-
39 37
   void unified_bed_leveling::echo_name(
40 38
     #if NUM_SERIAL > 1
41 39
       const int8_t port/*= -1*/
@@ -106,30 +104,19 @@
106 104
 
107 105
       if (xy_dist == 0.0) return;
108 106
 
109
-      SERIAL_ECHOPGM("   fpmm=");
110 107
       const float fpmm = de / xy_dist;
111
-      SERIAL_ECHO_F(fpmm, 6);
112
-
108
+      SERIAL_ECHOPGM("   fpmm="); SERIAL_ECHO_F(fpmm, 6);
113 109
       SERIAL_ECHOPGM("    current=( ");
114
-      SERIAL_ECHO_F(current_position[X_AXIS], 6);
115
-      SERIAL_ECHOPGM(", ");
116
-      SERIAL_ECHO_F(current_position[Y_AXIS], 6);
117
-      SERIAL_ECHOPGM(", ");
118
-      SERIAL_ECHO_F(current_position[Z_AXIS], 6);
119
-      SERIAL_ECHOPGM(", ");
120
-      SERIAL_ECHO_F(current_position[E_AXIS], 6);
121
-      SERIAL_ECHOPGM(" )   destination=( ");
122
-      debug_echo_axis(X_AXIS);
123
-      SERIAL_ECHOPGM(", ");
124
-      debug_echo_axis(Y_AXIS);
125
-      SERIAL_ECHOPGM(", ");
126
-      debug_echo_axis(Z_AXIS);
127
-      SERIAL_ECHOPGM(", ");
128
-      debug_echo_axis(E_AXIS);
129
-      SERIAL_ECHOPGM(" )   ");
110
+      SERIAL_ECHO_F(current_position[X_AXIS], 6); SERIAL_ECHOPGM(", ");
111
+      SERIAL_ECHO_F(current_position[Y_AXIS], 6); SERIAL_ECHOPGM(", ");
112
+      SERIAL_ECHO_F(current_position[Z_AXIS], 6); SERIAL_ECHOPGM(", ");
113
+      SERIAL_ECHO_F(current_position[E_AXIS], 6); SERIAL_ECHOPGM(" )   destination=( ");
114
+      debug_echo_axis(X_AXIS); SERIAL_ECHOPGM(", ");
115
+      debug_echo_axis(Y_AXIS); SERIAL_ECHOPGM(", ");
116
+      debug_echo_axis(Z_AXIS); SERIAL_ECHOPGM(", ");
117
+      debug_echo_axis(E_AXIS); SERIAL_ECHOPGM(" )   ");
130 118
       serialprintPGM(title);
131 119
       SERIAL_EOL();
132
-
133 120
     }
134 121
 
135 122
   #endif // UBL_DEVEL_DEBUGGING
@@ -150,7 +137,6 @@
150 137
   volatile int unified_bed_leveling::encoder_diff;
151 138
 
152 139
   unified_bed_leveling::unified_bed_leveling() {
153
-    ubl_cnt++;  // Debug counter to ensure we only have one UBL object present in memory.  We can eliminate this (and all references to ubl_cnt) very soon.
154 140
     reset();
155 141
   }
156 142
 

+ 7
- 9
Marlin/src/feature/bedlevel/ubl/ubl.h Ver arquivo

@@ -26,6 +26,7 @@
26 26
 #include "../bedlevel.h"
27 27
 #include "../../../module/planner.h"
28 28
 #include "../../../module/motion.h"
29
+#include "../../../lcd/ultralcd.h"
29 30
 #include "../../../Marlin.h"
30 31
 
31 32
 #define UBL_VERSION "1.01"
@@ -49,12 +50,6 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
49 50
 
50 51
 // External references
51 52
 
52
-extern uint8_t ubl_cnt;
53
-
54
-#if ENABLED(ULTRA_LCD)
55
-  void lcd_quick_feedback(const bool clear_buttons);
56
-#endif
57
-
58 53
 #define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
59 54
 #define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
60 55
 
@@ -88,12 +83,15 @@ class unified_bed_leveling {
88 83
     static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0;
89 84
     static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
90 85
     static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
91
-    static void g29_what_command();
92
-    static void g29_eeprom_dump();
93
-    static void g29_compare_current_mesh_to_stored_mesh();
94 86
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
95 87
     static void smart_fill_mesh();
96 88
 
89
+    #if ENABLED(UBL_DEVEL_DEBUGGING)
90
+      static void g29_what_command();
91
+      static void g29_eeprom_dump();
92
+      static void g29_compare_current_mesh_to_stored_mesh();
93
+    #endif
94
+
97 95
   public:
98 96
 
99 97
     static void echo_name(

+ 336
- 344
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Ver arquivo

@@ -53,7 +53,6 @@
53 53
   extern float destination[XYZE], current_position[XYZE];
54 54
 
55 55
   #if HAS_LCD_MENU
56
-    void lcd_return_to_status();
57 56
     void _lcd_ubl_output_map_lcd();
58 57
   #endif
59 58
 
@@ -345,9 +344,13 @@
345 344
       }
346 345
       SERIAL_PROTOCOLLNPGM("Loading test_pattern values.\n");
347 346
       switch (test_pattern) {
348
-        case -1:
349
-          g29_eeprom_dump();
350
-          break;
347
+
348
+        #if ENABLED(UBL_DEVEL_DEBUGGING)
349
+          case -1:
350
+            g29_eeprom_dump();
351
+            break;
352
+        #endif
353
+
351 354
         case 0:
352 355
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {   // Create a bowl shape - similar to
353 356
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
@@ -357,12 +360,14 @@
357 360
             }
358 361
           }
359 362
           break;
363
+
360 364
         case 1:
361 365
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {  // Create a diagonal line several Mesh cells thick that is raised
362 366
             z_values[x][x] += 9.999f;
363 367
             z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
364 368
           }
365 369
           break;
370
+
366 371
         case 2:
367 372
           // Allow the user to specify the height because 10mm is a little extreme in some cases.
368 373
           for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)   // Create a rectangular raised area in
@@ -554,19 +559,24 @@
554 559
       }
555 560
     }
556 561
 
557
-    //
558
-    // Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
559
-    // good to have the extra information. Soon... we prune this to just a few items
560
-    //
561
-    if (parser.seen('W')) g29_what_command();
562
+    #if ENABLED(UBL_DEVEL_DEBUGGING)
562 563
 
563
-    //
564
-    // When we are fully debugged, this may go away. But there are some valid
565
-    // use cases for the users. So we can wait and see what to do with it.
566
-    //
564
+      //
565
+      // Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
566
+      // good to have the extra information. Soon... we prune this to just a few items
567
+      //
568
+      if (parser.seen('W')) g29_what_command();
569
+
570
+      //
571
+      // When we are fully debugged, this may go away. But there are some valid
572
+      // use cases for the users. So we can wait and see what to do with it.
573
+      //
574
+
575
+      if (parser.seen('K')) // Kompare Current Mesh Data to Specified Stored Mesh
576
+        g29_compare_current_mesh_to_stored_mesh();
577
+
578
+    #endif // UBL_DEVEL_DEBUGGING
567 579
 
568
-    if (parser.seen('K')) // Kompare Current Mesh Data to Specified Stored Mesh
569
-      g29_compare_current_mesh_to_stored_mesh();
570 580
 
571 581
     //
572 582
     // Load a Mesh from the EEPROM
@@ -629,10 +639,10 @@
629 639
     LEAVE:
630 640
 
631 641
     #if HAS_LCD_MENU
632
-      lcd_reset_alert_level();
633
-      lcd_quick_feedback();
634
-      lcd_reset_status();
635
-      lcd_external_control = false;
642
+      ui.reset_alert_level();
643
+      ui.quick_feedback();
644
+      ui.reset_status();
645
+      ui.release();
636 646
     #endif
637 647
 
638 648
     return;
@@ -683,30 +693,6 @@
683 693
           z_values[x][y] += g29_constant;
684 694
   }
685 695
 
686
-  #if HAS_LCD_MENU
687
-
688
-    typedef void (*clickFunc_t)();
689
-
690
-    bool click_and_hold(const clickFunc_t func=NULL) {
691
-      if (is_lcd_clicked()) {
692
-        lcd_quick_feedback(false);                // Preserve button state for click-and-hold
693
-        const millis_t nxt = millis() + 1500UL;
694
-        while (is_lcd_clicked()) {                // Loop while the encoder is pressed. Uses hardware flag!
695
-          idle();                                 // idle, of course
696
-          if (ELAPSED(millis(), nxt)) {           // After 1.5 seconds
697
-            lcd_quick_feedback();
698
-            if (func) (*func)();
699
-            wait_for_release();
700
-            return true;
701
-          }
702
-        }
703
-      }
704
-      safe_delay(15);
705
-      return false;
706
-    }
707
-
708
-  #endif // HAS_LCD_MENU
709
-
710 696
   #if HAS_BED_PROBE
711 697
     /**
712 698
      * Probe all invalidated locations of the mesh that can be reached by the probe.
@@ -716,10 +702,10 @@
716 702
       mesh_index_pair location;
717 703
 
718 704
       #if HAS_LCD_MENU
719
-        lcd_external_control = true;
705
+        ui.capture();
720 706
       #endif
721 707
 
722
-      save_ubl_active_state_and_disable();   // No bed level correction so only raw data is obtained
708
+      save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
723 709
       DEPLOY_PROBE();
724 710
 
725 711
       uint16_t count = GRID_MAX_POINTS;
@@ -728,13 +714,13 @@
728 714
         if (do_ubl_mesh_map) display_map(g29_map_type);
729 715
 
730 716
         #if HAS_LCD_MENU
731
-          if (is_lcd_clicked()) {
732
-            lcd_quick_feedback(false); // Preserve button state for click-and-hold
717
+          if (ui.button_pressed()) {
718
+            ui.quick_feedback(false); // Preserve button state for click-and-hold
733 719
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
734 720
             STOW_PROBE();
735
-            wait_for_release();
736
-            lcd_quick_feedback();
737
-            lcd_external_control = false;
721
+            ui.wait_for_release();
722
+            ui.quick_feedback();
723
+            ui.release();
738 724
             restore_ubl_active_state_and_leave();
739 725
             return;
740 726
           }
@@ -769,14 +755,33 @@
769 755
       );
770 756
     }
771 757
 
772
-
773 758
   #endif // HAS_BED_PROBE
774 759
 
775 760
   #if HAS_LCD_MENU
776 761
 
762
+    typedef void (*clickFunc_t)();
763
+
764
+    bool click_and_hold(const clickFunc_t func=NULL) {
765
+      if (ui.button_pressed()) {
766
+        ui.quick_feedback(false);                // Preserve button state for click-and-hold
767
+        const millis_t nxt = millis() + 1500UL;
768
+        while (ui.button_pressed()) {                // Loop while the encoder is pressed. Uses hardware flag!
769
+          idle();                                 // idle, of course
770
+          if (ELAPSED(millis(), nxt)) {           // After 1.5 seconds
771
+            ui.quick_feedback();
772
+            if (func) (*func)();
773
+            ui.wait_for_release();
774
+            return true;
775
+          }
776
+        }
777
+      }
778
+      safe_delay(15);
779
+      return false;
780
+    }
781
+
777 782
     void unified_bed_leveling::move_z_with_encoder(const float &multiplier) {
778
-      wait_for_release();
779
-      while (!is_lcd_clicked()) {
783
+      ui.wait_for_release();
784
+      while (!ui.button_pressed()) {
780 785
         idle();
781 786
         gcode.reset_stepper_timeout(); // Keep steppers powered
782 787
         if (encoder_diff) {
@@ -796,7 +801,7 @@
796 801
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
797 802
 
798 803
     float unified_bed_leveling::measure_business_card_thickness(float in_height) {
799
-      lcd_external_control = true;
804
+      ui.capture();
800 805
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
801 806
 
802 807
       do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
@@ -805,7 +810,7 @@
805 810
 
806 811
       SERIAL_PROTOCOLPGM("Place shim under nozzle");
807 812
       LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
808
-      lcd_return_to_status();
813
+      ui.return_to_status();
809 814
       echo_and_take_a_measurement();
810 815
 
811 816
       const float z1 = measure_point_with_encoder();
@@ -828,7 +833,7 @@
828 833
         SERIAL_PROTOCOLLNPGM("mm thick.");
829 834
       }
830 835
 
831
-      lcd_external_control = false;
836
+      ui.release();
832 837
 
833 838
       restore_ubl_active_state_and_leave();
834 839
 
@@ -838,20 +843,20 @@
838 843
     void abort_manual_probe_remaining_mesh() {
839 844
       SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
840 845
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
841
-      lcd_external_control = false;
846
+      ui.release();
842 847
       KEEPALIVE_STATE(IN_HANDLER);
843
-      lcd_quick_feedback();
848
+      ui.quick_feedback();
844 849
       ubl.restore_ubl_active_state_and_leave();
845 850
     }
846 851
 
847 852
     void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
848 853
 
849
-      lcd_external_control = true;
854
+      ui.capture();
850 855
 
851
-      save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
856
+      save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
852 857
       do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_clearance);
853 858
 
854
-      lcd_return_to_status();
859
+      ui.return_to_status();
855 860
 
856 861
       mesh_index_pair location;
857 862
       do {
@@ -870,7 +875,7 @@
870 875
         do_blocking_move_to_z(z_clearance);
871 876
 
872 877
         KEEPALIVE_STATE(PAUSED_FOR_USER);
873
-        lcd_external_control = true;
878
+        ui.capture();
874 879
 
875 880
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show user where we're probing
876 881
 
@@ -884,7 +889,7 @@
884 889
         if (click_and_hold()) {
885 890
           SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
886 891
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
887
-          lcd_external_control = false;
892
+          ui.release();
888 893
           KEEPALIVE_STATE(IN_HANDLER);
889 894
           restore_ubl_active_state_and_leave();
890 895
           return;
@@ -905,12 +910,121 @@
905 910
       KEEPALIVE_STATE(IN_HANDLER);
906 911
       do_blocking_move_to(rx, ry, Z_CLEARANCE_DEPLOY_PROBE);
907 912
     }
908
-  #endif // HAS_LCD_MENU
909 913
 
910
-  inline void set_message_with_feedback(PGM_P const msg_P) {
911
-    lcd_setstatusPGM(msg_P);
912
-    lcd_quick_feedback();
913
-  }
914
+    inline void set_message_with_feedback(PGM_P const msg_P) {
915
+      ui.setstatusPGM(msg_P);
916
+      ui.quick_feedback();
917
+    }
918
+
919
+    void abort_fine_tune() {
920
+      ui.return_to_status();
921
+      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
922
+      set_message_with_feedback(PSTR(MSG_EDITING_STOPPED));
923
+    }
924
+
925
+    void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
926
+      if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
927
+        g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
928
+
929
+      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
930
+        const float h_offset = parser.seenval('H') ? parser.value_linear_units() : 0;
931
+        if (!WITHIN(h_offset, 0, 10)) {
932
+          SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
933
+          return;
934
+        }
935
+      #endif
936
+
937
+      mesh_index_pair location;
938
+
939
+      if (!position_is_reachable(rx, ry)) {
940
+        SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
941
+        return;
942
+      }
943
+
944
+      save_ubl_active_state_and_disable();
945
+
946
+      LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
947
+      ui.capture();                                                 // Take over control of the LCD encoder
948
+
949
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);      // Move to the given XY with probe clearance
950
+
951
+      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
952
+        do_blocking_move_to_z(h_offset);                            // Move Z to the given 'H' offset
953
+      #endif
954
+
955
+      uint16_t not_done[16];
956
+      memset(not_done, 0xFF, sizeof(not_done));
957
+      do {
958
+        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done);
959
+
960
+        if (location.x_index < 0) break;                            // Stop when there are no more reachable points
961
+
962
+        bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so a new
963
+                                                                    // location is used on the next loop
964
+
965
+        const float rawx = mesh_index_to_xpos(location.x_index),
966
+                    rawy = mesh_index_to_ypos(location.y_index);
967
+
968
+        if (!position_is_reachable(rawx, rawy)) break;              // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
969
+
970
+        do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point with probe clearance
971
+
972
+        #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
973
+          do_blocking_move_to_z(h_offset);                          // Move Z to the given 'H' offset before editing
974
+        #endif
975
+
976
+        KEEPALIVE_STATE(PAUSED_FOR_USER);
977
+
978
+        if (do_ubl_mesh_map) display_map(g29_map_type);             // Display the current point
979
+
980
+        ui.refresh();
981
+
982
+        float new_z = z_values[location.x_index][location.y_index];
983
+        if (isnan(new_z)) new_z = 0;                                // Invalid points begin at 0
984
+        new_z = FLOOR(new_z * 1000) * 0.001f;                       // Chop off digits after the 1000ths place
985
+
986
+        lcd_mesh_edit_setup(new_z);
987
+
988
+        do {
989
+          new_z = lcd_mesh_edit();
990
+          #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
991
+            do_blocking_move_to_z(h_offset + new_z);                // Move the nozzle as the point is edited
992
+          #endif
993
+          idle();
994
+          SERIAL_FLUSH();                                           // Prevent host M105 buffer overrun.
995
+        } while (!ui.button_pressed());
996
+
997
+        if (!lcd_map_control) ui.return_to_status();               // Just editing a single point? Return to status
998
+
999
+        if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT;   // If the click is held down, abort editing
1000
+
1001
+        z_values[location.x_index][location.y_index] = new_z;       // Save the updated Z value
1002
+
1003
+        safe_delay(20);                                             // No switch noise
1004
+        ui.refresh();
1005
+
1006
+      } while (location.x_index >= 0 && --g29_repetition_cnt > 0);
1007
+
1008
+      FINE_TUNE_EXIT:
1009
+
1010
+      ui.release();
1011
+      KEEPALIVE_STATE(IN_HANDLER);
1012
+
1013
+      if (do_ubl_mesh_map) display_map(g29_map_type);
1014
+      restore_ubl_active_state_and_leave();
1015
+
1016
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
1017
+
1018
+      LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1019
+      SERIAL_ECHOLNPGM("Done Editing Mesh");
1020
+
1021
+      if (lcd_map_control)
1022
+        ui.goto_screen(_lcd_ubl_output_map_lcd);
1023
+      else
1024
+        ui.return_to_status();
1025
+    }
1026
+
1027
+  #endif // HAS_LCD_MENU
914 1028
 
915 1029
   bool unified_bed_leveling::g29_parameter_parsing() {
916 1030
     bool err_flag = false;
@@ -1060,170 +1174,6 @@
1060 1174
     set_bed_leveling_enabled(ubl_state_at_invocation);
1061 1175
   }
1062 1176
 
1063
-  /**
1064
-   * Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
1065
-   * good to have the extra information. Soon... we prune this to just a few items
1066
-   */
1067
-  void unified_bed_leveling::g29_what_command() {
1068
-    report_state();
1069
-
1070
-    if (storage_slot == -1)
1071
-      SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1072
-    else {
1073
-      SERIAL_PROTOCOLPAIR("Mesh ", storage_slot);
1074
-      SERIAL_PROTOCOLPGM(" Loaded.");
1075
-    }
1076
-    SERIAL_EOL();
1077
-    safe_delay(50);
1078
-
1079
-    SERIAL_PROTOCOLLNPAIR("UBL object count: ", (int)ubl_cnt);
1080
-
1081
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1082
-      SERIAL_PROTOCOLPGM("planner.z_fade_height : ");
1083
-      SERIAL_PROTOCOL_F(planner.z_fade_height, 4);
1084
-      SERIAL_EOL();
1085
-    #endif
1086
-
1087
-    adjust_mesh_to_mean(g29_c_flag, g29_constant);
1088
-
1089
-    #if HAS_BED_PROBE
1090
-      SERIAL_PROTOCOLPGM("zprobe_zoffset: ");
1091
-      SERIAL_PROTOCOL_F(zprobe_zoffset, 7);
1092
-      SERIAL_EOL();
1093
-    #endif
1094
-
1095
-    SERIAL_ECHOLNPAIR("MESH_MIN_X  " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X);
1096
-    safe_delay(50);
1097
-    SERIAL_ECHOLNPAIR("MESH_MIN_Y  " STRINGIFY(MESH_MIN_Y) "=", MESH_MIN_Y);
1098
-    safe_delay(50);
1099
-    SERIAL_ECHOLNPAIR("MESH_MAX_X  " STRINGIFY(MESH_MAX_X) "=", MESH_MAX_X);
1100
-    safe_delay(50);
1101
-    SERIAL_ECHOLNPAIR("MESH_MAX_Y  " STRINGIFY(MESH_MAX_Y) "=", MESH_MAX_Y);
1102
-    safe_delay(50);
1103
-    SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_X  ", GRID_MAX_POINTS_X);
1104
-    safe_delay(50);
1105
-    SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_Y  ", GRID_MAX_POINTS_Y);
1106
-    safe_delay(50);
1107
-    SERIAL_ECHOLNPAIR("MESH_X_DIST  ", MESH_X_DIST);
1108
-    SERIAL_ECHOLNPAIR("MESH_Y_DIST  ", MESH_Y_DIST);
1109
-    safe_delay(50);
1110
-
1111
-    SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1112
-    for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1113
-      SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3);
1114
-      SERIAL_PROTOCOLPGM("  ");
1115
-      safe_delay(25);
1116
-    }
1117
-    SERIAL_EOL();
1118
-
1119
-    SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1120
-    for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; i++) {
1121
-      SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3);
1122
-      SERIAL_PROTOCOLPGM("  ");
1123
-      safe_delay(25);
1124
-    }
1125
-    SERIAL_EOL();
1126
-
1127
-    #if HAS_KILL
1128
-      SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
1129
-      SERIAL_PROTOCOLLNPAIR("  state:", READ(KILL_PIN));
1130
-    #endif
1131
-    SERIAL_EOL();
1132
-    safe_delay(50);
1133
-
1134
-    #if ENABLED(UBL_DEVEL_DEBUGGING)
1135
-      SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1136
-      SERIAL_EOL();
1137
-      SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1138
-      SERIAL_EOL();
1139
-      safe_delay(50);
1140
-
1141
-      SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()));
1142
-      SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.meshes_end_index()));
1143
-      safe_delay(50);
1144
-
1145
-      SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1146
-      SERIAL_EOL();
1147
-      SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1148
-      SERIAL_EOL();
1149
-      safe_delay(25);
1150
-
1151
-      SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
1152
-      safe_delay(50);
1153
-
1154
-      SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1155
-      SERIAL_PROTOCOLLNPGM(" meshes.\n");
1156
-      safe_delay(25);
1157
-    #endif // UBL_DEVEL_DEBUGGING
1158
-
1159
-    if (!sanity_check()) {
1160
-      echo_name();
1161
-      SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
1162
-    }
1163
-  }
1164
-
1165
-  /**
1166
-   * When we are fully debugged, the EEPROM dump command will get deleted also. But
1167
-   * right now, it is good to have the extra information. Soon... we prune this.
1168
-   */
1169
-  void unified_bed_leveling::g29_eeprom_dump() {
1170
-    uint8_t cccc;
1171
-
1172
-    SERIAL_ECHO_START();
1173
-    SERIAL_ECHOLNPGM("EEPROM Dump:");
1174
-    persistentStore.access_start();
1175
-    for (uint16_t i = 0; i < persistentStore.capacity(); i += 16) {
1176
-      if (!(i & 0x3)) idle();
1177
-      print_hex_word(i);
1178
-      SERIAL_ECHOPGM(": ");
1179
-      for (uint16_t j = 0; j < 16; j++) {
1180
-        persistentStore.read_data(i + j, &cccc, sizeof(uint8_t));
1181
-        print_hex_byte(cccc);
1182
-        SERIAL_ECHO(' ');
1183
-      }
1184
-      SERIAL_EOL();
1185
-    }
1186
-    SERIAL_EOL();
1187
-    persistentStore.access_finish();
1188
-  }
1189
-
1190
-  /**
1191
-   * When we are fully debugged, this may go away. But there are some valid
1192
-   * use cases for the users. So we can wait and see what to do with it.
1193
-   */
1194
-  void unified_bed_leveling::g29_compare_current_mesh_to_stored_mesh() {
1195
-    int16_t a = settings.calc_num_meshes();
1196
-
1197
-    if (!a) {
1198
-      SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
1199
-      return;
1200
-    }
1201
-
1202
-    if (!parser.has_value()) {
1203
-      SERIAL_PROTOCOLLNPGM("?Storage slot # required.");
1204
-      SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
1205
-      return;
1206
-    }
1207
-
1208
-    g29_storage_slot = parser.value_int();
1209
-
1210
-    if (!WITHIN(g29_storage_slot, 0, a - 1)) {
1211
-      SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
1212
-      SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
1213
-      return;
1214
-    }
1215
-
1216
-    float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1217
-    settings.load_mesh(g29_storage_slot, &tmp_z_values);
1218
-
1219
-    SERIAL_PROTOCOLPAIR("Subtracting mesh in slot ", g29_storage_slot);
1220
-    SERIAL_PROTOCOLLNPGM(" from current mesh.");
1221
-
1222
-    for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1223
-      for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
1224
-        z_values[x][y] -= tmp_z_values[x][y];
1225
-  }
1226
-
1227 1177
   mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1228 1178
 
1229 1179
     bool found_a_NAN  = false, found_a_real = false;
@@ -1338,118 +1288,6 @@
1338 1288
     return out_mesh;
1339 1289
   }
1340 1290
 
1341
-  #if HAS_LCD_MENU
1342
-
1343
-    void abort_fine_tune() {
1344
-      lcd_return_to_status();
1345
-      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1346
-      set_message_with_feedback(PSTR(MSG_EDITING_STOPPED));
1347
-    }
1348
-
1349
-    void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
1350
-      if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1351
-        g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1352
-
1353
-      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1354
-        const float h_offset = parser.seenval('H') ? parser.value_linear_units() : 0;
1355
-        if (!WITHIN(h_offset, 0, 10)) {
1356
-          SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
1357
-          return;
1358
-        }
1359
-      #endif
1360
-
1361
-      mesh_index_pair location;
1362
-
1363
-      if (!position_is_reachable(rx, ry)) {
1364
-        SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1365
-        return;
1366
-      }
1367
-
1368
-      save_ubl_active_state_and_disable();
1369
-
1370
-      LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1371
-      lcd_external_control = true;                                  // Take over control of the LCD encoder
1372
-
1373
-      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);      // Move to the given XY with probe clearance
1374
-
1375
-      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1376
-        do_blocking_move_to_z(h_offset);                            // Move Z to the given 'H' offset
1377
-      #endif
1378
-
1379
-      uint16_t not_done[16];
1380
-      memset(not_done, 0xFF, sizeof(not_done));
1381
-      do {
1382
-        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done);
1383
-
1384
-        if (location.x_index < 0) break;                            // Stop when there are no more reachable points
1385
-
1386
-        bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so a new
1387
-                                                                    // location is used on the next loop
1388
-
1389
-        const float rawx = mesh_index_to_xpos(location.x_index),
1390
-                    rawy = mesh_index_to_ypos(location.y_index);
1391
-
1392
-        if (!position_is_reachable(rawx, rawy)) break;              // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1393
-
1394
-        do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point with probe clearance
1395
-
1396
-        #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1397
-          do_blocking_move_to_z(h_offset);                          // Move Z to the given 'H' offset before editing
1398
-        #endif
1399
-
1400
-        KEEPALIVE_STATE(PAUSED_FOR_USER);
1401
-
1402
-        if (do_ubl_mesh_map) display_map(g29_map_type);             // Display the current point
1403
-
1404
-        lcd_refresh();
1405
-
1406
-        float new_z = z_values[location.x_index][location.y_index];
1407
-        if (isnan(new_z)) new_z = 0;                                // Invalid points begin at 0
1408
-        new_z = FLOOR(new_z * 1000) * 0.001f;                       // Chop off digits after the 1000ths place
1409
-
1410
-        lcd_mesh_edit_setup(new_z);
1411
-
1412
-        do {
1413
-          new_z = lcd_mesh_edit();
1414
-          #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1415
-            do_blocking_move_to_z(h_offset + new_z);                // Move the nozzle as the point is edited
1416
-          #endif
1417
-          idle();
1418
-          SERIAL_FLUSH();                                           // Prevent host M105 buffer overrun.
1419
-        } while (!is_lcd_clicked());
1420
-
1421
-        if (!lcd_map_control) lcd_return_to_status();               // Just editing a single point? Return to status
1422
-
1423
-        if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT;   // If the click is held down, abort editing
1424
-
1425
-        z_values[location.x_index][location.y_index] = new_z;       // Save the updated Z value
1426
-
1427
-        safe_delay(20);                                             // No switch noise
1428
-        lcd_refresh();
1429
-
1430
-      } while (location.x_index >= 0 && --g29_repetition_cnt > 0);
1431
-
1432
-      FINE_TUNE_EXIT:
1433
-
1434
-      lcd_external_control = false;
1435
-      KEEPALIVE_STATE(IN_HANDLER);
1436
-
1437
-      if (do_ubl_mesh_map) display_map(g29_map_type);
1438
-      restore_ubl_active_state_and_leave();
1439
-
1440
-      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
1441
-
1442
-      LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1443
-      SERIAL_ECHOLNPGM("Done Editing Mesh");
1444
-
1445
-      if (lcd_map_control)
1446
-        lcd_goto_screen(_lcd_ubl_output_map_lcd);
1447
-      else
1448
-        lcd_return_to_status();
1449
-    }
1450
-
1451
-  #endif // HAS_LCD_MENU
1452
-
1453 1291
   /**
1454 1292
    * 'Smart Fill': Scan from the outward edges of the mesh towards the center.
1455 1293
    * If an invalid location is found, use the next two points (if valid) to
@@ -1823,4 +1661,158 @@
1823 1661
     }
1824 1662
   #endif // UBL_G29_P31
1825 1663
 
1664
+  #if ENABLED(UBL_DEVEL_DEBUGGING)
1665
+    /**
1666
+     * Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
1667
+     * good to have the extra information. Soon... we prune this to just a few items
1668
+     */
1669
+    void unified_bed_leveling::g29_what_command() {
1670
+      report_state();
1671
+
1672
+      if (storage_slot == -1)
1673
+        SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1674
+      else {
1675
+        SERIAL_PROTOCOLPAIR("Mesh ", storage_slot);
1676
+        SERIAL_PROTOCOLPGM(" Loaded.");
1677
+      }
1678
+      SERIAL_EOL();
1679
+      safe_delay(50);
1680
+
1681
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1682
+        SERIAL_PROTOCOLPGM("planner.z_fade_height : ");
1683
+        SERIAL_PROTOCOL_F(planner.z_fade_height, 4);
1684
+        SERIAL_EOL();
1685
+      #endif
1686
+
1687
+      adjust_mesh_to_mean(g29_c_flag, g29_constant);
1688
+
1689
+      #if HAS_BED_PROBE
1690
+        SERIAL_PROTOCOLPGM("zprobe_zoffset: ");
1691
+        SERIAL_PROTOCOL_F(zprobe_zoffset, 7);
1692
+        SERIAL_EOL();
1693
+      #endif
1694
+
1695
+      SERIAL_ECHOLNPAIR("MESH_MIN_X  " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); safe_delay(50);
1696
+      SERIAL_ECHOLNPAIR("MESH_MIN_Y  " STRINGIFY(MESH_MIN_Y) "=", MESH_MIN_Y); safe_delay(50);
1697
+      SERIAL_ECHOLNPAIR("MESH_MAX_X  " STRINGIFY(MESH_MAX_X) "=", MESH_MAX_X); safe_delay(50);
1698
+      SERIAL_ECHOLNPAIR("MESH_MAX_Y  " STRINGIFY(MESH_MAX_Y) "=", MESH_MAX_Y); safe_delay(50);
1699
+      SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_X  ", GRID_MAX_POINTS_X);             safe_delay(50);
1700
+      SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_Y  ", GRID_MAX_POINTS_Y);             safe_delay(50);
1701
+      SERIAL_ECHOLNPAIR("MESH_X_DIST  ", MESH_X_DIST);
1702
+      SERIAL_ECHOLNPAIR("MESH_Y_DIST  ", MESH_Y_DIST);                         safe_delay(50);
1703
+
1704
+      SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1705
+      for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1706
+        SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3);
1707
+        SERIAL_PROTOCOLPGM("  ");
1708
+        safe_delay(25);
1709
+      }
1710
+      SERIAL_EOL();
1711
+
1712
+      SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1713
+      for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; i++) {
1714
+        SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3);
1715
+        SERIAL_PROTOCOLPGM("  ");
1716
+        safe_delay(25);
1717
+      }
1718
+      SERIAL_EOL();
1719
+
1720
+      #if HAS_KILL
1721
+        SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
1722
+        SERIAL_PROTOCOLLNPAIR("  state:", READ(KILL_PIN));
1723
+      #endif
1724
+      SERIAL_EOL();
1725
+      safe_delay(50);
1726
+
1727
+      #if ENABLED(UBL_DEVEL_DEBUGGING)
1728
+        SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation); SERIAL_EOL();
1729
+        SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk); SERIAL_EOL();
1730
+        safe_delay(50);
1731
+
1732
+        SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()));
1733
+        SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.meshes_end_index()));
1734
+        safe_delay(50);
1735
+
1736
+        SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));         SERIAL_EOL();
1737
+        SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values)); SERIAL_EOL();
1738
+        safe_delay(25);
1739
+
1740
+        SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
1741
+        safe_delay(50);
1742
+
1743
+        SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1744
+        SERIAL_PROTOCOLLNPGM(" meshes.\n");
1745
+        safe_delay(25);
1746
+      #endif // UBL_DEVEL_DEBUGGING
1747
+
1748
+      if (!sanity_check()) {
1749
+        echo_name();
1750
+        SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
1751
+      }
1752
+    }
1753
+
1754
+    /**
1755
+     * When we are fully debugged, the EEPROM dump command will get deleted also. But
1756
+     * right now, it is good to have the extra information. Soon... we prune this.
1757
+     */
1758
+    void unified_bed_leveling::g29_eeprom_dump() {
1759
+      uint8_t cccc;
1760
+
1761
+      SERIAL_ECHO_START();
1762
+      SERIAL_ECHOLNPGM("EEPROM Dump:");
1763
+      persistentStore.access_start();
1764
+      for (uint16_t i = 0; i < persistentStore.capacity(); i += 16) {
1765
+        if (!(i & 0x3)) idle();
1766
+        print_hex_word(i);
1767
+        SERIAL_ECHOPGM(": ");
1768
+        for (uint16_t j = 0; j < 16; j++) {
1769
+          persistentStore.read_data(i + j, &cccc, sizeof(uint8_t));
1770
+          print_hex_byte(cccc);
1771
+          SERIAL_ECHO(' ');
1772
+        }
1773
+        SERIAL_EOL();
1774
+      }
1775
+      SERIAL_EOL();
1776
+      persistentStore.access_finish();
1777
+    }
1778
+
1779
+    /**
1780
+     * When we are fully debugged, this may go away. But there are some valid
1781
+     * use cases for the users. So we can wait and see what to do with it.
1782
+     */
1783
+    void unified_bed_leveling::g29_compare_current_mesh_to_stored_mesh() {
1784
+      int16_t a = settings.calc_num_meshes();
1785
+
1786
+      if (!a) {
1787
+        SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
1788
+        return;
1789
+      }
1790
+
1791
+      if (!parser.has_value()) {
1792
+        SERIAL_PROTOCOLLNPGM("?Storage slot # required.");
1793
+        SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
1794
+        return;
1795
+      }
1796
+
1797
+      g29_storage_slot = parser.value_int();
1798
+
1799
+      if (!WITHIN(g29_storage_slot, 0, a - 1)) {
1800
+        SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
1801
+        SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
1802
+        return;
1803
+      }
1804
+
1805
+      float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1806
+      settings.load_mesh(g29_storage_slot, &tmp_z_values);
1807
+
1808
+      SERIAL_PROTOCOLPAIR("Subtracting mesh in slot ", g29_storage_slot);
1809
+      SERIAL_PROTOCOLLNPGM(" from current mesh.");
1810
+
1811
+      for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1812
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
1813
+          z_values[x][y] -= tmp_z_values[x][y];
1814
+    }
1815
+
1816
+  #endif // UBL_DEVEL_DEBUGGING
1817
+
1826 1818
 #endif // AUTO_BED_LEVELING_UBL

+ 1
- 1
Marlin/src/feature/pause.cpp Ver arquivo

@@ -586,7 +586,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
586 586
   #endif
587 587
 
588 588
   #if ENABLED(ULTRA_LCD)
589
-    lcd_reset_status();
589
+    ui.reset_status();
590 590
   #endif
591 591
 }
592 592
 

+ 28
- 29
Marlin/src/gcode/bedlevel/G26.cpp Ver arquivo

@@ -163,12 +163,12 @@ int8_t g26_prime_flag;
163 163
    * If the LCD is clicked, cancel, wait for release, return true
164 164
    */
165 165
   bool user_canceled() {
166
-    if (!is_lcd_clicked()) return false; // Return if the button isn't pressed
167
-    lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
166
+    if (!ui.button_pressed()) return false; // Return if the button isn't pressed
167
+    ui.setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
168 168
     #if HAS_LCD_MENU
169
-      lcd_quick_feedback();
169
+      ui.quick_feedback();
170 170
     #endif
171
-    wait_for_release();
171
+    ui.wait_for_release();
172 172
     return true;
173 173
   }
174 174
 
@@ -414,10 +414,10 @@ inline bool turn_on_heaters() {
414 414
 
415 415
     if (g26_bed_temp > 25) {
416 416
       #if ENABLED(ULTRA_LCD)
417
-        lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
418
-        lcd_quick_feedback();
417
+        ui.setstatusPGM(PSTR("G26 Heating Bed."), 99);
418
+        ui.quick_feedback();
419 419
         #if HAS_LCD_MENU
420
-          lcd_external_control = true;
420
+          ui.capture();
421 421
         #endif
422 422
       #endif
423 423
       thermalManager.setTargetBed(g26_bed_temp);
@@ -435,8 +435,8 @@ inline bool turn_on_heaters() {
435 435
 
436 436
   // Start heating the active nozzle
437 437
   #if ENABLED(ULTRA_LCD)
438
-    lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
439
-    lcd_quick_feedback();
438
+    ui.setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
439
+    ui.quick_feedback();
440 440
   #endif
441 441
   thermalManager.setTargetHotend(g26_hotend_temp, active_extruder);
442 442
 
@@ -449,8 +449,8 @@ inline bool turn_on_heaters() {
449 449
   ) return G26_ERR;
450 450
 
451 451
   #if ENABLED(ULTRA_LCD)
452
-    lcd_reset_status();
453
-    lcd_quick_feedback();
452
+    ui.reset_status();
453
+    ui.quick_feedback();
454 454
   #endif
455 455
 
456 456
   return G26_OK;
@@ -468,16 +468,16 @@ inline bool prime_nozzle() {
468 468
 
469 469
     if (g26_prime_flag == -1) {  // The user wants to control how much filament gets purged
470 470
 
471
-      lcd_external_control = true;
472
-      lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
473
-      lcd_chirp();
471
+      ui.capture();
472
+      ui.setstatusPGM(PSTR("User-Controlled Prime"), 99);
473
+      ui.chirp();
474 474
 
475 475
       set_destination_from_current();
476 476
 
477 477
       recover_filament(destination); // Make sure G26 doesn't think the filament is retracted().
478 478
 
479
-      while (!is_lcd_clicked()) {
480
-        lcd_chirp();
479
+      while (!ui.button_pressed()) {
480
+        ui.chirp();
481 481
         destination[E_AXIS] += 0.25;
482 482
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
483 483
           Total_Prime += 0.25;
@@ -491,18 +491,18 @@ inline bool prime_nozzle() {
491 491
                                   // action to give the user a more responsive 'Stop'.
492 492
       }
493 493
 
494
-      wait_for_release();
494
+      ui.wait_for_release();
495 495
 
496
-      lcd_setstatusPGM(PSTR("Done Priming"), 99);
497
-      lcd_quick_feedback();
498
-      lcd_external_control = false;
496
+      ui.setstatusPGM(PSTR("Done Priming"), 99);
497
+      ui.quick_feedback();
498
+      ui.release();
499 499
     }
500 500
     else
501 501
   #endif
502 502
   {
503 503
     #if ENABLED(ULTRA_LCD)
504
-      lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
505
-      lcd_quick_feedback();
504
+      ui.setstatusPGM(PSTR("Fixed Length Prime."), 99);
505
+      ui.quick_feedback();
506 506
     #endif
507 507
     set_destination_from_current();
508 508
     destination[E_AXIS] += g26_prime_length;
@@ -715,7 +715,7 @@ void GcodeSuite::G26() {
715 715
   move_to(destination, g26_ooze_amount);
716 716
 
717 717
   #if HAS_LCD_MENU
718
-    lcd_external_control = true;
718
+    ui.capture();
719 719
   #endif
720 720
 
721 721
   //debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
@@ -881,8 +881,7 @@ void GcodeSuite::G26() {
881 881
   } while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
882 882
 
883 883
   LEAVE:
884
-  lcd_setstatusPGM(PSTR("Leaving G26"), -1);
885
-  wait_for_release();
884
+  ui.setstatusPGM(PSTR("Leaving G26"), -1);
886 885
 
887 886
   retract_filament(destination);
888 887
   destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
@@ -891,15 +890,15 @@ void GcodeSuite::G26() {
891 890
   move_to(destination, 0); // Raise the nozzle
892 891
   //debug_current_and_destination(PSTR("done doing Z-Raise."));
893 892
 
894
-  destination[X_AXIS] = g26_x_pos;                               // Move back to the starting position
893
+  destination[X_AXIS] = g26_x_pos;                            // Move back to the starting position
895 894
   destination[Y_AXIS] = g26_y_pos;
896
-  //destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;            // Keep the nozzle where it is
895
+  //destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;         // Keep the nozzle where it is
897 896
 
898
-  move_to(destination, 0); // Move back to the starting position
897
+  move_to(destination, 0);                                    // Move back to the starting position
899 898
   //debug_current_and_destination(PSTR("done doing X/Y move."));
900 899
 
901 900
   #if HAS_LCD_MENU
902
-    lcd_external_control = false;     // Give back control of the LCD Panel!
901
+    ui.release();                                             // Give back control of the LCD
903 902
   #endif
904 903
 
905 904
   if (!g26_keep_heaters_on) {

+ 2
- 2
Marlin/src/gcode/bedlevel/abl/G29.cpp Ver arquivo

@@ -498,7 +498,7 @@ G29_TYPE GcodeSuite::G29() {
498 498
       set_bed_leveling_enabled(abl_should_enable);
499 499
       g29_in_progress = false;
500 500
       #if ENABLED(LCD_BED_LEVELING)
501
-        lcd_wait_for_move = false;
501
+        ui.wait_for_bl_move = false;
502 502
       #endif
503 503
     }
504 504
 
@@ -790,7 +790,7 @@ G29_TYPE GcodeSuite::G29() {
790 790
   #if ENABLED(PROBE_MANUALLY)
791 791
     g29_in_progress = false;
792 792
     #if ENABLED(LCD_BED_LEVELING)
793
-      lcd_wait_for_move = false;
793
+      ui.wait_for_bl_move = false;
794 794
     #endif
795 795
   #endif
796 796
 

+ 2
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp Ver arquivo

@@ -90,7 +90,7 @@ void GcodeSuite::G29() {
90 90
     case MeshStart:
91 91
       mbl.reset();
92 92
       mbl_probe_index = 0;
93
-      if (!lcd_wait_for_move) {
93
+      if (!ui.wait_for_bl_move) {
94 94
         enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
95 95
         return;
96 96
       }
@@ -151,7 +151,7 @@ void GcodeSuite::G29() {
151 151
         #endif
152 152
 
153 153
         #if ENABLED(LCD_BED_LEVELING)
154
-          lcd_wait_for_move = false;
154
+          ui.wait_for_bl_move = false;
155 155
         #endif
156 156
       }
157 157
       break;

+ 1
- 1
Marlin/src/gcode/calibrate/G28.cpp Ver arquivo

@@ -425,7 +425,7 @@ void GcodeSuite::G28(const bool always_home_all) {
425 425
     tool_change(old_tool_index, 0, NO_FETCH);
426 426
   #endif
427 427
 
428
-  lcd_refresh();
428
+  ui.refresh();
429 429
 
430 430
   report_current_position();
431 431
   #if ENABLED(NANODLP_Z_SYNC)

+ 4
- 4
Marlin/src/gcode/calibrate/G33.cpp Ver arquivo

@@ -522,7 +522,7 @@ void GcodeSuite::G33() {
522 522
   if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
523 523
   if (set_up) SERIAL_PROTOCOLPGM("  (SET-UP)");
524 524
   SERIAL_EOL();
525
-  lcd_setstatusPGM(checkingac);
525
+  ui.setstatusPGM(checkingac);
526 526
 
527 527
   print_calibration_settings(_endstop_results, _angle_results);
528 528
 
@@ -683,7 +683,7 @@ void GcodeSuite::G33() {
683 683
           sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
684 684
         else
685 685
           sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
686
-        lcd_setstatus(mess);
686
+        ui.setstatus(mess);
687 687
         print_calibration_settings(_endstop_results, _angle_results);
688 688
         serialprintPGM(save_message);
689 689
         SERIAL_EOL();
@@ -699,7 +699,7 @@ void GcodeSuite::G33() {
699 699
         SERIAL_PROTOCOLPGM("std dev:");
700 700
         SERIAL_PROTOCOL_F(zero_std_dev, 3);
701 701
         SERIAL_EOL();
702
-        lcd_setstatus(mess);
702
+        ui.setstatus(mess);
703 703
         if (verbose_level > 1)
704 704
           print_calibration_settings(_endstop_results, _angle_results);
705 705
       }
@@ -719,7 +719,7 @@ void GcodeSuite::G33() {
719 719
         sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
720 720
       else
721 721
         sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
722
-      lcd_setstatus(mess);
722
+      ui.setstatus(mess);
723 723
     }
724 724
     ac_home();
725 725
   }

+ 1
- 1
Marlin/src/gcode/control/M17_M18_M84.cpp Ver arquivo

@@ -63,7 +63,7 @@ void GcodeSuite::M18_M84() {
63 63
     #if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
64 64
       if (ubl.lcd_map_control) {
65 65
         ubl.lcd_map_control = false;
66
-        set_defer_return_to_status(false);
66
+        ui.defer_status_screen(false);
67 67
       }
68 68
     #endif
69 69
   }

+ 1
- 1
Marlin/src/gcode/control/M80_M81.cpp Ver arquivo

@@ -83,7 +83,7 @@
83 83
     #endif
84 84
 
85 85
     #if HAS_LCD_MENU
86
-      lcd_reset_status();
86
+      ui.reset_status();
87 87
     #endif
88 88
   }
89 89
 

+ 1
- 1
Marlin/src/gcode/control/M999.cpp Ver arquivo

@@ -38,7 +38,7 @@
38 38
  */
39 39
 void GcodeSuite::M999() {
40 40
   Running = true;
41
-  lcd_reset_alert_level();
41
+  ui.reset_alert_level();
42 42
 
43 43
   if (parser.boolval('S')) return;
44 44
 

+ 3
- 3
Marlin/src/gcode/lcd/M0_M1.cpp Ver arquivo

@@ -62,11 +62,11 @@ void GcodeSuite::M0_M1() {
62 62
   #if HAS_LCD_MENU
63 63
 
64 64
     if (has_message)
65
-      lcd_setstatus(args, true);
65
+      ui.setstatus(args, true);
66 66
     else {
67 67
       LCD_MESSAGEPGM(MSG_USERWAIT);
68 68
       #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
69
-        dontExpireStatus();
69
+        ui.reset_progress_bar_timeout();
70 70
       #endif
71 71
     }
72 72
 
@@ -94,7 +94,7 @@ void GcodeSuite::M0_M1() {
94 94
   #endif
95 95
 
96 96
   #if HAS_LCD_MENU
97
-    lcd_reset_status();
97
+    ui.reset_status();
98 98
   #endif
99 99
 
100 100
   wait_for_user = false;

+ 1
- 1
Marlin/src/gcode/lcd/M117.cpp Ver arquivo

@@ -28,6 +28,6 @@
28 28
  */
29 29
 void GcodeSuite::M117() {
30 30
 
31
-  lcd_setstatus(parser.string_arg);
31
+  ui.setstatus(parser.string_arg);
32 32
 
33 33
 }

+ 4
- 4
Marlin/src/gcode/lcd/M145.cpp Ver arquivo

@@ -37,7 +37,7 @@
37 37
  */
38 38
 void GcodeSuite::M145() {
39 39
   const uint8_t material = (uint8_t)parser.intval('S');
40
-  if (material >= COUNT(lcd_preheat_hotend_temp)) {
40
+  if (material >= COUNT(ui.preheat_hotend_temp)) {
41 41
     SERIAL_ERROR_START();
42 42
     SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
43 43
   }
@@ -45,16 +45,16 @@ void GcodeSuite::M145() {
45 45
     int v;
46 46
     if (parser.seenval('H')) {
47 47
       v = parser.value_int();
48
-      lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
48
+      ui.preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
49 49
     }
50 50
     if (parser.seenval('F')) {
51 51
       v = parser.value_int();
52
-      lcd_preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
52
+      ui.preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
53 53
     }
54 54
     #if TEMP_SENSOR_BED != 0
55 55
       if (parser.seenval('B')) {
56 56
         v = parser.value_int();
57
-        lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
57
+        ui.preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
58 58
       }
59 59
     #endif
60 60
   }

+ 2
- 4
Marlin/src/gcode/lcd/M250.cpp Ver arquivo

@@ -31,10 +31,8 @@
31 31
  * M250: Read and optionally set the LCD contrast
32 32
  */
33 33
 void GcodeSuite::M250() {
34
-  if (parser.seen('C')) set_lcd_contrast(parser.value_int());
35
-  SERIAL_PROTOCOLPGM("lcd contrast value: ");
36
-  SERIAL_PROTOCOL(lcd_contrast);
37
-  SERIAL_EOL();
34
+  if (parser.seen('C')) ui.set_contrast(parser.value_int());
35
+  SERIAL_PROTOCOLLNPAIR("LCD Contrast: ", ui.contrast);
38 36
 }
39 37
 
40 38
 #endif // HAS_LCD_CONTRAST

+ 2
- 4
Marlin/src/gcode/lcd/M73.cpp Ver arquivo

@@ -38,10 +38,8 @@
38 38
  *   This has no effect during an SD print job
39 39
  */
40 40
 void GcodeSuite::M73() {
41
-  if (!IS_SD_PRINTING() && parser.seen('P')) {
42
-    progress_bar_percent = parser.value_byte();
43
-    NOMORE(progress_bar_percent, 100);
44
-  }
41
+  if (parser.seen('P') && !IS_SD_PRINTING())
42
+    ui.set_progress(parser.value_byte());
45 43
 }
46 44
 
47 45
 #endif // ULTRA_LCD && LCD_SET_PROGRESS_MANUALLY

+ 1
- 1
Marlin/src/gcode/motion/G4.cpp Ver arquivo

@@ -38,7 +38,7 @@ void GcodeSuite::G4() {
38 38
     SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
39 39
   #endif
40 40
 
41
-  if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
41
+  if (!ui.hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
42 42
 
43 43
   dwell(dwell_ms);
44 44
 }

+ 1
- 1
Marlin/src/gcode/stats/M31.cpp Ver arquivo

@@ -40,7 +40,7 @@ void GcodeSuite::M31() {
40 40
   char buffer[21];
41 41
   duration_t elapsed = print_job_timer.duration();
42 42
   elapsed.toString(buffer);
43
-  lcd_setstatus(buffer);
43
+  ui.setstatus(buffer);
44 44
 
45 45
   SERIAL_ECHO_START_P(port);
46 46
   SERIAL_ECHOLNPAIR_P(port, "Print time: ", buffer);

+ 2
- 2
Marlin/src/gcode/temperature/M104_M109.cpp Ver arquivo

@@ -66,7 +66,7 @@ void GcodeSuite::M104() {
66 66
        */
67 67
       if (temp <= (EXTRUDE_MINTEMP) / 2) {
68 68
         print_job_timer.stop();
69
-        lcd_reset_status();
69
+        ui.reset_status();
70 70
       }
71 71
     #endif
72 72
   }
@@ -108,7 +108,7 @@ void GcodeSuite::M109() {
108 108
        */
109 109
       if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
110 110
         print_job_timer.stop();
111
-        lcd_reset_status();
111
+        ui.reset_status();
112 112
       }
113 113
       else
114 114
         print_job_timer.start();

+ 1
- 1
Marlin/src/gcode/temperature/M140_M190.cpp Ver arquivo

@@ -64,7 +64,7 @@ void GcodeSuite::M190() {
64 64
   }
65 65
   else return;
66 66
 
67
-  lcd_setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
67
+  ui.setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
68 68
 
69 69
   thermalManager.wait_for_bed(no_wait_for_cooling);
70 70
 }

+ 30
- 55
Marlin/src/inc/Conditionals_LCD.h Ver arquivo

@@ -296,47 +296,23 @@
296 296
   #define ULTIPANEL
297 297
 #endif
298 298
 
299
-#define HAS_GRAPHICAL_LCD ENABLED(DOGLCD)
300
-
301
-#if HAS_GRAPHICAL_LCD
302
-  #ifndef LCD_WIDTH
303
-    #ifdef LCD_WIDTH_OVERRIDE
304
-      #define LCD_WIDTH LCD_WIDTH_OVERRIDE
305
-    #else
306
-      #define LCD_WIDTH 22
307
-    #endif
308
-  #endif
309
-  #ifndef LCD_HEIGHT
310
-    #define LCD_HEIGHT 5
311
-  #endif
312
-#endif
313
-
314 299
 #if ENABLED(ULTIPANEL)
315 300
   #define NEWPANEL  // Disable this if you actually have no click-encoder panel
316 301
   #define ULTRA_LCD
317
-  #ifndef LCD_WIDTH
318
-    #define LCD_WIDTH 20
319
-  #endif
320
-  #ifndef LCD_HEIGHT
321
-    #define LCD_HEIGHT 4
322
-  #endif
323
-#elif ENABLED(ULTRA_LCD)  // no panel but just LCD
324
-  #ifndef LCD_WIDTH
325
-    #define LCD_WIDTH 16
326
-  #endif
327
-  #ifndef LCD_HEIGHT
328
-    #define LCD_HEIGHT 2
329
-  #endif
330 302
 #endif
331 303
 
332 304
 // Aliases for LCD features
333 305
 #define HAS_SPI_LCD          ENABLED(ULTRA_LCD)
334
-#define HAS_CHARACTER_LCD   (ENABLED(ULTRA_LCD) && DISABLED(DOGLCD))
306
+#define HAS_GRAPHICAL_LCD    ENABLED(DOGLCD)
307
+#define HAS_CHARACTER_LCD   (HAS_SPI_LCD && !HAS_GRAPHICAL_LCD)
335 308
 #define HAS_LCD_MENU        (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS))
309
+#define HAS_DIGITAL_ENCODER  ENABLED(NEWPANEL)
336 310
 
337 311
 #if HAS_GRAPHICAL_LCD
338
-  /* Custom characters defined in font Marlin_symbols.fon which was merged to ISO10646-0-3.bdf */
312
+  //
313
+  // Custom characters from Marlin_symbols.fon which was merged into ISO10646-0-3.bdf
339 314
   // \x00 intentionally skipped to avoid problems in strings
315
+  //
340 316
   #define LCD_STR_REFRESH     "\x01"
341 317
   #define LCD_STR_FOLDER      "\x02"
342 318
   #define LCD_STR_ARROW_RIGHT "\x03"
@@ -354,33 +330,18 @@
354 330
   // Symbol characters
355 331
   #define LCD_STR_FILAM_DIA   "\xf8"
356 332
   #define LCD_STR_FILAM_MUL   "\xa4"
357
-#else
358
-  // Custom characters defined in the first 8 characters of the LCD
359
-  #define LCD_BEDTEMP_CHAR     0x00  // Print only as a char. This will have 'unexpected' results when used in a string!
360
-  #define LCD_DEGREE_CHAR      0x01
361
-  #define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation
362
-  #define LCD_UPLEVEL_CHAR     0x03
363
-  #define LCD_STR_REFRESH     "\x04"
364
-  #define LCD_STR_FOLDER      "\x05"
365
-  #define LCD_FEEDRATE_CHAR    0x06
366
-  #define LCD_CLOCK_CHAR       0x07
367
-  #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
368
-#endif
369
-
370
-/**
371
- * Default LCD contrast for dogm-like LCD displays
372
- */
373
-#if HAS_GRAPHICAL_LCD
374 333
 
375
-  #define HAS_LCD_CONTRAST ( \
376
-      ENABLED(MAKRPANEL) \
377
-   || ENABLED(CARTESIO_UI) \
378
-   || ENABLED(VIKI2) \
379
-   || ENABLED(AZSMZ_12864) \
380
-   || ENABLED(miniVIKI) \
381
-   || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \
334
+  /**
335
+   * Default LCD contrast for dogm-like LCD displays
336
+   */
337
+  #define HAS_LCD_CONTRAST (                \
338
+       ENABLED(MAKRPANEL)                   \
339
+    || ENABLED(CARTESIO_UI)                 \
340
+    || ENABLED(VIKI2)                       \
341
+    || ENABLED(AZSMZ_12864)                 \
342
+    || ENABLED(miniVIKI)                    \
343
+    || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \
382 344
   )
383
-
384 345
   #if HAS_LCD_CONTRAST
385 346
     #ifndef LCD_CONTRAST_MIN
386 347
       #define LCD_CONTRAST_MIN 0
@@ -392,6 +353,20 @@
392 353
       #define DEFAULT_LCD_CONTRAST 32
393 354
     #endif
394 355
   #endif
356
+
357
+#else
358
+
359
+  // Custom characters defined in the first 8 characters of the LCD
360
+  #define LCD_BEDTEMP_CHAR     0x00  // Print only as a char. This will have 'unexpected' results when used in a string!
361
+  #define LCD_DEGREE_CHAR      0x01
362
+  #define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation
363
+  #define LCD_UPLEVEL_CHAR     0x03
364
+  #define LCD_STR_REFRESH     "\x04"
365
+  #define LCD_STR_FOLDER      "\x05"
366
+  #define LCD_FEEDRATE_CHAR    0x06
367
+  #define LCD_CLOCK_CHAR       0x07
368
+  #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
369
+
395 370
 #endif
396 371
 
397 372
 // Boot screens

+ 36
- 0
Marlin/src/inc/Conditionals_post.h Ver arquivo

@@ -1628,3 +1628,39 @@
1628 1628
 #else
1629 1629
   #define Z_STEPPER_COUNT 1
1630 1630
 #endif
1631
+
1632
+// Get LCD character width/height, which may be overridden by pins, configs, etc.
1633
+#if HAS_GRAPHICAL_LCD
1634
+  #ifndef LCD_WIDTH
1635
+    #ifdef LCD_WIDTH_OVERRIDE
1636
+      #define LCD_WIDTH LCD_WIDTH_OVERRIDE
1637
+    #elif ENABLED(LIGHTWEIGHT_UI)
1638
+      #define LCD_WIDTH 16
1639
+    #else
1640
+      #define LCD_WIDTH 22
1641
+    #endif
1642
+  #endif
1643
+  #ifndef LCD_HEIGHT
1644
+    #ifdef LCD_HEIGHT_OVERRIDE
1645
+      #define LCD_HEIGHT LCD_HEIGHT_OVERRIDE
1646
+    #elif ENABLED(LIGHTWEIGHT_UI)
1647
+      #define LCD_HEIGHT 4
1648
+    #else
1649
+      #define LCD_HEIGHT 5
1650
+    #endif
1651
+  #endif
1652
+#elif ENABLED(ULTIPANEL)
1653
+  #ifndef LCD_WIDTH
1654
+    #define LCD_WIDTH 20
1655
+  #endif
1656
+  #ifndef LCD_HEIGHT
1657
+    #define LCD_HEIGHT 4
1658
+  #endif
1659
+#elif HAS_SPI_LCD
1660
+  #ifndef LCD_WIDTH
1661
+    #define LCD_WIDTH 16
1662
+  #endif
1663
+  #ifndef LCD_HEIGHT
1664
+    #define LCD_HEIGHT 2
1665
+  #endif
1666
+#endif

+ 2
- 0
Marlin/src/inc/SanityCheck.h Ver arquivo

@@ -491,6 +491,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
491 491
     #error "LCD_PROGRESS_BAR does not apply to graphical displays."
492 492
   #elif ENABLED(FILAMENT_LCD_DISPLAY)
493 493
     #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both."
494
+  #elif PROGRESS_MSG_EXPIRE < 0
495
+    #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0."
494 496
   #endif
495 497
 #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && !HAS_GRAPHICAL_LCD
496 498
   #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR or Graphical LCD."

+ 1
- 65
Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h Ver arquivo

@@ -39,70 +39,6 @@
39 39
 // macro name. The mapping is independent of whether the button is directly connected or
40 40
 // via a shift/i2c register.
41 41
 
42
-#if HAS_LCD_MENU
43
-
44
-  extern volatile uint8_t buttons;
45
-
46
-  //
47
-  // Setup other button mappings of each panel
48
-  //
49
-  #if ENABLED(LCD_I2C_VIKI)
50
-    #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
51
-
52
-    // button and encoder bit positions within 'buttons'
53
-    #define B_LE (BUTTON_LEFT   << B_I2C_BTN_OFFSET)    // The remaining normalized buttons are all read via I2C
54
-    #define B_UP (BUTTON_UP     << B_I2C_BTN_OFFSET)
55
-    #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
56
-    #define B_DW (BUTTON_DOWN   << B_I2C_BTN_OFFSET)
57
-    #define B_RI (BUTTON_RIGHT  << B_I2C_BTN_OFFSET)
58
-
59
-    #undef LCD_CLICKED
60
-    #if BUTTON_EXISTS(ENC)
61
-      // the pause/stop/restart button is connected to BTN_ENC when used
62
-      #define B_ST (EN_C)                            // Map the pause/stop/resume button into its normalized functional name
63
-      #define LCD_CLICKED() (buttons & (B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
64
-    #else
65
-      #define LCD_CLICKED() (buttons & (B_MI|B_RI))
66
-    #endif
67
-
68
-    // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
69
-    #define LCD_HAS_SLOW_BUTTONS
70
-
71
-  #elif ENABLED(LCD_I2C_PANELOLU2)
72
-
73
-    #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
74
-
75
-      #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
76
-
77
-      #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
78
-
79
-      #undef LCD_CLICKED
80
-      #define LCD_CLICKED() (buttons & B_MI)
81
-
82
-      // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
83
-      #define LCD_HAS_SLOW_BUTTONS
84
-
85
-    #endif
86
-
87
-  #elif DISABLED(NEWPANEL) // old style ULTIPANEL
88
-    // Shift register bits correspond to buttons:
89
-    #define BL_LE 7   // Left
90
-    #define BL_UP 6   // Up
91
-    #define BL_MI 5   // Middle
92
-    #define BL_DW 4   // Down
93
-    #define BL_RI 3   // Right
94
-    #define BL_ST 2   // Red Button
95
-    #define B_LE (_BV(BL_LE))
96
-    #define B_UP (_BV(BL_UP))
97
-    #define B_MI (_BV(BL_MI))
98
-    #define B_DW (_BV(BL_DW))
99
-    #define B_RI (_BV(BL_RI))
100
-    #define B_ST (_BV(BL_ST))
101
-    #define LCD_CLICKED() (buttons & (B_MI|B_ST))
102
-  #endif
103
-
104
-#endif // HAS_LCD_MENU
105
-
106 42
 ////////////////////////////////////
107 43
 // Create LCD class instance and chipset-specific information
108 44
 #if ENABLED(LCD_I2C_TYPE_PCF8575)
@@ -122,7 +58,7 @@
122 58
   #define LCD_CLASS LiquidCrystal_I2C
123 59
 
124 60
 #elif ENABLED(LCD_I2C_TYPE_MCP23017)
125
-  // For the LED indicators (which may be mapped to different events in lcd_implementation_update_indicators())
61
+  // For the LED indicators (which may be mapped to different events in update_indicators())
126 62
   #define LCD_HAS_STATUS_INDICATORS
127 63
   #define LED_A 0x04 //100
128 64
   #define LED_B 0x02 //010

+ 99
- 147
Marlin/src/lcd/HD44780/ultralcd_impl_HD44780.cpp Ver arquivo

@@ -86,10 +86,6 @@
86 86
 
87 87
 #endif
88 88
 
89
-#if ENABLED(LCD_HAS_STATUS_INDICATORS)
90
-  static void lcd_implementation_update_indicators();
91
-#endif
92
-
93 89
 static void createChar_P(const char c, const byte * const ptr) {
94 90
   byte temp[8];
95 91
   for (uint8_t i = 0; i < 8; i++)
@@ -101,7 +97,7 @@ static void createChar_P(const char c, const byte * const ptr) {
101 97
   #define LCD_STR_PROGRESS  "\x03\x04\x05"
102 98
 #endif
103 99
 
104
-void lcd_set_custom_characters(
100
+void MarlinUI::set_custom_characters(
105 101
   #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
106 102
     const HD44780CharSet screen_charset/*=CHARSET_INFO*/
107 103
   #endif
@@ -319,7 +315,7 @@ void lcd_set_custom_characters(
319 315
 
320 316
 }
321 317
 
322
-void lcd_implementation_init() {
318
+void MarlinUI::init_lcd() {
323 319
 
324 320
   #if ENABLED(LCD_I2C_TYPE_PCF8575)
325 321
     lcd.begin(LCD_WIDTH, LCD_HEIGHT);
@@ -331,7 +327,7 @@ void lcd_implementation_init() {
331 327
   #elif ENABLED(LCD_I2C_TYPE_MCP23017)
332 328
     lcd.setMCPType(LTI_TYPE_MCP23017);
333 329
     lcd.begin(LCD_WIDTH, LCD_HEIGHT);
334
-    lcd_implementation_update_indicators();
330
+    update_indicators();
335 331
 
336 332
   #elif ENABLED(LCD_I2C_TYPE_MCP23008)
337 333
     lcd.setMCPType(LTI_TYPE_MCP23008);
@@ -345,12 +341,12 @@ void lcd_implementation_init() {
345 341
     lcd.begin(LCD_WIDTH, LCD_HEIGHT);
346 342
   #endif
347 343
 
348
-  LCD_SET_CHARSET(currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
344
+  LCD_SET_CHARSET(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
349 345
 
350 346
   lcd.clear();
351 347
 }
352 348
 
353
-void lcd_implementation_clear() { lcd.clear(); }
349
+void MarlinUI::clear_lcd() { lcd.clear(); }
354 350
 
355 351
 #if ENABLED(SHOW_BOOTSCREEN)
356 352
 
@@ -408,7 +404,7 @@ void lcd_implementation_clear() { lcd.clear(); }
408 404
     lcd_moveto(indent, 2); lcd_put_wchar('\x02'); lcd_put_u8str_P(PSTR( "------" ));  lcd_put_wchar('\x03');
409 405
   }
410 406
 
411
-  void lcd_bootscreen() {
407
+  void MarlinUI::show_bootscreen() {
412 408
     LCD_SET_CHARSET(CHARSET_BOOT);
413 409
     lcd.clear();
414 410
 
@@ -454,6 +450,9 @@ void lcd_implementation_clear() { lcd.clear(); }
454 450
         CENTER_OR_SCROLL(STRING_SPLASH_LINE1, _SPLASH_WAIT_1);
455 451
         #ifdef STRING_SPLASH_LINE2
456 452
           CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 1500);
453
+          #ifdef STRING_SPLASH_LINE3
454
+            CENTER_OR_SCROLL(STRING_SPLASH_LINE3, 1500);
455
+          #endif
457 456
         #endif
458 457
       }
459 458
     #elif defined(STRING_SPLASH_LINE2)
@@ -484,9 +483,9 @@ void lcd_implementation_clear() { lcd.clear(); }
484 483
 
485 484
 #endif // SHOW_BOOTSCREEN
486 485
 
487
-void lcd_kill_screen() {
486
+void MarlinUI::draw_kill_screen() {
488 487
   lcd_moveto(0, 0);
489
-  lcd_put_u8str(lcd_status_message);
488
+  lcd_put_u8str(status_message);
490 489
   #if LCD_HEIGHT < 4
491 490
     lcd_moveto(0, 2);
492 491
   #else
@@ -572,13 +571,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
572 571
 #if HAS_PRINT_PROGRESS
573 572
 
574 573
   FORCE_INLINE void _draw_print_progress() {
575
-    const uint8_t percent = (
576
-      #if ENABLED(SDSUPPORT)
577
-        IS_SD_PRINTING() ? card.percentDone() : 0
578
-      #else
579
-        progress_bar_percent
580
-      #endif
581
-    );
574
+    const uint8_t progress = ui.get_progress();
582 575
     lcd_put_u8str_P(PSTR(
583 576
       #if ENABLED(SDSUPPORT)
584 577
         "SD"
@@ -586,8 +579,8 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
586 579
         "P:"
587 580
       #endif
588 581
     ));
589
-    if (percent)
590
-      lcd_put_u8str(itostr3(percent));
582
+    if (progress)
583
+      lcd_put_u8str(itostr3(progress));
591 584
     else
592 585
       lcd_put_u8str_P(PSTR("---"));
593 586
     lcd_put_wchar('%');
@@ -616,7 +609,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
616 609
 
617 610
 #endif // LCD_PROGRESS_BAR
618 611
 
619
-FORCE_INLINE void _draw_status_message(const bool blink) {
612
+void MarlinUI::draw_status_message(const bool blink) {
620 613
 
621 614
   lcd_moveto(0, LCD_HEIGHT - 1);
622 615
 
@@ -624,17 +617,15 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
624 617
 
625 618
     // Draw the progress bar if the message has shown long enough
626 619
     // or if there is no message set.
627
-    #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
628
-      const uint8_t progress_bar_percent = card.percentDone();
629
-    #endif
630
-    if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
631
-      return lcd_draw_progress_bar(progress_bar_percent);
620
+    if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !has_status()) {
621
+      const uint8_t progress = get_progress();
622
+      if (progress > 2) return lcd_draw_progress_bar(progress);
623
+    }
632 624
 
633 625
   #elif ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
634 626
 
635
-    // Show Filament Diameter and Volumetric Multiplier %
636
-    // After allowing lcd_status_message to show for 5 seconds
637
-    if (ELAPSED(millis(), previous_lcd_status_ms + 5000UL)) {
627
+    // Alternate Status message and Filament display
628
+    if (ELAPSED(millis(), next_filament_display)) {
638 629
       lcd_put_u8str_P(PSTR("Dia "));
639 630
       lcd_put_u8str(ftostr12ns(filament_width_meas));
640 631
       lcd_put_u8str_P(PSTR(" V"));
@@ -654,13 +645,13 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
654 645
     static bool last_blink = false;
655 646
 
656 647
     // Get the UTF8 character count of the string
657
-    uint8_t slen = utf8_strlen(lcd_status_message);
648
+    uint8_t slen = utf8_strlen(status_message);
658 649
 
659 650
     // If the string fits into the LCD, just print it and do not scroll it
660 651
     if (slen <= LCD_WIDTH) {
661 652
 
662 653
       // The string isn't scrolling and may not fill the screen
663
-      lcd_put_u8str(lcd_status_message);
654
+      lcd_put_u8str(status_message);
664 655
 
665 656
       // Fill the rest with spaces
666 657
       while (slen < LCD_WIDTH) {
@@ -672,7 +663,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
672 663
       // String is larger than the available space in screen.
673 664
 
674 665
       // Get a pointer to the next valid UTF8 character
675
-      const char *stat = lcd_status_message + status_scroll_offset;
666
+      const char *stat = status_message + status_scroll_offset;
676 667
 
677 668
       // Get the string remaining length
678 669
       const uint8_t rlen = utf8_strlen(stat);
@@ -692,7 +683,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
692 683
         if (--chars) {                                    // Draw a second dot if there's space
693 684
           lcd_put_wchar('.');
694 685
           if (--chars)
695
-            lcd_put_u8str_max(lcd_status_message, chars); // Print a second copy of the message
686
+            lcd_put_u8str_max(status_message, chars); // Print a second copy of the message
696 687
         }
697 688
       }
698 689
       if (last_blink != blink) {
@@ -701,7 +692,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
701 692
         // Adjust by complete UTF8 characters
702 693
         if (status_scroll_offset < slen) {
703 694
           status_scroll_offset++;
704
-          while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
695
+          while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
705 696
             status_scroll_offset++;
706 697
         }
707 698
         else
@@ -712,10 +703,10 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
712 703
     UNUSED(blink);
713 704
 
714 705
     // Get the UTF8 character count of the string
715
-    uint8_t slen = utf8_strlen(lcd_status_message);
706
+    uint8_t slen = utf8_strlen(status_message);
716 707
 
717 708
     // Just print the string to the LCD
718
-    lcd_put_u8str_max(lcd_status_message, LCD_WIDTH);
709
+    lcd_put_u8str_max(status_message, LCD_WIDTH);
719 710
 
720 711
     // Fill the rest with spaces if there are missing spaces
721 712
     while (slen < LCD_WIDTH) {
@@ -725,34 +716,46 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
725 716
   #endif
726 717
 }
727 718
 
728
-#if LCD_INFO_SCREEN_STYLE == 0
729
-
730
-  /**
731
-   *  LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen
732
-   *
733
-   *  16x2   |000/000 B000/000|
734
-   *         |0123456789012345|
735
-   *
736
-   *  16x4   |000/000 B000/000|
737
-   *         |SD---%  Z 000.00|
738
-   *         |F---%     T--:--|
739
-   *         |0123456789012345|
740
-   *
741
-   *  20x2   |T000/000° B000/000° |
742
-   *         |01234567890123456789|
743
-   *
744
-   *  20x4   |T000/000° B000/000° |
745
-   *         |X 000 Y 000 Z000.000|
746
-   *         |F---%  SD---% T--:--|
747
-   *         |01234567890123456789|
748
-   */
749
-
750
-  void lcd_impl_status_screen_0() {
751
-    const bool blink = lcd_blink();
719
+/**
720
+ *  LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen
721
+ *
722
+ *  16x2   |000/000 B000/000|
723
+ *         |0123456789012345|
724
+ *
725
+ *  16x4   |000/000 B000/000|
726
+ *         |SD---%  Z 000.00|
727
+ *         |F---%     T--:--|
728
+ *         |0123456789012345|
729
+ *
730
+ *  20x2   |T000/000° B000/000° |
731
+ *         |01234567890123456789|
732
+ *
733
+ *  20x4   |T000/000° B000/000° |
734
+ *         |X 000 Y 000 Z000.000|
735
+ *         |F---%  SD---% T--:--|
736
+ *         |01234567890123456789|
737
+ *
738
+ *  LCD_INFO_SCREEN_STYLE 1 : Prusa-style Status Screen
739
+ *
740
+ *  |T000/000°  Z 000.00 |
741
+ *  |B000/000°  F---%    |
742
+ *  |SD---%     T--:--   |
743
+ *  |01234567890123456789|
744
+ *
745
+ *  |T000/000°  Z 000.00 |
746
+ *  |T000/000°  F---%    |
747
+ *  |B000/000°  SD---%   |
748
+ *  |01234567890123456789|
749
+ */
750
+
751
+void MarlinUI::draw_status_screen() {
752 752
 
753
-    // ========== Line 1 ==========
753
+  const bool blink = get_blink();
754
+  lcd_moveto(0, 0);
755
+
756
+  #if LCD_INFO_SCREEN_STYLE == 0
754 757
 
755
-    lcd_moveto(0, 0);
758
+    // ========== Line 1 ==========
756 759
 
757 760
     #if LCD_WIDTH < 20
758 761
 
@@ -885,39 +888,13 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
885 888
 
886 889
     #endif // LCD_HEIGHT > 3
887 890
 
888
-    // ========= Last Line ========
889
-
890
-    //
891
-    // Status Message (which may be a Progress Bar or Filament display)
892
-    //
893
-    _draw_status_message(blink);
894
-  }
895
-
896
-#elif LCD_INFO_SCREEN_STYLE == 1
897
-
898
-  /**
899
-   *  LCD_INFO_SCREEN_STYLE 1 : Prusa-style Status Screen
900
-   *
901
-   *  |T000/000°  Z 000.00 |
902
-   *  |B000/000°  F---%    |
903
-   *  |SD---%     T--:--   |
904
-   *  |01234567890123456789|
905
-   *
906
-   *  |T000/000°  Z 000.00 |
907
-   *  |T000/000°  F---%    |
908
-   *  |B000/000°  SD---%   |
909
-   *  |01234567890123456789|
910
-   */
911
-
912
-  void lcd_impl_status_screen_1() {
913
-    const bool blink = lcd_blink();
891
+  #elif LCD_INFO_SCREEN_STYLE == 1
914 892
 
915 893
     // ========== Line 1 ==========
916 894
 
917 895
     //
918 896
     // Hotend 0 Temperature
919 897
     //
920
-    lcd_moveto(0, 0);
921 898
     _draw_heater_status(0, LCD_STR_THERMOMETER[0], blink);
922 899
 
923 900
     //
@@ -977,30 +954,30 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
977 954
       lcd_put_u8str(buffer);
978 955
     #endif
979 956
 
980
-    // ========== Line 4 ==========
957
+  #endif // LCD_INFO_SCREEN_STYLE 1
981 958
 
982
-    //
983
-    // Status Message (which may be a Progress Bar or Filament display)
984
-    //
985
-    _draw_status_message(blink);
986
-  }
959
+  // ========= Last Line ========
987 960
 
988
-#endif
961
+  //
962
+  // Status Message (which may be a Progress Bar or Filament display)
963
+  //
964
+  draw_status_message(blink);
965
+}
989 966
 
990 967
 #if HAS_LCD_MENU
991 968
 
992 969
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
993 970
 
994
-    void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
971
+    void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
995 972
       if (row < LCD_HEIGHT) {
996 973
         lcd_moveto(LCD_WIDTH - 9, row);
997
-        _draw_heater_status(extruder, LCD_STR_THERMOMETER[0], lcd_blink());
974
+        _draw_heater_status(extruder, LCD_STR_THERMOMETER[0], ui.get_blink());
998 975
       }
999 976
     }
1000 977
 
1001 978
   #endif // ADVANCED_PAUSE_FEATURE
1002 979
 
1003
-  void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
980
+  void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
1004 981
     UNUSED(invert);
1005 982
     int8_t n = LCD_WIDTH;
1006 983
     lcd_moveto(0, row);
@@ -1013,35 +990,35 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
1013 990
     for (; n > 0; --n) lcd_put_wchar(' ');
1014 991
   }
1015 992
 
1016
-  void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
993
+  void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
1017 994
     uint8_t n = LCD_WIDTH - 2;
1018 995
     lcd_moveto(0, row);
1019
-    lcd_put_wchar(sel ? pre_char : ' ');
996
+    lcd_put_wchar(isSelected ? pre_char : ' ');
1020 997
     n -= lcd_put_u8str_max_P(pstr, n);
1021 998
     while (n--) lcd_put_wchar(' ');
1022 999
     lcd_put_wchar(post_char);
1023 1000
   }
1024 1001
 
1025
-  void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
1002
+  void draw_menu_item_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
1026 1003
     uint8_t n = LCD_WIDTH - 2 - utf8_strlen(data);
1027 1004
     lcd_moveto(0, row);
1028
-    lcd_put_wchar(sel ? pre_char : ' ');
1005
+    lcd_put_wchar(isSelected ? pre_char : ' ');
1029 1006
     n -= lcd_put_u8str_max_P(pstr, n);
1030 1007
     lcd_put_wchar(':');
1031 1008
     while (n--) lcd_put_wchar(' ');
1032 1009
     lcd_put_u8str(data);
1033 1010
   }
1034
-  void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
1011
+  void draw_menu_item_setting_edit_generic_P(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
1035 1012
     uint8_t n = LCD_WIDTH - 2 - utf8_strlen_P(data);
1036 1013
     lcd_moveto(0, row);
1037
-    lcd_put_wchar(sel ? pre_char : ' ');
1014
+    lcd_put_wchar(isSelected ? pre_char : ' ');
1038 1015
     n -= lcd_put_u8str_max_P(pstr, n);
1039 1016
     lcd_put_wchar(':');
1040 1017
     while (n--) lcd_put_wchar(' ');
1041 1018
     lcd_put_u8str_P(data);
1042 1019
   }
1043 1020
 
1044
-  void lcd_implementation_drawedit(PGM_P pstr, const char* const value/*=NULL*/) {
1021
+  void draw_edit_screen(PGM_P const pstr, const char* const value/*=NULL*/) {
1045 1022
     lcd_moveto(1, 1);
1046 1023
     lcd_put_u8str_P(pstr);
1047 1024
     if (value != NULL) {
@@ -1056,27 +1033,29 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
1056 1033
 
1057 1034
   #if ENABLED(SDSUPPORT)
1058 1035
 
1059
-    static void lcd_implementation_drawmenu_sd(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const uint8_t concat, const char post_char) {
1036
+    void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
1037
+      const char post_char = isDir ? LCD_STR_FOLDER[0] : ' ',
1038
+                 sel_char = isSelected ? '>' : ' ';
1060 1039
       UNUSED(pstr);
1061 1040
       lcd_moveto(0, row);
1062
-      lcd_put_wchar(sel ? '>' : ' ');
1041
+      lcd_put_wchar(sel_char);
1063 1042
 
1064
-      uint8_t n = LCD_WIDTH - concat;
1043
+      uint8_t n = LCD_WIDTH - 2;
1065 1044
       const char *outstr = theCard.longest_filename();
1066 1045
       if (theCard.longFilename[0]) {
1067 1046
         #if ENABLED(SCROLL_LONG_FILENAMES)
1068 1047
           static uint8_t filename_scroll_hash;
1069
-          if (sel) {
1048
+          if (isSelected) {
1070 1049
             uint8_t name_hash = row;
1071 1050
             for (uint8_t l = FILENAME_LENGTH; l--;)
1072 1051
               name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ theCard.filename[l];  // rotate, xor
1073 1052
             if (filename_scroll_hash != name_hash) {                            // If the hash changed...
1074 1053
               filename_scroll_hash = name_hash;                                 // Save the new hash
1075
-              filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - n);  // Update the scroll limit
1076
-              filename_scroll_pos = 0;                                          // Reset scroll to the start
1077
-              lcd_status_update_delay = 8;                                      // Don't scroll right away
1054
+              ui.filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - n); // Update the scroll limit
1055
+              ui.filename_scroll_pos = 0;                                       // Reset scroll to the start
1056
+              ui.lcd_status_update_delay = 8;                                   // Don't scroll right away
1078 1057
             }
1079
-            outstr += filename_scroll_pos;
1058
+            outstr += ui.filename_scroll_pos;
1080 1059
           }
1081 1060
         #else
1082 1061
           theCard.longFilename[n] = '\0'; // cutoff at screen edge
@@ -1084,45 +1063,18 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
1084 1063
       }
1085 1064
 
1086 1065
       lcd_moveto(0, row);
1087
-      lcd_put_wchar(sel ? '>' : ' ');
1066
+      lcd_put_wchar(sel_char);
1088 1067
       n -= lcd_put_u8str_max(outstr, n);
1089 1068
 
1090
-      while (n) { --n; lcd_put_wchar(' '); }
1069
+      for (; n; --n) lcd_put_wchar(' ');
1091 1070
       lcd_put_wchar(post_char);
1092 1071
     }
1093 1072
 
1094
-    void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
1095
-      lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, ' ');
1096
-    }
1097
-
1098
-    void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
1099
-      lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, LCD_STR_FOLDER[0]);
1100
-    }
1101
-
1102 1073
   #endif // SDSUPPORT
1103 1074
 
1104
-  #if ENABLED(LCD_HAS_SLOW_BUTTONS)
1105
-
1106
-    extern millis_t next_button_update_ms;
1107
-
1108
-    static uint8_t lcd_implementation_read_slow_buttons() {
1109
-      #if ENABLED(LCD_I2C_TYPE_MCP23017)
1110
-        // Reading these buttons this is likely to be too slow to call inside interrupt context
1111
-        // so they are called during normal lcd_update
1112
-        uint8_t slow_bits = lcd.readButtons() << B_I2C_BTN_OFFSET;
1113
-        #if ENABLED(LCD_I2C_VIKI)
1114
-          if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
1115
-            slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
1116
-        #endif // LCD_I2C_VIKI
1117
-        return slow_bits;
1118
-      #endif // LCD_I2C_TYPE_MCP23017
1119
-    }
1120
-
1121
-  #endif // LCD_HAS_SLOW_BUTTONS
1122
-
1123 1075
   #if ENABLED(LCD_HAS_STATUS_INDICATORS)
1124 1076
 
1125
-    static void lcd_implementation_update_indicators() {
1077
+    static void MarlinUI::update_indicators() {
1126 1078
       // Set the LEDS - referred to as backlights by the LiquidTWI2 library
1127 1079
       static uint8_t ledsprev = 0;
1128 1080
       uint8_t leds = 0;
@@ -1242,7 +1194,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
1242 1194
       lcd_put_wchar(c);
1243 1195
     }
1244 1196
 
1245
-    void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y) {
1197
+    void MarlinUI::ubl_plot(const uint8_t x, const uint8_t inverted_y) {
1246 1198
 
1247 1199
       #if LCD_WIDTH >= 20
1248 1200
         #define _LCD_W_POS 12
@@ -1292,7 +1244,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
1292 1244
         lower_right.column = 0;
1293 1245
         lower_right.row    = 0;
1294 1246
 
1295
-        lcd_implementation_clear();
1247
+        clear_lcd();
1296 1248
 
1297 1249
         x_map_pixels = (HD44780_CHAR_WIDTH) * (MESH_MAP_COLS) - 2;          // Minus 2 because we are drawing a box around the map
1298 1250
         y_map_pixels = (HD44780_CHAR_HEIGHT) * (MESH_MAP_ROWS) - 2;

+ 35
- 46
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Ver arquivo

@@ -135,35 +135,29 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
135 135
   }
136 136
 }
137 137
 
138
-FORCE_INLINE void lcd_implementation_status_message(const bool blink) {
139
-  #if ENABLED(STATUS_MESSAGE_SCROLLING)
140
-    static bool last_blink = false;
138
+void MarlinUI::draw_status_message(const bool blink) {
141 139
 
142
-    // Get the UTF8 character count of the string
143
-    uint8_t slen = utf8_strlen(lcd_status_message);
140
+  // Get the UTF8 character count of the string
141
+  uint8_t slen = utf8_strlen(status_message);
144 142
 
145
-    // If the string fits into the LCD, just print it and do not scroll it
146
-    if (slen <= LCD_WIDTH) {
143
+  #if ENABLED(STATUS_MESSAGE_SCROLLING)
147 144
 
148
-      // The string isn't scrolling and may not fill the screen
149
-      lcd_put_u8str(lcd_status_message);
145
+    static bool last_blink = false;
150 146
 
151
-      // Fill the rest with spaces
152
-      while (slen < LCD_WIDTH) {
153
-        lcd_put_wchar(' ');
154
-        ++slen;
155
-      }
147
+    if (slen <= LCD_WIDTH) {
148
+      // The string fits within the line. Print with no scrolling
149
+      lcd_put_u8str(status_message);
150
+      for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
156 151
     }
157 152
     else {
158
-      // String is larger than the available space in screen.
153
+      // String is longer than the available space
159 154
 
160 155
       // Get a pointer to the next valid UTF8 character
161
-      const char *stat = lcd_status_message + status_scroll_offset;
156
+      const char *stat = status_message + status_scroll_offset;
162 157
 
163 158
       // Get the string remaining length
164 159
       const uint8_t rlen = utf8_strlen(stat);
165 160
 
166
-      // If we have enough characters to display
167 161
       if (rlen >= LCD_WIDTH) {
168 162
         // The remaining string fills the screen - Print it
169 163
         lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
@@ -178,7 +172,7 @@ FORCE_INLINE void lcd_implementation_status_message(const bool blink) {
178 172
           lcd_put_wchar('.');
179 173
           if (--chars) {
180 174
             // Print a second copy of the message
181
-            lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH - ((rlen+2) * MENU_FONT_WIDTH));
175
+            lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
182 176
           }
183 177
         }
184 178
       }
@@ -188,36 +182,33 @@ FORCE_INLINE void lcd_implementation_status_message(const bool blink) {
188 182
         // Adjust by complete UTF8 characters
189 183
         if (status_scroll_offset < slen) {
190 184
           status_scroll_offset++;
191
-          while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
185
+          while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
192 186
             status_scroll_offset++;
193 187
         }
194 188
         else
195 189
           status_scroll_offset = 0;
196 190
       }
197 191
     }
198
-  #else
199
-    UNUSED(blink);
200 192
 
201
-    // Get the UTF8 character count of the string
202
-    uint8_t slen = utf8_strlen(lcd_status_message);
193
+  #else // !STATUS_MESSAGE_SCROLLING
194
+
195
+    UNUSED(blink);
203 196
 
204 197
     // Just print the string to the LCD
205
-    lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH);
198
+    lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH);
206 199
 
207
-    // Fill the rest with spaces if there are missing spaces
208
-    while (slen < LCD_WIDTH) {
209
-      lcd_put_wchar(' ');
210
-      ++slen;
211
-    }
212
-  #endif
200
+    // Fill the rest with spaces
201
+    for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
202
+
203
+  #endif // !STATUS_MESSAGE_SCROLLING
213 204
 }
214 205
 
215
-void lcd_impl_status_screen_0() {
206
+void MarlinUI::draw_status_screen() {
216 207
 
217
-  const bool blink = lcd_blink();
208
+  const bool blink = get_blink();
218 209
 
219 210
   // Status Menu Font
220
-  lcd_setFont(FONT_STATUSMENU);
211
+  set_font(FONT_STATUSMENU);
221 212
 
222 213
   //
223 214
   // Fan Animation
@@ -318,11 +309,9 @@ void lcd_impl_status_screen_0() {
318 309
         PROGRESS_BAR_WIDTH, 4
319 310
       );
320 311
 
321
-    #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
322
-      const uint8_t progress_bar_percent = card.percentDone();
323
-    #endif
312
+    const uint8_t progress = get_progress();
324 313
 
325
-    if (progress_bar_percent > 1) {
314
+    if (progress > 1) {
326 315
 
327 316
       //
328 317
       // Progress bar solid part
@@ -331,7 +320,7 @@ void lcd_impl_status_screen_0() {
331 320
       if (PAGE_CONTAINS(50, 51))     // 50-51 (or just 50)
332 321
         u8g.drawBox(
333 322
           PROGRESS_BAR_X + 1, 50,
334
-          (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2
323
+          (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress * 0.01), 2
335 324
         );
336 325
 
337 326
       //
@@ -342,7 +331,7 @@ void lcd_impl_status_screen_0() {
342 331
         if (PAGE_CONTAINS(41, 48)) {
343 332
           // Percent complete
344 333
           lcd_moveto(55, 48);
345
-          lcd_put_u8str(itostr3(progress_bar_percent));
334
+          lcd_put_u8str(itostr3(progress));
346 335
           lcd_put_wchar('%');
347 336
         }
348 337
       #endif
@@ -449,11 +438,11 @@ void lcd_impl_status_screen_0() {
449 438
   #define EXTRAS_BASELINE 50
450 439
 
451 440
   if (PAGE_CONTAINS(EXTRAS_BASELINE - (INFO_FONT_HEIGHT - 1), EXTRAS_BASELINE)) {
452
-    lcd_setFont(FONT_MENU);
441
+    set_font(FONT_MENU);
453 442
     lcd_moveto(3, EXTRAS_BASELINE);
454 443
     lcd_put_wchar(LCD_STR_FEEDRATE[0]);
455 444
 
456
-    lcd_setFont(FONT_STATUSMENU);
445
+    set_font(FONT_STATUSMENU);
457 446
     lcd_moveto(12, EXTRAS_BASELINE);
458 447
     lcd_put_u8str(itostr3(feedrate_percentage));
459 448
     lcd_put_wchar('%');
@@ -467,7 +456,7 @@ void lcd_impl_status_screen_0() {
467 456
       lcd_moveto(102, EXTRAS_BASELINE);
468 457
       lcd_put_u8str(mstring);
469 458
       lcd_put_wchar('%');
470
-      lcd_setFont(FONT_MENU);
459
+      set_font(FONT_MENU);
471 460
       lcd_moveto(47, EXTRAS_BASELINE);
472 461
       lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
473 462
       lcd_moveto(93, EXTRAS_BASELINE);
@@ -485,9 +474,9 @@ void lcd_impl_status_screen_0() {
485 474
     lcd_moveto(0, STATUS_BASELINE);
486 475
 
487 476
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
488
-      if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) {  //Display both Status message line and Filament display on the last line
489
-        lcd_implementation_status_message(blink);
490
-      }
477
+      // Alternate Status message and Filament display
478
+      if (PENDING(millis(), next_filament_display))
479
+        draw_status_message(blink);
491 480
       else {
492 481
         lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
493 482
         lcd_put_wchar(':');
@@ -498,7 +487,7 @@ void lcd_impl_status_screen_0() {
498 487
         lcd_put_wchar('%');
499 488
       }
500 489
     #else
501
-      lcd_implementation_status_message(blink);
490
+      draw_status_message(blink);
502 491
     #endif
503 492
   }
504 493
 }

+ 102
- 142
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Ver arquivo

@@ -230,12 +230,8 @@ void ST7920_Lite_Status_Screen::load_cgram_icon(const uint16_t addr, const void
230 230
  */
231 231
 void ST7920_Lite_Status_Screen::draw_gdram_icon(uint8_t x, uint8_t y, const void *data) {
232 232
   const uint16_t *p_word = (const uint16_t *)data;
233
-  if (y > 2) { // Handle display folding
234
-    y -= 2;
235
-    x += 8;
236
-  }
237
-  --x;
238
-  --y;
233
+  // Handle display folding
234
+  if (y > 1) y -= 2, x += 8;
239 235
   for (int i = 0; i < 16; i++) {
240 236
     set_gdram_address(x, i + y * 16);
241 237
     begin_data();
@@ -398,24 +394,20 @@ const uint16_t feedrate_icon[] PROGMEM = {
398 394
 
399 395
 /************************** MAIN SCREEN *************************************/
400 396
 
401
-// The ST7920 does not have a degree character, but we
402
-// can fake it by writing it to GDRAM.
403
-// This function takes as an argument character positions
404
-// i.e x is [1-16], while the y position is [1-4]
405
-void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, bool draw) {
397
+/**
398
+ * The ST7920 has no degree character, so draw it to GDRAM.
399
+ * This function takes character position xy
400
+ * i.e., x is [0-15], while the y position is [0-3]
401
+ */
402
+void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, const bool draw) {
406 403
   const uint8_t *p_bytes = degree_symbol;
407
-    if (y > 2) {
408
-      // Handle display folding
409
-      y -= 2;
410
-      x += 16;
411
-    }
412
-    x -= 1;
413
-    y -= 1;
404
+    // Handle display folding
405
+    if (y > 1) y -= 2, x += 16;
414 406
     const bool    oddChar = x & 1;
415
-    const uint8_t x_word  = x >> 1;
416
-    const uint8_t y_top   = degree_symbol_y_top;
417
-    const uint8_t y_bot   = y_top + sizeof(degree_symbol)/sizeof(degree_symbol[0]);
418
-    for(uint8_t i = y_top; i < y_bot; i++) {
407
+    const uint8_t x_word  = x >> 1,
408
+                  y_top   = degree_symbol_y_top,
409
+                  y_bot   = y_top + sizeof(degree_symbol)/sizeof(degree_symbol[0]);
410
+    for (uint8_t i = y_top; i < y_bot; i++) {
419 411
       uint8_t byte = pgm_read_byte(p_bytes++);
420 412
       set_gdram_address(x_word, i + y * 16);
421 413
       begin_data();
@@ -438,14 +430,14 @@ void ST7920_Lite_Status_Screen::draw_static_elements() {
438 430
   load_cgram_icon(CGRAM_ICON_4_ADDR, fan2_icon);
439 431
 
440 432
   // Draw the static icons in GDRAM
441
-  draw_gdram_icon(1, 1, nozzle_icon);
433
+  draw_gdram_icon(0, 0, nozzle_icon);
442 434
   #if HOTENDS > 1
443
-    draw_gdram_icon(1,2,nozzle_icon);
444
-    draw_gdram_icon(1,3,bed_icon);
435
+    draw_gdram_icon(0, 1, nozzle_icon);
436
+    draw_gdram_icon(0, 2, bed_icon);
445 437
   #else
446
-    draw_gdram_icon(1,2,bed_icon);
438
+    draw_gdram_icon(0, 1, bed_icon);
447 439
   #endif
448
-  draw_gdram_icon(6,2,feedrate_icon);
440
+  draw_gdram_icon(5, 1, feedrate_icon);
449 441
 
450 442
   // Draw the initial fan icon
451 443
   draw_fan_icon(false);
@@ -462,15 +454,15 @@ void ST7920_Lite_Status_Screen::draw_static_elements() {
462 454
 void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) {
463 455
   #if HOTENDS == 1
464 456
     // If we have only one extruder, draw a long progress bar on the third line
465
-    const uint8_t top     = 1,         // Top in pixels
466
-                  bottom  = 13,        // Bottom in pixels
467
-                  left    = 12,        // Left edge, in 16-bit words
468
-                  width   = 4;         // Width of progress bar, in 16-bit words
457
+    constexpr uint8_t top     = 1,         // Top in pixels
458
+                      bottom  = 13,        // Bottom in pixels
459
+                      left    = 12,        // Left edge, in 16-bit words
460
+                      width   = 4;         // Width of progress bar, in 16-bit words
469 461
   #else
470
-    const uint8_t top     = 16 + 1,
471
-                  bottom  = 16 + 13,
472
-                  left    = 5,
473
-                  width   = 3;
462
+    constexpr uint8_t top     = 16 + 1,
463
+                      bottom  = 16 + 13,
464
+                      left    = 5,
465
+                      width   = 3;
474 466
   #endif
475 467
   const uint8_t char_pcnt  = 100 / width; // How many percent does each 16-bit word represent?
476 468
 
@@ -557,10 +549,10 @@ static struct {
557 549
 
558 550
 void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange) {
559 551
   switch (line) {
560
-    case 1: set_ddram_address(DDRAM_LINE_1 + 1); break;
561
-    case 2: set_ddram_address(DDRAM_LINE_2 + 1); break;
552
+    case 0: set_ddram_address(DDRAM_LINE_1 + 1); break;
553
+    case 1: set_ddram_address(DDRAM_LINE_2 + 1); break;
554
+    case 2: set_ddram_address(DDRAM_LINE_3 + 1); break;
562 555
     case 3: set_ddram_address(DDRAM_LINE_3 + 1); break;
563
-    case 4: set_ddram_address(DDRAM_LINE_3 + 1); break;
564 556
   }
565 557
   begin_data();
566 558
   write_number(temp);
@@ -572,27 +564,27 @@ void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, con
572 564
 
573 565
   if (targetStateChange) {
574 566
     if (!showTarget) write_str(F("    "));
575
-    draw_degree_symbol(6,  line, !showTarget);
576
-    draw_degree_symbol(10, line, showTarget);
567
+    draw_degree_symbol(5, line, !showTarget);
568
+    draw_degree_symbol(9, line,  showTarget);
577 569
   }
578 570
 }
579 571
 
580 572
 void ST7920_Lite_Status_Screen::draw_extruder_1_temp(const int16_t temp, const int16_t target, bool forceUpdate) {
581 573
   const bool show_target = target && FAR(temp, target);
582
-  draw_temps(1, temp, target, show_target, display_state.E1_show_target != show_target || forceUpdate);
574
+  draw_temps(0, temp, target, show_target, display_state.E1_show_target != show_target || forceUpdate);
583 575
   display_state.E1_show_target = show_target;
584 576
 }
585 577
 
586 578
 void ST7920_Lite_Status_Screen::draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate) {
587 579
   const bool show_target = target && FAR(temp, target);
588
-  draw_temps(2, temp, target, show_target, display_state.E2_show_target != show_target || forceUpdate);
580
+  draw_temps(1, temp, target, show_target, display_state.E2_show_target != show_target || forceUpdate);
589 581
   display_state.E2_show_target = show_target;
590 582
 }
591 583
 
592 584
 #if HAS_HEATED_BED
593 585
   void ST7920_Lite_Status_Screen::draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate) {
594 586
     const bool show_target = target && FAR(temp, target);
595
-    draw_temps(2
587
+    draw_temps(1
596 588
       #if HOTENDS > 1
597 589
         + 1
598 590
       #endif
@@ -632,44 +624,38 @@ void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint16_t percenta
632 624
   #endif
633 625
 }
634 626
 
635
-void ST7920_Lite_Status_Screen::draw_status_message(const char *str) {
627
+void ST7920_Lite_Status_Screen::draw_status_message() {
628
+  const char *str = ui.status_message;
629
+
636 630
   set_ddram_address(DDRAM_LINE_4);
637 631
   begin_data();
638
-  const uint8_t lcd_len = 16;
639 632
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
640 633
 
641 634
     uint8_t slen = utf8_strlen(str);
642 635
 
643
-    // If the string fits into the LCD, just print it and do not scroll it
644
-    if (slen <= lcd_len) {
645
-
646
-      // The string isn't scrolling and may not fill the screen
636
+    if (slen <= LCD_WIDTH) {
637
+      // String fits the LCD, so just print it
647 638
       write_str(str);
648
-
649
-      // Fill the rest with spaces
650
-      while (slen < lcd_len) {
651
-        write_byte(' ');
652
-        ++slen;
653
-      }
639
+      for (; slen < LCD_WIDTH; ++slen) write_byte(' ');
654 640
     }
655 641
     else {
656 642
       // String is larger than the available space in screen.
657 643
 
658 644
       // Get a pointer to the next valid UTF8 character
659
-      const char *stat = str + status_scroll_offset;
645
+      const char *stat = str + ui.status_scroll_offset;
660 646
 
661 647
       // Get the string remaining length
662 648
       const uint8_t rlen = utf8_strlen(stat);
663 649
 
664 650
       // If we have enough characters to display
665
-      if (rlen >= lcd_len) {
651
+      if (rlen >= LCD_WIDTH) {
666 652
         // The remaining string fills the screen - Print it
667
-        write_str(stat, lcd_len);
653
+        write_str(stat, LCD_WIDTH);
668 654
       }
669 655
       else {
670 656
         // The remaining string does not completely fill the screen
671 657
         write_str(stat);                        // The string leaves space
672
-        uint8_t chars = lcd_len - rlen;         // Amount of space left in characters
658
+        uint8_t chars = LCD_WIDTH - rlen;         // Amount of space left in characters
673 659
 
674 660
         write_byte('.');                        // Always at 1+ spaces left, draw a dot
675 661
         if (--chars) {                          // Draw a second dot if there's space
@@ -680,26 +666,21 @@ void ST7920_Lite_Status_Screen::draw_status_message(const char *str) {
680 666
       }
681 667
 
682 668
       // Adjust by complete UTF8 characters
683
-      if (status_scroll_offset < slen) {
684
-        status_scroll_offset++;
685
-        while (!START_OF_UTF8_CHAR(str[status_scroll_offset]))
686
-          status_scroll_offset++;
669
+      if (ui.status_scroll_offset < slen) {
670
+        ui.status_scroll_offset++;
671
+        while (!START_OF_UTF8_CHAR(str[ui.status_scroll_offset]))
672
+          ui.status_scroll_offset++;
687 673
       }
688 674
       else
689
-        status_scroll_offset = 0;
675
+        ui.status_scroll_offset = 0;
690 676
     }
677
+
691 678
   #else
692
-    // Get the UTF8 character count of the string
693
-    uint8_t slen = utf8_strlen(str);
694 679
 
695
-    // Just print the string to the LCD
696
-    write_str(str, lcd_len);
680
+    uint8_t slen = utf8_strlen(str);
681
+    write_str(str, LCD_WIDTH);
682
+    for (; slen < LCD_WIDTH; ++slen) write_byte(' ');
697 683
 
698
-    // Fill the rest with spaces if there are missing spaces
699
-    while (slen < lcd_len) {
700
-      write_byte(' ');
701
-      ++slen;
702
-    }
703 684
   #endif
704 685
 }
705 686
 
@@ -709,7 +690,7 @@ void ST7920_Lite_Status_Screen::draw_position(const float x, const float y, cons
709 690
   begin_data();
710 691
 
711 692
   // If position is unknown, flash the labels.
712
-  const unsigned char alt_label = position_known ? 0 : (lcd_blink() ? ' ' : 0);
693
+  const unsigned char alt_label = position_known ? 0 : (ui.get_blink() ? ' ' : 0);
713 694
 
714 695
   dtostrf(x, -4, 0, str);
715 696
   write_byte(alt_label ? alt_label : 'X');
@@ -728,7 +709,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
728 709
   // We only add the target temperatures to the checksum
729 710
   // because the actual temps fluctuate so by updating
730 711
   // them only during blinks we gain a bit of stability.
731
-  const bool       blink             = lcd_blink();
712
+  const bool       blink             = ui.get_blink();
732 713
   const uint16_t   feedrate_perc     = feedrate_percentage;
733 714
   const uint8_t    fs                = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
734 715
   const int16_t    extruder_1_target = thermalManager.degTargetHotend(0);
@@ -754,7 +735,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
754 735
 
755 736
 void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
756 737
   if (forceUpdate || indicators_changed()) {
757
-    const bool       blink             = lcd_blink();
738
+    const bool       blink             = ui.get_blink();
758 739
     const duration_t elapsed           = print_job_timer.duration();
759 740
     const uint16_t   feedrate_perc     = feedrate_percentage;
760 741
     const uint8_t    fs                = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
@@ -783,41 +764,32 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
783 764
     // Update the fan and bed animations
784 765
     if (fs) draw_fan_icon(blink);
785 766
     #if HAS_HEATED_BED
786
-      if (bed_target > 0)
787
-        draw_heat_icon(blink, true);
788
-      else
789
-        draw_heat_icon(false, false);
767
+      draw_heat_icon(bed_target > 0 && blink, bed_target > 0);
790 768
     #endif
791 769
   }
792 770
 }
793 771
 
794 772
 bool ST7920_Lite_Status_Screen::position_changed() {
795
-  const float x_pos = current_position[X_AXIS],
796
-              y_pos = current_position[Y_AXIS],
797
-              z_pos = current_position[Z_AXIS];
773
+  const float x_pos = current_position[X_AXIS], y_pos = current_position[Y_AXIS], z_pos = current_position[Z_AXIS];
798 774
   const uint8_t checksum = uint8_t(x_pos) ^ uint8_t(y_pos) ^ uint8_t(z_pos);
799
-
800
-  static uint8_t last_checksum = 0;
801
-  if (last_checksum == checksum) return false;
802
-  last_checksum = checksum;
803
-  return true;
775
+  static uint8_t last_checksum = 0, changed = last_checksum != checksum;
776
+  if (changed) last_checksum = checksum;
777
+  return changed;
804 778
 }
805 779
 
806 780
 bool ST7920_Lite_Status_Screen::status_changed() {
807 781
   uint8_t checksum = 0;
808
-  for (const char *p = lcd_status_message; *p; p++) checksum ^= *p;
809
-  static uint8_t last_checksum = 0;
810
-  if (last_checksum == checksum) return false;
811
-  last_checksum = checksum;
812
-  return true;
782
+  for (const char *p = ui.status_message; *p; p++) checksum ^= *p;
783
+  static uint8_t last_checksum = 0, changed = last_checksum != checksum;
784
+  if (changed) last_checksum = checksum;
785
+  return changed;
813 786
 }
814 787
 
815 788
 bool ST7920_Lite_Status_Screen::blink_changed() {
816 789
   static uint8_t last_blink = 0;
817
-  const bool blink = lcd_blink();
818
-  if (last_blink == blink) return false;
819
-  last_blink = blink;
820
-  return true;
790
+  const bool blink = ui.get_blink(), changed = last_blink != blink;
791
+  if (changed) last_blink = blink;
792
+  return changed;
821 793
 }
822 794
 
823 795
 #ifndef STATUS_EXPIRE_SECONDS
@@ -831,60 +803,56 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
831 803
   #endif
832 804
 
833 805
   /**
834
-   * There is only enough room in the display for either the
835
-   * status message or the position, not both, so we choose
836
-   * one or another. Whenever the status message changes,
837
-   * we show it for a number of consecutive seconds, but
838
-   * then go back to showing the position as soon as the
839
-   * head moves, i.e:
806
+   * There's only enough room for either the status message or the position,
807
+   * so draw one or the other. When the status message changes, show it for
808
+   * a few seconds, then return to the position display once the head moves.
840 809
    *
841
-   *    countdown > 1    -- Show status
842
-   *    countdown = 1    -- Show status, until movement
843
-   *    countdown = 0    -- Show position
810
+   *  countdown > 1  -- Show status
811
+   *  countdown = 1  -- Show status, until movement
812
+   *  countdown = 0  -- Show position
844 813
    *
845
-   * If STATUS_EXPIRE_SECONDS is zero, the position display
846
-   * will be disabled and only the status will be shown.
814
+   * If STATUS_EXPIRE_SECONDS is zero, only the status is shown.
847 815
    */
848 816
   if (forceUpdate || status_changed()) {
849 817
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
850
-      status_scroll_offset = 0;
818
+      ui.status_scroll_offset = 0;
851 819
     #endif
852 820
     #if STATUS_EXPIRE_SECONDS
853
-      countdown = lcd_status_message[0] ? STATUS_EXPIRE_SECONDS : 0;
821
+      countdown = ui.status_message[0] ? STATUS_EXPIRE_SECONDS : 0;
854 822
     #endif
855
-    draw_status_message(lcd_status_message);
823
+    draw_status_message();
856 824
     blink_changed(); // Clear changed flag
857 825
   }
858 826
   #if !STATUS_EXPIRE_SECONDS
859 827
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
860 828
       else
861
-        draw_status_message(lcd_status_message);
829
+        draw_status_message();
862 830
     #endif
863 831
   #else
864
-    else if (countdown > 1 && blink_changed()) {
865
-      countdown--;
866
-      #if ENABLED(STATUS_MESSAGE_SCROLLING)
867
-        draw_status_message(lcd_status_message);
868
-      #endif
869
-    }
870
-    else if (countdown > 0 && blink_changed()) {
871
-      if (position_changed()) {
832
+    else if (blink_changed()) {
833
+      if (countdown > 1) {
872 834
         countdown--;
873
-        forceUpdate = true;
835
+        #if ENABLED(STATUS_MESSAGE_SCROLLING)
836
+          draw_status_message();
837
+        #endif
838
+      }
839
+      else if (countdown > 0) {
840
+        if (position_changed()) {
841
+          countdown--;
842
+          forceUpdate = true;
843
+        }
844
+        #if ENABLED(STATUS_MESSAGE_SCROLLING)
845
+          draw_status_message();
846
+        #endif
874 847
       }
875
-      #if ENABLED(STATUS_MESSAGE_SCROLLING)
876
-        draw_status_message(lcd_status_message);
877
-      #endif
878 848
     }
849
+
879 850
     if (countdown == 0 && (forceUpdate || position_changed() ||
880 851
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
881 852
         blink_changed()
882 853
       #endif
883 854
     )) {
884
-      draw_position(
885
-        current_position[X_AXIS],
886
-        current_position[Y_AXIS],
887
-        current_position[Z_AXIS],
855
+      draw_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
888 856
         #if ENABLED(DISABLE_REDUCED_ACCURACY_WARNING)
889 857
           true
890 858
         #else
@@ -898,24 +866,16 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
898 866
 void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) {
899 867
   #if ENABLED(LCD_SET_PROGRESS_MANUALLY) || ENABLED(SDSUPPORT)
900 868
 
901
-    #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
902
-      uint8_t progress_bar_percent = 0;
903
-    #endif
904
-
905
-    #if ENABLED(SDSUPPORT)
906
-      // Progress bar % comes from SD when actively printing
907
-      if (IS_SD_PRINTING()) progress_bar_percent = card.percentDone();
908
-    #endif
909
-
910 869
     // Since the progress bar involves writing
911 870
     // quite a few bytes to GDRAM, only do this
912 871
     // when an update is actually necessary.
913 872
 
914 873
     static uint8_t last_progress = 0;
915
-    if (!forceUpdate && last_progress == progress_bar_percent) return;
916
-    last_progress = progress_bar_percent;
917
-
918
-    draw_progress_bar(progress_bar_percent);
874
+    const uint8_t progress = ui.get_progress();
875
+    if (forceUpdate || last_progress != progress) {
876
+      last_progress = progress;
877
+      draw_progress_bar(progress);
878
+    }
919 879
 
920 880
   #else
921 881
 
@@ -966,7 +926,7 @@ void ST7920_Lite_Status_Screen::clear_text_buffer() {
966 926
   ncs();
967 927
 }
968 928
 
969
-void lcd_impl_status_screen_0() {
929
+void MarlinUI::draw_status_screen() {
970 930
   ST7920_Lite_Status_Screen::update(false);
971 931
 }
972 932
 

+ 2
- 2
Marlin/src/lcd/dogm/status_screen_lite_ST7920_class.h Ver arquivo

@@ -74,7 +74,7 @@ class ST7920_Lite_Status_Screen {
74 74
     static uint8_t string_checksum(const char *str);
75 75
 
76 76
   protected:
77
-    static void draw_degree_symbol(uint8_t x, uint8_t y, bool draw);
77
+    static void draw_degree_symbol(uint8_t x, uint8_t y, const bool draw);
78 78
     static void draw_static_elements();
79 79
     static void draw_progress_bar(const uint8_t value);
80 80
     static void draw_fan_icon(const bool whichIcon);
@@ -86,7 +86,7 @@ class ST7920_Lite_Status_Screen {
86 86
     static void draw_fan_speed(const uint8_t value);
87 87
     static void draw_print_time(const duration_t &elapsed);
88 88
     static void draw_feedrate_percentage(const uint16_t percentage);
89
-    static void draw_status_message(const char *str);
89
+    static void draw_status_message();
90 90
     static void draw_position(const float x, const float y, const float z, bool position_known = true);
91 91
 
92 92
     static bool indicators_changed();

+ 28
- 29
Marlin/src/lcd/dogm/ultralcd_impl_DOGM.cpp Ver arquivo

@@ -75,16 +75,16 @@ U8GLIB *pu8g = &u8g;
75 75
 
76 76
 #if HAS_LCD_CONTRAST
77 77
 
78
-  int16_t lcd_contrast; // Initialized by settings.load()
78
+  int16_t MarlinUI::contrast; // Initialized by settings.load()
79 79
 
80
-  void set_lcd_contrast(const int16_t value) {
81
-    lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
82
-    u8g.setContrast(lcd_contrast);
80
+  void MarlinUI::set_contrast(const int16_t value) {
81
+    contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
82
+    u8g.setContrast(contrast);
83 83
   }
84 84
 
85 85
 #endif
86 86
 
87
-void lcd_setFont(const MarlinFont font_nr) {
87
+void MarlinUI::set_font(const MarlinFont font_nr) {
88 88
   static char currentfont = 0;
89 89
   if (font_nr != currentfont) {
90 90
     switch ((currentfont = font_nr)) {
@@ -141,7 +141,7 @@ void lcd_setFont(const MarlinFont font_nr) {
141 141
 
142 142
   #endif // SHOW_CUSTOM_BOOTSCREEN
143 143
 
144
-  void lcd_bootscreen() {
144
+  void MarlinUI::show_bootscreen() {
145 145
     #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
146 146
       lcd_custom_bootscreen();
147 147
     #endif
@@ -160,7 +160,7 @@ void lcd_setFont(const MarlinFont font_nr) {
160 160
     u8g.firstPage();
161 161
     do {
162 162
       u8g.drawBitmapP(offx, offy, (START_BMPWIDTH + 7) / 8, START_BMPHEIGHT, start_bmp);
163
-      lcd_setFont(FONT_MENU);
163
+      ui.set_font(FONT_MENU);
164 164
       #ifndef STRING_SPLASH_LINE2
165 165
         const uint8_t txt1X = width - (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH);
166 166
         u8g.drawStr(txt1X, (height + MENU_FONT_HEIGHT) / 2, STRING_SPLASH_LINE1);
@@ -181,7 +181,7 @@ void lcd_setFont(const MarlinFont font_nr) {
181 181
 #endif
182 182
 
183 183
 // Initialize or re-initialize the LCD
184
-void lcd_implementation_init() {
184
+void MarlinUI::init_lcd() {
185 185
 
186 186
   #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
187 187
     OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
@@ -206,7 +206,7 @@ void lcd_implementation_init() {
206 206
   #endif
207 207
 
208 208
   #if HAS_LCD_CONTRAST
209
-    set_lcd_contrast(lcd_contrast);
209
+    refresh_contrast();
210 210
   #endif
211 211
 
212 212
   #if ENABLED(LCD_SCREEN_ROT_90)
@@ -221,16 +221,16 @@ void lcd_implementation_init() {
221 221
 }
222 222
 
223 223
 // The kill screen is displayed for unrecoverable conditions
224
-void lcd_kill_screen() {
224
+void MarlinUI::draw_kill_screen() {
225 225
   #if ENABLED(LIGHTWEIGHT_UI)
226 226
     ST7920_Lite_Status_Screen::clear_text_buffer();
227 227
   #endif
228 228
   const uint8_t h4 = u8g.getHeight() / 4;
229 229
   u8g.firstPage();
230 230
   do {
231
-    lcd_setFont(FONT_MENU);
231
+    set_font(FONT_MENU);
232 232
     lcd_moveto(0, h4 * 1);
233
-    lcd_put_u8str(lcd_status_message);
233
+    lcd_put_u8str(status_message);
234 234
     lcd_moveto(0, h4 * 2);
235 235
     lcd_put_u8str_P(PSTR(MSG_HALTED));
236 236
     lcd_moveto(0, h4 * 3);
@@ -238,7 +238,7 @@ void lcd_kill_screen() {
238 238
   } while (u8g.nextPage());
239 239
 }
240 240
 
241
-void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
241
+void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
242 242
 
243 243
 #if HAS_LCD_MENU
244 244
 
@@ -246,7 +246,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
246 246
 
247 247
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
248 248
 
249
-    void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
249
+    void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
250 250
       row_y1 = row * (MENU_FONT_HEIGHT) + 1;
251 251
       row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
252 252
 
@@ -259,7 +259,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
259 259
       lcd_put_u8str(itostr3(thermalManager.degHotend(extruder)));
260 260
       lcd_put_wchar('/');
261 261
 
262
-      if (lcd_blink() || !thermalManager.is_heater_idle(extruder))
262
+      if (get_blink() || !thermalManager.is_heater_idle(extruder))
263 263
         lcd_put_u8str(itostr3(thermalManager.degTargetHotend(extruder)));
264 264
     }
265 265
 
@@ -295,7 +295,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
295 295
   }
296 296
 
297 297
   // Draw a static line of text in the same idiom as a menu item
298
-  void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char* valstr/*=NULL*/) {
298
+  void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char* valstr/*=NULL*/) {
299 299
 
300 300
     if (mark_as_selected(row, invert)) {
301 301
 
@@ -315,7 +315,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
315 315
   }
316 316
 
317 317
   // Draw a generic menu item
318
-  void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
318
+  void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) {
319 319
     UNUSED(pre_char);
320 320
 
321 321
     if (mark_as_selected(row, isSelected)) {
@@ -330,7 +330,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
330 330
   }
331 331
 
332 332
   // Draw a menu item with an editable value
333
-  void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
333
+  void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) {
334 334
     if (mark_as_selected(row, isSelected)) {
335 335
       const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
336 336
       uint8_t n = LCD_WIDTH - 2 - vallen;
@@ -343,7 +343,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
343 343
     }
344 344
   }
345 345
 
346
-  void lcd_implementation_drawedit(PGM_P const pstr, const char* const value/*=NULL*/) {
346
+  void draw_edit_screen(PGM_P const pstr, const char* const value/*=NULL*/) {
347 347
     const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
348 348
 
349 349
     bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
@@ -356,12 +356,12 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
356 356
         if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
357 357
         lcd_chr_fit = lcd_edit_width + 1;
358 358
         one_chr_width = EDIT_FONT_WIDTH;
359
-        lcd_setFont(FONT_EDIT);
359
+        ui.set_font(FONT_EDIT);
360 360
       }
361 361
       else {
362 362
         lcd_chr_fit = LCD_WIDTH;
363 363
         one_chr_width = MENU_FONT_WIDTH;
364
-        lcd_setFont(FONT_MENU);
364
+        ui.set_font(FONT_MENU);
365 365
       }
366 366
     #else
367 367
       constexpr uint8_t lcd_chr_fit = LCD_WIDTH,
@@ -397,7 +397,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
397 397
 
398 398
   #if ENABLED(SDSUPPORT)
399 399
 
400
-    void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
400
+    void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
401 401
       UNUSED(pstr);
402 402
 
403 403
       mark_as_selected(row, isSelected);
@@ -415,11 +415,11 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
415 415
               name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ theCard.filename[l];  // rotate, xor
416 416
             if (filename_scroll_hash != name_hash) {                            // If the hash changed...
417 417
               filename_scroll_hash = name_hash;                                 // Save the new hash
418
-              filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit
419
-              filename_scroll_pos = 0;                                          // Reset scroll to the start
420
-              lcd_status_update_delay = 8;                                      // Don't scroll right away
418
+              ui.filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit
419
+              ui.filename_scroll_pos = 0;                                       // Reset scroll to the start
420
+              ui.lcd_status_update_delay = 8;                                   // Don't scroll right away
421 421
             }
422
-            outstr += filename_scroll_pos;
422
+            outstr += ui.filename_scroll_pos;
423 423
           }
424 424
         #else
425 425
           theCard.longFilename[maxlen] = '\0'; // cutoff at screen edge
@@ -428,8 +428,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
428 428
 
429 429
       if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
430 430
 
431
-      int n;
432
-      n = lcd_put_u8str_max(outstr, maxlen * (MENU_FONT_WIDTH));
431
+      uint8_t n = lcd_put_u8str_max(outstr, maxlen * (MENU_FONT_WIDTH));
433 432
       n = maxlen * (MENU_FONT_WIDTH) - n;
434 433
       while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
435 434
     }
@@ -446,7 +445,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
446 445
     #define MAP_MAX_PIXELS_X        53
447 446
     #define MAP_MAX_PIXELS_Y        49
448 447
 
449
-    void lcd_implementation_ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
448
+    void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
450 449
       // Scale the box pixels appropriately
451 450
       uint8_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X),
452 451
               y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y),

+ 14
- 14
Marlin/src/lcd/extensible_ui/ui_api.cpp Ver arquivo

@@ -681,14 +681,14 @@ namespace UI {
681 681
 
682 682
 // At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future
683 683
 
684
-void lcd_init() {
684
+void MarlinUI::init() {
685 685
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
686 686
     SET_INPUT_PULLUP(SD_DETECT_PIN);
687 687
   #endif
688 688
   UI::onStartup();
689 689
 }
690 690
 
691
-void lcd_update() {
691
+void MarlinUI::update() {
692 692
   #if ENABLED(SDSUPPORT)
693 693
     static bool last_sd_status;
694 694
     const bool sd_status = IS_SD_INSERTED();
@@ -712,15 +712,15 @@ void lcd_update() {
712 712
   UI::onIdle();
713 713
 }
714 714
 
715
-bool lcd_hasstatus() { return true; }
716
-bool lcd_detected() { return true; }
717
-void lcd_reset_alert_level() { }
718
-void lcd_refresh() { }
719
-void lcd_setstatus(const char * const message, const bool persist /* = false */) { UI::onStatusChanged(message); }
720
-void lcd_setstatusPGM(const char * const message, int8_t level /* = 0 */)        { UI::onStatusChanged((progmem_str)message); }
721
-void lcd_setalertstatusPGM(const char * const message)                           { lcd_setstatusPGM(message, 0); }
715
+bool MarlinUI::hasstatus() { return true; }
716
+bool MarlinUI::detected() { return true; }
717
+void MarlinUI::reset_alert_level() { }
718
+void MarlinUI::refresh() { }
719
+void MarlinUI::setstatus(const char * const message, const bool persist /* = false */) { UI::onStatusChanged(message); }
720
+void MarlinUI::setstatusPGM(const char * const message, int8_t level /* = 0 */)        { UI::onStatusChanged((progmem_str)message); }
721
+void MarlinUI::setalertstatusPGM(const char * const message)                    { setstatusPGM(message, 0); }
722 722
 
723
-void lcd_reset_status() {
723
+void MarlinUI::reset_status() {
724 724
   static const char paused[] PROGMEM = MSG_PRINT_PAUSED;
725 725
   static const char printing[] PROGMEM = MSG_PRINTING;
726 726
   static const char welcome[] PROGMEM = WELCOME_MSG;
@@ -729,17 +729,17 @@ void lcd_reset_status() {
729 729
     msg = paused;
730 730
   #if ENABLED(SDSUPPORT)
731 731
     else if (IS_SD_PRINTING())
732
-      return lcd_setstatus(card.longest_filename(), true);
732
+      return setstatus(card.longest_filename(), true);
733 733
   #endif
734 734
   else if (print_job_timer.isRunning())
735 735
     msg = printing;
736 736
   else
737 737
     msg = welcome;
738 738
 
739
-  lcd_setstatusPGM(msg, -1);
739
+  setstatusPGM(msg, -1);
740 740
 }
741 741
 
742
-void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) {
742
+void MarlinUI::status_printf_P(const uint8_t level, const char * const fmt, ...) {
743 743
   char buff[64];
744 744
   va_list args;
745 745
   va_start(args, fmt);
@@ -749,7 +749,7 @@ void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) {
749 749
   UI::onStatusChanged(buff);
750 750
 }
751 751
 
752
-void kill_screen(PGM_P msg) {
752
+void MarlinUI::kill_screen(PGM_P const msg) {
753 753
   if (!flags.printer_killed) {
754 754
     flags.printer_killed = true;
755 755
     UI::onPrinterKilled(msg);

+ 1
- 1
Marlin/src/lcd/language/language_es.h Ver arquivo

@@ -204,7 +204,7 @@
204 204
 #define MSG_INFO_PROTOCOL                   _UxGT("Protocolo")
205 205
 #define MSG_CASE_LIGHT                      _UxGT("Luz cabina")
206 206
 
207
-#if LCD_WIDTH > 19
207
+#if LCD_WIDTH >= 20
208 208
   #define MSG_INFO_PRINT_COUNT              _UxGT("Conteo de impresión")
209 209
   #define MSG_INFO_COMPLETED_PRINTS         _UxGT("Completadas")
210 210
   #define MSG_INFO_PRINT_TIME               _UxGT("Tiempo total de imp.")

+ 1
- 1
Marlin/src/lcd/language/language_zh_CN.h Ver arquivo

@@ -324,7 +324,7 @@
324 324
 #define MSG_CASE_LIGHT                      _UxGT("外壳灯") // "Case light"
325 325
 #define MSG_CASE_LIGHT_BRIGHTNESS           _UxGT("灯亮度") // "Light BRIGHTNESS"
326 326
 
327
-#if LCD_WIDTH > 19
327
+#if LCD_WIDTH >= 20
328 328
   #define MSG_INFO_PRINT_COUNT              _UxGT("打印计数")  //"Print Count"
329 329
   #define MSG_INFO_COMPLETED_PRINTS         _UxGT("完成了")  //"Completed"
330 330
   #define MSG_INFO_PRINT_TIME               _UxGT("总打印时间")  //"Total print time"

+ 1
- 1
Marlin/src/lcd/language/language_zh_TW.h Ver arquivo

@@ -324,7 +324,7 @@
324 324
 #define MSG_CASE_LIGHT                      _UxGT("外殼燈") // "Case light"
325 325
 #define MSG_CASE_LIGHT_BRIGHTNESS           _UxGT("燈亮度") // "Light BRIGHTNESS"
326 326
 
327
-#if LCD_WIDTH > 19
327
+#if LCD_WIDTH >= 20
328 328
   #define MSG_INFO_PRINT_COUNT              _UxGT("列印計數")  //"Print Count"
329 329
   #define MSG_INFO_COMPLETED_PRINTS         _UxGT("已完成")  //"Completed"
330 330
   #define MSG_INFO_PRINT_TIME               _UxGT("總列印時間")  //"Total print time"

+ 3
- 3
Marlin/src/lcd/malyanlcd.cpp Ver arquivo

@@ -417,7 +417,7 @@ void update_usb_status(const bool forceUpdate) {
417 417
  * The optimize attribute fixes a register Compile
418 418
  * error for amtel.
419 419
  */
420
-void lcd_update() {
420
+void MarlinUI::update() {
421 421
   static char inbound_buffer[MAX_CURLY_COMMAND];
422 422
 
423 423
   // First report USB status.
@@ -461,7 +461,7 @@ void lcd_update() {
461 461
  * it and translate into gcode, which then gets injected into
462 462
  * the command queue where possible.
463 463
  */
464
-void lcd_init() {
464
+void MarlinUI::init() {
465 465
   inbound_count = 0;
466 466
   LCD_SERIAL.begin(500000);
467 467
 
@@ -479,7 +479,7 @@ void lcd_init() {
479 479
 /**
480 480
  * Set an alert.
481 481
  */
482
-void lcd_setalertstatusPGM(PGM_P message) {
482
+void MarlinUI::setalertstatusPGM(PGM_P message) {
483 483
   char message_buffer[MAX_CURLY_COMMAND];
484 484
   sprintf_P(message_buffer, PSTR("{E:%s}"), message);
485 485
   write_to_lcd(message_buffer);

+ 60
- 71
Marlin/src/lcd/menu/menu.cpp Ver arquivo

@@ -30,6 +30,7 @@
30 30
 #include "../../module/motion.h"
31 31
 #include "../../gcode/queue.h"
32 32
 #include "../../sd/cardreader.h"
33
+#include "../../libs/buzzer.h"
33 34
 
34 35
 #if ENABLED(EEPROM_SETTINGS)
35 36
   #include "../../module/configuration_store.h"
@@ -61,10 +62,6 @@ menuPosition screen_history[6];
61 62
 uint8_t screen_history_depth = 0;
62 63
 bool screen_changed;
63 64
 
64
-#if LCD_TIMEOUT_TO_STATUS
65
-  bool defer_return_to_status;
66
-#endif
67
-
68 65
 // Value Editing
69 66
 PGM_P editLabel;
70 67
 void *editValue;
@@ -79,9 +76,9 @@ bool no_reentry = false;
79 76
 //////// Menu Navigation & History /////////
80 77
 ////////////////////////////////////////////
81 78
 
82
-void lcd_return_to_status() { lcd_goto_screen(lcd_status_screen); }
79
+void MarlinUI::return_to_status() { goto_screen(status_screen); }
83 80
 
84
-void lcd_save_previous_screen() {
81
+void MarlinUI::save_previous_screen() {
85 82
   if (screen_history_depth < COUNT(screen_history)) {
86 83
     screen_history[screen_history_depth].menu_function = currentScreen;
87 84
     screen_history[screen_history_depth].encoder_position = encoderPosition;
@@ -89,25 +86,18 @@ void lcd_save_previous_screen() {
89 86
   }
90 87
 }
91 88
 
92
-void lcd_goto_previous_menu() {
89
+void MarlinUI::goto_previous_screen() {
93 90
   if (screen_history_depth > 0) {
94 91
     --screen_history_depth;
95
-    lcd_goto_screen(
92
+    goto_screen(
96 93
       screen_history[screen_history_depth].menu_function,
97 94
       screen_history[screen_history_depth].encoder_position
98 95
     );
99 96
   }
100 97
   else
101
-    lcd_return_to_status();
98
+    return_to_status();
102 99
 }
103 100
 
104
-#if LCD_TIMEOUT_TO_STATUS
105
-  void lcd_goto_previous_menu_no_defer() {
106
-    set_defer_return_to_status(false);
107
-    lcd_goto_previous_menu();
108
-  }
109
-#endif
110
-
111 101
 ////////////////////////////////////////////
112 102
 /////////// Common Menu Actions ////////////
113 103
 ////////////////////////////////////////////
@@ -142,34 +132,33 @@ void menu_item_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode)
142 132
  * ...which calls:
143 133
  *       menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
144 134
  */
145
-void menu_item_invariants::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
146
-  ENCODER_DIRECTION_NORMAL();
147
-  if ((int32_t)encoderPosition < 0) encoderPosition = 0;
148
-  if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue;
149
-  if (lcdDrawUpdate)
150
-    lcd_implementation_drawedit(editLabel, strfunc(encoderPosition + minEditValue));
151
-  if (lcd_clicked || (liveEdit && lcdDrawUpdate)) {
152
-    if (editValue != NULL) loadfunc(editValue, encoderPosition + minEditValue);
153
-    if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)();
154
-    if (lcd_clicked) lcd_goto_previous_menu();
155
-    lcd_clicked = false;
135
+void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
136
+  ui.encoder_direction_normal();
137
+  if ((int32_t)ui.encoderPosition < 0) ui.encoderPosition = 0;
138
+  if ((int32_t)ui.encoderPosition > maxEditValue) ui.encoderPosition = maxEditValue;
139
+  if (ui.should_draw())
140
+    draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
141
+  if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
142
+    if (editValue != NULL) loadfunc(editValue, ui.encoderPosition + minEditValue);
143
+    if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
144
+    if (ui.use_click()) ui.goto_previous_screen();
156 145
   }
157 146
 }
158 147
 
159
-void menu_item_invariants::init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint32_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le) {
160
-  lcd_save_previous_screen();
161
-  lcd_refresh();
148
+void MenuItemBase::init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint32_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le) {
149
+  ui.save_previous_screen();
150
+  ui.refresh();
162 151
   editLabel = el;
163 152
   editValue = ev;
164 153
   minEditValue = minv;
165 154
   maxEditValue = maxv;
166
-  encoderPosition = ep;
167
-  currentScreen = cs;
155
+  ui.encoderPosition = ep;
156
+  ui.currentScreen = cs;
168 157
   callbackFunc = cb;
169 158
   liveEdit = le;
170 159
 }
171 160
 
172
-#define DEFINE_MENU_EDIT_ITEM(NAME) template class menu_item_template<NAME ## _item_info>;
161
+#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuItem<NAME ## _item_info>;
173 162
 
174 163
 DEFINE_MENU_EDIT_ITEM(int3);
175 164
 DEFINE_MENU_EDIT_ITEM(int4);
@@ -184,7 +173,7 @@ DEFINE_MENU_EDIT_ITEM(float62);
184 173
 DEFINE_MENU_EDIT_ITEM(long5);
185 174
 
186 175
 void menu_item_bool::action_setting_edit(PGM_P pstr, bool *ptr, screenFunc_t callback) {
187
-  UNUSED(pstr); *ptr ^= true; lcd_refresh();
176
+  UNUSED(pstr); *ptr ^= true; ui.refresh();
188 177
   if (callback) (*callback)();
189 178
 }
190 179
 
@@ -202,7 +191,7 @@ bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING(); }
202 191
 /**
203 192
  * General function to go directly to a screen
204 193
  */
205
-void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
194
+void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
206 195
   if (currentScreen != screen) {
207 196
 
208 197
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
@@ -215,10 +204,10 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
215 204
       // Going to menu_main from status screen? Remember first click time.
216 205
       // Going back to status screen within a very short time? Go to Z babystepping.
217 206
       if (screen == menu_main) {
218
-        if (currentScreen == lcd_status_screen)
207
+        if (on_status_screen())
219 208
           doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
220 209
       }
221
-      else if (screen == lcd_status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
210
+      else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
222 211
         if (printer_busy()) {
223 212
           screen =
224 213
             #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
@@ -239,25 +228,25 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
239 228
 
240 229
     currentScreen = screen;
241 230
     encoderPosition = encoder;
242
-    if (screen == lcd_status_screen) {
243
-      set_defer_return_to_status(false);
231
+    if (screen == status_screen) {
232
+      ui.defer_status_screen(false);
244 233
       #if ENABLED(AUTO_BED_LEVELING_UBL)
245 234
         ubl.lcd_map_control = false;
246 235
       #endif
247 236
       screen_history_depth = 0;
248 237
     }
249 238
 
250
-    lcd_implementation_clear();
239
+    clear_lcd();
251 240
 
252 241
     // Re-initialize custom characters that may be re-used
253 242
     #if HAS_CHARACTER_LCD
254 243
       #if ENABLED(AUTO_BED_LEVELING_UBL)
255 244
         if (!ubl.lcd_map_control)
256 245
       #endif
257
-          LCD_SET_CHARSET(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
246
+          LCD_SET_CHARSET(screen == status_screen ? CHARSET_INFO : CHARSET_MENU);
258 247
     #endif
259 248
 
260
-    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
249
+    refresh(LCDVIEW_CALL_REDRAW_NEXT);
261 250
     screen_changed = true;
262 251
     #if HAS_GRAPHICAL_LCD
263 252
       drawing_screen = false;
@@ -276,24 +265,24 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
276 265
 //
277 266
 static PGM_P sync_message;
278 267
 
279
-void _lcd_synchronize() {
280
-  if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
268
+void MarlinUI::_synchronize() {
269
+  if (should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
281 270
   if (no_reentry) return;
282 271
   // Make this the current handler till all moves are done
283 272
   no_reentry = true;
284 273
   const screenFunc_t old_screen = currentScreen;
285
-  lcd_goto_screen(_lcd_synchronize);
274
+  goto_screen(_synchronize);
286 275
   planner.synchronize(); // idle() is called until moves complete
287 276
   no_reentry = false;
288
-  lcd_goto_screen(old_screen);
277
+  goto_screen(old_screen);
289 278
 }
290 279
 
291 280
 // Display the synchronize screen with a custom message
292 281
 // ** This blocks the command queue! **
293
-void lcd_synchronize(PGM_P const msg/*=NULL*/) {
282
+void MarlinUI::synchronize(PGM_P const msg/*=NULL*/) {
294 283
   static const char moving[] PROGMEM = MSG_MOVING;
295 284
   sync_message = msg ? msg : moving;
296
-  _lcd_synchronize();
285
+  _synchronize();
297 286
 }
298 287
 
299 288
 /**
@@ -308,16 +297,16 @@ void lcd_synchronize(PGM_P const msg/*=NULL*/) {
308 297
  */
309 298
 int8_t encoderLine, screen_items;
310 299
 void scroll_screen(const uint8_t limit, const bool is_menu) {
311
-  ENCODER_DIRECTION_MENUS();
300
+  ui.encoder_direction_menus();
312 301
   ENCODER_RATE_MULTIPLY(false);
313
-  if (encoderPosition > 0x8000) encoderPosition = 0;
314
-  if (first_page) {
315
-    encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
302
+  if (ui.encoderPosition > 0x8000) ui.encoderPosition = 0;
303
+  if (ui.first_page) {
304
+    encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
316 305
     screen_changed = false;
317 306
   }
318 307
   if (screen_items > 0 && encoderLine >= screen_items - limit) {
319 308
     encoderLine = MAX(0, screen_items - limit);
320
-    encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
309
+    ui.encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
321 310
   }
322 311
   if (is_menu) {
323 312
     NOMORE(encoderTopLine, encoderLine);
@@ -328,12 +317,12 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
328 317
     encoderTopLine = encoderLine;
329 318
 }
330 319
 
331
-void lcd_completion_feedback(const bool good/*=true*/) {
320
+void MarlinUI::completion_feedback(const bool good/*=true*/) {
332 321
   if (good) {
333
-    lcd_buzz(100, 659);
334
-    lcd_buzz(100, 698);
322
+    BUZZ(100, 659);
323
+    BUZZ(100, 698);
335 324
   }
336
-  else lcd_buzz(20, 440);
325
+  else BUZZ(20, 440);
337 326
 }
338 327
 
339 328
 #if HAS_LINE_TO_Z
@@ -348,17 +337,17 @@ void lcd_completion_feedback(const bool good/*=true*/) {
348 337
 #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
349 338
 
350 339
   void lcd_babystep_zoffset() {
351
-    if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
352
-    set_defer_return_to_status(true);
340
+    if (ui.use_click()) return ui.goto_previous_screen_no_defer();
341
+    ui.defer_status_screen(true);
353 342
     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
354 343
       const bool do_probe = (active_extruder == 0);
355 344
     #else
356 345
       constexpr bool do_probe = true;
357 346
     #endif
358
-    ENCODER_DIRECTION_NORMAL();
359
-    if (encoderPosition) {
360
-      const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
361
-      encoderPosition = 0;
347
+    ui.encoder_direction_normal();
348
+    if (ui.encoderPosition) {
349
+      const int16_t babystep_increment = (int32_t)ui.encoderPosition * (BABYSTEP_MULTIPLICATOR);
350
+      ui.encoderPosition = 0;
362 351
 
363 352
       const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
364 353
                   new_probe_offset = zprobe_zoffset + diff,
@@ -378,16 +367,16 @@ void lcd_completion_feedback(const bool good/*=true*/) {
378 367
           else hotend_offset[Z_AXIS][active_extruder] = new_offs;
379 368
         #endif
380 369
 
381
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
370
+        ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
382 371
       }
383 372
     }
384
-    if (lcdDrawUpdate) {
373
+    if (ui.should_draw()) {
385 374
       #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
386 375
         if (!do_probe)
387
-          lcd_implementation_drawedit(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
376
+          draw_edit_screen(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
388 377
         else
389 378
       #endif
390
-          lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
379
+          draw_edit_screen(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
391 380
 
392 381
       #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
393 382
         if (do_probe) _lcd_zoffset_overlay_gfx(zprobe_zoffset);
@@ -447,14 +436,14 @@ void watch_temp_callback_bed() {
447 436
 #endif
448 437
 
449 438
 #if ENABLED(EEPROM_SETTINGS)
450
-  void lcd_store_settings()   { lcd_completion_feedback(settings.save()); }
451
-  void lcd_load_settings()    { lcd_completion_feedback(settings.load()); }
439
+  void lcd_store_settings()   { ui.completion_feedback(settings.save()); }
440
+  void lcd_load_settings()    { ui.completion_feedback(settings.load()); }
452 441
 #endif
453 442
 
454 443
 void _lcd_draw_homing() {
455 444
   constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
456
-  if (lcdDrawUpdate) lcd_implementation_drawmenu_static(line, PSTR(MSG_LEVEL_BED_HOMING));
457
-  lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
445
+  if (ui.should_draw()) draw_menu_item_static(line, PSTR(MSG_LEVEL_BED_HOMING));
446
+  ui.refresh(LCDVIEW_CALL_NO_REDRAW);
458 447
 }
459 448
 
460 449
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))

+ 55
- 96
Marlin/src/lcd/menu/menu.h Ver arquivo

@@ -31,14 +31,6 @@ constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, H
31 31
 
32 32
 void scroll_screen(const uint8_t limit, const bool is_menu);
33 33
 bool printer_busy();
34
-void lcd_completion_feedback(const bool good=true);
35
-void lcd_save_previous_screen();
36
-void lcd_goto_previous_menu();
37
-#if LCD_TIMEOUT_TO_STATUS
38
-  void lcd_goto_previous_menu_no_defer();
39
-#else
40
-  #define lcd_goto_previous_menu_no_defer() lcd_goto_previous_menu()
41
-#endif
42 34
 
43 35
 ////////////////////////////////////////////
44 36
 ////////// Menu Item Numeric Types /////////
@@ -67,60 +59,46 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f);
67 59
 ///////// Menu Item Draw Functions /////////
68 60
 ////////////////////////////////////////////
69 61
 
62
+void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
63
+void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
64
+void draw_edit_screen(PGM_P const pstr, const char* const value=NULL);
70 65
 #if ENABLED(SDSUPPORT)
71 66
   class CardReader;
72
-#endif
73
-
74
-void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char);
75
-void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
76
-void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL);
77
-#if ENABLED(ADVANCED_PAUSE_FEATURE)
78
-  void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder);
67
+  void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
68
+  inline void draw_menu_item_sdfile(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, false); }
69
+  inline void draw_menu_item_sdfolder(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, true); }
79 70
 #endif
80 71
 #if HAS_GRAPHICAL_LCD
81 72
   void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm);
82
-  #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
83
-  #define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
84
-  #define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
85
-  #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, SRC)
86
-  #define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
87
-  #if ENABLED(SDSUPPORT)
88
-    void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
89
-    #define lcd_implementation_drawmenu_sdfile(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, false)
90
-    #define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, true)
91
-  #endif
73
+  #define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
74
+  #define draw_menu_item_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
75
+  #define draw_menu_item_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
76
+  #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, SRC)
77
+  #define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
92 78
   #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY)
93 79
     void _lcd_zoffset_overlay_gfx(const float zvalue);
94 80
   #endif
95 81
 #else
96
-  #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
97
-  void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
98
-  void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
99
-  #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', SRC)
100
-  #define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
101
-  #if ENABLED(SDSUPPORT)
102
-    void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
103
-    void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
104
-  #endif
105
-#endif
106
-#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
107
-#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
108
-#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
109
-
110
-#if ENABLED(AUTO_BED_LEVELING_UBL)
111
-  void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y);
82
+  #define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
83
+  void draw_menu_item_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
84
+  void draw_menu_item_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
85
+  #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, '>', SRC)
86
+  #define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
112 87
 #endif
88
+#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
89
+#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item_generic(sel, row, pstr, '>', ' ')
90
+#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', ' ')
113 91
 
114 92
 ////////////////////////////////////////////
115 93
 /////// Edit Setting Draw Functions ////////
116 94
 ////////////////////////////////////////////
117 95
 
118 96
 #define _DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(TYPE, NAME, STRFUNC) \
119
-  FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE * const data, ...) { \
97
+  FORCE_INLINE void draw_menu_item_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE * const data, ...) { \
120 98
     UNUSED(pstr2); \
121 99
     DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
122 100
   } \
123
-  FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
101
+  FORCE_INLINE void draw_menu_item_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
124 102
     UNUSED(pstr2); UNUSED(pset); \
125 103
     DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
126 104
   } \
@@ -139,8 +117,8 @@ DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float52sign);
139 117
 DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float62);
140 118
 DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long5);
141 119
 
142
-#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data, ...)           DRAW_BOOL_SETTING(sel, row, pstr, data)
143
-#define lcd_implementation_drawmenu_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
120
+#define draw_menu_item_setting_edit_bool(sel, row, pstr, pstr2, data, ...)           DRAW_BOOL_SETTING(sel, row, pstr, data)
121
+#define draw_menu_item_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
144 122
 
145 123
 ////////////////////////////////////////////
146 124
 /////////////// Menu Actions ///////////////
@@ -148,12 +126,12 @@ DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long5);
148 126
 
149 127
 class menu_item_back {
150 128
   public:
151
-    static inline void action() { lcd_goto_previous_menu(); }
129
+    static inline void action() { ui.goto_previous_screen(); }
152 130
 };
153 131
 
154 132
 class menu_item_submenu {
155 133
   public:
156
-    static inline void action(const screenFunc_t func) { lcd_save_previous_screen(); lcd_goto_screen(func); }
134
+    static inline void action(const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
157 135
 };
158 136
 
159 137
 class menu_item_gcode {
@@ -170,7 +148,7 @@ class menu_item_function {
170 148
 /////////// Menu Editing Actions ///////////
171 149
 ////////////////////////////////////////////
172 150
 
173
-class menu_item_invariants {
151
+class MenuItemBase {
174 152
   protected:
175 153
     typedef char* (*strfunc_t)(const int32_t);
176 154
     typedef void (*loadfunc_t)(void *, const int32_t);
@@ -179,7 +157,7 @@ class menu_item_invariants {
179 157
 };
180 158
 
181 159
 template<typename NAME>
182
-class menu_item_template : menu_item_invariants {
160
+class TMenuItem : MenuItemBase {
183 161
   private:
184 162
     typedef typename NAME::type_t type_t;
185 163
     inline static float unscale(const float value)    {return value * (1.0f / NAME::scale);}
@@ -191,10 +169,10 @@ class menu_item_template : menu_item_invariants {
191 169
       const int32_t minv = scale(minValue);
192 170
       init(pstr, ptr, minv, int32_t(scale(maxValue)) - minv, int32_t(scale(*ptr)) - minv, edit, callback, live);
193 171
     }
194
-    static void edit() {menu_item_invariants::edit(to_string, load);}
172
+    static void edit() { MenuItemBase::edit(to_string, load); }
195 173
 };
196 174
 
197
-#define DECLARE_MENU_EDIT_ITEM(NAME) typedef menu_item_template<NAME ## _item_info> menu_item_ ## NAME;
175
+#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuItem<NAME ## _item_info> menu_item_ ## NAME;
198 176
 
199 177
 DECLARE_MENU_EDIT_ITEM(int3);
200 178
 DECLARE_MENU_EDIT_ITEM(int4);
@@ -210,7 +188,7 @@ DECLARE_MENU_EDIT_ITEM(long5);
210 188
 
211 189
 class menu_item_bool {
212 190
   public:
213
-    static void action_setting_edit(PGM_P pstr, bool* ptr, const screenFunc_t callbackFunc=NULL);
191
+    static void action_setting_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=NULL);
214 192
 };
215 193
 
216 194
 ////////////////////////////////////////////
@@ -256,69 +234,47 @@ class menu_item_bool {
256 234
   screen_items = _thisItemNr; \
257 235
   UNUSED(_skipStatic)
258 236
 
259
-/**
260
- * REVERSE_MENU_DIRECTION
261
- *
262
- * To reverse the menu direction we need a general way to reverse
263
- * the direction of the encoder everywhere. So encoderDirection is
264
- * added to allow the encoder to go the other way.
265
- *
266
- * This behavior is limited to scrolling Menus and SD card listings,
267
- * and is disabled in other contexts.
268
- */
269
-#if ENABLED(REVERSE_MENU_DIRECTION)
270
-  extern int8_t encoderDirection;
271
-  #define ENCODER_DIRECTION_NORMAL() (encoderDirection =  1)
272
-  #define ENCODER_DIRECTION_MENUS()  (encoderDirection = -1)
273
-#else
274
-  #define ENCODER_DIRECTION_NORMAL() NOOP
275
-  #define ENCODER_DIRECTION_MENUS()  NOOP
276
-#endif
277
-
278 237
 #if ENABLED(ENCODER_RATE_MULTIPLIER)
279
-  extern millis_t lastEncoderMovementMillis;
280
-  extern bool encoderRateMultiplierEnabled;
281
-  #define ENCODER_RATE_MULTIPLY(F) (encoderRateMultiplierEnabled = F)
282
-  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) if (USE_MULTIPLIER) { encoderRateMultiplierEnabled = true; lastEncoderMovementMillis = 0; }
238
+  #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
239
+  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
283 240
   //#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
284
-#else // !ENCODER_RATE_MULTIPLIER
241
+#else
285 242
   #define ENCODER_RATE_MULTIPLY(F) NOOP
286 243
   #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
287
-#endif // !ENCODER_RATE_MULTIPLIER
244
+#endif
288 245
 
289 246
 /**
290 247
  * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
291 248
  *
292
- *   lcd_implementation_drawmenu_<type>[_variant](sel, row, label, arg3...)
249
+ *   draw_menu_item_<type>[_variant](sel, row, label, arg3...)
293 250
  *   menu_item_<type>::action[_variant](arg3...)
294 251
  *
295 252
  * Examples:
296 253
  *   MENU_ITEM(back, MSG_WATCH, 0 [dummy parameter] )
297 254
  *   or
298 255
  *   MENU_BACK(MSG_WATCH)
299
- *     lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH))
256
+ *     draw_menu_item_back(sel, row, PSTR(MSG_WATCH))
300 257
  *     menu_item_back::action()
301 258
  *
302 259
  *   MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
303
- *     lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
260
+ *     draw_menu_item_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
304 261
  *     menu_item_function::action(lcd_sdcard_pause)
305 262
  *
306 263
  *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
307
- *     lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
264
+ *     draw_menu_item_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
308 265
  *     menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
309 266
  *
310 267
  */
311 268
 #define _MENU_ITEM_VARIANT_P(TYPE, VARIANT, USE_MULTIPLIER, PLABEL, ...) do { \
312 269
     _skipStatic = false; \
313 270
     if (_menuLineNr == _thisItemNr) { \
314
-      if (encoderLine == _thisItemNr && lcd_clicked) { \
315
-        lcd_clicked = false; \
271
+      if (encoderLine == _thisItemNr && ui.use_click()) { \
316 272
         _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
317 273
         menu_item_ ## TYPE ::action ## VARIANT(__VA_ARGS__); \
318 274
         if (screen_changed) return; \
319 275
       } \
320
-      if (lcdDrawUpdate) \
321
-        lcd_implementation_drawmenu ## VARIANT ## _ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
276
+      if (ui.should_draw()) \
277
+        draw_menu_item ## VARIANT ## _ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
322 278
     } \
323 279
   ++_thisItemNr; \
324 280
 }while(0)
@@ -328,17 +284,17 @@ class menu_item_bool {
328 284
 #define STATIC_ITEM_P(PLABEL, ...) do{ \
329 285
   if (_menuLineNr == _thisItemNr) { \
330 286
     if (_skipStatic && encoderLine <= _thisItemNr) { \
331
-      encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
287
+      ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
332 288
       ++encoderLine; \
333 289
     } \
334
-    if (lcdDrawUpdate) \
335
-      lcd_implementation_drawmenu_static(_lcdLineNr, PLABEL, ## __VA_ARGS__); \
290
+    if (ui.should_draw()) \
291
+      draw_menu_item_static(_lcdLineNr, PLABEL, ## __VA_ARGS__); \
336 292
   } \
337 293
   ++_thisItemNr; \
338 294
 } while(0)
339 295
 
340 296
 #define MENU_ITEM_ADDON_START(X) \
341
-  if (lcdDrawUpdate && _menuLineNr == _thisItemNr - 1) { \
297
+  if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
342 298
     SETCURSOR(X, _lcdLineNr)
343 299
 
344 300
 #define MENU_ITEM_ADDON_END() } (0)
@@ -347,12 +303,12 @@ class menu_item_bool {
347 303
 
348 304
 #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL)
349 305
 #define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
350
-#define MENU_ITEM_P(TYPE, PLABEL, ...)                       _MENU_ITEM_VARIANT_P(TYPE,              , 0, PLABEL,                   ## __VA_ARGS__)
351
-#define MENU_ITEM(TYPE, LABEL, ...)                          _MENU_ITEM_VARIANT_P(TYPE,              , 0, PSTR(LABEL),              ## __VA_ARGS__)
352
-#define MENU_ITEM_EDIT(TYPE, LABEL, ...)                     _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 0, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
353
-#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...)            _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 0, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
354
-#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...)          _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 1, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
355
-#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 1, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
306
+#define MENU_ITEM_P(TYPE, PLABEL, ...)                       _MENU_ITEM_VARIANT_P(TYPE,              , false, PLABEL,                   ## __VA_ARGS__)
307
+#define MENU_ITEM(TYPE, LABEL, ...)                          _MENU_ITEM_VARIANT_P(TYPE,              , false, PSTR(LABEL),              ## __VA_ARGS__)
308
+#define MENU_ITEM_EDIT(TYPE, LABEL, ...)                     _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
309
+#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...)            _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
310
+#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...)          _MENU_ITEM_VARIANT_P(TYPE, _setting_edit,  true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
311
+#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit,  true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
356 312
 
357 313
 ////////////////////////////////////////////
358 314
 /////////////// Menu Screens ///////////////
@@ -379,7 +335,6 @@ void menu_move();
379 335
 ////////////////////////////////////////////
380 336
 
381 337
 void lcd_move_z();
382
-void lcd_synchronize(PGM_P const msg=NULL);
383 338
 void _lcd_draw_homing();
384 339
 
385 340
 void watch_temp_callback_E0();
@@ -426,3 +381,7 @@ void watch_temp_callback_bed();
426 381
   void lcd_store_settings();
427 382
   void lcd_load_settings();
428 383
 #endif
384
+
385
+#if ENABLED(POWER_LOSS_RECOVERY)
386
+  void menu_job_recovery();
387
+#endif

+ 6
- 6
Marlin/src/lcd/menu/menu_advanced.cpp Ver arquivo

@@ -52,7 +52,7 @@
52 52
   //
53 53
   void _lcd_set_home_offsets() {
54 54
     enqueue_and_echo_commands_P(PSTR("M428"));
55
-    lcd_return_to_status();
55
+    ui.return_to_status();
56 56
   }
57 57
 #endif
58 58
 
@@ -65,9 +65,9 @@
65 65
   //
66 66
   static void _lcd_toggle_sd_update() {
67 67
     const bool new_state = !settings.sd_update_status();
68
-    lcd_completion_feedback(settings.set_sd_update_status(new_state));
69
-    lcd_return_to_status();
70
-    if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else lcd_reset_status();
68
+    ui.completion_feedback(settings.set_sd_update_status(new_state));
69
+    ui.return_to_status();
70
+    if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
71 71
   }
72 72
 #endif
73 73
 
@@ -539,8 +539,8 @@ void menu_advanced_temperature() {
539 539
     #include "../../module/configuration_store.h"
540 540
 
541 541
     static void lcd_init_eeprom() {
542
-      lcd_completion_feedback(settings.init_eeprom());
543
-      lcd_goto_previous_menu();
542
+      ui.completion_feedback(settings.init_eeprom());
543
+      ui.goto_previous_screen();
544 544
     }
545 545
 
546 546
     static void lcd_init_eeprom_confirm() {

+ 4
- 4
Marlin/src/lcd/menu/menu_bed_corners.cpp Ver arquivo

@@ -77,7 +77,7 @@ void menu_level_bed_corners() {
77 77
       MSG_NEXT_CORNER
78 78
     #endif
79 79
     , _lcd_goto_next_corner);
80
-  MENU_ITEM(function, MSG_BACK, lcd_goto_previous_menu_no_defer);
80
+  MENU_ITEM(function, MSG_BACK, ui.goto_previous_screen_no_defer);
81 81
   END_MENU();
82 82
 }
83 83
 
@@ -85,18 +85,18 @@ void _lcd_level_bed_corners_homing() {
85 85
   _lcd_draw_homing();
86 86
   if (all_axes_homed()) {
87 87
     bed_corner = 0;
88
-    lcd_goto_screen(menu_level_bed_corners);
88
+    ui.goto_screen(menu_level_bed_corners);
89 89
     _lcd_goto_next_corner();
90 90
   }
91 91
 }
92 92
 
93 93
 void _lcd_level_bed_corners() {
94
-  set_defer_return_to_status(true);
94
+  ui.defer_status_screen(true);
95 95
   if (!all_axes_known()) {
96 96
     set_all_unhomed();
97 97
     enqueue_and_echo_commands_P(PSTR("G28"));
98 98
   }
99
-  lcd_goto_screen(_lcd_level_bed_corners_homing);
99
+  ui.goto_screen(_lcd_level_bed_corners_homing);
100 100
 }
101 101
 
102 102
 #endif // HAS_LCD_MENU && LEVEL_BED_CORNERS

+ 30
- 30
Marlin/src/lcd/menu/menu_bed_leveling.cpp Ver arquivo

@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "../../inc/MarlinConfigPre.h"
28 28
 
29
-#if HAS_LCD_MENU && ENABLED(LCD_BED_LEVELING)
29
+#if ENABLED(LCD_BED_LEVELING)
30 30
 
31 31
 #include "menu.h"
32 32
 #include "../../module/planner.h"
@@ -56,7 +56,7 @@
56 56
     #endif
57 57
   );
58 58
 
59
-  bool lcd_wait_for_move;
59
+  bool MarlinUI::wait_for_bl_move; // = false
60 60
 
61 61
   //
62 62
   // Bed leveling is done. Wait for G29 to complete.
@@ -70,17 +70,17 @@
70 70
   // ** This blocks the command queue! **
71 71
   //
72 72
   void _lcd_level_bed_done() {
73
-    if (!lcd_wait_for_move) {
73
+    if (!ui.wait_for_bl_move) {
74 74
       #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
75 75
         // Display "Done" screen and wait for moves to complete
76 76
         line_to_z(MANUAL_PROBE_HEIGHT);
77
-        lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
77
+        ui.synchronize(PSTR(MSG_LEVEL_BED_DONE));
78 78
       #endif
79
-      lcd_goto_previous_menu_no_defer();
80
-      lcd_completion_feedback();
79
+      ui.goto_previous_screen_no_defer();
80
+      ui.completion_feedback();
81 81
     }
82
-    if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
83
-    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
82
+    if (ui.should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
83
+    ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
84 84
   }
85 85
 
86 86
   void _lcd_level_goto_next_point();
@@ -89,9 +89,9 @@
89 89
   // Step 7: Get the Z coordinate, click goes to the next point or exits
90 90
   //
91 91
   void _lcd_level_bed_get_z() {
92
-    ENCODER_DIRECTION_NORMAL();
92
+    ui.encoder_direction_normal();
93 93
 
94
-    if (use_click()) {
94
+    if (ui.use_click()) {
95 95
 
96 96
       //
97 97
       // Save the current Z position and move
@@ -102,8 +102,8 @@
102 102
         //
103 103
         // The last G29 records the point and enables bed leveling
104 104
         //
105
-        lcd_wait_for_move = true;
106
-        lcd_goto_screen(_lcd_level_bed_done);
105
+        ui.wait_for_bl_move = true;
106
+        ui.goto_screen(_lcd_level_bed_done);
107 107
         #if ENABLED(MESH_BED_LEVELING)
108 108
           enqueue_and_echo_commands_P(PSTR("G29 S2"));
109 109
         #elif ENABLED(PROBE_MANUALLY)
@@ -119,19 +119,19 @@
119 119
     //
120 120
     // Encoder knob or keypad buttons adjust the Z position
121 121
     //
122
-    if (encoderPosition) {
123
-      const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MESH_EDIT_Z_STEP);
122
+    if (ui.encoderPosition) {
123
+      const float z = current_position[Z_AXIS] + float((int32_t)ui.encoderPosition) * (MESH_EDIT_Z_STEP);
124 124
       line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
125
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
126
-      encoderPosition = 0;
125
+      ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
126
+      ui.encoderPosition = 0;
127 127
     }
128 128
 
129 129
     //
130 130
     // Draw on first display, then only on Z change
131 131
     //
132
-    if (lcdDrawUpdate) {
132
+    if (ui.should_draw()) {
133 133
       const float v = current_position[Z_AXIS];
134
-      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
134
+      draw_edit_screen(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
135 135
     }
136 136
   }
137 137
 
@@ -139,23 +139,23 @@
139 139
   // Step 6: Display "Next point: 1 / 9" while waiting for move to finish
140 140
   //
141 141
   void _lcd_level_bed_moving() {
142
-    if (lcdDrawUpdate) {
142
+    if (ui.should_draw()) {
143 143
       char msg[10];
144 144
       sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
145
-      lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
145
+      draw_edit_screen(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
146 146
     }
147
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
148
-    if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
147
+    ui.refresh(LCDVIEW_CALL_NO_REDRAW);
148
+    if (!ui.wait_for_bl_move) ui.goto_screen(_lcd_level_bed_get_z);
149 149
   }
150 150
 
151 151
   //
152 152
   // Step 5: Initiate a move to the next point
153 153
   //
154 154
   void _lcd_level_goto_next_point() {
155
-    lcd_goto_screen(_lcd_level_bed_moving);
155
+    ui.goto_screen(_lcd_level_bed_moving);
156 156
 
157 157
     // G29 Records Z, moves, and signals when it pauses
158
-    lcd_wait_for_move = true;
158
+    ui.wait_for_bl_move = true;
159 159
     #if ENABLED(MESH_BED_LEVELING)
160 160
       enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
161 161
     #elif ENABLED(PROBE_MANUALLY)
@@ -168,8 +168,8 @@
168 168
   //         Move to the first probe position
169 169
   //
170 170
   void _lcd_level_bed_homing_done() {
171
-    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
172
-    if (use_click()) {
171
+    if (ui.should_draw()) draw_edit_screen(PSTR(MSG_LEVEL_BED_WAITING));
172
+    if (ui.use_click()) {
173 173
       manual_probe_index = 0;
174 174
       _lcd_level_goto_next_point();
175 175
     }
@@ -180,7 +180,7 @@
180 180
   //
181 181
   void _lcd_level_bed_homing() {
182 182
     _lcd_draw_homing();
183
-    if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done);
183
+    if (all_axes_homed()) ui.goto_screen(_lcd_level_bed_homing_done);
184 184
   }
185 185
 
186 186
   #if ENABLED(PROBE_MANUALLY)
@@ -191,9 +191,9 @@
191 191
   // Step 2: Continue Bed Leveling...
192 192
   //
193 193
   void _lcd_level_bed_continue() {
194
-    set_defer_return_to_status(true);
194
+    ui.defer_status_screen(true);
195 195
     set_all_unhomed();
196
-    lcd_goto_screen(_lcd_level_bed_homing);
196
+    ui.goto_screen(_lcd_level_bed_homing);
197 197
     enqueue_and_echo_commands_P(PSTR("G28"));
198 198
   }
199 199
 
@@ -292,4 +292,4 @@ void menu_bed_leveling() {
292 292
   END_MENU();
293 293
 }
294 294
 
295
-#endif // HAS_LCD_MENU && LCD_BED_LEVELING
295
+#endif // LCD_BED_LEVELING

+ 11
- 15
Marlin/src/lcd/menu/menu_configuration.cpp Ver arquivo

@@ -41,35 +41,31 @@
41 41
 void menu_advanced_settings();
42 42
 void menu_delta_calibrate();
43 43
 
44
-#if HAS_LCD_CONTRAST
45
-  void lcd_callback_set_contrast() { set_lcd_contrast(lcd_contrast); }
46
-#endif
47
-
48 44
 static void lcd_factory_settings() {
49 45
   settings.reset();
50
-  lcd_completion_feedback();
46
+  ui.completion_feedback();
51 47
 }
52 48
 
53 49
 #if ENABLED(LCD_PROGRESS_BAR_TEST)
54 50
 
55 51
   static void progress_bar_test() {
56 52
     static int8_t bar_percent = 0;
57
-    if (use_click()) {
58
-      lcd_goto_previous_menu();
53
+    if (ui.use_click()) {
54
+      ui.goto_previous_screen();
59 55
       LCD_SET_CHARSET(CHARSET_MENU);
60 56
       return;
61 57
     }
62
-    bar_percent += (int8_t)encoderPosition;
58
+    bar_percent += (int8_t)ui.encoderPosition;
63 59
     bar_percent = constrain(bar_percent, 0, 100);
64
-    encoderPosition = 0;
65
-    lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
60
+    ui.encoderPosition = 0;
61
+    draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
66 62
     lcd_moveto((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
67 63
     lcd_put_u8str(int(bar_percent)); lcd_put_wchar('%');
68 64
     lcd_moveto(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
69 65
   }
70 66
 
71 67
   void _progress_bar_test() {
72
-    lcd_goto_screen(progress_bar_test);
68
+    ui.goto_screen(progress_bar_test);
73 69
     LCD_SET_CHARSET(CHARSET_INFO);
74 70
   }
75 71
 
@@ -271,12 +267,12 @@ static void lcd_factory_settings() {
271 267
     #endif
272 268
     START_MENU();
273 269
     MENU_BACK(MSG_CONFIGURATION);
274
-    MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
270
+    MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255);
275 271
     #if HAS_TEMP_HOTEND
276
-      MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
272
+      MENU_ITEM_EDIT(int3, MSG_NOZZLE, &ui.preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
277 273
     #endif
278 274
     #if HAS_HEATED_BED
279
-      MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
275
+      MENU_ITEM_EDIT(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
280 276
     #endif
281 277
     #if ENABLED(EEPROM_SETTINGS)
282 278
       MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
@@ -338,7 +334,7 @@ void menu_configuration() {
338 334
   #endif
339 335
 
340 336
   #if HAS_LCD_CONTRAST
341
-    MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
337
+    MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
342 338
   #endif
343 339
   #if ENABLED(FWRETRACT)
344 340
     MENU_ITEM(submenu, MSG_RETRACT, menu_config_retract);

+ 2
- 2
Marlin/src/lcd/menu/menu_custom.cpp Ver arquivo

@@ -40,10 +40,10 @@
40 40
 void _lcd_user_gcode(PGM_P const cmd) {
41 41
   enqueue_and_echo_commands_P(cmd);
42 42
   #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK)
43
-    lcd_completion_feedback();
43
+    ui.completion_feedback();
44 44
   #endif
45 45
   #if ENABLED(USER_SCRIPT_RETURN)
46
-    lcd_return_to_status();
46
+    ui.return_to_status();
47 47
   #endif
48 48
 }
49 49
 

+ 6
- 6
Marlin/src/lcd/menu/menu_delta_calibrate.cpp Ver arquivo

@@ -38,9 +38,9 @@
38 38
 
39 39
 void _man_probe_pt(const float &rx, const float &ry) {
40 40
   do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
41
-  lcd_synchronize();
41
+  ui.synchronize();
42 42
   move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
43
-  lcd_goto_screen(lcd_move_z);
43
+  ui.goto_screen(lcd_move_z);
44 44
 }
45 45
 
46 46
 #if ENABLED(DELTA_AUTO_CALIBRATION)
@@ -50,11 +50,11 @@ void _man_probe_pt(const float &rx, const float &ry) {
50 50
   float lcd_probe_pt(const float &rx, const float &ry) {
51 51
     _man_probe_pt(rx, ry);
52 52
     KEEPALIVE_STATE(PAUSED_FOR_USER);
53
-    set_defer_return_to_status(true);
53
+    ui.defer_status_screen(true);
54 54
     wait_for_user = true;
55 55
     while (wait_for_user) idle();
56 56
     KEEPALIVE_STATE(IN_HANDLER);
57
-    lcd_goto_previous_menu_no_defer();
57
+    ui.goto_previous_screen_no_defer();
58 58
     return current_position[Z_AXIS];
59 59
   }
60 60
 
@@ -66,12 +66,12 @@ void _man_probe_pt(const float &rx, const float &ry) {
66 66
 
67 67
   void _lcd_calibrate_homing() {
68 68
     _lcd_draw_homing();
69
-    if (all_axes_homed()) lcd_goto_previous_menu();
69
+    if (all_axes_homed()) ui.goto_previous_screen();
70 70
   }
71 71
 
72 72
   void _lcd_delta_calibrate_home() {
73 73
     enqueue_and_echo_commands_P(PSTR("G28"));
74
-    lcd_goto_screen(_lcd_calibrate_homing);
74
+    ui.goto_screen(_lcd_calibrate_homing);
75 75
   }
76 76
 
77 77
   void _goto_tower_x() { _man_probe_pt(cos(RADIANS(210)) * delta_calibration_radius, sin(RADIANS(210)) * delta_calibration_radius); }

+ 8
- 8
Marlin/src/lcd/menu/menu_filament.cpp Ver arquivo

@@ -323,15 +323,15 @@ static PGM_P advanced_pause_header() {
323 323
 // Portions from STATIC_ITEM...
324 324
 #define HOTEND_STATUS_ITEM() do { \
325 325
   if (_menuLineNr == _thisItemNr) { \
326
-    if (lcdDrawUpdate) { \
327
-      lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
328
-      lcd_implementation_hotend_status(_lcdLineNr, hotend_status_extruder); \
326
+    if (ui.should_draw()) { \
327
+      draw_menu_item_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
328
+      ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
329 329
     } \
330 330
     if (_skipStatic && encoderLine <= _thisItemNr) { \
331
-      encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
331
+      ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
332 332
       ++encoderLine; \
333 333
     } \
334
-    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
334
+    ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); \
335 335
   } \
336 336
   ++_thisItemNr; \
337 337
 }while(0)
@@ -507,11 +507,11 @@ void lcd_advanced_pause_show_message(
507 507
   hotend_status_extruder = extruder;
508 508
   const screenFunc_t next_screen = ap_message_screen(message);
509 509
   if (next_screen) {
510
-    set_defer_return_to_status(true);
511
-    lcd_goto_screen(next_screen);
510
+    ui.defer_status_screen(true);
511
+    ui.goto_screen(next_screen);
512 512
   }
513 513
   else
514
-    lcd_return_to_status();
514
+    ui.return_to_status();
515 515
 }
516 516
 
517 517
 #endif // HAS_LCD_MENU && ADVANCED_PAUSE_FEATURE

+ 4
- 4
Marlin/src/lcd/menu/menu_info.cpp Ver arquivo

@@ -47,7 +47,7 @@
47 47
   // About Printer > Printer Stats
48 48
   //
49 49
   void menu_info_stats() {
50
-    if (use_click()) { return lcd_goto_previous_menu(); }
50
+    if (ui.use_click()) return ui.goto_previous_screen();
51 51
 
52 52
     char buffer[21];
53 53
     printStatistics stats = print_job_timer.getStats();
@@ -80,7 +80,7 @@
80 80
 // About Printer > Thermistors
81 81
 //
82 82
 void menu_info_thermistors() {
83
-  if (use_click()) { return lcd_goto_previous_menu(); }
83
+  if (ui.use_click()) return ui.goto_previous_screen();
84 84
   START_SCREEN();
85 85
   #define THERMISTOR_ID TEMP_SENSOR_0
86 86
   #include "../thermistornames.h"
@@ -139,7 +139,7 @@ void menu_info_thermistors() {
139 139
 // About Printer > Board Info
140 140
 //
141 141
 void menu_info_board() {
142
-  if (use_click()) { return lcd_goto_previous_menu(); }
142
+  if (ui.use_click()) return ui.goto_previous_screen();
143 143
   START_SCREEN();
144 144
   STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
145 145
   STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@@ -158,7 +158,7 @@ void menu_info_board() {
158 158
 // About Printer > Printer Info
159 159
 //
160 160
 void menu_info_printer() {
161
-  if (use_click()) { return lcd_goto_previous_menu(); }
161
+  if (ui.use_click()) return ui.goto_previous_screen();
162 162
   START_SCREEN();
163 163
   STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
164 164
   STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch

+ 3
- 3
Marlin/src/lcd/menu/menu_job_recovery.cpp Ver arquivo

@@ -37,7 +37,7 @@ static void lcd_power_loss_recovery_resume() {
37 37
   char cmd[20];
38 38
 
39 39
   // Return to status now
40
-  lcd_return_to_status();
40
+  ui.return_to_status();
41 41
 
42 42
   // Turn leveling off and home
43 43
   enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
@@ -91,11 +91,11 @@ static void lcd_power_loss_recovery_resume() {
91 91
 static void lcd_power_loss_recovery_cancel() {
92 92
   card.removeJobRecoveryFile();
93 93
   card.autostart_index = 0;
94
-  lcd_return_to_status();
94
+  ui.return_to_status();
95 95
 }
96 96
 
97 97
 void menu_job_recovery() {
98
-  set_defer_return_to_status(true);
98
+  ui.defer_status_screen(true);
99 99
   START_MENU();
100 100
   STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
101 101
   MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);

+ 4
- 4
Marlin/src/lcd/menu/menu_main.cpp Ver arquivo

@@ -43,7 +43,7 @@
43 43
     #if ENABLED(PARK_HEAD_ON_PAUSE)
44 44
       enqueue_and_echo_commands_P(PSTR("M125"));
45 45
     #endif
46
-    lcd_reset_status();
46
+    ui.reset_status();
47 47
   }
48 48
 
49 49
   void lcd_sdcard_resume() {
@@ -53,14 +53,14 @@
53 53
       card.startFileprint();
54 54
       print_job_timer.start();
55 55
     #endif
56
-    lcd_reset_status();
56
+    ui.reset_status();
57 57
   }
58 58
 
59 59
   void lcd_sdcard_stop() {
60 60
     wait_for_heatup = wait_for_user = false;
61 61
     card.abort_sd_printing = true;
62
-    lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
63
-    lcd_return_to_status();
62
+    ui.setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
63
+    ui.return_to_status();
64 64
   }
65 65
 
66 66
   #if ENABLED(MENU_ADDAUTOSTART)

+ 26
- 32
Marlin/src/lcd/menu/menu_motion.cpp Ver arquivo

@@ -46,9 +46,6 @@
46 46
 
47 47
 extern millis_t manual_move_start_time;
48 48
 extern int8_t manual_move_axis;
49
-#if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
50
-  extern int8_t manual_move_e_index;
51
-#endif
52 49
 #if ENABLED(MANUAL_E_MOVES_RELATIVE)
53 50
   float manual_move_e_origin = 0;
54 51
 #endif
@@ -57,18 +54,15 @@ extern int8_t manual_move_axis;
57 54
 #endif
58 55
 
59 56
 //
60
-// Tell lcd_update() to start a move to current_position" after a short delay.
57
+// Tell ui.update() to start a move to current_position" after a short delay.
61 58
 //
62 59
 inline void manual_move_to_current(AxisEnum axis
63 60
   #if E_MANUAL > 1
64 61
     , const int8_t eindex=-1
65 62
   #endif
66 63
 ) {
67
-  #if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
68
-    #if E_MANUAL > 1
69
-      if (axis == E_AXIS)
70
-    #endif
71
-        manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
64
+  #if E_MANUAL > 1
65
+    if (axis == E_AXIS) ui.manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
72 66
   #endif
73 67
   manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
74 68
   manual_move_axis = (int8_t)axis;
@@ -79,9 +73,9 @@ inline void manual_move_to_current(AxisEnum axis
79 73
 //
80 74
 
81 75
 static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
82
-  if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
83
-  ENCODER_DIRECTION_NORMAL();
84
-  if (encoderPosition && !processing_manual_move) {
76
+  if (ui.use_click()) return ui.goto_previous_screen_no_defer();
77
+  ui.encoder_direction_normal();
78
+  if (ui.encoderPosition && !ui.processing_manual_move) {
85 79
 
86 80
     // Start with no limits to movement
87 81
     float min = current_position[axis] - 1000,
@@ -127,32 +121,32 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
127 121
     #endif
128 122
 
129 123
     // Get the new position
130
-    const float diff = float((int32_t)encoderPosition) * move_menu_scale;
124
+    const float diff = float((int32_t)ui.encoderPosition) * move_menu_scale;
131 125
     #if IS_KINEMATIC
132 126
       manual_move_offset += diff;
133
-      if ((int32_t)encoderPosition < 0)
127
+      if ((int32_t)ui.encoderPosition < 0)
134 128
         NOLESS(manual_move_offset, min - current_position[axis]);
135 129
       else
136 130
         NOMORE(manual_move_offset, max - current_position[axis]);
137 131
     #else
138 132
       current_position[axis] += diff;
139
-      if ((int32_t)encoderPosition < 0)
133
+      if ((int32_t)ui.encoderPosition < 0)
140 134
         NOLESS(current_position[axis], min);
141 135
       else
142 136
         NOMORE(current_position[axis], max);
143 137
     #endif
144 138
 
145 139
     manual_move_to_current(axis);
146
-    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
140
+    ui.refresh(LCDVIEW_REDRAW_NOW);
147 141
   }
148
-  encoderPosition = 0;
149
-  if (lcdDrawUpdate) {
150
-    const float pos = NATIVE_TO_LOGICAL(processing_manual_move ? destination[axis] : current_position[axis]
142
+  ui.encoderPosition = 0;
143
+  if (ui.should_draw()) {
144
+    const float pos = NATIVE_TO_LOGICAL(ui.processing_manual_move ? destination[axis] : current_position[axis]
151 145
       #if IS_KINEMATIC
152 146
         + manual_move_offset
153 147
       #endif
154 148
     , axis);
155
-    lcd_implementation_drawedit(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
149
+    draw_edit_screen(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
156 150
   }
157 151
 }
158 152
 void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
@@ -163,11 +157,11 @@ static void _lcd_move_e(
163 157
     const int8_t eindex=-1
164 158
   #endif
165 159
 ) {
166
-  if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
167
-  ENCODER_DIRECTION_NORMAL();
168
-  if (encoderPosition) {
169
-    if (!processing_manual_move) {
170
-      const float diff = float((int32_t)encoderPosition) * move_menu_scale;
160
+  if (ui.use_click()) return ui.goto_previous_screen_no_defer();
161
+  ui.encoder_direction_normal();
162
+  if (ui.encoderPosition) {
163
+    if (!ui.processing_manual_move) {
164
+      const float diff = float((int32_t)ui.encoderPosition) * move_menu_scale;
171 165
       #if IS_KINEMATIC
172 166
         manual_move_offset += diff;
173 167
       #else
@@ -178,11 +172,11 @@ static void _lcd_move_e(
178 172
           , eindex
179 173
         #endif
180 174
       );
181
-      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
175
+      ui.refresh(LCDVIEW_REDRAW_NOW);
182 176
     }
183
-    encoderPosition = 0;
177
+    ui.encoderPosition = 0;
184 178
   }
185
-  if (lcdDrawUpdate) {
179
+  if (ui.should_draw()) {
186 180
     PGM_P pos_label;
187 181
     #if E_MANUAL == 1
188 182
       pos_label = PSTR(MSG_MOVE_E);
@@ -205,7 +199,7 @@ static void _lcd_move_e(
205 199
       }
206 200
     #endif // E_MANUAL > 1
207 201
 
208
-    lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]
202
+    draw_edit_screen(pos_label, ftostr41sign(current_position[E_AXIS]
209 203
       #if IS_KINEMATIC
210 204
         + manual_move_offset
211 205
       #endif
@@ -241,9 +235,9 @@ inline void lcd_move_e() { _lcd_move_e(); }
241 235
 screenFunc_t _manual_move_func_ptr;
242 236
 
243 237
 void _goto_manual_move(const float scale) {
244
-  set_defer_return_to_status(true);
238
+  ui.defer_status_screen(true);
245 239
   move_menu_scale = scale;
246
-  lcd_goto_screen(_manual_move_func_ptr);
240
+  ui.goto_screen(_manual_move_func_ptr);
247 241
 }
248 242
 void menu_move_10mm() { _goto_manual_move(10); }
249 243
 void menu_move_1mm()  { _goto_manual_move( 1); }
@@ -305,7 +299,7 @@ void lcd_move_get_e_amount() { _menu_move_distance(E_AXIS, lcd_move_e, -1); }
305 299
 #if ENABLED(DELTA)
306 300
   void lcd_lower_z_to_clip_height() {
307 301
     line_to_z(delta_clip_start_height);
308
-    lcd_synchronize();
302
+    ui.synchronize();
309 303
   }
310 304
 #endif
311 305
 

+ 29
- 28
Marlin/src/lcd/menu/menu_sdcard.cpp Ver arquivo

@@ -39,35 +39,36 @@
39 39
 #endif
40 40
 
41 41
 void lcd_sd_updir() {
42
-  encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
42
+  ui.encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
43 43
   encoderTopLine = 0;
44 44
   screen_changed = true;
45
-  lcd_refresh();
45
+  ui.refresh();
46 46
 }
47 47
 
48 48
 #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
49
+
49 50
   uint32_t last_sdfile_encoderPosition = 0xFFFF;
50 51
 
51
-  void lcd_reselect_last_file() {
52
+  void MarlinUI::reselect_last_file() {
52 53
     if (last_sdfile_encoderPosition == 0xFFFF) return;
53
-    #if HAS_GRAPHICAL_LCD
54
-      // Some of this is a hack to force the screen update to work.
55
-      // TODO: Fix the real issue that causes this!
56
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
57
-      lcd_synchronize();
58
-      safe_delay(50);
59
-      lcd_synchronize();
60
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
61
-      drawing_screen = screen_changed = true;
62
-    #endif
63
-
64
-    lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
65
-    set_defer_return_to_status(true);
54
+    //#if HAS_GRAPHICAL_LCD
55
+    //  // This is a hack to force a screen update.
56
+    //  ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
57
+    //  ui.synchronize();
58
+    //  safe_delay(50);
59
+    //  ui.synchronize();
60
+    //  ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
61
+    //  ui.drawing_screen = screen_changed = true;
62
+    //#endif
63
+
64
+    goto_screen(menu_sdcard, last_sdfile_encoderPosition);
66 65
     last_sdfile_encoderPosition = 0xFFFF;
67 66
 
68
-    #if HAS_GRAPHICAL_LCD
69
-      lcd_update();
70
-    #endif
67
+    defer_status_screen(true);
68
+
69
+    //#if HAS_GRAPHICAL_LCD
70
+    //  update();
71
+    //#endif
71 72
   }
72 73
 #endif
73 74
 
@@ -75,30 +76,30 @@ class menu_item_sdfile {
75 76
   public:
76 77
     static void action(CardReader &theCard) {
77 78
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
78
-        last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
79
+        last_sdfile_encoderPosition = ui.encoderPosition;  // Save which file was selected for later use
79 80
       #endif
80 81
       card.openAndPrintFile(theCard.filename);
81
-      lcd_return_to_status();
82
-      lcd_reset_status();
82
+      ui.return_to_status();
83
+      ui.reset_status();
83 84
     }
84 85
 };
85 86
 
86
-class menu_item_sddirectory {
87
+class menu_item_sdfolder {
87 88
   public:
88 89
     static void action(CardReader &theCard) {
89 90
       card.chdir(theCard.filename);
90 91
       encoderTopLine = 0;
91
-      encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
92
+      ui.encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
92 93
       screen_changed = true;
93 94
       #if HAS_GRAPHICAL_LCD
94
-        drawing_screen = false;
95
+        ui.drawing_screen = false;
95 96
       #endif
96
-      lcd_refresh();
97
+      ui.refresh();
97 98
     }
98 99
 };
99 100
 
100 101
 void menu_sdcard() {
101
-  ENCODER_DIRECTION_MENUS();
102
+  ui.encoder_direction_menus();
102 103
 
103 104
   const uint16_t fileCnt = card.get_num_Files();
104 105
 
@@ -125,7 +126,7 @@ void menu_sdcard() {
125 126
       card.getfilename_sorted(nr);
126 127
 
127 128
       if (card.filenameIsDir)
128
-        MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
129
+        MENU_ITEM(sdfolder, MSG_CARD_MENU, card);
129 130
       else
130 131
         MENU_ITEM(sdfile, MSG_CARD_MENU, card);
131 132
     }

+ 40
- 40
Marlin/src/lcd/menu/menu_temperature.cpp Ver arquivo

@@ -36,8 +36,8 @@
36 36
 #endif
37 37
 
38 38
 // Initialized by settings.load()
39
-int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
40
-uint8_t lcd_preheat_fan_speed[2];
39
+int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
40
+uint8_t MarlinUI::preheat_fan_speed[2];
41 41
 
42 42
 //
43 43
 // "Temperature" submenu items
@@ -59,44 +59,44 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
59 59
   #else
60 60
     UNUSED(fan);
61 61
   #endif
62
-  lcd_return_to_status();
62
+  ui.return_to_status();
63 63
 }
64 64
 
65 65
 #if HOTENDS > 1
66 66
 
67
-  void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
68
-  void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
67
+  void lcd_preheat_m1_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
68
+  void lcd_preheat_m2_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
69 69
   #if HAS_HEATED_BED
70
-    void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
71
-    void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
70
+    void lcd_preheat_m1_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
71
+    void lcd_preheat_m2_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
72 72
   #endif
73 73
   #if HOTENDS > 2
74
-    void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
75
-    void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
74
+    void lcd_preheat_m1_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
75
+    void lcd_preheat_m2_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
76 76
     #if HAS_HEATED_BED
77
-      void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
78
-      void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
77
+      void lcd_preheat_m1_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
78
+      void lcd_preheat_m2_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
79 79
     #endif
80 80
     #if HOTENDS > 3
81
-      void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
82
-      void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
81
+      void lcd_preheat_m1_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
82
+      void lcd_preheat_m2_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
83 83
       #if HAS_HEATED_BED
84
-        void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
85
-        void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
84
+        void lcd_preheat_m1_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
85
+        void lcd_preheat_m2_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
86 86
       #endif
87 87
       #if HOTENDS > 4
88
-        void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
89
-        void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
88
+        void lcd_preheat_m1_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
89
+        void lcd_preheat_m2_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
90 90
         #if HAS_HEATED_BED
91
-          void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
92
-          void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
91
+          void lcd_preheat_m1_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
92
+          void lcd_preheat_m2_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
93 93
         #endif
94 94
         #if HOTENDS > 5
95
-          void lcd_preheat_m1_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
96
-          void lcd_preheat_m2_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
95
+          void lcd_preheat_m1_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
96
+          void lcd_preheat_m2_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
97 97
           #if HAS_HEATED_BED
98
-            void lcd_preheat_m1_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
99
-            void lcd_preheat_m2_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
98
+            void lcd_preheat_m1_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
99
+            void lcd_preheat_m2_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
100 100
           #endif
101 101
         #endif // HOTENDS > 5
102 102
       #endif // HOTENDS > 4
@@ -113,15 +113,15 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
113 113
 
114 114
   void lcd_preheat_m1_all() {
115 115
     #if HOTENDS > 1
116
-      thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
116
+      thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 1);
117 117
       #if HOTENDS > 2
118
-        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
118
+        thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 2);
119 119
         #if HOTENDS > 3
120
-          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
120
+          thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 3);
121 121
           #if HOTENDS > 4
122
-            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 4);
122
+            thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 4);
123 123
             #if HOTENDS > 5
124
-              thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 5);
124
+              thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 5);
125 125
             #endif // HOTENDS > 5
126 126
           #endif // HOTENDS > 4
127 127
         #endif // HOTENDS > 3
@@ -136,15 +136,15 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
136 136
 
137 137
   void lcd_preheat_m2_all() {
138 138
     #if HOTENDS > 1
139
-      thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
139
+      thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 1);
140 140
       #if HOTENDS > 2
141
-        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
141
+        thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 2);
142 142
         #if HOTENDS > 3
143
-          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
143
+          thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 3);
144 144
           #if HOTENDS > 4
145
-            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 4);
145
+            thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 4);
146 146
             #if HOTENDS > 5
147
-              thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 5);
147
+              thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 5);
148 148
             #endif // HOTENDS > 5
149 149
           #endif // HOTENDS > 4
150 150
         #endif // HOTENDS > 3
@@ -161,14 +161,14 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
161 161
 
162 162
 #if HAS_TEMP_HOTEND || HAS_HEATED_BED
163 163
 
164
-  void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
165
-  void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
164
+  void lcd_preheat_m1_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
165
+  void lcd_preheat_m2_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
166 166
 
167 167
   #if HAS_HEATED_BED
168
-    void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
169
-    void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
170
-    void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
171
-    void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
168
+    void lcd_preheat_m1_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
169
+    void lcd_preheat_m2_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
170
+    void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
171
+    void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
172 172
   #endif
173 173
 
174 174
   void menu_preheat_m1() {
@@ -294,7 +294,7 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
294 294
   void lcd_cooldown() {
295 295
     zero_fan_speeds();
296 296
     thermalManager.disable_all_heaters();
297
-    lcd_return_to_status();
297
+    ui.return_to_status();
298 298
   }
299 299
 
300 300
 #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED

+ 11
- 11
Marlin/src/lcd/menu/menu_tune.cpp Ver arquivo

@@ -62,29 +62,29 @@ void _lcd_refresh_e_factor_0() { planner.refresh_e_factor(0); }
62 62
   long babysteps_done = 0;
63 63
 
64 64
   void _lcd_babystep(const AxisEnum axis, PGM_P msg) {
65
-    if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
66
-    ENCODER_DIRECTION_NORMAL();
67
-    if (encoderPosition) {
68
-      const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
69
-      encoderPosition = 0;
70
-      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
65
+    if (ui.use_click()) return ui.goto_previous_screen_no_defer();
66
+    ui.encoder_direction_normal();
67
+    if (ui.encoderPosition) {
68
+      const int16_t babystep_increment = (int32_t)ui.encoderPosition * (BABYSTEP_MULTIPLICATOR);
69
+      ui.encoderPosition = 0;
70
+      ui.refresh(LCDVIEW_REDRAW_NOW);
71 71
       thermalManager.babystep_axis(axis, babystep_increment);
72 72
       babysteps_done += babystep_increment;
73 73
     }
74
-    if (lcdDrawUpdate)
75
-      lcd_implementation_drawedit(msg, ftostr43sign(planner.steps_to_mm[axis] * babysteps_done));
74
+    if (ui.should_draw())
75
+      draw_edit_screen(msg, ftostr43sign(planner.steps_to_mm[axis] * babysteps_done));
76 76
   }
77 77
 
78 78
   #if ENABLED(BABYSTEP_XY)
79 79
     void _lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEP_X)); }
80 80
     void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEP_Y)); }
81
-    void lcd_babystep_x() { lcd_goto_screen(_lcd_babystep_x); babysteps_done = 0; set_defer_return_to_status(true); }
82
-    void lcd_babystep_y() { lcd_goto_screen(_lcd_babystep_y); babysteps_done = 0; set_defer_return_to_status(true); }
81
+    void lcd_babystep_x() { ui.goto_screen(_lcd_babystep_x); babysteps_done = 0; ui.defer_status_screen(true); }
82
+    void lcd_babystep_y() { ui.goto_screen(_lcd_babystep_y); babysteps_done = 0; ui.defer_status_screen(true); }
83 83
   #endif
84 84
 
85 85
   #if DISABLED(BABYSTEP_ZPROBE_OFFSET)
86 86
     void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEP_Z)); }
87
-    void lcd_babystep_z() { lcd_goto_screen(_lcd_babystep_z); babysteps_done = 0; set_defer_return_to_status(true); }
87
+    void lcd_babystep_z() { ui.goto_screen(_lcd_babystep_z); babysteps_done = 0; ui.defer_status_screen(true); }
88 88
   #endif
89 89
 
90 90
 #endif // BABYSTEPPING

+ 31
- 31
Marlin/src/lcd/menu/menu_ubl.cpp Ver arquivo

@@ -51,22 +51,22 @@ float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5
51 51
 static int16_t ubl_encoderPosition = 0;
52 52
 
53 53
 static void _lcd_mesh_fine_tune(PGM_P msg) {
54
-  set_defer_return_to_status(true);
54
+  ui.defer_status_screen(true);
55 55
   if (ubl.encoder_diff) {
56 56
     ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
57 57
     ubl.encoder_diff = 0;
58 58
 
59 59
     mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
60 60
     mesh_edit_value = mesh_edit_accumulator;
61
-    encoderPosition = 0;
62
-    lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
61
+    ui.encoderPosition = 0;
62
+    ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
63 63
 
64 64
     const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
65 65
     mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
66 66
   }
67 67
 
68
-  if (lcdDrawUpdate) {
69
-    lcd_implementation_drawedit(msg, ftostr43sign(mesh_edit_value));
68
+  if (ui.should_draw()) {
69
+    draw_edit_screen(msg, ftostr43sign(mesh_edit_value));
70 70
     #if ENABLED(MESH_EDIT_GFX_OVERLAY)
71 71
       _lcd_zoffset_overlay_gfx(mesh_edit_value);
72 72
     #endif
@@ -74,19 +74,19 @@ static void _lcd_mesh_fine_tune(PGM_P msg) {
74 74
 }
75 75
 
76 76
 void _lcd_mesh_edit_NOP() {
77
-  set_defer_return_to_status(true);
77
+  ui.defer_status_screen(true);
78 78
 }
79 79
 
80 80
 float lcd_mesh_edit() {
81
-  lcd_goto_screen(_lcd_mesh_edit_NOP);
82
-  lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
81
+  ui.goto_screen(_lcd_mesh_edit_NOP);
82
+  ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
83 83
   _lcd_mesh_fine_tune(PSTR("Mesh Editor"));
84 84
   return mesh_edit_value;
85 85
 }
86 86
 
87 87
 void lcd_mesh_edit_setup(const float &initial) {
88 88
   mesh_edit_value = mesh_edit_accumulator = initial;
89
-  lcd_goto_screen(_lcd_mesh_edit_NOP);
89
+  ui.goto_screen(_lcd_mesh_edit_NOP);
90 90
 }
91 91
 
92 92
 void _lcd_z_offset_edit() {
@@ -94,13 +94,13 @@ void _lcd_z_offset_edit() {
94 94
 }
95 95
 
96 96
 float lcd_z_offset_edit() {
97
-  lcd_goto_screen(_lcd_z_offset_edit);
97
+  ui.goto_screen(_lcd_z_offset_edit);
98 98
   return mesh_edit_value;
99 99
 }
100 100
 
101 101
 void lcd_z_offset_edit_setup(const float &initial) {
102 102
   mesh_edit_value = mesh_edit_accumulator = initial;
103
-  lcd_goto_screen(_lcd_z_offset_edit);
103
+  ui.goto_screen(_lcd_z_offset_edit);
104 104
 }
105 105
 
106 106
 /**
@@ -160,7 +160,7 @@ void _menu_ubl_height_adjust() {
160 160
   START_MENU();
161 161
   MENU_BACK(MSG_EDIT_MESH);
162 162
   MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
163
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
163
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
164 164
   END_MENU();
165 165
 }
166 166
 
@@ -179,7 +179,7 @@ void _lcd_ubl_edit_mesh() {
179 179
   MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
180 180
   MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
181 181
   MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
182
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
182
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
183 183
   END_MENU();
184 184
 }
185 185
 
@@ -220,7 +220,7 @@ void _lcd_ubl_validate_mesh() {
220 220
     MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
221 221
   #endif
222 222
   MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
223
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
223
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
224 224
   END_MENU();
225 225
 }
226 226
 
@@ -261,7 +261,7 @@ void _lcd_ubl_mesh_leveling() {
261 261
   MENU_BACK(MSG_UBL_TOOLS);
262 262
   MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
263 263
   MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
264
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
264
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
265 265
   END_MENU();
266 266
 }
267 267
 
@@ -290,7 +290,7 @@ void _menu_ubl_fillin() {
290 290
   MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
291 291
   MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
292 292
   MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
293
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
293
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
294 294
   END_MENU();
295 295
 }
296 296
 
@@ -353,7 +353,7 @@ void _lcd_ubl_build_mesh() {
353 353
   MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
354 354
   MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
355 355
   MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
356
-  MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
356
+  MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
357 357
   END_MENU();
358 358
 }
359 359
 
@@ -408,11 +408,11 @@ void _lcd_ubl_storage_mesh() {
408 408
 void _lcd_ubl_output_map_lcd();
409 409
 
410 410
 void _lcd_ubl_map_homing() {
411
-  set_defer_return_to_status(true);
411
+  ui.defer_status_screen(true);
412 412
   _lcd_draw_homing();
413 413
   if (all_axes_homed()) {
414 414
     ubl.lcd_map_control = true; // Return to the map screen
415
-    lcd_goto_screen(_lcd_ubl_output_map_lcd);
415
+    ui.goto_screen(_lcd_ubl_output_map_lcd);
416 416
   }
417 417
 }
418 418
 
@@ -444,10 +444,10 @@ void sync_plan_position();
444 444
 
445 445
 void _lcd_do_nothing() {}
446 446
 void _lcd_hard_stop() {
447
-  const screenFunc_t old_screen = currentScreen;
448
-  currentScreen = _lcd_do_nothing;
447
+  const screenFunc_t old_screen = ui.currentScreen;
448
+  ui.currentScreen = _lcd_do_nothing;
449 449
   planner.quick_stop();
450
-  currentScreen = old_screen;
450
+  ui.currentScreen = old_screen;
451 451
   set_current_from_steppers_for_axis(ALL_AXES);
452 452
   sync_plan_position();
453 453
 }
@@ -455,15 +455,15 @@ void _lcd_hard_stop() {
455 455
 void _lcd_ubl_output_map_lcd() {
456 456
   static int16_t step_scaler = 0;
457 457
 
458
-  if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
459
-  ENCODER_DIRECTION_NORMAL();
458
+  if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
459
+  ui.encoder_direction_normal();
460 460
 
461
-  if (encoderPosition) {
462
-    step_scaler += (int32_t)encoderPosition;
461
+  if (ui.encoderPosition) {
462
+    step_scaler += (int32_t)ui.encoderPosition;
463 463
     x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
464 464
     if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
465
-    encoderPosition = 0;
466
-    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
465
+    ui.encoderPosition = 0;
466
+    ui.refresh(LCDVIEW_REDRAW_NOW);
467 467
   }
468 468
 
469 469
   // Encoder to the right (++)
@@ -487,8 +487,8 @@ void _lcd_ubl_output_map_lcd() {
487 487
     n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
488 488
   #endif
489 489
 
490
-  if (lcdDrawUpdate) {
491
-    lcd_implementation_ubl_plot(x_plot, y_plot);
490
+  if (ui.should_draw()) {
491
+    ui.ubl_plot(x_plot, y_plot);
492 492
 
493 493
     if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
494 494
       _lcd_hard_stop();
@@ -505,7 +505,7 @@ void _lcd_ubl_output_map_lcd_cmd() {
505 505
     set_all_unhomed();
506 506
     enqueue_and_echo_commands_P(PSTR("G28"));
507 507
   }
508
-  lcd_goto_screen(_lcd_ubl_map_homing);
508
+  ui.goto_screen(_lcd_ubl_map_homing);
509 509
 }
510 510
 
511 511
 /**

+ 242
- 295
Marlin/src/lcd/ultralcd.cpp
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 382
- 220
Marlin/src/lcd/ultralcd.h Ver arquivo

@@ -23,6 +23,21 @@
23 23
 
24 24
 #include "../inc/MarlinConfig.h"
25 25
 
26
+#if HAS_SPI_LCD
27
+
28
+  #include "../Marlin.h"
29
+
30
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
31
+    #include "../feature/pause.h"
32
+    #include "../module/motion.h" // for active_extruder
33
+  #endif
34
+
35
+#endif
36
+
37
+#if HAS_BUZZER
38
+  #include "../libs/buzzer.h"
39
+#endif
40
+
26 41
 #if HAS_GRAPHICAL_LCD
27 42
 
28 43
   #ifndef LCD_PIXEL_WIDTH
@@ -171,13 +186,11 @@
171 186
   #define INFO_FONT_DESCENT 2
172 187
   #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
173 188
 
174
-  // Font IDs
175 189
   enum MarlinFont : uint8_t {
176 190
     FONT_STATUSMENU = 1,
177 191
     FONT_EDIT,
178 192
     FONT_MENU
179 193
   };
180
-  void lcd_setFont(const MarlinFont font_nr);
181 194
 
182 195
   #if ENABLED(LIGHTWEIGHT_UI)
183 196
     void lcd_in_status(const bool inStatus);
@@ -185,46 +198,10 @@
185 198
 
186 199
 #endif // HAS_GRAPHICAL_LCD
187 200
 
188
-#if HAS_SPI_LCD || ENABLED(MALYAN_LCD) || ENABLED(EXTENSIBLE_UI)
189
-  void lcd_init();
190
-  bool lcd_detected();
191
-  void lcd_update();
192
-  void lcd_setalertstatusPGM(PGM_P message);
193
-  void kill_screen(PGM_P lcd_msg);
194
-#else
195
-  inline void lcd_init() {}
196
-  inline bool lcd_detected() { return true; }
197
-  inline void lcd_update() {}
198
-  inline void lcd_setalertstatusPGM(PGM_P message) { UNUSED(message); }
199
-#endif
200
-
201 201
 #define HAS_ENCODER_ACTION (HAS_LCD_MENU || ENABLED(ULTIPANEL_FEEDMULTIPLY))
202 202
 
203
-#if HAS_ENCODER_ACTION
204
-  extern uint32_t encoderPosition;
205
-#endif
206
-
207 203
 #if HAS_SPI_LCD
208 204
 
209
-  #include "../Marlin.h"
210
-
211
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
212
-    #include "../feature/pause.h"
213
-    #include "../module/motion.h" // for active_extruder
214
-  #endif
215
-
216
-  void lcd_status_screen();
217
-  void lcd_return_to_status();
218
-  bool lcd_hasstatus();
219
-  void lcd_setstatus(const char* message, const bool persist=false);
220
-  void lcd_setstatusPGM(PGM_P message, const int8_t level=0);
221
-  void lcd_setalertstatusPGM(PGM_P message);
222
-  void lcd_reset_alert_level();
223
-  void lcd_reset_status();
224
-  void lcd_status_printf_P(const uint8_t level, PGM_P const fmt, ...);
225
-  void lcd_kill_screen();
226
-  void kill_screen(PGM_P lcd_msg);
227
-
228 205
   enum LCDViewAction : uint8_t {
229 206
     LCDVIEW_NONE,
230 207
     LCDVIEW_REDRAW_NOW,
@@ -233,37 +210,10 @@
233 210
     LCDVIEW_CALL_NO_REDRAW
234 211
   };
235 212
 
236
-  extern LCDViewAction lcdDrawUpdate;
237
-  inline void lcd_refresh() { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; }
238
-
239
-  #if HAS_BUZZER
240
-    void lcd_buzz(const long duration, const uint16_t freq);
241
-  #else
242
-    inline void lcd_buzz(const long duration, const uint16_t freq) { UNUSED(duration); UNUSED(freq); }
243
-  #endif
244
-
245
-  void lcd_quick_feedback(const bool clear_buttons=true); // Audible feedback for a button click - could also be visual
246
-
247
-  #if ENABLED(LCD_PROGRESS_BAR)
248
-    extern millis_t progress_bar_ms;  // Start time for the current progress bar cycle
249
-    #if PROGRESS_MSG_EXPIRE > 0
250
-      void dontExpireStatus();
251
-    #endif
252
-  #endif
253
-
254
-  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
255
-    extern uint8_t progress_bar_percent;
256
-  #endif
257
-
258 213
   #if ENABLED(ADC_KEYPAD)
259 214
     uint8_t get_ADC_keyValue();
260 215
   #endif
261 216
 
262
-  #if HAS_LCD_CONTRAST
263
-    extern int16_t lcd_contrast;
264
-    void set_lcd_contrast(const int16_t value);
265
-  #endif
266
-
267 217
   #if HAS_GRAPHICAL_LCD
268 218
     #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
269 219
     #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - len * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
@@ -272,10 +222,6 @@
272 222
     #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - len, row)
273 223
   #endif
274 224
 
275
-  #if ENABLED(SHOW_BOOTSCREEN)
276
-    void lcd_bootscreen();
277
-  #endif
278
-
279 225
   #define LCD_UPDATE_INTERVAL 100
280 226
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
281 227
   #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
@@ -284,41 +230,10 @@
284 230
 
285 231
     typedef void (*screenFunc_t)();
286 232
     typedef void (*menuAction_t)();
287
-    extern screenFunc_t currentScreen;
288
-    void lcd_goto_screen(const screenFunc_t screen, const uint32_t encoder=0);
289
-
290
-    extern bool lcd_clicked;
291
-    #if LCD_TIMEOUT_TO_STATUS
292
-      extern bool defer_return_to_status;
293
-      inline void set_defer_return_to_status(const bool defer) { defer_return_to_status = defer; }
294
-    #else
295
-      constexpr bool defer_return_to_status = false;
296
-      #define set_defer_return_to_status(D) NOOP
297
-    #endif
298
-
299
-    extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
300
-    extern uint8_t lcd_preheat_fan_speed[2];
301
-
302
-    #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
303
-      extern bool lcd_external_control;
304
-    #else
305
-      constexpr bool lcd_external_control = false;
306
-    #endif
307
-
308
-    #if ENABLED(LCD_BED_LEVELING)
309
-      extern bool lcd_wait_for_move;
310
-    #else
311
-      constexpr bool lcd_wait_for_move = false;
312
-    #endif
313 233
 
314 234
     // Manual Movement
315 235
     constexpr float manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
316 236
     extern float move_menu_scale;
317
-    #if IS_KINEMATIC
318
-      extern bool processing_manual_move;
319
-    #else
320
-      constexpr bool processing_manual_move = false;
321
-    #endif
322 237
 
323 238
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
324 239
       void lcd_advanced_pause_show_message(const AdvancedPauseMessage message,
@@ -326,65 +241,15 @@
326 241
                                            const uint8_t extruder=active_extruder);
327 242
     #endif
328 243
 
329
-    #if ENABLED(G26_MESH_VALIDATION)
330
-      void lcd_chirp();
331
-    #endif
332
-
333 244
     #if ENABLED(AUTO_BED_LEVELING_UBL)
334 245
       void lcd_mesh_edit_setup(const float &initial);
335 246
       float lcd_mesh_edit();
336 247
     #endif
337 248
 
338
-    #if ENABLED(SCROLL_LONG_FILENAMES)
339
-      extern uint8_t filename_scroll_pos, filename_scroll_max;
340
-    #endif
341
-
342 249
   #endif // HAS_LCD_MENU
343 250
 
344
-  #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
345
-    extern millis_t previous_lcd_status_ms;
346
-  #endif
347
-
348
-  #if ENABLED(STATUS_MESSAGE_SCROLLING)
349
-    extern uint8_t status_scroll_offset;
350
-  #endif
351
-
352
-  bool lcd_blink();
353
-
354
-  bool use_click();
355
-
356
-  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
357
-    bool is_lcd_clicked();
358
-    void wait_for_release();
359
-  #endif
360
-
361
-#elif ENABLED(EXTENSIBLE_UI)
362
-
363
-  // These functions are defined elsewhere
364
-  void lcd_setstatus(const char* const message, const bool persist=false);
365
-  void lcd_setstatusPGM(const char* const message, const int8_t level=0);
366
-  void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...);
367
-  void lcd_reset_status();
368
-  void lcd_refresh();
369
-  void lcd_reset_alert_level();
370
-  bool lcd_hasstatus();
371
-
372
-#else // MALYAN_LCD or no LCD
373
-
374
-  constexpr bool lcd_wait_for_move = false;
375
-
376
-  inline void lcd_refresh() {}
377
-  inline bool lcd_hasstatus() { return false; }
378
-  inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
379
-  inline void lcd_setstatusPGM(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
380
-  inline void lcd_status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); }
381
-  inline void lcd_reset_alert_level() {}
382
-  inline void lcd_reset_status() {}
383
-
384 251
 #endif
385 252
 
386
-#define HAS_DIGITAL_ENCODER (HAS_SPI_LCD && ENABLED(NEWPANEL))
387
-
388 253
 #if HAS_DIGITAL_ENCODER
389 254
 
390 255
   // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
@@ -402,103 +267,400 @@
402 267
   #if BUTTON_EXISTS(BACK)
403 268
     #define BLEN_D 3
404 269
     #define EN_D _BV(BLEN_D)
405
-    #define LCD_BACK_CLICKED (buttons & EN_D)
270
+    #define LCD_BACK_CLICKED() (buttons & EN_D)
406 271
   #endif
407 272
 
408
-#endif // HAS_DIGITAL_ENCODER
273
+  #if ENABLED(REPRAPWORLD_KEYPAD)
274
+    #define REPRAPWORLD_BTN_OFFSET          0 // Bit offset into buttons for shift register values
275
+
276
+    #define BLEN_REPRAPWORLD_KEYPAD_F3      0
277
+    #define BLEN_REPRAPWORLD_KEYPAD_F2      1
278
+    #define BLEN_REPRAPWORLD_KEYPAD_F1      2
279
+    #define BLEN_REPRAPWORLD_KEYPAD_DOWN    3
280
+    #define BLEN_REPRAPWORLD_KEYPAD_RIGHT   4
281
+    #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE  5
282
+    #define BLEN_REPRAPWORLD_KEYPAD_UP      6
283
+    #define BLEN_REPRAPWORLD_KEYPAD_LEFT    7
284
+
285
+    #define EN_REPRAPWORLD_KEYPAD_F1        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
286
+    #define EN_REPRAPWORLD_KEYPAD_F2        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
287
+    #define EN_REPRAPWORLD_KEYPAD_F3        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
288
+    #define EN_REPRAPWORLD_KEYPAD_DOWN      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
289
+    #define EN_REPRAPWORLD_KEYPAD_RIGHT     (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
290
+    #define EN_REPRAPWORLD_KEYPAD_MIDDLE    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
291
+    #define EN_REPRAPWORLD_KEYPAD_UP        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
292
+    #define EN_REPRAPWORLD_KEYPAD_LEFT      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
293
+
294
+    #define RRK(B) (buttons_reprapworld_keypad & (B))
295
+
296
+    #ifdef EN_C
297
+      #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE))
298
+    #else
299
+      #define BUTTON_CLICK() RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)
300
+    #endif
409 301
 
410
-#if HAS_LCD_MENU
302
+  #elif ENABLED(LCD_I2C_VIKI)
411 303
 
412
-  extern volatile uint8_t buttons;  // The last-checked buttons in a bit array.
413
-  void lcd_buttons_update();
304
+    #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
414 305
 
415
-#else
306
+    // button and encoder bit positions within 'buttons'
307
+    #define B_LE (BUTTON_LEFT   << B_I2C_BTN_OFFSET)    // The remaining normalized buttons are all read via I2C
308
+    #define B_UP (BUTTON_UP     << B_I2C_BTN_OFFSET)
309
+    #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
310
+    #define B_DW (BUTTON_DOWN   << B_I2C_BTN_OFFSET)
311
+    #define B_RI (BUTTON_RIGHT  << B_I2C_BTN_OFFSET)
416 312
 
417
-  inline void lcd_buttons_update() {}
313
+    #if BUTTON_EXISTS(ENC)                                // The pause/stop/restart button is connected to BTN_ENC when used
314
+      #define B_ST (EN_C)                                 // Map the pause/stop/resume button into its normalized functional name
315
+      #define BUTTON_CLICK() (buttons & (B_MI|B_RI|B_ST))  // Pause/stop also acts as click until a proper pause/stop is implemented.
316
+    #else
317
+      #define BUTTON_CLICK() (buttons & (B_MI|B_RI))
318
+    #endif
418 319
 
419
-#endif
320
+    // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
321
+    #define LCD_HAS_SLOW_BUTTONS
420 322
 
421
-#if ENABLED(LCD_HAS_SLOW_BUTTONS)
422
-  extern volatile uint8_t slow_buttons;
423
-#endif
323
+  #elif ENABLED(LCD_I2C_PANELOLU2)
424 324
 
425
-#if ENABLED(REPRAPWORLD_KEYPAD)
426
-  #define REPRAPWORLD_BTN_OFFSET          0 // Bit offset into buttons for shift register values
427
-
428
-  #define BLEN_REPRAPWORLD_KEYPAD_F3      0
429
-  #define BLEN_REPRAPWORLD_KEYPAD_F2      1
430
-  #define BLEN_REPRAPWORLD_KEYPAD_F1      2
431
-  #define BLEN_REPRAPWORLD_KEYPAD_DOWN    3
432
-  #define BLEN_REPRAPWORLD_KEYPAD_RIGHT   4
433
-  #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE  5
434
-  #define BLEN_REPRAPWORLD_KEYPAD_UP      6
435
-  #define BLEN_REPRAPWORLD_KEYPAD_LEFT    7
436
-
437
-  #define EN_REPRAPWORLD_KEYPAD_F1        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
438
-  #define EN_REPRAPWORLD_KEYPAD_F2        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
439
-  #define EN_REPRAPWORLD_KEYPAD_F3        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
440
-  #define EN_REPRAPWORLD_KEYPAD_DOWN      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
441
-  #define EN_REPRAPWORLD_KEYPAD_RIGHT     (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
442
-  #define EN_REPRAPWORLD_KEYPAD_MIDDLE    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
443
-  #define EN_REPRAPWORLD_KEYPAD_UP        (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
444
-  #define EN_REPRAPWORLD_KEYPAD_LEFT      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
445
-
446
-  #define RRK(B) (buttons_reprapworld_keypad & (B))
325
+    #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
326
+
327
+      #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
328
+
329
+      #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
330
+
331
+      #define BUTTON_CLICK() (buttons & B_MI)
332
+
333
+      // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
334
+      #define LCD_HAS_SLOW_BUTTONS
335
+
336
+    #endif
447 337
 
448
-  #ifdef EN_C
449
-    #define LCD_CLICKED() ((buttons & EN_C) || RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE))
450
-  #else
451
-    #define LCD_CLICKED() RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)
452 338
   #endif
453 339
 
454
-#endif // REPRAPWORLD_KEYPAD
340
+#else
341
+
342
+  // Shift register bits correspond to buttons:
343
+  #define BL_LE 7   // Left
344
+  #define BL_UP 6   // Up
345
+  #define BL_MI 5   // Middle
346
+  #define BL_DW 4   // Down
347
+  #define BL_RI 3   // Right
348
+  #define BL_ST 2   // Red Button
349
+  #define B_LE (_BV(BL_LE))
350
+  #define B_UP (_BV(BL_UP))
351
+  #define B_MI (_BV(BL_MI))
352
+  #define B_DW (_BV(BL_DW))
353
+  #define B_RI (_BV(BL_RI))
354
+  #define B_ST (_BV(BL_ST))
355
+  #define BUTTON_CLICK() (buttons & (B_MI|B_ST))
356
+
357
+#endif
455 358
 
456
-#ifndef LCD_CLICKED
359
+#ifndef BUTTON_CLICK
457 360
   #ifdef EN_C
458
-    #define LCD_CLICKED() (buttons & EN_C)
361
+    #define BUTTON_CLICK() (buttons & EN_C)
459 362
   #else
460
-    #define LCD_CLICKED() false
363
+    #define BUTTON_CLICK() false
461 364
   #endif
462 365
 #endif
463 366
 
464
-extern uint8_t lcd_status_update_delay;
465
-extern char lcd_status_message[];
367
+#define LCD_MESSAGEPGM(x)      ui.setstatusPGM(PSTR(x))
368
+#define LCD_ALERTMESSAGEPGM(x) ui.setalertstatusPGM(PSTR(x))
466 369
 
467
-#define LCD_MESSAGEPGM(x)      lcd_setstatusPGM(PSTR(x))
468
-#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatusPGM(PSTR(x))
370
+////////////////////////////////////////////
371
+//////////// MarlinUI Singleton ////////////
372
+////////////////////////////////////////////
469 373
 
470
-// For i2c define BUZZ to use lcd_buzz
471
-#if ENABLED(LCD_USE_I2C_BUZZER)
472
-  #define BUZZ(d,f) lcd_buzz(d, f)
473
-#endif
374
+class MarlinUI {
375
+public:
474 376
 
475
-#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
476
-  void lcd_reselect_last_file();
477
-#endif
377
+  MarlinUI() {
378
+    #if HAS_LCD_MENU
379
+      currentScreen = status_screen;
380
+    #endif
381
+  }
478 382
 
479
-#if HAS_GRAPHICAL_LCD
480
-  extern bool drawing_screen, first_page;
481
-#elif HAS_SPI_LCD
482
-  constexpr bool first_page = true;
483
-#endif
383
+  static inline void buzz(const long duration, const uint16_t freq) {
384
+    #if ENABLED(LCD_USE_I2C_BUZZER)
385
+      lcd.buzz(duration, freq);
386
+    #elif PIN_EXISTS(BEEPER)
387
+      buzzer.tone(duration, freq);
388
+    #else
389
+      UNUSED(duration); UNUSED(freq);
390
+    #endif
391
+  }
392
+
393
+  // LCD implementations
394
+  static void clear_lcd();
395
+  static void init_lcd();
396
+
397
+  #if HAS_SPI_LCD || ENABLED(MALYAN_LCD) || ENABLED(EXTENSIBLE_UI)
398
+    static void init();
399
+    static void update();
400
+    static bool detected();
401
+    static void setalertstatusPGM(PGM_P message);
402
+  #else // NO LCD
403
+    static inline void init() {}
404
+    static inline void update() {}
405
+    static constexpr bool detected() { return true; }
406
+    static inline void setalertstatusPGM(PGM_P message) { UNUSED(message); }
407
+  #endif
408
+
409
+  #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
410
+
411
+    #if HAS_SPI_LCD
412
+
413
+      static LCDViewAction lcdDrawUpdate;
414
+      static inline bool should_draw() { return bool(lcdDrawUpdate); }
415
+      static inline void refresh(const LCDViewAction type) { lcdDrawUpdate = type; }
416
+      static inline void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); }
417
+
418
+      #if ENABLED(SHOW_BOOTSCREEN)
419
+        static void show_bootscreen();
420
+      #endif
421
+
422
+      #if HAS_GRAPHICAL_LCD
423
+
424
+        static bool drawing_screen, first_page;
425
+
426
+        static void set_font(const MarlinFont font_nr);
427
+
428
+      #else
429
+
430
+        static constexpr bool drawing_screen = false, first_page = true;
431
+
432
+        enum HD44780CharSet : uint8_t { CHARSET_MENU, CHARSET_INFO, CHARSET_BOOT };
433
+
434
+        static void set_custom_characters(
435
+          #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
436
+            const HD44780CharSet screen_charset=CHARSET_INFO
437
+          #endif
438
+        );
439
+
440
+        #if ENABLED(LCD_PROGRESS_BAR)
441
+          static millis_t progress_bar_ms;  // Start time for the current progress bar cycle
442
+          #if PROGRESS_MSG_EXPIRE > 0
443
+            static millis_t MarlinUI::expire_status_ms; // = 0
444
+            static inline void reset_progress_bar_timeout() { expire_status_ms = 0; }
445
+          #endif
446
+          #define LCD_SET_CHARSET(C) set_custom_characters(C)
447
+        #else
448
+          #define LCD_SET_CHARSET(C) set_custom_characters()
449
+        #endif
450
+
451
+      #endif
452
+
453
+      // Status message
454
+      static char status_message[];
455
+      #if ENABLED(STATUS_MESSAGE_SCROLLING)
456
+        static uint8_t status_scroll_offset;
457
+      #endif
458
+
459
+      static uint8_t lcd_status_update_delay;
460
+      static uint8_t status_message_level;      // Higher levels block lower levels
461
+      static inline void reset_alert_level() { status_message_level = 0; }
462
+
463
+      #if HAS_PRINT_PROGRESS
464
+        #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
465
+          static uint8_t progress_bar_percent;
466
+          static void set_progress(const uint8_t progress) { progress_bar_percent = MIN(progress, 100); }
467
+        #endif
468
+        static uint8_t get_progress();
469
+      #else
470
+        static constexpr uint8_t get_progress() { return 0; }
471
+      #endif
472
+
473
+      #if HAS_LCD_CONTRAST
474
+        static int16_t contrast;
475
+        static void set_contrast(const int16_t value);
476
+        static inline void refresh_contrast() { set_contrast(contrast); }
477
+      #endif
478
+
479
+      #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
480
+        static millis_t next_filament_display;
481
+      #endif
482
+
483
+      static void quick_feedback(const bool clear_buttons=true);
484
+      static void completion_feedback(const bool good=true);
485
+
486
+      #if DISABLED(LIGHTWEIGHT_UI)
487
+        static void draw_status_message(const bool blink);
488
+      #endif
489
+
490
+      #if ENABLED(ADVANCED_PAUSE_FEATURE)
491
+        static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
492
+      #endif
493
+
494
+      static void status_screen();
495
+
496
+    #else
497
+
498
+      static void refresh();
499
+      static void reset_alert_level();
500
+
501
+    #endif
502
+
503
+    static bool get_blink();
504
+    static void kill_screen(PGM_P const lcd_msg);
505
+    static void draw_kill_screen();
506
+    static bool hasstatus();
507
+    static void setstatus(const char* const message, const bool persist=false);
508
+    static void setstatusPGM(PGM_P const message, const int8_t level=0);
509
+    static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
510
+    static void reset_status();
511
+
512
+  #else // MALYAN_LCD or NO LCD
513
+
514
+    static inline void refresh() {}
515
+    static constexpr bool hasstatus() { return false; }
516
+    static inline void setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
517
+    static inline void setstatusPGM(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
518
+    static inline void status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); }
519
+    static inline void reset_status() {}
520
+    static inline void reset_alert_level() {}
521
+
522
+  #endif
523
+
524
+  #if HAS_LCD_MENU
525
+
526
+    #if ENABLED(ENCODER_RATE_MULTIPLIER)
527
+      static bool encoderRateMultiplierEnabled;
528
+      static millis_t lastEncoderMovementMillis;
529
+      static void enable_encoder_multiplier(const bool onoff);
530
+    #endif
531
+
532
+    #if ENABLED(SCROLL_LONG_FILENAMES)
533
+      static uint8_t filename_scroll_pos, filename_scroll_max;
534
+    #endif
535
+
536
+    #if IS_KINEMATIC
537
+      static bool processing_manual_move;
538
+    #else
539
+      static constexpr bool processing_manual_move = false;
540
+    #endif
541
+
542
+    #if E_MANUAL > 1
543
+      static int8_t manual_move_e_index;
544
+    #else
545
+      static constexpr int8_t manual_move_e_index = 0;
546
+    #endif
484 547
 
485
-// LCD implementations
486
-void lcd_implementation_clear();
487
-void lcd_implementation_init();
548
+    static int16_t preheat_hotend_temp[2], preheat_bed_temp[2];
549
+    static uint8_t preheat_fan_speed[2];
488 550
 
489
-#if HAS_CHARACTER_LCD
551
+    static void manage_manual_move();
490 552
 
491
-  enum HD44780CharSet : uint8_t { CHARSET_MENU, CHARSET_INFO, CHARSET_BOOT };
553
+    static bool lcd_clicked;
554
+    static bool use_click();
492 555
 
493
-  void lcd_set_custom_characters(
494
-    #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
495
-      const HD44780CharSet screen_charset=CHARSET_INFO
556
+    static void synchronize(PGM_P const msg=NULL);
557
+
558
+    static screenFunc_t currentScreen;
559
+    static void goto_screen(const screenFunc_t screen, const uint32_t encoder=0);
560
+    static void save_previous_screen();
561
+    static void goto_previous_screen();
562
+    static void return_to_status();
563
+    static inline bool on_status_screen() { return currentScreen == status_screen; }
564
+    static inline void run_current_screen() { (*currentScreen)(); }
565
+
566
+    static inline void defer_status_screen(const bool defer) {
567
+      #if LCD_TIMEOUT_TO_STATUS
568
+        defer_return_to_status = defer;
569
+      #else
570
+        UNUSED(defer);
571
+      #endif
572
+    }
573
+
574
+    static inline void goto_previous_screen_no_defer() {
575
+      defer_status_screen(false);
576
+      goto_previous_screen();
577
+    }
578
+
579
+    #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
580
+      static void reselect_last_file();
496 581
     #endif
497
-  );
498
-  #if ENABLED(LCD_PROGRESS_BAR)
499
-    #define LCD_SET_CHARSET(C) lcd_set_custom_characters(C)
582
+
583
+    #if ENABLED(G26_MESH_VALIDATION)
584
+      static inline void chirp() { buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); }
585
+    #endif
586
+
587
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
588
+      static void ubl_plot(const uint8_t x, const uint8_t inverted_y);
589
+    #endif
590
+
591
+  #elif HAS_SPI_LCD
592
+
593
+    static constexpr bool lcd_clicked = false;
594
+    static constexpr bool on_status_screen() { return true; }
595
+    static inline void run_current_screen() { status_screen(); }
596
+
597
+  #endif
598
+
599
+  #if ENABLED(LCD_BED_LEVELING) && (ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING))
600
+    static bool wait_for_bl_move;
500 601
   #else
501
-    #define LCD_SET_CHARSET(C) lcd_set_custom_characters()
602
+    static constexpr bool wait_for_bl_move = false;
502 603
   #endif
503 604
 
504
-#endif
605
+  #if HAS_LCD_MENU && (ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION))
606
+    static bool external_control;
607
+    FORCE_INLINE static void capture() { external_control = true; }
608
+    FORCE_INLINE static void release() { external_control = false; }
609
+  #else
610
+    static constexpr bool external_control = false;
611
+  #endif
612
+
613
+  #if HAS_ENCODER_ACTION
614
+
615
+    static volatile uint8_t buttons;
616
+    #if ENABLED(LCD_HAS_SLOW_BUTTONS)
617
+      static volatile uint8_t slow_buttons;
618
+      static uint8_t read_slow_buttons();
619
+    #endif
620
+    static void update_buttons();
621
+    static inline bool button_pressed() { return BUTTON_CLICK(); }
622
+    #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
623
+      static void wait_for_release();
624
+    #endif
625
+
626
+    static uint32_t encoderPosition;
627
+
628
+    #if ENABLED(REVERSE_ENCODER_DIRECTION)
629
+      #define ENCODERBASE -1
630
+    #else
631
+      #define ENCODERBASE +1
632
+    #endif
633
+    #if ENABLED(REVERSE_MENU_DIRECTION)
634
+      static int8_t encoderDirection;
635
+      static inline void encoder_direction_normal() { encoderDirection = +(ENCODERBASE); }
636
+      static inline void encoder_direction_menus()  { encoderDirection = -(ENCODERBASE); }
637
+    #else
638
+      static constexpr int8_t encoderDirection = ENCODERBASE;
639
+      static inline void encoder_direction_normal() { }
640
+      static inline void encoder_direction_menus()  { }
641
+    #endif
642
+
643
+  #else
644
+
645
+    static inline void update_buttons() { }
646
+
647
+  #endif
648
+
649
+private:
650
+
651
+  static void _synchronize();
652
+
653
+  #if HAS_SPI_LCD
654
+    #if HAS_LCD_MENU
655
+      #if LCD_TIMEOUT_TO_STATUS
656
+        static bool defer_return_to_status;
657
+      #else
658
+        static constexpr bool defer_return_to_status = false;
659
+      #endif
660
+    #endif
661
+    static void draw_status_screen();
662
+    static void finishstatus(const bool persist);
663
+  #endif
664
+};
665
+
666
+extern MarlinUI ui;

+ 85
- 84
Marlin/src/libs/buzzer.h Ver arquivo

@@ -23,94 +23,95 @@
23 23
 
24 24
 #include "../inc/MarlinConfig.h"
25 25
 
26
-// Make a buzzer and macro
27 26
 #if ENABLED(LCD_USE_I2C_BUZZER)
28
-  // BUZZ() will be defined in ultralcd.h
29
-#elif PIN_EXISTS(BEEPER)
30
-
31
-#include "circularqueue.h"
32 27
 
33
-#define TONE_QUEUE_LENGTH 4
28
+  #define BUZZ(d,f) ui.buzz(d,f)
34 29
 
35
-/**
36
- * @brief Tone structure
37
- * @details Simple abstraction of a tone based on a duration and a frequency.
38
- */
39
-struct tone_t {
40
-  uint16_t duration;
41
-  uint16_t frequency;
42
-};
30
+#elif PIN_EXISTS(BEEPER)
43 31
 
44
-/**
45
- * @brief Buzzer class
46
- */
47
-class Buzzer {
48
-  public:
49
-
50
-    typedef struct {
51
-      tone_t   tone;
52
-      uint32_t endtime;
53
-    } state_t;
54
-
55
-  private:
56
-    static state_t state;
57
-
58
-  protected:
59
-    static CircularQueue<tone_t, TONE_QUEUE_LENGTH> buffer;
60
-
61
-    /**
62
-     * @brief Inverts the sate of a digital PIN
63
-     * @details This will invert the current state of an digital IO pin.
64
-     */
65
-    FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
66
-
67
-    /**
68
-     * @brief Turn off a digital PIN
69
-     * @details Alias of digitalWrite(PIN, LOW) using FastIO
70
-     */
71
-    FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
72
-
73
-    /**
74
-     * @brief Turn on a digital PIN
75
-     * @details Alias of digitalWrite(PIN, HIGH) using FastIO
76
-     */
77
-    FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
78
-
79
-    /**
80
-     * @brief Resets the state of the class
81
-     * @details Brings the class state to a known one.
82
-     */
83
-    static inline void reset() {
84
-      off();
85
-      state.endtime = 0;
86
-    }
87
-
88
-  public:
89
-    /**
90
-     * @brief Class constructor
91
-     */
92
-    Buzzer() {
93
-      SET_OUTPUT(BEEPER_PIN);
94
-      reset();
95
-    }
96
-
97
-    /**
98
-     * @brief Add a tone to the queue
99
-     * @details Adds a tone_t structure to the ring buffer, will block IO if the
100
-     *          queue is full waiting for one slot to get available.
101
-     *
102
-     * @param duration Duration of the tone in milliseconds
103
-     * @param frequency Frequency of the tone in hertz
104
-     */
105
-    static void tone(const uint16_t duration, const uint16_t frequency=0);
106
-
107
-    /**
108
-     * @brief Tick function
109
-     * @details This function should be called at loop, it will take care of
110
-     *          playing the tones in the queue.
111
-     */
112
-    static void tick();
113
-};
32
+  #include "circularqueue.h"
33
+
34
+  #define TONE_QUEUE_LENGTH 4
35
+
36
+  /**
37
+   * @brief Tone structure
38
+   * @details Simple abstraction of a tone based on a duration and a frequency.
39
+   */
40
+  struct tone_t {
41
+    uint16_t duration;
42
+    uint16_t frequency;
43
+  };
44
+
45
+  /**
46
+   * @brief Buzzer class
47
+   */
48
+  class Buzzer {
49
+    public:
50
+
51
+      typedef struct {
52
+        tone_t   tone;
53
+        uint32_t endtime;
54
+      } state_t;
55
+
56
+    private:
57
+      static state_t state;
58
+
59
+    protected:
60
+      static CircularQueue<tone_t, TONE_QUEUE_LENGTH> buffer;
61
+
62
+      /**
63
+       * @brief Inverts the sate of a digital PIN
64
+       * @details This will invert the current state of an digital IO pin.
65
+       */
66
+      FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
67
+
68
+      /**
69
+       * @brief Turn off a digital PIN
70
+       * @details Alias of digitalWrite(PIN, LOW) using FastIO
71
+       */
72
+      FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
73
+
74
+      /**
75
+       * @brief Turn on a digital PIN
76
+       * @details Alias of digitalWrite(PIN, HIGH) using FastIO
77
+       */
78
+      FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
79
+
80
+      /**
81
+       * @brief Resets the state of the class
82
+       * @details Brings the class state to a known one.
83
+       */
84
+      static inline void reset() {
85
+        off();
86
+        state.endtime = 0;
87
+      }
88
+
89
+    public:
90
+      /**
91
+       * @brief Class constructor
92
+       */
93
+      Buzzer() {
94
+        SET_OUTPUT(BEEPER_PIN);
95
+        reset();
96
+      }
97
+
98
+      /**
99
+       * @brief Add a tone to the queue
100
+       * @details Adds a tone_t structure to the ring buffer, will block IO if the
101
+       *          queue is full waiting for one slot to get available.
102
+       *
103
+       * @param duration Duration of the tone in milliseconds
104
+       * @param frequency Frequency of the tone in hertz
105
+       */
106
+      static void tone(const uint16_t duration, const uint16_t frequency=0);
107
+
108
+      /**
109
+       * @brief Tick function
110
+       * @details This function should be called at loop, it will take care of
111
+       *          playing the tones in the queue.
112
+       */
113
+      static void tick();
114
+  };
114 115
 
115 116
   // Provide a buzzer instance
116 117
   extern Buzzer buzzer;

+ 50
- 35
Marlin/src/module/configuration_store.cpp Ver arquivo

@@ -201,9 +201,9 @@ typedef struct SettingsDataStruct {
201 201
   //
202 202
   // ULTIPANEL
203 203
   //
204
-  int16_t lcd_preheat_hotend_temp[2],                   // M145 S0 H
205
-          lcd_preheat_bed_temp[2];                      // M145 S0 B
206
-  uint8_t lcd_preheat_fan_speed[2];                     // M145 S0 F
204
+  int16_t ui_preheat_hotend_temp[2],                    // M145 S0 H
205
+          ui_preheat_bed_temp[2];                       // M145 S0 B
206
+  uint8_t ui_preheat_fan_speed[2];                      // M145 S0 F
207 207
 
208 208
   //
209 209
   // PIDTEMP
@@ -680,15 +680,19 @@ void MarlinSettings::postprocess() {
680 680
     {
681 681
       _FIELD_TEST(lcd_preheat_hotend_temp);
682 682
 
683
-      #if !HAS_LCD_MENU
684
-        constexpr int16_t lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
685
-                          lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
686
-        constexpr uint8_t lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
683
+      #if HAS_LCD_MENU
684
+        const int16_t (&ui_preheat_hotend_temp)[2]  = ui.preheat_hotend_temp,
685
+                      (&ui_preheat_bed_temp)[2]     = ui.preheat_bed_temp;
686
+        const uint8_t (&ui_preheat_fan_speed)[2]    = ui.preheat_fan_speed;
687
+      #else
688
+        constexpr int16_t ui_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
689
+                          ui_preheat_bed_temp[2]    = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
690
+        constexpr uint8_t ui_preheat_fan_speed[2]   = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
687 691
       #endif
688 692
 
689
-      EEPROM_WRITE(lcd_preheat_hotend_temp);
690
-      EEPROM_WRITE(lcd_preheat_bed_temp);
691
-      EEPROM_WRITE(lcd_preheat_fan_speed);
693
+      EEPROM_WRITE(ui_preheat_hotend_temp);
694
+      EEPROM_WRITE(ui_preheat_bed_temp);
695
+      EEPROM_WRITE(ui_preheat_fan_speed);
692 696
     }
693 697
 
694 698
     //
@@ -717,6 +721,7 @@ void MarlinSettings::postprocess() {
717 721
     //
718 722
     {
719 723
       _FIELD_TEST(bedPID);
724
+
720 725
       #if DISABLED(PIDTEMPBED)
721 726
         const PID_t bed_pid = { DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE };
722 727
         EEPROM_WRITE(bed_pid);
@@ -731,9 +736,13 @@ void MarlinSettings::postprocess() {
731 736
     {
732 737
       _FIELD_TEST(lcd_contrast);
733 738
 
734
-      #if !HAS_LCD_CONTRAST
735
-        const int16_t lcd_contrast = 32;
736
-      #endif
739
+      const int16_t lcd_contrast =
740
+        #if HAS_LCD_CONTRAST
741
+          ui.contrast
742
+        #else
743
+          32
744
+        #endif
745
+      ;
737 746
       EEPROM_WRITE(lcd_contrast);
738 747
     }
739 748
 
@@ -1304,15 +1313,19 @@ void MarlinSettings::postprocess() {
1304 1313
       // LCD Preheat settings
1305 1314
       //
1306 1315
       {
1307
-        _FIELD_TEST(lcd_preheat_hotend_temp);
1316
+        _FIELD_TEST(ui_preheat_hotend_temp);
1308 1317
 
1309
-        #if !HAS_LCD_MENU
1310
-          int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
1311
-          uint8_t lcd_preheat_fan_speed[2];
1318
+        #if HAS_LCD_MENU
1319
+          int16_t (&ui_preheat_hotend_temp)[2]  = ui.preheat_hotend_temp,
1320
+                  (&ui_preheat_bed_temp)[2]     = ui.preheat_bed_temp;
1321
+          uint8_t (&ui_preheat_fan_speed)[2]    = ui.preheat_fan_speed;
1322
+        #else
1323
+          int16_t ui_preheat_hotend_temp[2], ui_preheat_bed_temp[2];
1324
+          uint8_t ui_preheat_fan_speed[2];
1312 1325
         #endif
1313
-        EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
1314
-        EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
1315
-        EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
1326
+        EEPROM_READ(ui_preheat_hotend_temp); // 2 floats
1327
+        EEPROM_READ(ui_preheat_bed_temp);    // 2 floats
1328
+        EEPROM_READ(ui_preheat_fan_speed);   // 2 floats
1316 1329
       }
1317 1330
 
1318 1331
       //
@@ -1366,10 +1379,12 @@ void MarlinSettings::postprocess() {
1366 1379
       //
1367 1380
       {
1368 1381
         _FIELD_TEST(lcd_contrast);
1369
-        #if !HAS_LCD_CONTRAST
1370
-          int16_t lcd_contrast;
1371
-        #endif
1382
+
1383
+        int16_t lcd_contrast;
1372 1384
         EEPROM_READ(lcd_contrast);
1385
+        #if HAS_LCD_CONTRAST
1386
+          ui.set_contrast(lcd_contrast);
1387
+        #endif
1373 1388
       }
1374 1389
 
1375 1390
       //
@@ -2028,12 +2043,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2028 2043
   #endif
2029 2044
 
2030 2045
   #if HAS_LCD_MENU
2031
-    lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
2032
-    lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
2033
-    lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
2034
-    lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
2035
-    lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
2036
-    lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
2046
+    ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
2047
+    ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
2048
+    ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
2049
+    ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
2050
+    ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
2051
+    ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
2037 2052
   #endif
2038 2053
 
2039 2054
   #if ENABLED(PIDTEMP)
@@ -2057,7 +2072,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2057 2072
   #endif
2058 2073
 
2059 2074
   #if HAS_LCD_CONTRAST
2060
-    lcd_contrast = DEFAULT_LCD_CONTRAST;
2075
+    ui.set_contrast(DEFAULT_LCD_CONTRAST);
2061 2076
   #endif
2062 2077
 
2063 2078
   #if ENABLED(FWRETRACT)
@@ -2561,12 +2576,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2561 2576
         CONFIG_ECHO_START;
2562 2577
         SERIAL_ECHOLNPGM_P(port, "Material heatup parameters:");
2563 2578
       }
2564
-      for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
2579
+      for (uint8_t i = 0; i < COUNT(ui.preheat_hotend_temp); i++) {
2565 2580
         CONFIG_ECHO_START;
2566 2581
         SERIAL_ECHOPAIR_P(port, "  M145 S", (int)i);
2567
-        SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
2568
-        SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
2569
-        SERIAL_ECHOLNPAIR_P(port, " F", int(lcd_preheat_fan_speed[i]));
2582
+        SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(ui.preheat_hotend_temp[i]));
2583
+        SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(ui.preheat_bed_temp[i]));
2584
+        SERIAL_ECHOLNPAIR_P(port, " F", int(ui.preheat_fan_speed[i]));
2570 2585
       }
2571 2586
 
2572 2587
     #endif
@@ -2625,7 +2640,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2625 2640
         SERIAL_ECHOLNPGM_P(port, "LCD Contrast:");
2626 2641
       }
2627 2642
       CONFIG_ECHO_START;
2628
-      SERIAL_ECHOLNPAIR_P(port, "  M250 C", lcd_contrast);
2643
+      SERIAL_ECHOLNPAIR_P(port, "  M250 C", ui.contrast);
2629 2644
     #endif
2630 2645
 
2631 2646
     #if ENABLED(FWRETRACT)

+ 1
- 1
Marlin/src/module/endstops.cpp Ver arquivo

@@ -337,7 +337,7 @@ void Endstops::event_handler() {
337 337
     SERIAL_EOL();
338 338
 
339 339
     #if ENABLED(ULTRA_LCD)
340
-      lcd_status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
340
+      ui.status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
341 341
     #endif
342 342
 
343 343
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)

+ 2
- 2
Marlin/src/module/motion.cpp Ver arquivo

@@ -1026,7 +1026,7 @@ void prepare_move_to_destination() {
1026 1026
       SERIAL_ECHOLNPGM(" " MSG_FIRST);
1027 1027
 
1028 1028
       #if ENABLED(ULTRA_LCD)
1029
-        lcd_status_printf_P(0, PSTR(MSG_HOME " %s%s%s " MSG_FIRST), xx ? MSG_X : "", yy ? MSG_Y : "", zz ? MSG_Z : "");
1029
+        ui.status_printf_P(0, PSTR(MSG_HOME " %s%s%s " MSG_FIRST), xx ? MSG_X : "", yy ? MSG_Y : "", zz ? MSG_Z : "");
1030 1030
       #endif
1031 1031
       return true;
1032 1032
     }
@@ -1121,7 +1121,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
1121 1121
       serialprintPGM(msg_wait_for_bed_heating);
1122 1122
       LCD_MESSAGEPGM(MSG_BED_HEATING);
1123 1123
       while (thermalManager.isHeatingBed()) safe_delay(200);
1124
-      lcd_reset_status();
1124
+      ui.reset_status();
1125 1125
     }
1126 1126
   #endif
1127 1127
 

+ 4
- 4
Marlin/src/module/probe.cpp Ver arquivo

@@ -370,15 +370,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
370 370
     BUZZ(100, 698);
371 371
 
372 372
     PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
373
-    lcd_return_to_status();       // To display the new status message
374
-    lcd_setstatusPGM(ds_str, 99);
373
+    ui.return_to_status();       // To display the new status message
374
+    ui.setstatusPGM(ds_str, 99);
375 375
     serialprintPGM(ds_str);
376 376
     SERIAL_EOL();
377 377
 
378 378
     KEEPALIVE_STATE(PAUSED_FOR_USER);
379 379
     wait_for_user = true;
380 380
     while (wait_for_user) idle();
381
-    lcd_reset_status();
381
+    ui.reset_status();
382 382
     KEEPALIVE_STATE(IN_HANDLER);
383 383
 
384 384
   #endif // PAUSE_BEFORE_DEPLOY_STOW
@@ -527,7 +527,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
527 527
       serialprintPGM(msg_wait_for_bed_heating);
528 528
       LCD_MESSAGEPGM(MSG_BED_HEATING);
529 529
       while (thermalManager.isHeatingBed()) safe_delay(200);
530
-      lcd_reset_status();
530
+      ui.reset_status();
531 531
     }
532 532
   #endif
533 533
 

+ 10
- 10
Marlin/src/module/temperature.cpp Ver arquivo

@@ -498,7 +498,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
498 498
 
499 499
         return;
500 500
       }
501
-      lcd_update();
501
+      ui.update();
502 502
     }
503 503
     disable_all_heaters();
504 504
     #if ENABLED(PRINTER_EVENT_LEDS)
@@ -2123,7 +2123,7 @@ void Temperature::isr() {
2123 2123
   // Update lcd buttons 488 times per second
2124 2124
   //
2125 2125
   static bool do_buttons;
2126
-  if ((do_buttons ^= true)) lcd_buttons_update();
2126
+  if ((do_buttons ^= true)) ui.update_buttons();
2127 2127
 
2128 2128
   /**
2129 2129
    * One sensor is sampled on every other call of the ISR.
@@ -2425,9 +2425,9 @@ void Temperature::isr() {
2425 2425
     void Temperature::set_heating_message(const uint8_t e) {
2426 2426
       const bool heating = isHeatingHotend(e);
2427 2427
       #if HOTENDS > 1
2428
-        lcd_status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
2428
+        ui.status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
2429 2429
       #else
2430
-        lcd_setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
2430
+        ui.setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
2431 2431
       #endif
2432 2432
     }
2433 2433
   #endif
@@ -2530,16 +2530,16 @@ void Temperature::isr() {
2530 2530
         }
2531 2531
 
2532 2532
         #if G26_CLICK_CAN_CANCEL
2533
-          if (click_to_cancel && use_click()) {
2533
+          if (click_to_cancel && ui.use_click()) {
2534 2534
             wait_for_heatup = false;
2535
-            lcd_quick_feedback();
2535
+            ui.quick_feedback();
2536 2536
           }
2537 2537
         #endif
2538 2538
 
2539 2539
       } while (wait_for_heatup && TEMP_CONDITIONS);
2540 2540
 
2541 2541
       if (wait_for_heatup) {
2542
-        lcd_reset_status();
2542
+        ui.reset_status();
2543 2543
         #if ENABLED(PRINTER_EVENT_LEDS)
2544 2544
           printerEventLEDs.onHeatingDone();
2545 2545
         #endif
@@ -2655,15 +2655,15 @@ void Temperature::isr() {
2655 2655
         }
2656 2656
 
2657 2657
         #if G26_CLICK_CAN_CANCEL
2658
-          if (click_to_cancel && use_click()) {
2658
+          if (click_to_cancel && ui.use_click()) {
2659 2659
             wait_for_heatup = false;
2660
-            lcd_quick_feedback();
2660
+            ui.quick_feedback();
2661 2661
           }
2662 2662
         #endif
2663 2663
 
2664 2664
       } while (wait_for_heatup && TEMP_BED_CONDITIONS);
2665 2665
 
2666
-      if (wait_for_heatup) lcd_reset_status();
2666
+      if (wait_for_heatup) ui.reset_status();
2667 2667
 
2668 2668
       #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
2669 2669
         gcode.busy_state = old_busy_state;

+ 1
- 1
Marlin/src/module/tool_change.cpp Ver arquivo

@@ -540,7 +540,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
540 540
     }
541 541
 
542 542
     #if HAS_LCD_MENU
543
-      lcd_return_to_status();
543
+      ui.return_to_status();
544 544
     #endif
545 545
 
546 546
     #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)

+ 4
- 4
Marlin/src/sd/cardreader.cpp Ver arquivo

@@ -446,7 +446,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
446 446
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
447 447
 
448 448
       getfilename(0, fname);
449
-      lcd_setstatus(longFilename[0] ? longFilename : fname);
449
+      ui.setstatus(longFilename[0] ? longFilename : fname);
450 450
       //if (longFilename[0]) {
451 451
       //  SERIAL_PROTOCOLPAIR(MSG_SD_FILE_LONG_NAME, longFilename);
452 452
       //}
@@ -470,7 +470,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
470 470
         emergency_parser.disable();
471 471
       #endif
472 472
       SERIAL_PROTOCOLLNPAIR(MSG_SD_WRITE_TO_FILE, fname);
473
-      lcd_setstatus(fname);
473
+      ui.setstatus(fname);
474 474
     }
475 475
   }
476 476
 }
@@ -963,10 +963,10 @@ void CardReader::printingHasFinished() {
963 963
       presort();
964 964
     #endif
965 965
     #if ENABLED(ULTRA_LCD) && ENABLED(LCD_SET_PROGRESS_MANUALLY)
966
-      progress_bar_percent = 0;
966
+      ui.progress_bar_percent = 0;
967 967
     #endif
968 968
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
969
-      lcd_reselect_last_file();
969
+      ui.reselect_last_file();
970 970
     #endif
971 971
   }
972 972
 }

Carregando…
Cancelar
Salvar