Browse Source

Merge pull request #6894 from thinkyhead/bf_lcd_draw_order

Fix LCD to draw after value changes
Scott Lahteine 8 years ago
parent
commit
bad432add7
4 changed files with 40 additions and 43 deletions
  1. 2
    2
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 6
    14
      Marlin/ubl_G29.cpp
  3. 24
    20
      Marlin/ultralcd.cpp
  4. 8
    7
      Marlin/ultralcd.h

+ 2
- 2
Marlin/G26_Mesh_Validation_Tool.cpp View File

@@ -191,7 +191,7 @@
191 191
     // ask the user to resolve the issue
192 192
     lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
193 193
     while (ubl_lcd_clicked()) idle();             // unless this loop happens
194
-    lcd_setstatusPGM(PSTR(""), -1);
194
+    lcd_reset_status();
195 195
 
196 196
     return true;
197 197
   }
@@ -771,7 +771,7 @@
771 771
     }
772 772
 
773 773
     #if ENABLED(ULTRA_LCD)
774
-      lcd_setstatusPGM(PSTR(""), -1);
774
+      lcd_reset_status();
775 775
       lcd_quick_feedback();
776 776
     #endif
777 777
 

+ 6
- 14
Marlin/ubl_G29.cpp View File

@@ -40,8 +40,6 @@
40 40
   extern float destination[XYZE], current_position[XYZE];
41 41
 
42 42
   void lcd_return_to_status();
43
-  bool lcd_clicked();
44
-  void lcd_implementation_clear();
45 43
   void lcd_mesh_edit_setup(float initial);
46 44
   float lcd_mesh_edit();
47 45
   void lcd_z_offset_edit_setup(float);
@@ -54,12 +52,6 @@
54 52
   #define SIZE_OF_LITTLE_RAISE 1
55 53
   #define BIG_RAISE_NOT_NEEDED 0
56 54
 
57
-  extern void lcd_status_screen();
58
-  typedef void (*screenFunc_t)();
59
-  extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0);
60
-  extern void lcd_setstatus(const char* message, const bool persist);
61
-  extern void lcd_setstatusPGM(const char* message, const int8_t level);
62
-
63 55
   int    unified_bed_leveling::g29_verbose_level,
64 56
          unified_bed_leveling::g29_phase_value,
65 57
          unified_bed_leveling::g29_repetition_cnt,
@@ -662,7 +654,7 @@
662 654
         do_blocking_move_to_z(measured_z);  // Get close to the bed, but leave some space so we don't damage anything
663 655
                                             // The user is not going to be locking in a new Z-Offset very often so
664 656
                                             // it won't be that painful to spin the Encoder Wheel for 1.5mm
665
-        lcd_implementation_clear();
657
+        lcd_refresh();
666 658
         lcd_z_offset_edit_setup(measured_z);
667 659
 
668 660
         KEEPALIVE_STATE(PAUSED_FOR_USER);
@@ -698,7 +690,7 @@
698 690
 
699 691
         state.z_offset = measured_z;
700 692
 
701
-        lcd_implementation_clear();
693
+        lcd_refresh();
702 694
         restore_ubl_active_state_and_leave();
703 695
       }
704 696
     }
@@ -940,7 +932,7 @@
940 932
 
941 933
     SERIAL_PROTOCOLPGM("Place shim under nozzle");
942 934
     LCD_MESSAGEPGM("Place shim & measure"); // TODO: Make translatable string
943
-    lcd_goto_screen(lcd_status_screen);
935
+    lcd_return_to_status();
944 936
     echo_and_take_a_measurement();
945 937
 
946 938
     const float z1 = measure_point_with_encoder();
@@ -979,7 +971,7 @@
979 971
     do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
980 972
     do_blocking_move_to_xy(lx, ly);
981 973
 
982
-    lcd_goto_screen(lcd_status_screen);
974
+    lcd_return_to_status();
983 975
     mesh_index_pair location;
984 976
     do {
985 977
       location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_NOZZLE_AS_REFERENCE, NULL, false);
@@ -1456,7 +1448,7 @@
1456 1448
 
1457 1449
       if (do_ubl_mesh_map) display_map(g29_map_type);  // show the user which point is being adjusted
1458 1450
 
1459
-      lcd_implementation_clear();
1451
+      lcd_refresh();
1460 1452
 
1461 1453
       lcd_mesh_edit_setup(new_z);
1462 1454
 
@@ -1497,7 +1489,7 @@
1497 1489
 
1498 1490
       z_values[location.x_index][location.y_index] = new_z;
1499 1491
 
1500
-      lcd_implementation_clear();
1492
+      lcd_refresh();
1501 1493
 
1502 1494
     } while (location.x_index >= 0 && --g29_repetition_cnt > 0);
1503 1495
 

