瀏覽代碼

Merge pull request #3579 from thinkyhead/rc_fix_dogm_and_mbl_menus

Fix menu redraw for DOGLCD, improve MBL
Scott Lahteine 9 年之前
父節點
當前提交
6fac4d9211
共有 4 個檔案被更改,包括 111 行新增88 行删除
  1. 1
    1
      Marlin/dogm_lcd_implementation.h
  2. 3
    0
      Marlin/language_en.h
  3. 106
    86
      Marlin/ultralcd.cpp
  4. 1
    1
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 1
- 1
Marlin/dogm_lcd_implementation.h 查看文件

517
 #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
517
 #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
518
 #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
518
 #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
519
 
519
 
520
-void lcd_implementation_drawedit(const char* pstr, const char* value) {
520
+void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
521
   uint8_t rows = 1;
521
   uint8_t rows = 1;
522
   uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
522
   uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
523
   uint8_t vallen = lcd_strlen(value);
523
   uint8_t vallen = lcd_strlen(value);

+ 3
- 0
Marlin/language_en.h 查看文件

70
 #ifndef MSG_LEVEL_BED_WAITING
70
 #ifndef MSG_LEVEL_BED_WAITING
71
   #define MSG_LEVEL_BED_WAITING               "Click to Begin"
71
   #define MSG_LEVEL_BED_WAITING               "Click to Begin"
72
 #endif
72
 #endif
73
+#ifndef MSG_LEVEL_BED_NEXT_POINT
74
+  #define MSG_LEVEL_BED_NEXT_POINT            "Next Point"
75
+#endif
73
 #ifndef MSG_LEVEL_BED_DONE
76
 #ifndef MSG_LEVEL_BED_DONE
74
   #define MSG_LEVEL_BED_DONE                  "Leveling Done!"
77
   #define MSG_LEVEL_BED_DONE                  "Leveling Done!"
75
 #endif
78
 #endif

+ 106
- 86
Marlin/ultralcd.cpp 查看文件

262
   uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
262
   uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
263
   millis_t next_button_update_ms;
263
   millis_t next_button_update_ms;
264
   uint8_t lastEncoderBits;
264
   uint8_t lastEncoderBits;
265
-  uint32_t encoderPosition;
265
+  uint32_t encoderPosition, nextEncoderPosition;
266
   #if PIN_EXISTS(SD_DETECT)
266
   #if PIN_EXISTS(SD_DETECT)
267
     uint8_t lcd_sd_status;
267
     uint8_t lcd_sd_status;
268
   #endif
268
   #endif
277
 } menuPosition;
277
 } menuPosition;
278
 
278
 
279
 menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
279
 menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
280
+menuFunc_t nextMenu = NULL; // the next menu handler to activate
280
 
281
 
281
 menuPosition menu_history[10];
282
 menuPosition menu_history[10];
282
 uint8_t menu_history_depth = 0;
283
 uint8_t menu_history_depth = 0;
311
  * Remembers the previous position
312
  * Remembers the previous position
312
  */
313
  */
313
 static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
314
 static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
314
-  if (currentMenu != menu) {
315
-    currentMenu = menu;
316
-    lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
315
+  if (currentMenu != menu && nextMenu != menu) {
316
+    nextMenu = menu;
317
+    nextEncoderPosition = encoder;
317
     #if ENABLED(NEWPANEL)
318
     #if ENABLED(NEWPANEL)
318
-      encoderPosition = encoder;
319
       if (feedback) lcd_quick_feedback();
319
       if (feedback) lcd_quick_feedback();
320
     #endif
320
     #endif
321
     if (menu == lcd_status_screen) {
321
     if (menu == lcd_status_screen) {
322
       defer_return_to_status = false;
322
       defer_return_to_status = false;
323
       menu_history_depth = 0;
323
       menu_history_depth = 0;
324
     }
324
     }
325
-    #if ENABLED(LCD_PROGRESS_BAR)
326
-      // For LCD_PROGRESS_BAR re-initialize custom characters
327
-      lcd_set_custom_characters(menu == lcd_status_screen);
328
-    #endif
329
   }
325
   }
