Browse Source

Fix value editing with callback

Scott Lahteine 7 years ago
parent
commit
1239e8eda2
1 changed files with 6 additions and 8 deletions
  1. 6
    8
      Marlin/src/lcd/ultralcd.cpp

+ 6
- 8
Marlin/src/lcd/ultralcd.cpp View File

258
     void menu_edit_callback_ ## _name(); \
258
     void menu_edit_callback_ ## _name(); \
259
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \
259
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \
260
     void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue); \
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
     typedef void _name##_void
262
     typedef void _name##_void
263
 
263
 
264
   DECLARE_MENU_EDIT_TYPE(int16_t, int3);
264
   DECLARE_MENU_EDIT_TYPE(int16_t, int3);
4816
       if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \
4816
       if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \
4817
         _type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
4817
         _type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
4818
         if (editValue != NULL) *((_type*)editValue) = value; \
4818
         if (editValue != NULL) *((_type*)editValue) = value; \
4819
-        if (liveEdit) (*callbackFunc)(); \
4819
+        if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)(); \
4820
         if (lcd_clicked) lcd_goto_previous_menu(); \
4820
         if (lcd_clicked) lcd_goto_previous_menu(); \
4821
       } \
4821
       } \
4822
       return use_click(); \
4822
       return use_click(); \
4823
     } \
4823
     } \
4824
     void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
4824
     void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
4825
-    void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \
4826
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \
4825
     void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \
4827
       lcd_save_previous_screen(); \
4826
       lcd_save_previous_screen(); \
4828
       lcd_refresh(); \
4827
       lcd_refresh(); \
4833
       maxEditValue = maxValue * _scale - minEditValue; \
4832
       maxEditValue = maxValue * _scale - minEditValue; \
4834
       encoderPosition = (*ptr) * _scale - minEditValue; \
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
     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) { \
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
       _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
4836
       _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
4842
-      currentScreen = menu_edit_callback_ ## _name; \
4837
+      currentScreen = menu_edit_ ## _name; \
4843
       callbackFunc = callback; \
4838
       callbackFunc = callback; \
4844
       liveEdit = live; \
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
     typedef void _name##_void
4844
     typedef void _name##_void
4847
 
4845
 
4848
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
4846
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);

Loading…
Cancel
Save