From 34ce9c4c1cdcb878ab30ac34db338443b04bca97 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:05:11 -0700 Subject: [PATCH 01/11] Restore save previous for menu edit items --- Marlin/ultralcd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index b9ee875caf..483d021fea 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1778,6 +1778,8 @@ static void lcd_control_volumetric_menu() { void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \ void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \ static void _menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \ + lcd_save_previous_menu(); \ + \ lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW; \ currentMenu = menu_edit_ ## _name; \ \ From 8459f7fa5c7d0425a13ad991b52d8f7b6059111e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 01:34:09 -0700 Subject: [PATCH 02/11] Use `ms` where possible. --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 483d021fea..effde0c655 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2184,7 +2184,7 @@ void lcd_update() { // Return to Status Screen after a timeout if (defer_return_to_status) return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; - else if (currentMenu != lcd_status_screen && millis() > return_to_status_ms) { + else if (currentMenu != lcd_status_screen && ms > return_to_status_ms) { lcd_return_to_status(); } From f5c2fb27cda0241d82c0793ee7d0b48d43327c14 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:05:41 -0700 Subject: [PATCH 03/11] Handle defer_return_to_status in lcd_goto_menu --- Marlin/ultralcd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index effde0c655..746c3002db 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -319,7 +319,10 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui encoderPosition = encoder; if (feedback) lcd_quick_feedback(); #endif - if (menu == lcd_status_screen) menu_history_depth = 0; + if (menu == lcd_status_screen) { + defer_return_to_status = false; + menu_history_depth = 0; + } #if ENABLED(LCD_PROGRESS_BAR) // For LCD_PROGRESS_BAR re-initialize custom characters lcd_set_custom_characters(menu == lcd_status_screen); @@ -327,10 +330,7 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui } } -static void lcd_return_to_status() { - defer_return_to_status = false; - lcd_goto_menu(lcd_status_screen); -} +static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); } inline void lcd_save_previous_menu() { if (menu_history_depth < COUNT(menu_history)) { From f936df950701f92e32b2564f2031c7b7c6ad0438 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:06:52 -0700 Subject: [PATCH 04/11] Small cleanup of feedrate dead-zone --- Marlin/ultralcd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 746c3002db..667f3f32de 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -432,13 +432,13 @@ static void lcd_status_screen() { } #if ENABLED(ULTIPANEL_FEEDMULTIPLY) + int new_frm = feedrate_multiplier + int(encoderPosition); // Dead zone at 100% feedrate - if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) || - (feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) { - encoderPosition = 0; + if ((feedrate_multiplier < 100 && new_frm > 100) || (feedrate_multiplier > 100 && new_frm < 100)) { feedrate_multiplier = 100; + encoderPosition = 0; } - if (feedrate_multiplier == 100) { + else if (feedrate_multiplier == 100) { if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { feedrate_multiplier += int(encoderPosition) - (ENCODER_FEEDRATE_DEADZONE); encoderPosition = 0; @@ -449,7 +449,7 @@ static void lcd_status_screen() { } } else { - feedrate_multiplier += int(encoderPosition); + feedrate_multiplier = new_frm; encoderPosition = 0; } #endif // ULTIPANEL_FEEDMULTIPLY From aa97328cd35e891ba045363a29baa64378a39375 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:08:22 -0700 Subject: [PATCH 05/11] Use min_pos/max_pos for _lcd_move --- Marlin/ultralcd.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 667f3f32de..b7e14460e4 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1123,7 +1123,7 @@ static void lcd_prepare_menu() { float move_menu_scale; static void lcd_move_menu_axis(); -static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { +static void _lcd_move(const char* name, AxisEnum axis, float min, float max) { ENCODER_DIRECTION_NORMAL(); if ((encoderPosition != 0) && (movesplanned() <= 3)) { refresh_cmd_timeout(); @@ -1140,13 +1140,13 @@ static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { #if ENABLED(DELTA) static float delta_clip_radius_2 = (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS); static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a*a); } - static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); } - static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, max(Y_MIN_POS, -clip), min(Y_MAX_POS, clip)); } + static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(min_pos[X_AXIS], -clip), min(max_pos[X_AXIS], clip)); } + static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, max(min_pos[Y_AXIS], -clip), min(max_pos[Y_AXIS], clip)); } #else - static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, X_MIN_POS, X_MAX_POS); } - static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, Y_MIN_POS, Y_MAX_POS); } + static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, min_pos[X_AXIS], max_pos[X_AXIS]); } + static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, min_pos[Y_AXIS], max_pos[Y_AXIS]); } #endif -static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, Z_MIN_POS, Z_MAX_POS); } +static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, min_pos[Z_AXIS], max_pos[Z_AXIS]); } static void lcd_move_e( #if EXTRUDERS > 1 uint8_t e From 86372cd394272be0630b8e95c4f72386fd62badc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:09:13 -0700 Subject: [PATCH 06/11] Add underscore to internal lcd move function names --- Marlin/ultralcd.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index b7e14460e4..33acfd8c71 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1121,7 +1121,6 @@ static void lcd_prepare_menu() { */ float move_menu_scale; -static void lcd_move_menu_axis(); static void _lcd_move(const char* name, AxisEnum axis, float min, float max) { ENCODER_DIRECTION_NORMAL(); @@ -1204,7 +1203,7 @@ static void lcd_move_e( * */ -static void lcd_move_menu_axis() { +static void _lcd_move_menu_axis() { START_MENU(); MENU_ITEM(back, MSG_MOVE_AXIS); MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); @@ -1229,15 +1228,15 @@ static void lcd_move_menu_axis() { static void lcd_move_menu_10mm() { move_menu_scale = 10.0; - lcd_move_menu_axis(); + _lcd_move_menu_axis(); } static void lcd_move_menu_1mm() { move_menu_scale = 1.0; - lcd_move_menu_axis(); + _lcd_move_menu_axis(); } static void lcd_move_menu_01mm() { move_menu_scale = 0.1; - lcd_move_menu_axis(); + _lcd_move_menu_axis(); } /** From 24cde86a4fff0213d7ca2b2a66358fcd79261263 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:10:00 -0700 Subject: [PATCH 07/11] Fix syntax highlighting of menu_edit_type lines --- Marlin/ultralcd.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 33acfd8c71..022626f826 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1797,14 +1797,14 @@ static void lcd_control_volumetric_menu() { currentMenu = menu_edit_callback_ ## _name; \ callbackFunc = callback; \ } -menu_edit_type(int, int3, itostr3, 1) -menu_edit_type(float, float3, ftostr3, 1) -menu_edit_type(float, float32, ftostr32, 100) -menu_edit_type(float, float43, ftostr43, 1000) -menu_edit_type(float, float5, ftostr5, 0.01) -menu_edit_type(float, float51, ftostr51, 10) -menu_edit_type(float, float52, ftostr52, 100) -menu_edit_type(unsigned long, long5, ftostr5, 0.01) +menu_edit_type(int, int3, itostr3, 1); +menu_edit_type(float, float3, ftostr3, 1); +menu_edit_type(float, float32, ftostr32, 100); +menu_edit_type(float, float43, ftostr43, 1000); +menu_edit_type(float, float5, ftostr5, 0.01); +menu_edit_type(float, float51, ftostr51, 10); +menu_edit_type(float, float52, ftostr52, 100); +menu_edit_type(unsigned long, long5, ftostr5, 0.01); /** * From 0f247187b8c1f4bd594ecb211871926d1aea9231 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:11:02 -0700 Subject: [PATCH 08/11] Drop extra setting of currentMenu --- Marlin/ultralcd.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 022626f826..40aaa2baca 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1780,7 +1780,6 @@ static void lcd_control_volumetric_menu() { lcd_save_previous_menu(); \ \ lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW; \ - currentMenu = menu_edit_ ## _name; \ \ editLabel = pstr; \ editValue = ptr; \ From a70c3ffc214de7945c9c3299f50263bafea7a76c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:11:29 -0700 Subject: [PATCH 09/11] Minor syntax tweak with encoderPosition --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 40aaa2baca..588f7ddc73 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -901,7 +901,7 @@ void lcd_cooldown() { ENCODER_DIRECTION_NORMAL(); // Encoder wheel adjusts the Z position - if (encoderPosition != 0 && movesplanned() <= 3) { + if (encoderPosition && movesplanned() <= 3) { refresh_cmd_timeout(); current_position[Z_AXIS] += float((int)encoderPosition) * (MBL_Z_STEP); if (min_software_endstops) NOLESS(current_position[Z_AXIS], Z_MIN_POS); From 582b58e660bdbc3bd39e1499280d9b7d94a27352 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 14:49:38 -0700 Subject: [PATCH 10/11] Add audio feedback to edit items --- Marlin/ultralcd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 588f7ddc73..2e7cce3935 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -583,7 +583,7 @@ void lcd_set_home_offsets() { #endif } if (lcdDrawUpdate) lcd_implementation_drawedit(msg, NULL); - if (LCD_CLICKED) lcd_goto_previous_menu(); + if (LCD_CLICKED) lcd_goto_previous_menu(true); } #if ENABLED(BABYSTEP_XY) @@ -1134,7 +1134,7 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) { lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW; } if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); - if (LCD_CLICKED) lcd_goto_previous_menu(); + if (LCD_CLICKED) lcd_goto_previous_menu(true); } #if ENABLED(DELTA) static float delta_clip_radius_2 = (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS); @@ -1180,7 +1180,7 @@ static void lcd_move_e( #endif //EXTRUDERS > 1 lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS])); } - if (LCD_CLICKED) lcd_goto_previous_menu(); + if (LCD_CLICKED) lcd_goto_previous_menu(true); #if EXTRUDERS > 1 active_extruder = original_active_extruder; #endif @@ -1648,7 +1648,7 @@ static void lcd_control_volumetric_menu() { lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); #endif } - if (LCD_CLICKED) lcd_goto_previous_menu(); + if (LCD_CLICKED) lcd_goto_previous_menu(true); } #endif // HAS_LCD_CONTRAST From fb38d698db5a056d92c68275cf14e4c677e9c0dd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Apr 2016 15:35:05 -0700 Subject: [PATCH 11/11] Add feedback after "Click to Begin" --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 2e7cce3935..af31e954e2 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -978,7 +978,7 @@ void lcd_cooldown() { current_position[Y_AXIS] = MESH_MIN_Y; line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); _lcd_level_bed_position = 0; - lcd_goto_menu(_lcd_level_bed_procedure); + lcd_goto_menu(_lcd_level_bed_procedure, true); } }