330
 }
326
 }
331
 
327
 
891
    *
887
    *
892
    */
888
    */
893
 
889
 
894
-  static int _lcd_level_bed_position;
895
-  static bool mbl_wait_for_move = false;
890
+  static uint8_t _lcd_level_bed_position;
896
 
891
 
897
   // Utility to go to the next mesh point
892
   // Utility to go to the next mesh point
898
   // A raise is added between points if MIN_Z_HEIGHT_FOR_HOMING is in use
893
   // A raise is added between points if MIN_Z_HEIGHT_FOR_HOMING is in use
899
   // Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
894
   // Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
900
   // Z position will be restored with the final action, a G28
895
   // Z position will be restored with the final action, a G28
901
   inline void _mbl_goto_xy(float x, float y) {
896
   inline void _mbl_goto_xy(float x, float y) {
902
-    mbl_wait_for_move = true;
903
     current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
897
     current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
904
       #if MIN_Z_HEIGHT_FOR_HOMING > 0
898
       #if MIN_Z_HEIGHT_FOR_HOMING > 0
905
         + MIN_Z_HEIGHT_FOR_HOMING
899
         + MIN_Z_HEIGHT_FOR_HOMING
914
       line_to_current(Z_AXIS);
908
       line_to_current(Z_AXIS);
915
     #endif
909
     #endif
916
     st_synchronize();
910
     st_synchronize();
917
-    mbl_wait_for_move = false;
911
+  }
912
+
913
+  static void _lcd_level_goto_next_point();
914
+
915
+  static void _lcd_level_bed_done() {
916
+    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
918
   }
917
   }
919
 
918
 
920
   /**
919
   /**
921
-   * 5. MBL Wait for controller movement and clicks:
922
-   *        - Movement adjusts the Z axis
923
-   *        - Click saves the Z, goes to the next mesh point
920
+   * Step 7: Get the Z coordinate, then goto next point or exit
924
    */
921
    */
925
-  static void _lcd_level_bed_procedure() {
926
-    // Menu handlers may be called in a re-entrant fashion
927
-    // if they call st_synchronize or plan_buffer_line. So
928
-    // while waiting for a move we just ignore new input.
929
-    if (mbl_wait_for_move) {
930
-      lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
931
-      return;
932
-    }
933
-
922
+  static void _lcd_level_bed_get_z() {
934
     ENCODER_DIRECTION_NORMAL();
923
     ENCODER_DIRECTION_NORMAL();
935
 
924
 
936
     // Encoder wheel adjusts the Z position
925
     // Encoder wheel adjusts the Z position
937
     if (encoderPosition && movesplanned() <= 3) {
926
     if (encoderPosition && movesplanned() <= 3) {
938
       refresh_cmd_timeout();
927
       refresh_cmd_timeout();
939
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
928
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
940
-      if (min_software_endstops) NOLESS(current_position[Z_AXIS], Z_MIN_POS);
941
-      if (max_software_endstops) NOMORE(current_position[Z_AXIS], Z_MAX_POS);
942
-      encoderPosition = 0;
929
+      NOLESS(current_position[Z_AXIS], 0);
930
+      NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
943
       line_to_current(Z_AXIS);
931
       line_to_current(Z_AXIS);
944
-      lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
945
     }
932
     }
933
+    encoderPosition = 0;
946
 
934
 
947
-    // Update on first display, then only on updates to Z position
948
-    if (lcdDrawUpdate) {
949
-      float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
950
-      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
951
-    }
952
-
953
-    // We want subsequent calls, but don't force redraw
954
-    // Set here so it can be overridden by lcd_return_to_status below
955
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
956
-
957
-    // Click sets the current Z and moves to the next position
958
     static bool debounce_click = false;
935
     static bool debounce_click = false;
959
     if (LCD_CLICKED) {
936
     if (LCD_CLICKED) {
960
       if (!debounce_click) {
937
       if (!debounce_click) {
961
         debounce_click = true; // ignore multiple "clicks" in a row
938
         debounce_click = true; // ignore multiple "clicks" in a row
962
         mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
939
         mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
963
         if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
940
         if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
964
-          lcd_return_to_status();
965
-          LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
966
-          #if HAS_BUZZER
967
-            buzz(200, 659);
968
-            buzz(200, 698);
969
-          #endif
941
+          lcd_goto_menu(_lcd_level_bed_done, true);
942
+
970
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
943
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
971
             #if MIN_Z_HEIGHT_FOR_HOMING > 0
944
             #if MIN_Z_HEIGHT_FOR_HOMING > 0
972
               + MIN_Z_HEIGHT_FOR_HOMING
945
               + MIN_Z_HEIGHT_FOR_HOMING
974
           ;
947
           ;
975
           line_to_current(Z_AXIS);
948
           line_to_current(Z_AXIS);
976
           st_synchronize();
949
           st_synchronize();
950
+
977
           mbl.active = true;
951
           mbl.active = true;
978
           enqueue_and_echo_commands_P(PSTR("G28"));
952
           enqueue_and_echo_commands_P(PSTR("G28"));
953
+          lcd_return_to_status();
954
+          //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
955
+          #if HAS_BUZZER
956
+            buzz(200, 659);
957
+            buzz(200, 698);
958
+          #endif
979
         }
959
         }
980
         else {
960
         else {
981
-          #if ENABLED(NEWPANEL)
982
-            lcd_quick_feedback();
983
-          #endif
984
-          int ix, iy;
985
-          mbl.zigzag(_lcd_level_bed_position, ix, iy);
986
-          _mbl_goto_xy(mbl.get_x(ix), mbl.get_y(iy));
987
-          encoderPosition = 0;
961
+          lcd_goto_menu(_lcd_level_goto_next_point, true);
988
         }
962
         }
989
       }
963
       }
990
     }
964
     }
