ソースを参照

Fix value editing with callback

Scott Lahteine 7年前
コミット
1239e8eda2
1個のファイルの変更6行の追加8行の削除
  1. 6
    8
      Marlin/src/lcd/ultralcd.cpp

+ 6
- 8
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);
@@ -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);

読み込み中…
キャンセル
保存