From b6e228d5a568152881711e965e2dc9f91583876b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 15 Apr 2023 09:34:25 +0000 Subject: [PATCH] Fix double feedback in First Layer Calibration For MMU users: This happens when the user selects a filament to load from 1 to 5 For non-MMU: this happens when clicking the knob within 2 seconds. Additionally fixed the code indendation it was a mix of spaces and tabs --- Firmware/ultralcd.cpp | 61 ++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5b4f4dc86..647d74ab5 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3607,46 +3607,38 @@ void lcd_first_layer_calibration_reset() } -void lcd_v2_calibration() -{ - if (MMU2::mmu2.Enabled()) - { - const uint8_t filament = choose_menu_P( - _T(MSG_SELECT_FILAMENT), - _T(MSG_FILAMENT),(_T(MSG_CANCEL)+1)); //Hack to reuse MSG but strip 1st char off - if (filament < 5) - { - lay1cal_filament = filament; - } - else - { - menu_back(); - return; - } +void lcd_v2_calibration() { + if (MMU2::mmu2.Enabled()) { + const uint8_t filament = choose_menu_P( + _T(MSG_SELECT_FILAMENT), + _T(MSG_FILAMENT),(_T(MSG_CANCEL)+1)); //Hack to reuse MSG but strip 1st char off + if (filament < MMU_FILAMENT_COUNT) { + lay1cal_filament = filament; + } else { + menu_back(); + return; + } } #ifdef FILAMENT_SENSOR else if (!eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { - bool loaded = false; - if (fsensor.isReady()) - { - loaded = fsensor.getFilamentPresent(); - } - else - { - loaded = !lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_LOADED), false, LCD_MIDDLE_BUTTON_CHOICE); - lcd_update_enabled = true; + bool loaded = false; + if (fsensor.isReady()) { + loaded = fsensor.getFilamentPresent(); + } else { + loaded = !lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_LOADED), false, LCD_MIDDLE_BUTTON_CHOICE); + lcd_update_enabled = true; + } - } - - - if (!loaded) - { + if (!loaded) { lcd_display_message_fullscreen_P(_i("Please load filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 lcd_consume_click(); for (uint_least8_t i = 0; i < 20; i++) { //wait max. 2s delay_keep_alive(100); - if (lcd_clicked()) { + if (LCD_CLICKED) { + // Click event is consumed below when + // rendering the preheat menu. We use this + // to check whether a audio feedback should be shown break; } } @@ -3658,7 +3650,12 @@ void lcd_v2_calibration() #endif //FILAMENT_SENSOR eFilamentAction = FilamentAction::Lay1Cal; - menu_goto(lcd_generic_preheat_menu, 0, true, true); + + // Produce feedback if the LCD knob was not clicked + // Note for non-MMU setups there is a 2 second timeout in case + // the user does not click the knob, in such a case we want feedback + // since the firmware is changing the menu silently. + menu_goto(lcd_generic_preheat_menu, 0, true, !lcd_clicked()); } void lcd_wizard() {