991
     else {
965
     else {
992
       debounce_click = false;
966
       debounce_click = false;
993
     }
967
     }
968
+
969
+    // Update on first display, then only on updates to Z position
970
+    // Show message above on clicks instead
971
+    if (lcdDrawUpdate) {
972
+      float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
973
+      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
974
+    }
975
+
994
   }
976
   }
995
 
977
 
996
   /**
978
   /**
997
-   * 4. MBL Display "Click to Begin", wait for click
998
-   *        Move to the first probe position
979
+   * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
980
+   */
981
+  static void _lcd_level_bed_moving() {
982
+    if (lcdDrawUpdate) {
983
+      char msg[10];
984
+      sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
985
+      lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
986
+    }
987
+  }
988
+
989
+  /**
990
+   * Step 5: Initiate a move to the next point
991
+   */
992
+  static void _lcd_level_goto_next_point() {
993
+    // Set the menu to display ahead of blocking call
994
+    lcd_goto_menu(_lcd_level_bed_moving);
995
+
996
+    // _mbl_goto_xy runs the menu loop until the move is done
997
+    int ix, iy;
998
+    mbl.zigzag(_lcd_level_bed_position, ix, iy);
999
+    _mbl_goto_xy(mbl.get_x(ix), mbl.get_y(iy));
1000
+
1001
+    // After the blocking function returns, change menus
1002
+    lcd_goto_menu(_lcd_level_bed_get_z);
1003
+  }
1004
+
1005
+  /**
1006
+   * Step 4: Display "Click to Begin", wait for click
1007
+   *         Move to the first probe position
999
    */
1008
    */
1000
   static void _lcd_level_bed_homing_done() {
1009
   static void _lcd_level_bed_homing_done() {
1001
-    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING), NULL);
1002
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
1003
-    if (mbl_wait_for_move) return;
1010
+    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1004
     if (LCD_CLICKED) {
1011
     if (LCD_CLICKED) {
1012
+      _lcd_level_bed_position = 0;
1005
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1013
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1006
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1014
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1007
-      _mbl_goto_xy(MESH_MIN_X, MESH_MIN_Y);
1008
-      _lcd_level_bed_position = 0;
1009
-      lcd_goto_menu(_lcd_level_bed_procedure, true);
1015
+      lcd_goto_menu(_lcd_level_goto_next_point, true);
1010
     }
1016
     }
