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

+ 6
- 14
Marlin/ubl_G29.cpp View File

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

+ 24
- 20
Marlin/ultralcd.cpp View File

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

+ 8
- 7
Marlin/ultralcd.h View File

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

Loading…
Cancel
Save