Ver código fonte

Merge pull request #11075 from thinkyhead/bf2_value_editing

[2.0.x] Fix value editing (with callback)
Scott Lahteine 6 anos atrás
pai
commit
a5c11bf578
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 10 adições e 12 exclusões
  1. 10
    12
      Marlin/src/lcd/ultralcd.cpp

+ 10
- 12
Marlin/src/lcd/ultralcd.cpp Ver arquivo

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);
1407
     // Leveling Fade Height
1407
     // Leveling Fade Height
1408
     //
1408
     //
1409
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(SLIM_LCD_MENUS)
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
     #endif
1411
     #endif
1412
 
1412
 
1413
     //
1413
     //
2559
       MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
2559
       MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
2560
       MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
2560
       MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
2561
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
       #endif
2563
       #endif
2564
       END_MENU();
2564
       END_MENU();
2565
     }
2565
     }
2615
 
2615
 
2616
       // Z Fade Height
2616
       // Z Fade Height
2617
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
       #endif
2619
       #endif
2620
 
2620
 
2621
       //
2621
       //
2701
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
2701
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
2702
       }
2702
       }
2703
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
       #endif
2705
       #endif
2706
 
2706
 
2707
     #endif
2707
     #endif
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);

Carregando…
Cancelar
Salvar