1011
   }
1017
   }
1012
 
1018
 
1013
   /**
1019
   /**
1014
-   * 3. MBL Display "Hoing XYZ" - Wait for homing to finish
1020
+   * Step 3: Display "Homing XYZ" - Wait for homing to finish
1015
    */
1021
    */
1016
   static void _lcd_level_bed_homing() {
1022
   static void _lcd_level_bed_homing() {
1017
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
1023
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
1018
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
1019
-    if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])
1024
+    if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
1020
       lcd_goto_menu(_lcd_level_bed_homing_done);
1025
       lcd_goto_menu(_lcd_level_bed_homing_done);
1026
+    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW; // counts as a draw flag during graphical loop
1021
   }
1027
   }
1022
 
1028
 
1023
   /**
1029
   /**
1024
-   * 2. MBL Continue Bed Leveling...
1030
+   * Step 2: Continue Bed Leveling...
1025
    */
1031
    */
1026
   static void _lcd_level_bed_continue() {
1032
   static void _lcd_level_bed_continue() {
1027
     defer_return_to_status = true;
1033
     defer_return_to_status = true;
1028
-    axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
1034
+    axis_homed[X_AXIS] = axis_homed[Y_AXIS] = axis_homed[Z_AXIS] = false;
1029
     mbl.reset();
1035
     mbl.reset();
1030
     enqueue_and_echo_commands_P(PSTR("G28"));
1036
     enqueue_and_echo_commands_P(PSTR("G28"));
1031
     lcd_goto_menu(_lcd_level_bed_homing);
1037
     lcd_goto_menu(_lcd_level_bed_homing);
1032
   }
1038
   }
1033
 
1039
 
1034
   /**
1040
   /**
1035
-   * 1. MBL entry-point: "Cancel" or "Level Bed"
1041
+   * Step 1: MBL entry-point: "Cancel" or "Level Bed"
1036
    */
1042
    */
1037
   static void lcd_level_bed() {
1043
   static void lcd_level_bed() {
1038
     START_MENU();
1044
     START_MENU();
1072
   // Level Bed
1078
   // Level Bed
1073
   //
1079
   //
1074
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
1080
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
1075
-    if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])
1076
-      MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29"));
1081
+    MENU_ITEM(gcode, MSG_LEVEL_BED,
1082
+      axis_homed[X_AXIS] && axis_homed[Y_AXIS] ? PSTR("G29") : PSTR("G28\nG29")
1083
+    );
1077
   #elif ENABLED(MANUAL_BED_LEVELING)
1084
   #elif ENABLED(MANUAL_BED_LEVELING)
1078
     MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
1085
     MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
1079
   #endif
1086
   #endif
1157
     current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1164
     current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1158
     if (min_software_endstops) NOLESS(current_position[axis], min);
1165
     if (min_software_endstops) NOLESS(current_position[axis], min);
1159
     if (max_software_endstops) NOMORE(current_position[axis], max);
1166
     if (max_software_endstops) NOMORE(current_position[axis], max);
1160
-    encoderPosition = 0;
1161
     line_to_current(axis);
1167
     line_to_current(axis);
1162
-    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1163
   }
1168
   }
1169
+  encoderPosition = 0;
1164
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1170
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1165
   if (LCD_CLICKED) lcd_goto_previous_menu(true);
1171
   if (LCD_CLICKED) lcd_goto_previous_menu(true);
1166
 }
1172
 }
1186
   #endif
1192
   #endif
1187
   if (encoderPosition && movesplanned() <= 3) {
1193
   if (encoderPosition && movesplanned() <= 3) {
1188
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1194
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1189
-    encoderPosition = 0;
1190
     line_to_current(E_AXIS);
1195
     line_to_current(E_AXIS);
1191
-    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1192
   }
1196
   }