+ 24
- 20
Marlin/ultralcd.cpp View File

@@ -236,23 +236,23 @@ uint16_t max_display_update_time = 0;
236 236
    *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
237 237
    *
238 238
    */
239
-  #define _MENU_ITEM_PART_1(TYPE, LABEL, ...) \
239
+  #define _MENU_ITEM_PART_1(TYPE, ...) \
240 240
     if (_menuLineNr == _thisItemNr) { \
241
-      if (lcdDrawUpdate) \
242
-        lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
243 241
       if (lcd_clicked && encoderLine == _thisItemNr) {
244 242
 
245
-  #define _MENU_ITEM_PART_2(TYPE, ...) \
243
+  #define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \
246 244
         menu_action_ ## TYPE(__VA_ARGS__); \
247 245
         if (screen_changed) return; \
248 246
       } \
247
+      if (lcdDrawUpdate) \
248
+        lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
249 249
     } \
250 250
     ++_thisItemNr
251 251
 
252 252
   #define MENU_ITEM(TYPE, LABEL, ...) do { \
253 253
       _skipStatic = false; \
254
-      _MENU_ITEM_PART_1(TYPE, LABEL, ## __VA_ARGS__); \
255
-      _MENU_ITEM_PART_2(TYPE, ## __VA_ARGS__); \
254
+      _MENU_ITEM_PART_1(TYPE, ## __VA_ARGS__); \
255
+      _MENU_ITEM_PART_2(TYPE, LABEL, ## __VA_ARGS__); \
256 256
     } while(0)
257 257
 
258 258
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
@@ -281,10 +281,10 @@ uint16_t max_display_update_time = 0;
281 281
      * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
282 282
      */
283 283
     #define MENU_MULTIPLIER_ITEM(type, label, ...) do { \
284
-        _MENU_ITEM_PART_1(type, label, ## __VA_ARGS__); \
284
+        _MENU_ITEM_PART_1(type, ## __VA_ARGS__); \
285 285
         encoderRateMultiplierEnabled = true; \
286 286
         lastEncoderMovementMillis = 0; \
287
-        _MENU_ITEM_PART_2(type, ## __VA_ARGS__); \
287
+        _MENU_ITEM_PART_2(type, label, ## __VA_ARGS__); \
288 288
       } while(0)
289 289
 
290 290
   #else // !ENCODER_RATE_MULTIPLIER
@@ -581,8 +581,6 @@ void lcd_status_screen() {
581 581
     #endif
582 582
   #endif // LCD_PROGRESS_BAR
583 583
 
584
-  lcd_implementation_status_screen();
585
-
586 584
   #if ENABLED(ULTIPANEL)
587 585
 
588 586
     if (lcd_clicked) {
@@ -595,6 +593,7 @@ void lcd_status_screen() {
595 593
         #endif
596 594
       );
597 595
       lcd_goto_screen(lcd_main_menu);
596
+      return;
598 597
     }
599 598
 
600 599
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
@@ -623,8 +622,12 @@ void lcd_status_screen() {
623 622
     feedrate_percentage = constrain(feedrate_percentage, 10, 999);
624 623
 
625 624
   #endif // ULTIPANEL
625
+
626
+  lcd_implementation_status_screen();
626 627
 }
627 628
 
629
+void lcd_reset_status() { lcd_setstatusPGM(PSTR(""), -1); }
630
+
628 631
 /**
629 632
  *
630 633
  * draw the kill screen
@@ -632,7 +635,7 @@ void lcd_status_screen() {
632 635
  */
633 636
 void kill_screen(const char* lcd_msg) {
634 637
   lcd_init();
635
-  lcd_setalertstatuspgm(lcd_msg);
638
+  lcd_setalertstatusPGM(lcd_msg);
636 639
   #if ENABLED(DOGLCD)
637 640
     u8g.firstPage();
638 641
     do {
@@ -704,7 +707,7 @@ void kill_screen(const char* lcd_msg) {
704 707
         card.startFileprint();
705 708
         print_job_timer.start();
706 709
       #endif
707
-      lcd_setstatusPGM(PSTR(""), -1);
710
+      lcd_reset_status();
708 711
     }
709 712
 
710 713
     void lcd_sdcard_stop() {
@@ -717,7 +720,8 @@ void kill_screen(const char* lcd_msg) {
717 720
         for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
718 721
       #endif
719 722
       wait_for_heatup = false;
720
-      lcd_setstatusPGM(PSTR(MSG_PRINT_PAUSED), -1);
723
+      lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
724
+      lcd_return_to_status();
721 725
     }
722 726
 
723 727
   #endif // SDSUPPORT
@@ -1764,7 +1768,7 @@ void kill_screen(const char* lcd_msg) {
1764 1768
       MENU_BACK(MSG_UBL_EDIT_MESH_MENU);
1765 1769
       MENU_ITEM_EDIT(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9);
1766 1770
       MENU_ITEM(function, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_adjust_height_cmd);
1767
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1771
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1768 1772
       END_MENU();
1769 1773
     }
1770 1774
 
@@ -1778,7 +1782,7 @@ void kill_screen(const char* lcd_msg) {
1778 1782
       MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R T"));
1779 1783
       MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
1780 1784
       MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_height_adjust_menu);
1781
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1785
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1782 1786
       END_MENU();
1783 1787
     }
1784 1788
 
@@ -1812,7 +1816,7 @@ void kill_screen(const char* lcd_msg) {
1812 1816
         MENU_ITEM(gcode, MSG_UBL_VALIDATE_ABS_MESH, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
1813 1817
       #endif
1814 1818
       MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
1815
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1819
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1816 1820
       END_MENU();
1817 1821
     }
1818 1822
 
@@ -1844,7 +1848,7 @@ void kill_screen(const char* lcd_msg) {
1844 1848
       MENU_BACK(MSG_UBL_TOOLS);
1845 1849
       MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
1846 1850
       MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
1847
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1851
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1848 1852
       END_MENU();
1849 1853
     }
1850 1854
 
@@ -1876,7 +1880,7 @@ void kill_screen(const char* lcd_msg) {
1876 1880
       MENU_ITEM(function, MSG_UBL_FILLIN_MESH, _lcd_ubl_fillin_amount_cmd);
1877 1881
       MENU_ITEM(function, MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd);
1878 1882
       MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
1879
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1883
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1880 1884
       END_MENU();
1881 1885
     }
1882 1886
 
@@ -1928,7 +1932,7 @@ void kill_screen(const char* lcd_msg) {
1928 1932
       MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
1929 1933
       MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
1930 1934
       MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
1931
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1935
+      MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
1932 1936
       END_MENU();
1933 1937
     }
1934 1938
 
@@ -4158,7 +4162,7 @@ void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) {
4158 4162
   lcd_finishstatus(level > 0);
4159 4163
 }
4160 4164
 
4161
-void lcd_setalertstatuspgm(const char * const message) {
4165
+void lcd_setalertstatusPGM(const char * const message) {
4162 4166
   lcd_setstatusPGM(message, 1);
4163 4167
   #if ENABLED(ULTIPANEL)
4164 4168
     lcd_return_to_status();

+ 8
- 7
Marlin/ultralcd.h View File

@@ -39,8 +39,8 @@
39 39
   bool lcd_hasstatus();
40 40
   void lcd_setstatus(const char* message, const bool persist=false);
41 41
   void lcd_setstatusPGM(const char* message, const int8_t level=0);
42
+  void lcd_setalertstatusPGM(const char* message);
42 43
   void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...);
43
-  void lcd_setalertstatuspgm(const char* message);
44 44
   void lcd_reset_alert_level();
45 45
   void lcd_kill_screen();
46 46
   void kill_screen(const char* lcd_msg);
@@ -64,9 +64,6 @@
64 64
     void bootscreen();
65 65
   #endif
66 66
 
67
-  #define LCD_MESSAGEPGM(x) lcd_setstatusPGM(PSTR(x))
68
-  #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
69
-
70 67
   #define LCD_UPDATE_INTERVAL 100
71 68
 
72 69
   #if ENABLED(ULTIPANEL)
@@ -152,22 +149,26 @@
152 149
   #endif
153 150
 
154 151
 #else // no LCD
152
+
155 153
   inline void lcd_update() {}
156 154
   inline void lcd_init() {}
157 155
   inline bool lcd_hasstatus() { return false; }
158 156
   inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
159 157
   inline void lcd_setstatusPGM(const char* const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
158
+  inline void lcd_setalertstatusPGM(const char* message) { UNUSED(message); }
160 159
   inline void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { UNUSED(level); UNUSED(fmt); }
161 160
   inline void lcd_buttons_update() {}
162 161
   inline void lcd_reset_alert_level() {}
163 162
   inline bool lcd_detected() { return true; }
164 163
   inline void lcd_refresh() {}
165 164
 
166
-  #define LCD_MESSAGEPGM(x) NOOP
167
-  #define LCD_ALERTMESSAGEPGM(x) NOOP
168
-
169 165
 #endif // ULTRA_LCD
170 166
 
167
+#define LCD_MESSAGEPGM(x)      lcd_setstatusPGM(PSTR(x))
168
+#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatusPGM(PSTR(x))
169
+
170
+void lcd_reset_status();
171
+
171 172
 #if ENABLED(AUTO_BED_LEVELING_UBL)
172 173
   void lcd_mesh_edit_setup(float initial);
173 174
   float lcd_mesh_edit();

Loading…
Cancel
Save