From 543ad6eb4130a8c1cb47b0a2d96a4b74315e9da1 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 30 Sep 2019 19:58:09 +0200 Subject: [PATCH 1/8] Ask to reset Z offset before first layer calibration. --- Firmware/ultralcd.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 77af6d5f..e352c874 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4774,6 +4774,12 @@ void lcd_toshiba_flash_air_compatibility_toggle() void lcd_v2_calibration() { + if(lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Start from zero offset?"), false, false))////r=15 + { + eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base-> + s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset)),0xffff); + } + if (mmu_enabled) { const uint8_t filament = choose_menu_P( From 72aed3c544f393653f9c2581eb952b55e9f77f99 Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 1 Oct 2019 10:51:02 +0200 Subject: [PATCH 2/8] Allow knob-long-press only in listed menus --- Firmware/ultralcd.cpp | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 77af6d5f..4812e343 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8606,7 +8606,6 @@ uint8_t get_message_level() return lcd_status_message_level; } - void menu_lcd_longpress_func(void) { if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z) @@ -8616,15 +8615,41 @@ void menu_lcd_longpress_func(void) return; } + // explicitely listed menus which are allowed to rise the move-z or live-adj-z functions + // The lists are not the same for both functions, so first decide which function is to be performed + // @@TODO - handle full-screen modal dialogs safely - i.e. they should not hang the printer while doing long press if (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU && (moves_planned() || IS_SD_PRINTING || is_usb_printing )) - { - lcd_clear(); - menu_submenu(lcd_babystep_z); - } - else - { - move_menu_scale = 1.0; - menu_submenu(lcd_move_z); + { // long press as live-adj-z + if(menu_menu == lcd_status_screen + || menu_menu == lcd_tune_menu + || menu_menu == lcd_support_menu + ){ + lcd_clear(); + menu_submenu(lcd_babystep_z); + } else { + // otherwise consume the long press as normal click + // consume the loreturns to sheet menu + menu_back(); + } + } else { // long press as move-z + if(menu_menu == lcd_status_screen + || menu_menu == lcd_main_menu + || menu_menu == lcd_preheat_menu + || menu_menu == lcd_sdcard_menu + || menu_menu == lcd_settings_menu + || menu_menu == lcd_control_temperature_menu +#if (LANG_MODE != 0) + || menu_menu == lcd_language +#endif + || menu_menu == lcd_support_menu + ){ + move_menu_scale = 1.0; + menu_submenu(lcd_move_z); + } else { + // otherwise consume the long press as normal click + // consume the loreturns to sheet menu + menu_back(); + } } } From 9ae75612b57661b3db55131179df6a3a8d7cc569 Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 1 Oct 2019 15:31:01 +0200 Subject: [PATCH 3/8] Fixes after first feature tests --- Firmware/ultralcd.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4812e343..a966c81f 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8618,11 +8618,13 @@ void menu_lcd_longpress_func(void) // explicitely listed menus which are allowed to rise the move-z or live-adj-z functions // The lists are not the same for both functions, so first decide which function is to be performed // @@TODO - handle full-screen modal dialogs safely - i.e. they should not hang the printer while doing long press - if (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU && (moves_planned() || IS_SD_PRINTING || is_usb_printing )) - { // long press as live-adj-z - if(menu_menu == lcd_status_screen - || menu_menu == lcd_tune_menu - || menu_menu == lcd_support_menu + if ( (moves_planned() || IS_SD_PRINTING || is_usb_printing )){ // long press as live-adj-z + if(( current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU ) // only allow live-adj-z up to 2mm of print height + && ( menu_menu == lcd_status_screen // and in listed menus... + || menu_menu == lcd_main_menu + || menu_menu == lcd_tune_menu + || menu_menu == lcd_support_menu + ) ){ lcd_clear(); menu_submenu(lcd_babystep_z); From f3c3526aa5cdf49df526e2a2660d2ee43535112c Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 1 Oct 2019 17:13:36 +0200 Subject: [PATCH 4/8] fix the knob long-press causing hang in modal dialogs --- Firmware/lcd.cpp | 3 +-- Firmware/ultralcd.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index 71948789..3e39312c 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -761,8 +761,7 @@ void lcd_buttons_update(void) //else if (menu_menu == lcd_move_z) lcd_quick_feedback(); //lcd_button_pressed is set back to false via lcd_quick_feedback function } - else - lcd_long_press_active = 0; + lcd_long_press_active = 0; } lcd_buttons = newbutton; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a966c81f..ac0067d0 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8617,7 +8617,6 @@ void menu_lcd_longpress_func(void) // explicitely listed menus which are allowed to rise the move-z or live-adj-z functions // The lists are not the same for both functions, so first decide which function is to be performed - // @@TODO - handle full-screen modal dialogs safely - i.e. they should not hang the printer while doing long press if ( (moves_planned() || IS_SD_PRINTING || is_usb_printing )){ // long press as live-adj-z if(( current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU ) // only allow live-adj-z up to 2mm of print height && ( menu_menu == lcd_status_screen // and in listed menus... @@ -8630,8 +8629,8 @@ void menu_lcd_longpress_func(void) menu_submenu(lcd_babystep_z); } else { // otherwise consume the long press as normal click - // consume the loreturns to sheet menu - menu_back(); + if( menu_menu != lcd_status_screen ) + menu_back(); } } else { // long press as move-z if(menu_menu == lcd_status_screen @@ -8649,8 +8648,8 @@ void menu_lcd_longpress_func(void) menu_submenu(lcd_move_z); } else { // otherwise consume the long press as normal click - // consume the loreturns to sheet menu - menu_back(); + if( menu_menu != lcd_status_screen ) + menu_back(); } } } From 7c3f397a6240aba9bb7bf3cc9cb0617013f868bb Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 1 Oct 2019 18:22:12 +0200 Subject: [PATCH 5/8] Print sheet name and Z offset in first layer calibration reset dialog. --- Firmware/ultralcd.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e352c874..4038cb3e 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4772,6 +4772,17 @@ void lcd_toshiba_flash_air_compatibility_toggle() eeprom_update_byte((uint8_t*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY, card.ToshibaFlashAir_isEnabled()); } +void lcd_first_layer_calibration_reset() +{ + SheetFormatBuffer buffer; + menu_format_sheet_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], buffer); + lcd_set_cursor(0, 0); + lcd_print(buffer.c); + lcd_set_cursor(0, 1); + float offset = static_cast(eeprom_read_word(reinterpret_cast(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))/cs.axis_steps_per_unit[Z_AXIS]; + lcd_printf_P(PSTR("%.14S%+5.3f"), _i("Adjusting Z:"), offset); //// c=14 +} + void lcd_v2_calibration() { if(lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Start from zero offset?"), false, false))////r=15 @@ -5751,7 +5762,7 @@ static void lcd_calibration_menu() if (!isPrintPaused) { MENU_ITEM_FUNCTION_P(_i("Wizard"), lcd_wizard);////MSG_WIZARD c=17 r=1 - MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration); + MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_first_layer_calibration_reset); MENU_ITEM_GCODE_P(_T(MSG_AUTO_HOME), PSTR("G28 W")); MENU_ITEM_FUNCTION_P(_i("Selftest "), lcd_selftest_v);////MSG_SELFTEST #ifdef MK1BP @@ -6673,7 +6684,7 @@ static void lcd_reset_sheet() static void activate_calibrate_sheet() { eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet); - lcd_v2_calibration(); + lcd_first_layer_calibration_reset(); } static void lcd_sheet_menu() From aabf7655dcb5dcd6ac0aee3df4072cbcbbfcfd3f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 1 Oct 2019 19:20:36 +0200 Subject: [PATCH 6/8] Do all text formatting in first layer calibration reset dialog in one line. --- Firmware/ultralcd.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4038cb3e..b5527f98 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4774,13 +4774,12 @@ void lcd_toshiba_flash_air_compatibility_toggle() void lcd_first_layer_calibration_reset() { - SheetFormatBuffer buffer; - menu_format_sheet_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], buffer); + + char sheet_name[7]; + eeprom_read_block(sheet_name, &EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, 7); lcd_set_cursor(0, 0); - lcd_print(buffer.c); - lcd_set_cursor(0, 1); float offset = static_cast(eeprom_read_word(reinterpret_cast(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))/cs.axis_steps_per_unit[Z_AXIS]; - lcd_printf_P(PSTR("%.14S%+5.3f"), _i("Adjusting Z:"), offset); //// c=14 + lcd_printf_P(_i("Sheet %.7s actual\nZ offset: %+1.3f\n%cContinue\n%cStart from zero"), sheet_name, offset); //// r=4 } void lcd_v2_calibration() From 087d3cb25032c1cd5b7b0d230cbe9af0663351ff Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 1 Oct 2019 21:04:00 +0200 Subject: [PATCH 7/8] Continue to lcd_v2_calibration() after selection is made in lcd_first_layer_calibration_reset(). Do not ask for selection if sheet is not calibrated, it is calibrated to zero offset or no first layer calibration was ever made. --- Firmware/ultralcd.cpp | 54 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b5527f98..0630eb7c 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -130,6 +130,7 @@ static void lcd_menu_xyz_offset(); static void lcd_menu_fails_stats_mmu(); static void lcd_menu_fails_stats_mmu_print(); static void lcd_menu_fails_stats_mmu_total(); +static void lcd_v2_calibration(); //static void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") static void mmu_fil_eject_menu(); @@ -4772,24 +4773,59 @@ void lcd_toshiba_flash_air_compatibility_toggle() eeprom_update_byte((uint8_t*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY, card.ToshibaFlashAir_isEnabled()); } +//! @brief Continue first layer calibration with previous value or start from zero? +//! +//! @code{.unparsed} +//! |01234567890123456789| +//! |Sheet Smooth1 actual| c=a, c=b, a+b = 13 +//! |Z offset: -1.480 mm | c=a, c=b, a+b = 14 +//! |>Continue | c=19 +//! | Start from zero | c=19 +//! ---------------------- +//! @endcode void lcd_first_layer_calibration_reset() { + typedef struct + { + bool reset; + } MenuData; + static_assert(sizeof(menu_data)>= sizeof(MenuData),"_menu_data_t doesn't fit into menu_data"); + MenuData* menuData = (MenuData*)&(menu_data[0]); - char sheet_name[7]; - eeprom_read_block(sheet_name, &EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, 7); + if(LCD_CLICKED || !eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))) || + (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST) || + (0 == static_cast(eeprom_read_word(reinterpret_cast + (&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset))))) + { + if (menuData->reset) + { + eeprom_update_word(reinterpret_cast(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset), 0xffff); + } + menu_goto(lcd_v2_calibration,0,true,true); + } + + if (lcd_encoder > 0) + { + menuData->reset = true; + lcd_encoder = 1; + } + else if (lcd_encoder < 1) + { + menuData->reset = false; + lcd_encoder = 0; + } + + char sheet_name[sizeof(Sheet::name)]; + eeprom_read_block(sheet_name, &EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name)); lcd_set_cursor(0, 0); float offset = static_cast(eeprom_read_word(reinterpret_cast(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))/cs.axis_steps_per_unit[Z_AXIS]; - lcd_printf_P(_i("Sheet %.7s actual\nZ offset: %+1.3f\n%cContinue\n%cStart from zero"), sheet_name, offset); //// r=4 + lcd_printf_P(_i("Sheet %.7s actual\nZ offset: %+1.3f mm\n%cContinue\n%cStart from zero"), //// \n denotes line break, %.7s is replaced by 7 character long sheet name, %+1.3f is replaced by 6 character long floating point number, %c is replaced by > or white space (one character) based on whether first or second option is selected. % denoted place holders can not be reordered. r=4 + sheet_name, offset, menuData->reset ? ' ' : '>', menuData->reset ? '>' : ' '); + } void lcd_v2_calibration() { - if(lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Start from zero offset?"), false, false))////r=15 - { - eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base-> - s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset)),0xffff); - } - if (mmu_enabled) { const uint8_t filament = choose_menu_P( From ca9ef3aba123e45b792bddc4eace803ffedfd455 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 1 Oct 2019 22:57:15 +0200 Subject: [PATCH 8/8] Use content supplied strings for lcd_first_layer_calibration_reset(), as we have translations prepared for release. It will be reverted later to show current Z offset. --- Firmware/ultralcd.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0630eb7c..9f498e01 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4777,10 +4777,10 @@ void lcd_toshiba_flash_air_compatibility_toggle() //! //! @code{.unparsed} //! |01234567890123456789| -//! |Sheet Smooth1 actual| c=a, c=b, a+b = 13 -//! |Z offset: -1.480 mm | c=a, c=b, a+b = 14 -//! |>Continue | c=19 -//! | Start from zero | c=19 +//! |[Smooth1]Live adj. Z| c=11 +//! |value set, continue | c=20 +//! |or start from zero? | c=20 +//! |>Continue Reset | c=a, c=b, a+b = 18 //! ---------------------- //! @endcode void lcd_first_layer_calibration_reset() @@ -4818,9 +4818,8 @@ void lcd_first_layer_calibration_reset() char sheet_name[sizeof(Sheet::name)]; eeprom_read_block(sheet_name, &EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name)); lcd_set_cursor(0, 0); - float offset = static_cast(eeprom_read_word(reinterpret_cast(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))/cs.axis_steps_per_unit[Z_AXIS]; - lcd_printf_P(_i("Sheet %.7s actual\nZ offset: %+1.3f mm\n%cContinue\n%cStart from zero"), //// \n denotes line break, %.7s is replaced by 7 character long sheet name, %+1.3f is replaced by 6 character long floating point number, %c is replaced by > or white space (one character) based on whether first or second option is selected. % denoted place holders can not be reordered. r=4 - sheet_name, offset, menuData->reset ? ' ' : '>', menuData->reset ? '>' : ' '); + lcd_printf_P(_i("[%.7s]Live adj. Z\nvalue set, continue\nor start from zero?\n%cContinue%cReset"), //// \n denotes line break, %.7s is replaced by 7 character long sheet name, %+1.3f is replaced by 6 character long floating point number, %c is replaced by > or white space (one character) based on whether first or second option is selected. % denoted place holders can not be reordered. r=4 + sheet_name, menuData->reset ? ' ' : '>', menuData->reset ? '>' : ' '); }