1197
+  encoderPosition = 0;
1193
   if (lcdDrawUpdate) {
1198
   if (lcdDrawUpdate) {
1194
     PGM_P pos_label;
1199
     PGM_P pos_label;
1195
     #if EXTRUDERS == 1
1200
     #if EXTRUDERS == 1
1342
 
1347
 
1343
   static void _lcd_autotune(int e) {
1348
   static void _lcd_autotune(int e) {
1344
     char cmd[30];
1349
     char cmd[30];
1345
-    sprintf_P(cmd, PSTR("M303 U1 E%d S%d"), e,
1350
+    sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
1346
       #if HAS_PID_FOR_BOTH
1351
       #if HAS_PID_FOR_BOTH
1347
         e < 0 ? autotune_temp_bed : autotune_temp[e]
1352
         e < 0 ? autotune_temp_bed : autotune_temp[e]
1348
       #elif ENABLED(PIDTEMPBED)
1353
       #elif ENABLED(PIDTEMPBED)
1678
         lcd_contrast &= 0x3F;
1683
         lcd_contrast &= 0x3F;
1679
       #endif
1684
       #endif
1680
       encoderPosition = 0;
1685
       encoderPosition = 0;
1681
-      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1682
       u8g.setContrast(lcd_contrast);
1686
       u8g.setContrast(lcd_contrast);
1683
     }
1687
     }
1684
     if (lcdDrawUpdate) {
1688
     if (lcdDrawUpdate) {
1829
   } \
1833
   } \
1830
   static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
1834
   static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
1831
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1835
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1832
-    currentMenu = menu_edit_ ## _name; \
1836
+    lcd_goto_menu(menu_edit_ ## _name); \
1833
   }\
1837
   }\
1834
   static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
1838
   static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
1835
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1839
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1836
-    currentMenu = menu_edit_callback_ ## _name; \
1837
     callbackFunc = callback; \
1840
     callbackFunc = callback; \
1841
+    lcd_goto_menu(menu_edit_callback_ ## _name); \
1838
   }
1842
   }
1839
 menu_edit_type(int, int3, itostr3, 1);
1843
 menu_edit_type(int, int3, itostr3, 1);
1840
 menu_edit_type(float, float3, ftostr3, 1);
1844
 menu_edit_type(float, float3, ftostr3, 1);
1900
 #endif
1904
 #endif
1901
 
1905
 
1902
 void lcd_quick_feedback() {
1906
 void lcd_quick_feedback() {
1903
-  lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
1904
   next_button_update_ms = millis() + 500;
1907
   next_button_update_ms = millis() + 500;
1905
 
1908
 
1906
   #if ENABLED(LCD_USE_I2C_BUZZER)
1909
   #if ENABLED(LCD_USE_I2C_BUZZER)
2067
  *   - Act on RepRap World keypad input
2070
  *   - Act on RepRap World keypad input
2068
  *   - Update the encoder position
2071
  *   - Update the encoder position
2069
  *   - Apply acceleration to the encoder position
2072
  *   - Apply acceleration to the encoder position
2070
- *   - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT on controller events
2073
+ *   - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NOW on controller events
2071
  *   - Reset the Info Screen timeout if there's any input
2074
  *   - Reset the Info Screen timeout if there's any input
2072
  *   - Update status indicators, if any
2075
  *   - Update status indicators, if any
2073
  *
2076
  *
2075
  *   - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE
2078
  *   - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE
2076
  *   - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE
2079
  *   - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE
2077
  *   - Call the menu handler. Menu handlers should do the following:
2080
  *   - Call the menu handler. Menu handlers should do the following:
2078
- *     - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW
2081
+ *     - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW and draw the value
2082
+ *       (Encoder events automatically set lcdDrawUpdate for you.)
2079
  *     - if (lcdDrawUpdate) { redraw }
2083
  *     - if (lcdDrawUpdate) { redraw }
2080
  *     - Before exiting the handler set lcdDrawUpdate to:
2084
  *     - Before exiting the handler set lcdDrawUpdate to:
2081
- *       - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE for no callbacks until the next controller event.
2082
  *       - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
2085
  *       - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
2083
- *       - LCDVIEW_CALL_NO_REDRAW for a callback with no forced redraw on the next loop.
2084
- *     - NOTE: For some displays, the menu handler may be called 2 or more times per loop.
2086
+ *       - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE to keep drawingm but only in this loop.
2087
+ *       - LCDVIEW_REDRAW_NEXT to keep drawing and draw on the next loop also.
2088
+ *       - LCDVIEW_CALL_NO_REDRAW to keep drawing (or start drawing) with no redraw on the next loop.
2089
+ *     - NOTE: For graphical displays menu handlers may be called 2 or more times per loop,
2090
+ *             so don't change lcdDrawUpdate without considering this.
2085
  *
2091
  *
2086
  *   After the menu handler callback runs (or not):
2092
  *   After the menu handler callback runs (or not):
2093
+ *   - Set lcdDrawUpdate to nextLcdDrawUpdate (usually unchanged)
2087
  *   - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
2094
  *   - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
2088
- *   - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually)
2095
+ *   - Transition lcdDrawUpdate to the next state
2089
  *
2096
  *
2090
  * No worries. This function is only called from the main thread.
2097
  * No worries. This function is only called from the main thread.
2091
  */
2098
  */
2217
       }
2224
       }
