From b05fcad7fec55b8eb401335458318dd91845fe47 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 21 Jun 2018 11:47:41 -0400 Subject: [PATCH 1/2] Fix value editing with callback --- Marlin/ultralcd.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 329f6584ab..2de03b0a3e 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -246,7 +246,7 @@ uint16_t max_display_update_time = 0; void menu_edit_callback_ ## _name(); \ void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \ void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue); \ - 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); \ + 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); \ typedef void _name##_void DECLARE_MENU_EDIT_TYPE(int16_t, int3); @@ -4807,13 +4807,12 @@ void lcd_quick_feedback(const bool clear_buttons) { if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \ _type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \ if (editValue != NULL) *((_type*)editValue) = value; \ - if (liveEdit) (*callbackFunc)(); \ + if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)(); \ if (lcd_clicked) lcd_goto_previous_menu(); \ } \ return use_click(); \ } \ void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \ - void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \ void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \ lcd_save_previous_screen(); \ lcd_refresh(); \ @@ -4824,16 +4823,15 @@ void lcd_quick_feedback(const bool clear_buttons) { maxEditValue = maxValue * _scale - minEditValue; \ encoderPosition = (*ptr) * _scale - minEditValue; \ } \ - void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \ - _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \ - currentScreen = menu_edit_ ## _name; \ - } \ 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) { \ _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \ - currentScreen = menu_edit_callback_ ## _name; \ + currentScreen = menu_edit_ ## _name; \ callbackFunc = callback; \ liveEdit = live; \ } \ + FORCE_INLINE void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \ + menu_action_setting_edit_callback_ ## _name(pstr, ptr, minValue, maxValue); \ + } \ typedef void _name##_void DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1); From bd10791b6d77fba213cb154f8a33628f79a3a447 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 21 Jun 2018 11:47:59 -0400 Subject: [PATCH 2/2] Edit Z fade as whole numbers --- Marlin/ultralcd.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 2de03b0a3e..c181925348 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1397,7 +1397,7 @@ void lcd_quick_feedback(const bool clear_buttons) { // Leveling Fade Height // #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(SLIM_LCD_MENUS) - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); #endif // @@ -2016,8 +2016,7 @@ void lcd_quick_feedback(const bool clear_buttons) { void _lcd_level_bed_homing() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL); lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW; - if (all_axes_homed()) - lcd_goto_screen(_lcd_level_bed_homing_done); + if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done); } #if ENABLED(PROBE_MANUALLY) @@ -2549,7 +2548,7 @@ void lcd_quick_feedback(const bool clear_buttons) { MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu); MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W")); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); #endif END_MENU(); } @@ -2605,7 +2604,7 @@ void lcd_quick_feedback(const bool clear_buttons) { // Z Fade Height #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); #endif // @@ -2623,8 +2622,7 @@ void lcd_quick_feedback(const bool clear_buttons) { #if ENABLED(LEVEL_BED_CORNERS) // Move to the next corner for leveling - if (all_axes_homed()) - MENU_ITEM(submenu, MSG_LEVEL_CORNERS, _lcd_level_bed_corners); + if (all_axes_homed()) MENU_ITEM(submenu, MSG_LEVEL_CORNERS, _lcd_level_bed_corners); #endif #if ENABLED(EEPROM_SETTINGS) @@ -2692,7 +2690,7 @@ void lcd_quick_feedback(const bool clear_buttons) { MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling); } #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height); #endif #endif