Переглянути джерело

Merge pull request #11075 from thinkyhead/bf2_value_editing

[2.0.x] Fix value editing (with callback)
Scott Lahteine 6 роки тому
джерело
коміт
a5c11bf578
Аккаунт користувача з таким Email не знайдено
1 змінених файлів з 10 додано та 12 видалено
  1. 10
    12
      Marlin/src/lcd/ultralcd.cpp

+ 10
- 12
Marlin/src/lcd/ultralcd.cpp Переглянути файл

@@ -258,7 +258,7 @@ uint16_t max_display_update_time = 0;
258 258
     void menu_edit_callback_ ## _name(); \
259 259
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \
260 260
     void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue); \
261
-    void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback, const bool live=false); \
261
+    void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback=NULL, const bool live=false); \
262 262
     typedef void _name##_void
263 263
 
264 264
   DECLARE_MENU_EDIT_TYPE(int16_t, int3);
@@ -1407,7 +1407,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
1407 1407
     // Leveling Fade Height
1408 1408
     //
1409 1409
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(SLIM_LCD_MENUS)
1410
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
1410
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
1411 1411
     #endif
1412 1412
 
1413 1413
     //
@@ -2559,7 +2559,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2559 2559
       MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
2560 2560
       MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
2561 2561
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2562
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2562
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2563 2563
       #endif
2564 2564
       END_MENU();
2565 2565
     }
@@ -2615,7 +2615,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2615 2615
 
2616 2616
       // Z Fade Height
2617 2617
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2618
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2618
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2619 2619
       #endif
2620 2620
 
2621 2621
       //
@@ -2701,7 +2701,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2701 2701
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
2702 2702
       }
2703 2703
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2704
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2704
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
2705 2705
       #endif
2706 2706
 
2707 2707
     #endif
@@ -4816,13 +4816,12 @@ void lcd_quick_feedback(const bool clear_buttons) {
4816 4816
       if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \
4817 4817
         _type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
4818 4818
         if (editValue != NULL) *((_type*)editValue) = value; \
4819
-        if (liveEdit) (*callbackFunc)(); \
4819
+        if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)(); \
4820 4820
         if (lcd_clicked) lcd_goto_previous_menu(); \
4821 4821
       } \
4822 4822
       return use_click(); \
4823 4823
     } \
4824 4824
     void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
4825
-    void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \
4826 4825
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \
4827 4826
       lcd_save_previous_screen(); \
4828 4827
       lcd_refresh(); \
@@ -4833,16 +4832,15 @@ void lcd_quick_feedback(const bool clear_buttons) {
4833 4832
       maxEditValue = maxValue * _scale - minEditValue; \
4834 4833
       encoderPosition = (*ptr) * _scale - minEditValue; \
4835 4834
     } \
4836
-    void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \
4837
-      _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
4838
-      currentScreen = menu_edit_ ## _name; \
4839
-    } \
4840 4835
     void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback, const bool live) { \
4841 4836
       _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
4842
-      currentScreen = menu_edit_callback_ ## _name; \
4837
+      currentScreen = menu_edit_ ## _name; \
4843 4838
       callbackFunc = callback; \
4844 4839
       liveEdit = live; \
4845 4840
     } \
4841
+    FORCE_INLINE void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \
4842
+      menu_action_setting_edit_callback_ ## _name(pstr, ptr, minValue, maxValue); \
4843
+    } \
4846 4844
     typedef void _name##_void
4847 4845
 
4848 4846
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);

Завантаження…
Відмінити
Зберегти