2218
 
2225
 
2219
       #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2226
       #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2220
-        bool blink = lcd_blink();
2227
+        static int8_t dot_color = 0;
2228
+        dot_color = 1 - dot_color;
2221
         u8g.firstPage();
2229
         u8g.firstPage();
2222
         do {
2230
         do {
2223
           lcd_setFont(FONT_MENU);
2231
           lcd_setFont(FONT_MENU);
2224
           u8g.setPrintPos(125, 0);
2232
           u8g.setPrintPos(125, 0);
2225
-          u8g.setColorIndex(blink ? 1 : 0); // Set color for the alive dot
2233
+          u8g.setColorIndex(dot_color); // Set color for the alive dot
2226
           u8g.drawPixel(127, 63); // draw alive dot
2234
           u8g.drawPixel(127, 63); // draw alive dot
2227
           u8g.setColorIndex(1); // black on white
2235
           u8g.setColorIndex(1); // black on white
2228
           (*currentMenu)();
2236
           (*currentMenu)();
2242
 
2250
 
2243
     #endif // ULTIPANEL
2251
     #endif // ULTIPANEL
2244
 
2252
 
2253
+    // If a new menu was set, update the pointer, set to clear & redraw
2254
+    if (nextMenu) {
2255
+      currentMenu = nextMenu;
2256
+      encoderPosition = nextEncoderPosition;
2257
+      nextMenu = NULL;
2258
+      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2259
+      #if ENABLED(LCD_PROGRESS_BAR)
2260
+        // For LCD_PROGRESS_BAR re-initialize custom characters
2261
+        lcd_set_custom_characters(currentMenu == lcd_status_screen);
2262
+      #endif
2263
+    }
2264
+
2245
     switch (lcdDrawUpdate) {
2265
     switch (lcdDrawUpdate) {
2246
       case LCDVIEW_CLEAR_CALL_REDRAW:
2266
       case LCDVIEW_CLEAR_CALL_REDRAW:
2247
         lcd_implementation_clear();
2267
         lcd_implementation_clear();

+ 1
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h 查看文件

873
 #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5(*(data)))
873
 #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5(*(data)))
874
 #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
874
 #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
875
 
875
 
876
-void lcd_implementation_drawedit(const char* pstr, const char* value) {
876
+void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
877
   lcd.setCursor(1, 1);
877
   lcd.setCursor(1, 1);
878
   lcd_printPGM(pstr);
878
   lcd_printPGM(pstr);
879
   if (value != NULL) {
879
   if (value != NULL) {

Loading…
取消
儲存