From 8dfc32c2466cc7542fd10acd27259c2b7fe048d8 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Sat, 26 Nov 2022 12:01:12 +0100 Subject: [PATCH] Soft reset printer after disabling mmu --- Firmware/ultralcd.cpp | 378 +++++++++++++++++++++--------------------- 1 file changed, 189 insertions(+), 189 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 68528f74..1cd74ec9 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -551,11 +551,11 @@ void lcdui_print_time(void) print_t = print_tc; suff = 'C'; } else -//#endif //CLOCK_INTERVAL_TIME +//#endif //CLOCK_INTERVAL_TIME if (print_tr != PRINT_TIME_REMAINING_INIT) { print_t = print_tr; suff = 'R'; - } else + } else print_t = _millis() / 60000 - starttime / 60000; if (feedmultiply != 100 && (print_t == print_tr || print_t == print_tc)) { @@ -776,7 +776,7 @@ void lcdui_print_status_screen(void) // Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") { - if (firstrun == 1) + if (firstrun == 1) { firstrun = 0; if(lcd_status_message_level == 0) @@ -1313,7 +1313,7 @@ void lcd_commands() } if (lcd_commands_type == LcdCommands::PidExtruder) { char cmd1[30]; - + if (lcd_commands_step == 0) { custom_message_type = CustomMsg::PidCal; custom_message_state = 1; @@ -1446,7 +1446,7 @@ void lcd_menu_extruder_info() // NOT static due to using ins char nozzle[maxChars], print[maxChars]; pgmtext_with_colon(_i("Nozzle FAN"), nozzle, maxChars); ////MSG_NOZZLE_FAN c=10 pgmtext_with_colon(_i("Print FAN"), print, maxChars); ////MSG_PRINT_FAN c=10 - lcd_printf_P(_N("%s %4d RPM\n" "%s %4d RPM\n"), nozzle, 60*fan_speed[0], print, 60*fan_speed[1] ); + lcd_printf_P(_N("%s %4d RPM\n" "%s %4d RPM\n"), nozzle, 60*fan_speed[0], print, 60*fan_speed[1] ); menu_back_if_clicked(); } @@ -1488,7 +1488,7 @@ static void lcd_menu_fails_stats_mmu_print() { lcd_timeoutToStatus.stop(); //infinite timeout lcd_home(); - lcd_printf_P(PSTR("%S\n" " %-16.16S%-3d\n" " %-16.16S%-3d"), + lcd_printf_P(PSTR("%S\n" " %-16.16S%-3d\n" " %-16.16S%-3d"), _T(MSG_LAST_PRINT_FAILURES), _T(MSG_MMU_FAILS), clamp999( eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) ), _T(MSG_MMU_LOAD_FAILS), clamp999( eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) )); @@ -1511,7 +1511,7 @@ static void lcd_menu_fails_stats_mmu_total() mmu_command(MmuCmd::S3); lcd_timeoutToStatus.stop(); //infinite timeout lcd_home(); - lcd_printf_P(PSTR("%S\n" " %-16.16S%-3d\n" " %-16.16S%-3d\n" " %-16.16S%-3d"), + lcd_printf_P(PSTR("%S\n" " %-16.16S%-3d\n" " %-16.16S%-3d\n" " %-16.16S%-3d"), _T(MSG_TOTAL_FAILURES), _T(MSG_MMU_FAILS), clamp999( eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) ), _T(MSG_MMU_LOAD_FAILS), clamp999( eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) ), @@ -1537,12 +1537,12 @@ static void lcd_menu_fails_stats_total() { lcd_timeoutToStatus.stop(); //infinite timeout lcd_home(); - lcd_printf_P(failStatsFmt, + lcd_printf_P(failStatsFmt, _T(MSG_TOTAL_FAILURES), _T(MSG_POWER_FAILURES), clamp999( eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) ), _T(MSG_FIL_RUNOUTS), clamp999( eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) ), _T(MSG_CRASH), - clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) ), + clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) ), clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) )); menu_back_if_clicked_fb(); } @@ -1598,11 +1598,11 @@ static void lcd_menu_fails_stats_print() } //! @brief Open fail statistics menu -//! +//! //! This version of function is used, when there is filament sensor, //! power failure and crash detection. //! There are Last print and Total menu items. -//! +//! //! @code{.unparsed} //! |01234567890123456789| //! | Main | MSG_MAIN c=18 @@ -1623,12 +1623,12 @@ static void lcd_menu_fails_stats() #elif defined(FILAMENT_SENSOR) static const char failStatsFmt[] PROGMEM = "%S\n" " %-16.16S%-3d\n" "%S\n" " %-16.16S%-3d\n"; -//! +//! //! @brief Print last print and total filament run outs -//! +//! //! This version of function is used, when there is filament sensor, //! but no other sensors (e.g. power failure, crash detection). -//! +//! //! Example screen: //! @code{.unparsed} //! |01234567890123456789| @@ -1645,7 +1645,7 @@ static void lcd_menu_fails_stats() uint8_t filamentLast = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); uint16_t filamentTotal = clamp999( eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) ); lcd_home(); - lcd_printf_P(failStatsFmt, + lcd_printf_P(failStatsFmt, _T(MSG_LAST_PRINT_FAILURES), _T(MSG_FIL_RUNOUTS), filamentLast, _T(MSG_TOTAL_FAILURES), @@ -1700,7 +1700,7 @@ static void lcd_menu_debug() //! @param [in] ipgmLabel pointer to string in PROGMEM //! @param [in] value to be printed behind the label static void lcd_menu_temperatures_line(const char *ipgmLabel, int value){ - static const size_t maxChars = 15; + static const size_t maxChars = 15; char tmp[maxChars]; pgmtext_with_colon(ipgmLabel, tmp, maxChars); lcd_printf_P(PSTR(" %s%3d\x01 \n"), tmp, value); // no need to add -14.14 to string alignment @@ -1783,7 +1783,7 @@ static void lcd_menu_belt_status() } #endif //TMC2130 -#ifdef RESUME_DEBUG +#ifdef RESUME_DEBUG extern void stop_and_save_print_to_ram(float z_move, float e_move); extern void restore_print_from_ram_and_continue(float e_move); @@ -1796,7 +1796,7 @@ static void lcd_menu_test_restore() { restore_print_from_ram_and_continue(0.8); } -#endif //RESUME_DEBUG +#endif //RESUME_DEBUG //! @brief Show Preheat Menu static void lcd_preheat_menu() @@ -1879,54 +1879,54 @@ static void lcd_stack_crash() //! | MMM DD YYYY | __DATE__ //! | -------------- | STR_SEPARATOR //! @endcode -//! +//! //! If MMU is connected -//! +//! //! @code{.unparsed} //! | MMU2 connected | c=18 //! | FW: 1.0.6-7064523 | //! @endcode -//! +//! //! If MMU is not connected -//! +//! //! @code{.unparsed} //! | MMU2 N/A | c=18 //! @endcode -//! +//! //! If Flash Air is connected -//! +//! //! @code{.unparsed} //! | -------------- | STR_SEPARATOR //! | FlashAir IP Addr: | c=18 //! | 192.168.1.100 | //! @endcode -//! +//! //! @code{.unparsed} //! | -------------- | STR_SEPARATOR //! | XYZ cal. details | MSG_XYZ_DETAILS c=18 //! | Extruder info | MSG_INFO_EXTRUDER //! | XYZ cal. details | MSG_INFO_SENSORS //! @endcode -//! +//! //! If TMC2130 defined -//! +//! //! @code{.unparsed} //! | Belt status | MSG_BELT_STATUS //! @endcode -//! +//! //! @code{.unparsed} //! | Temperatures | MSG_MENU_TEMPERATURES //! @endcode -//! +//! //! If Voltage Bed and PWR Pin are defined -//! +//! //! @code{.unparsed} //! | Voltages | MSG_MENU_VOLTAGES //! @endcode -//! -//! +//! +//! //! If DEBUG_BUILD is defined -//! +//! //! @code{.unparsed} //! | Debug | c=18 //! @endcode @@ -1974,7 +1974,7 @@ static void lcd_support_menu() } else { MENU_ITEM_BACK_P(PSTR("FW - " FW_version)); }*/ - + MENU_ITEM_BACK_P(_n("prusa3d.com"));////MSG_PRUSA3D c=18 MENU_ITEM_BACK_P(_n("forum.prusa3d.com"));////MSG_PRUSA3D_FORUM c=18 MENU_ITEM_BACK_P(_n("howto.prusa3d.com"));////MSG_PRUSA3D_HOWTO c=18 @@ -2023,10 +2023,10 @@ static void lcd_support_menu() lcd_printf_P(PSTR("%s"), _md->ip_str); } } - + // Show the printer IP address, if it is available. if (IP_address) { - + MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(PSTR("Printer IP Addr:")); ////MSG_PRINTER_IP c=18 MENU_ITEM_BACK_P(PSTR(" ")); @@ -2046,7 +2046,7 @@ static void lcd_support_menu() #ifdef TMC2130 MENU_ITEM_SUBMENU_P(_T(MSG_BELT_STATUS), lcd_menu_belt_status);////MSG_BELT_STATUS c=18 #endif //TMC2130 - + MENU_ITEM_SUBMENU_P(_i("Temperatures"), lcd_menu_temperatures);////MSG_MENU_TEMPERATURES c=18 #if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) @@ -2289,7 +2289,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) lcd_draw_update = 1; lcd_clear(); - lcd_puts_at_P(0, 3, _T(MSG_CANCEL)); ////MSG_CANCEL + lcd_puts_at_P(0, 3, _T(MSG_CANCEL));////MSG_CANCEL lcd_set_cursor(0, 1); switch (eFilamentAction) @@ -2486,7 +2486,7 @@ void lcd_wait_interact() { lcd_clear(); lcd_set_cursor(0, 1); -#ifdef SNMM +#ifdef SNMM lcd_puts_P(_i("Prepare new filament"));////MSG_PREPARE_FILAMENT c=20 #else lcd_puts_P(_i("Insert filament"));////MSG_INSERT_FILAMENT c=20 @@ -2506,7 +2506,7 @@ void lcd_change_success() { } -static void lcd_loading_progress_bar(uint16_t loading_time_ms) { +static void lcd_loading_progress_bar(uint16_t loading_time_ms) { for (uint_least8_t i = 0; i < LCD_WIDTH; i++) { lcd_putc_at(i, 3, '.'); @@ -2631,7 +2631,7 @@ void lcd_alright() { } void show_preheat_nozzle_warning() -{ +{ lcd_clear(); lcd_puts_at_P(0, 0, _T(MSG_ERROR)); lcd_puts_at_P(0, 2, _T(MSG_PREHEAT_NOZZLE)); @@ -2871,7 +2871,7 @@ float _deg(float rad) } //! @brief Show Measured XYZ Skew -//! +//! //! @code{.unparsed} //! |01234567890123456789| //! |Measured skew :0.00D| MSG_MEASURED_SKEW c=14, c=4 @@ -2908,7 +2908,7 @@ static void lcd_menu_xyz_skew() menu_goto(lcd_menu_xyz_offset, 0, true, true); } //! @brief Show measured bed offset from expected position -//! +//! //! @code{.unparsed} //! |01234567890123456789| //! |[0;0] point offset | MSG_MEASURED_OFFSET c=20 @@ -3000,7 +3000,7 @@ static void lcd_babystep_z() // Initialize its status. _md->status = 1; check_babystep(); - + if(!eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){ _md->babystepMemZ = 0; } @@ -3049,7 +3049,7 @@ static void lcd_babystep_z() uint8_t active_sheet=eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)); eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[active_sheet].z_offset)),_md->babystepMemZ); eeprom_update_byte(&(EEPROM_Sheets_base->s[active_sheet].bed_temp),target_temperature_bed); -#ifdef PINDA_THERMISTOR +#ifdef PINDA_THERMISTOR eeprom_update_byte(&(EEPROM_Sheets_base->s[active_sheet].pinda_temp),current_temperature_pinda); #endif //PINDA_THERMISTOR calibration_status_store(CALIBRATION_STATUS_CALIBRATED); @@ -3081,7 +3081,7 @@ void lcd_adjust_bed_reset(void) } //! @brief Show Bed level correct -//! +//! //! @code{.unparsed} //! |01234567890123456789| //! |Settings: | MSG_SETTINGS @@ -3130,7 +3130,7 @@ void lcd_adjust_bed(void) } //! @brief Show PID Extruder -//! +//! //! @code{.unparsed} //! |01234567890123456789| //! |Set temperature: | MSG_SET_TEMPERATURE c=20 @@ -3295,13 +3295,13 @@ void lcd_wait_for_cool_down() { lcd_set_cursor(0, 4); lcd_print(LCD_STR_THERMOMETER[0]); lcd_print(ftostr3(degHotend(0))); - lcd_print("/0"); + lcd_print("/0"); lcd_print(LCD_STR_DEGREE); lcd_set_cursor(9, 4); lcd_print(LCD_STR_BEDTEMP[0]); lcd_print(ftostr3(degBed())); - lcd_print("/0"); + lcd_print("/0"); lcd_print(LCD_STR_DEGREE); lcd_set_custom_characters(); delay_keep_alive(1000); @@ -3470,7 +3470,7 @@ const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines) // uint8_t nlines; return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines); } -const char* lcd_display_message_fullscreen_P(const char *msg) +const char* lcd_display_message_fullscreen_P(const char *msg) { uint8_t nlines; return lcd_display_message_fullscreen_P(msg, nlines); @@ -3653,7 +3653,7 @@ int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow { lcd_display_message_fullscreen_P(msg); - + if (default_yes) { lcd_putc_at(0, 2, '>'); lcd_puts_P(_T(MSG_YES)); @@ -3759,7 +3759,7 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui } void lcd_temp_cal_show_result(bool result) { - + custom_message_type = CustomMsg::Status; disable_x(); disable_y(); @@ -3827,7 +3827,7 @@ static void lcd_print_state(uint8_t state) case STATE_OFF: lcd_puts_P(_N(" 0")); break; - default: + default: lcd_puts_P(_T(MSG_NA)); break; } @@ -3838,9 +3838,9 @@ static void lcd_print_state(uint8_t state) //! @code{.unparsed} //! |01234567890123456789| //! |PINDA N/A FINDA N/A| MSG_PINDA c=5 MSG_FINDA c=5 -//! |Fil. sensor N/A| MSG_FSENSOR +//! |Fil. sensor N/A| MSG_FSENSOR //! |Xd 000 Yd 000| MSG_XD -//! |Int 000 Shut 000| +//! |Int 000 Shut 000| //! ---------------------- //! @endcode static void lcd_show_sensors_state() @@ -3859,24 +3859,24 @@ static void lcd_show_sensors_state() lcd_puts_at_P(0, 0, _T(MSG_PINDA)); lcd_set_cursor(LCD_WIDTH - 14, 0); lcd_print_state(pinda_state); - + if (mmu_enabled == true) { lcd_puts_at_P(10, 0, _n("FINDA"));////MSG_FINDA c=5 lcd_set_cursor(LCD_WIDTH - 3, 0); lcd_print_state(finda_state); } - + if (ir_sensor_detected) { idler_state = !READ(IR_SENSOR_PIN); lcd_puts_at_P(0, 1, _i("Fil. sensor")); lcd_set_cursor(LCD_WIDTH - 3, 1); lcd_print_state(idler_state); } - + #ifdef PAT9125 - // Display X and Y difference from Filament sensor + // Display X and Y difference from Filament sensor // Display Light intensity from Filament sensor // Frame_Avg register represents the average brightness of all pixels within a frame (324 pixels). This // value ranges from 0(darkest) to 255(brightest). @@ -3940,8 +3940,8 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { { case 0: // default message - if (busy_state == PAUSED_FOR_USER) - { + if (busy_state == PAUSED_FOR_USER) + { prusa_statistics_case0(15); } else if (isPrintPaused) @@ -4054,7 +4054,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { prusa_stat_farm_number(); status_number = 5; break; - + case 90: // Error - Thermal Runaway prusa_statistics_err('1'); break; @@ -4074,7 +4074,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { prusa_stat_farm_number(); break; } - SERIAL_ECHOLN('}'); + SERIAL_ECHOLN('}'); } @@ -4138,65 +4138,65 @@ void lcd_pick_babystep(){ int enc_dif = 0; int cursor_pos = 1; int fsm = 0; - - - - + + + + lcd_clear(); - + lcd_set_cursor(0, 0); - + lcd_puts_P(_i("Pick print"));////MSG_PICK_Z - - + + lcd_set_cursor(3, 2); - + lcd_print('1'); - + lcd_set_cursor(3, 3); - + lcd_print('2'); - + lcd_set_cursor(12, 2); - + lcd_print('3'); - + lcd_set_cursor(12, 3); - + lcd_print('4'); - + lcd_set_cursor(1, 2); - + lcd_print('>'); - - + + enc_dif = lcd_encoder_diff; - + while (fsm == 0) { - + manage_heater(); manage_inactivity(true); - + if ( abs((enc_dif - lcd_encoder_diff)) > 4 ) { - + if ( (abs(enc_dif - lcd_encoder_diff)) > 1 ) { if (enc_dif > lcd_encoder_diff ) { cursor_pos --; } - + if (enc_dif < lcd_encoder_diff ) { cursor_pos ++; } - + if (cursor_pos > 4) { cursor_pos = 4; } - + if (cursor_pos < 1) { cursor_pos = 1; } - + lcd_set_cursor(1, 2); lcd_print(' '); lcd_set_cursor(1, 3); @@ -4205,7 +4205,7 @@ void lcd_pick_babystep(){ lcd_print(' '); lcd_set_cursor(10, 3); lcd_print(' '); - + if (cursor_pos < 3) { lcd_set_cursor(1, cursor_pos+1); lcd_print('>'); @@ -4213,14 +4213,14 @@ void lcd_pick_babystep(){ lcd_set_cursor(10, cursor_pos-1); lcd_print('>'); } - - + + enc_dif = lcd_encoder_diff; _delay(100); } - + } - + if (lcd_clicked()) { fsm = cursor_pos; int babyStepZ; @@ -4228,10 +4228,10 @@ void lcd_pick_babystep(){ EEPROM_save_B(EEPROM_BABYSTEP_Z,&babyStepZ); calibration_status_store(CALIBRATION_STATUS_CALIBRATED); _delay(500); - + } }; - + lcd_clear(); lcd_return_to_status(); } @@ -4413,7 +4413,7 @@ static void crash_mode_switch() else menu_goto(lcd_settings_menu, 9, true, true); } #endif //TMC2130 - + #ifdef FILAMENT_SENSOR static void lcd_fsensor_state_set() @@ -4483,7 +4483,7 @@ static void lcd_language_menu() } uint8_t cnt = lang_get_count(); #ifdef XFLASH - if (cnt == 2) //display secondary language in case of clear xflash + if (cnt == 2) //display secondary language in case of clear xflash { if (menu_item_text_P(lang_get_name_by_code(lang_get_code(1)))) { @@ -4504,7 +4504,7 @@ static void lcd_language_menu() #ifdef COMMUNITY_LANG_SUPPORT #ifdef XFLASH - MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu); ////MSG_COMMUNITY_MADE c=18 + MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu);////MSG_COMMUNITY_MADE c=18 #endif //XFLASH #endif //COMMUNITY_LANG_SUPPORT && W52X20CL @@ -4563,12 +4563,12 @@ void lcd_calibrate_pinda() { #ifndef SNMM /*void lcd_calibrate_extruder() { - + if (degHotend0() > EXTRUDE_MINTEMP) { current_position[E_AXIS] = 0; //set initial position to zero plan_set_e_position(current_position[E_AXIS]); - + //long steps_start = st_get_position(E_AXIS); long steps_final; @@ -4582,8 +4582,8 @@ void lcd_calibrate_pinda() { lcd_show_fullscreen_message_and_wait_P(_i("Mark filament 100mm from extruder body. Click when done."));////MSG_MARK_FIL c=20 r=8 lcd_clear(); - - + + lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_PLEASE_WAIT)); current_position[E_AXIS] += e_shift_calibration; plan_buffer_line_curposXYZE(feedrate, active_extruder); @@ -4610,23 +4610,23 @@ void lcd_calibrate_pinda() { current_position[E_AXIS] += float(abs((int)lcd_encoder)) * 0.01; //0.05 lcd_encoder = 0; plan_buffer_line_curposXYZE(feedrate, active_extruder); - + } - } + } } - + steps_final = current_position[E_AXIS] * axis_steps_per_unit[E_AXIS]; //steps_final = st_get_position(E_AXIS); lcd_draw_update = 1; e_steps_per_unit = ((float)(steps_final)) / 100.0f; - if (e_steps_per_unit < MIN_E_STEPS_PER_UNIT) e_steps_per_unit = MIN_E_STEPS_PER_UNIT; + if (e_steps_per_unit < MIN_E_STEPS_PER_UNIT) e_steps_per_unit = MIN_E_STEPS_PER_UNIT; if (e_steps_per_unit > MAX_E_STEPS_PER_UNIT) e_steps_per_unit = MAX_E_STEPS_PER_UNIT; lcd_clear(); axis_steps_per_unit[E_AXIS] = e_steps_per_unit; enquecommand_P(PSTR("M500")); //store settings to eeprom - + //lcd_drawedit(PSTR("Result"), ftostr31(axis_steps_per_unit[E_AXIS])); //delay_keep_alive(2000); delay_keep_alive(500); @@ -4703,7 +4703,7 @@ void lcd_first_layer_calibration_reset() 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\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 + lcd_printf_P(_i("Sheet %.7s\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 ? '>' : ' '); } @@ -4813,7 +4813,7 @@ static void wait_preheat() lcdui_print_temp(LCD_STR_THERMOMETER[0], (int)(degHotend(0) + 0.5), (int)(degTargetHotend(0) + 0.5)); delay_keep_alive(1000); } - + } static void lcd_wizard_load() @@ -4822,11 +4822,11 @@ static void lcd_wizard_load() { lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament into the first tube of the MMU, then press the knob to load it."));////MSG_MMU_INSERT_FILAMENT_FIRST_TUBE c=20 r=6 tmp_extruder = 0; - } + } else { lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament into the extruder, then press the knob to load it."));////MSG_WIZARD_LOAD_FILAMENT c=20 r=6 - } + } lcd_update_enable(false); lcd_clear(); lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT)); @@ -4905,14 +4905,14 @@ void lcd_wizard(WizState state) // Make sure EEPROM_WIZARD_ACTIVE is true if entering using different entry point // other than WizState::Run - it is useful for debugging wizard. if (state != S::Run) eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); - + FORCE_BL_ON_START; - + while (!end) { printf_P(PSTR("Wizard state: %d\n"), state); switch (state) { case S::Run: //Run wizard? - + // 2019-08-07 brutal hack - solving the "viper" situation. // It is caused by the fact, that tmc2130_st_isr makes a crash detection before the printers really starts. // And thus it calles stop_and_save_print_to_ram which sets the saved_printing flag. @@ -4921,9 +4921,9 @@ void lcd_wizard(WizState state) // This primarily happens when the printer is new and parked in 0,0 // So any new printer will fail the first layer calibration unless being reset or the Stop function gets called. // We really must find a way to prevent the crash from happening before the printer is started - that would be the correct solution. - // Btw. the flag may even trigger the viper situation on normal start this way and the user won't be able to find out why. + // Btw. the flag may even trigger the viper situation on normal start this way and the user won't be able to find out why. saved_printing = false; - + if( eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)==2){ lcd_show_fullscreen_message_and_wait_P(_T(MSG_WIZARD_WELCOME_SHIPPING)); state = S::Restore; @@ -4947,7 +4947,7 @@ void lcd_wizard(WizState state) case CALIBRATION_STATUS_CALIBRATED: end = true; eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0); break; default: state = S::Selftest; break; //if calibration status is unknown, run wizard from the beginning } - break; + break; case S::Selftest: lcd_show_fullscreen_message_and_wait_P(_i("First, I will run the selftest to check most common assembly problems."));////MSG_WIZARD_SELFTEST c=20 r=8 wizard_event = lcd_selftest(); @@ -5048,9 +5048,9 @@ void lcd_wizard(WizState state) default: break; } } - + FORCE_BL_ON_END; - + printf_P(_N("Wizard end state: %d\n"), state); switch (state) { //final message case S::Restore: //printer was already calibrated @@ -5066,7 +5066,7 @@ void lcd_wizard(WizState state) msg = _T(MSG_WIZARD_DONE); lcd_reset_alert_level(); lcd_setstatuspgm(_T(WELCOME_MSG)); - lcd_return_to_status(); + lcd_return_to_status(); break; default: @@ -5183,6 +5183,7 @@ static void disable_mmu_switch() { MMU_Disabled_from_menu = !MMU_Disabled_from_menu; eeprom_update_byte((unsigned char *)EEPROM_MMU_DISABLED_FROM_MENU, MMU_Disabled_from_menu); + softReset(); } static bool settingsDisableMMUFromMenu() @@ -5297,7 +5298,7 @@ do\ else MENU_ITEM_TOGGLE_P(_T(MSG_MMU_MODE), _T(MSG_STEALTH), lcd_silent_mode_mmu_set);\ }\ }\ -while (0) +while (0) #else //MMU_FORCE_STEALTH_MODE #define SETTINGS_MMU_MODE #endif //MMU_FORCE_STEALTH_MODE @@ -5340,10 +5341,10 @@ do\ switch(e_mbl_type)\ {\ case e_MBL_FAST:\ - MENU_ITEM_FUNCTION_P(_i("Mode [Fast]"),mbl_mode_set);\ + MENU_ITEM_FUNCTION_P(_i("Mode [Fast]"),mbl_mode_set);\ break; \ case e_MBL_OPTIMAL:\ - MENU_ITEM_FUNCTION_P(_i("Mode [Optimal]"), mbl_mode_set); \ + MENU_ITEM_FUNCTION_P(_i("Mode [Optimal]"), mbl_mode_set); \ break; \ case e_MBL_PREC:\ MENU_ITEM_FUNCTION_P(_i("Mode [Precise]"), mbl_mode_set); \ @@ -5715,7 +5716,7 @@ void lcd_hw_setup_menu(void) // can not be "static" //! The SuperPINDA is detected when the PINDA temp is below its defined limit. //! This works well on the EINSY board but not on the miniRAMBo board as //! as a disconnected SuperPINDA will show higher temps compared to an EINSY board. - //! + //! //! This menu allows the user to en-/disable the SuperPINDA manualy MENU_ITEM_TOGGLE_P(_N("SuperPINDA"), eeprom_read_byte((uint8_t *)EEPROM_PINDA_TEMP_COMPENSATION) ? _T(MSG_YES) : _T(MSG_NO), lcd_pinda_temp_compensation_toggle); #endif //PINDA_TEMP_COMP @@ -5740,7 +5741,7 @@ static void lcd_settings_menu() SETTINGS_FILAMENT_SENSOR; SETTINGS_AUTO_DEPLETE; - + SETTINGS_DISABLE_MMU_FROM_MENU; SETTINGS_CUTTER; @@ -5754,7 +5755,7 @@ static void lcd_settings_menu() bSettings=true; // flag ('fake parameter') for 'lcd_hw_setup_menu()' function MENU_ITEM_SUBMENU_P(_T(MSG_HW_SETUP), lcd_hw_setup_menu); } - + SETTINGS_MMU_MODE; MENU_ITEM_SUBMENU_P(_T(MSG_MESH_BED_LEVELING), lcd_mesh_bed_leveling_settings); @@ -5853,7 +5854,7 @@ static void lcd_calibration_menu() #endif // "Mesh Bed Leveling" MENU_ITEM_SUBMENU_P(_T(MSG_MESH_BED_LEVELING), lcd_mesh_bedleveling); - + #endif //MK1BP MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=18 @@ -5874,7 +5875,7 @@ static void lcd_calibration_menu() } #endif //MK1BP } - + MENU_END(); } @@ -6007,7 +6008,7 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be if (cursor_pos < 1){ cursor_pos = 1; Sound_MakeSound(e_SOUND_TYPE_BlindAlert); - } + } lcd_puts_at_P(0, 1, PSTR(" \n \n ")); lcd_set_cursor(0, cursor_pos); @@ -6023,7 +6024,7 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be return(cursor_pos - 1); } } - + } #endif //SNMM @@ -6048,7 +6049,7 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite int8_t first = 0; int8_t enc_dif = lcd_encoder_diff; int8_t cursor_pos = 1; - + lcd_clear(); KEEPALIVE_STATE(PAUSED_FOR_USER); @@ -6073,7 +6074,7 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite } if (cursor_pos > 3) - { + { cursor_pos = 3; if (first < items_no - 3) { @@ -6144,13 +6145,12 @@ char reset_menu() { , PSTR("Bowden length") #endif }; - enc_dif = lcd_encoder_diff; lcd_clear(); lcd_set_cursor(0, 0); lcd_putc('>'); lcd_consume_click(); - while (1) { + while (1) { for (uint_least8_t i = 0; i < 4; i++) { lcd_puts_at_P(1, i, item[first + i]); @@ -6216,7 +6216,7 @@ static void lcd_disable_farm_mode() } lcd_update_enable(true); lcd_draw_update = 2; - + } @@ -6418,7 +6418,7 @@ unsigned char lcd_choose_color() { manage_inactivity(true); proc_commands(); if (abs((enc_dif - lcd_encoder_diff)) > 12) { - + if (enc_dif > lcd_encoder_diff) { cursor_pos--; } @@ -6426,7 +6426,7 @@ unsigned char lcd_choose_color() { if (enc_dif < lcd_encoder_diff) { cursor_pos++; } - + if (cursor_pos > active_rows) { cursor_pos = active_rows; Sound_MakeSound(e_SOUND_TYPE_BlindAlert); @@ -6654,8 +6654,8 @@ static void lcd_sheet_menu() //! //! | recover print | ifdef TMC2130_DEBUG //! | power panic | ifdef TMC2130_DEBUG -//! -//! | Live adjust Z | printing + Z low +//! +//! | Live adjust Z | printing + Z low //! //! | Change filament | farm mode //! @@ -6675,7 +6675,7 @@ static void lcd_sheet_menu() //! | Eject filament | not printing + mmu or paused //! | Cut filament | not printing + mmu or paused + cut atctive //! | Settings | not printing or paused -//! | Calibration | not printing +//! | Calibration | not printing //! | Statistics | not printing //! | Fail stats | allways //! | Fail stats MMU | mmu @@ -6691,12 +6691,12 @@ static void lcd_main_menu() MENU_ITEM_BACK_P(_T(MSG_WATCH)); -#ifdef RESUME_DEBUG - if (!saved_printing) +#ifdef RESUME_DEBUG + if (!saved_printing) MENU_ITEM_FUNCTION_P(PSTR("tst - Save"), lcd_menu_test_save); else MENU_ITEM_FUNCTION_P(PSTR("tst - Restore"), lcd_menu_test_restore); -#endif //RESUME_DEBUG +#endif //RESUME_DEBUG #ifdef TMC2130_DEBUG MENU_ITEM_FUNCTION_P(PSTR("recover print"), recover_print); @@ -6846,7 +6846,7 @@ void stepper_timer_overflow() { static void lcd_colorprint_change() { - + enquecommand_P(PSTR("M600")); custom_message_type = CustomMsg::FilamentLoading; //just print status message @@ -7041,7 +7041,7 @@ static void mbl_probe_nr_toggle() { static void lcd_mesh_bed_leveling_settings() { - + bool magnet_elimination = (eeprom_read_byte((uint8_t*)EEPROM_MBL_MAGNET_ELIMINATION) > 0); uint8_t points_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_POINTS_NR); char sToggle[4]; //enough for nxn format @@ -7080,13 +7080,13 @@ static void lcd_backlight_menu() ON_MENU_LEAVE( backlight_save(); ); - + MENU_ITEM_BACK_P(_T(MSG_BACK)); MENU_ITEM_EDIT_int3_P(_T(MSG_BL_HIGH), &backlightLevel_HIGH, backlightLevel_LOW, 255); MENU_ITEM_EDIT_int3_P(_T(MSG_BL_LOW), &backlightLevel_LOW, 0, backlightLevel_HIGH); MENU_ITEM_TOGGLE_P(_T(MSG_MODE), ((backlightMode==BACKLIGHT_MODE_BRIGHT) ? _T(MSG_BRIGHT) : ((backlightMode==BACKLIGHT_MODE_DIM) ? _T(MSG_DIM) : _T(MSG_AUTO))), backlight_mode_toggle); MENU_ITEM_EDIT_int3_P(_T(MSG_TIMEOUT), &backlightTimer_period, 1, 999); - + MENU_END(); } #endif //LCD_BL_PIN @@ -7190,9 +7190,9 @@ void lcd_print_stop() custom_message_type = CustomMsg::Status; planner_abort_hard(); //needs to be done since plan_buffer_line resets waiting_inside_plan_buffer_line_print_aborted to false. Also copies current to destination. - + axis_relative_modes = E_AXIS_MASK; //XYZ absolute, E relative - + isPrintPaused = false; //clear isPrintPaused flag to allow starting next print after pause->stop scenario. } @@ -7207,7 +7207,7 @@ void lcd_sdcard_stop() if ((int32_t)lcd_encoder > 2) { lcd_encoder = 2; } if ((int32_t)lcd_encoder < 1) { lcd_encoder = 1; } - + lcd_putc_at(0, 1 + lcd_encoder, '>'); if (lcd_clicked()) @@ -7242,7 +7242,7 @@ void lcd_sdcard_menu() } _menu_data_sdcard_t; static_assert(sizeof(menu_data)>= sizeof(_menu_data_sdcard_t),"_menu_data_sdcard_t doesn't fit into menu_data"); _menu_data_sdcard_t* _md = (_menu_data_sdcard_t*)&(menu_data[0]); - + switch(_md->menuState) { case _uninitialized: //Initialize menu data @@ -7274,12 +7274,12 @@ void lcd_sdcard_menu() } if (lcd_draw_update == 0 && !LCD_CLICKED) return; // nothing to do (so don't thrash the SD card) - + _md->row = -1; // assume that no SD file/dir is currently selected. Once they are rendered, it will be changed to the correct row for the _scrolling state. - + //if we reached this point it means that the encoder moved or clicked or the state is being switched. Reset the scrollTimer. _md->lcd_scrollTimer.start(); - + MENU_BEGIN(); MENU_ITEM_BACK_P(_T(bMain?MSG_MAIN:MSG_BACK)); // i.e. default menu-item / menu-item after card insertion card.getWorkDirName(); @@ -7310,7 +7310,7 @@ void lcd_sdcard_menu() #endif if (lcd_encoder == menu_item) //If the file is selected. { - + _md->selectedFileID = i; _md->isDir = card.filenameIsDir; _md->row = menu_row; @@ -7327,7 +7327,7 @@ void lcd_sdcard_menu() case _scrolling: //scrolling filename { const bool rewindFlag = LCD_CLICKED || lcd_draw_update; //flag that says whether the menu should return to _standard state. - + if (_md->scrollPointer == NULL) { //load filename to memory. @@ -7341,7 +7341,7 @@ void lcd_sdcard_menu() #endif _md->scrollPointer = (card.longFilename[0] == '\0') ? card.filename : card.longFilename; } - + if (rewindFlag == 1) _md->offset = 0; //redraw once again from the beginning. if (_md->lcd_scrollTimer.expired(300) || rewindFlag) @@ -7390,13 +7390,13 @@ void lcd_belttest() lcd_clear(); // Belttest requires high power mode. Enable it. FORCE_HIGH_POWER_START; - + uint16_t X = eeprom_read_word((uint16_t*)(EEPROM_BELTSTATUS_X)); uint16_t Y = eeprom_read_word((uint16_t*)(EEPROM_BELTSTATUS_Y)); lcd_printf_P(_T(MSG_CHECKING_X)); lcd_set_cursor(0,1), lcd_printf_P(PSTR("X: %u -> ..."),X); KEEPALIVE_STATE(IN_HANDLER); - + // N.B: it doesn't make sense to handle !lcd_selfcheck...() because selftest_sg throws its own error screen // that clobbers ours, with more info than we could provide. So on fail we just fall through to take us back to status. if (lcd_selfcheck_axis_sg(X_AXIS)){ @@ -7413,7 +7413,7 @@ void lcd_belttest() lcd_wait_for_click_delay(10); } } - + FORCE_HIGH_POWER_END; KEEPALIVE_STATE(NOT_BUSY); } @@ -7692,7 +7692,7 @@ bool lcd_selftest() { if (mmu_enabled) - { + { _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filaments sensor _result = selftest_irsensor(); if (_result) @@ -7734,7 +7734,7 @@ bool lcd_selftest() lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); lcd_update_enable(true); - + if (_result) { LCD_ALERTMESSAGERPGM(_i("Self test OK"));////MSG_SELFTEST_OK c=20 @@ -7746,9 +7746,9 @@ bool lcd_selftest() #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif // TMC2130 - + FORCE_BL_ON_END; - + KEEPALIVE_STATE(NOT_BUSY); return(_result); } @@ -7763,7 +7763,7 @@ static void reset_crash_det(unsigned char axis) { } static bool lcd_selfcheck_axis_sg(unsigned char axis) { -// each axis length is measured twice +// each axis length is measured twice float axis_length, current_position_init, current_position_final; float measured_axis_length[2]; float margin = 60; @@ -7783,12 +7783,12 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { st_synchronize(); tmc2130_home_enter(1 << axis); -// first axis length measurement begin - +// first axis length measurement begin + current_position[axis] -= (axis_length + margin); plan_buffer_line_curposXYZE(manual_feedrate[0] / 60); - + st_synchronize(); tmc2130_sg_meassure_start(axis); @@ -7812,16 +7812,16 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { measured_axis_length[0] = abs(current_position_final - current_position_init); -// first measurement end and second measurement begin +// first measurement end and second measurement begin current_position[axis] -= margin; plan_buffer_line_curposXYZE(manual_feedrate[0] / 60); - st_synchronize(); + st_synchronize(); current_position[axis] -= (axis_length + margin); plan_buffer_line_curposXYZE(manual_feedrate[0] / 60); - + st_synchronize(); current_position_init = st_get_position_mm(axis); @@ -7854,7 +7854,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { } printf_P(_N("Axis length difference:%.3f\n"), abs(measured_axis_length[0] - measured_axis_length[1])); - + if (abs(measured_axis_length[0] - measured_axis_length[1]) > 1) { //check if difference between first and second measurement is low //loose pulleys const char *_error_1; @@ -7977,7 +7977,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel) { lcd_selftest_error(TestError::Motor, _error_1, _error_2); } - } + } current_position[_axis] = 0; //simulate axis home to avoid negative numbers for axis position, especially Z. plan_set_position_curposXYZE(); @@ -7996,7 +7996,7 @@ static bool lcd_selfcheck_pulleys(int axis) refresh_cmd_timeout(); manage_inactivity(true); - if (axis == 0) move = 50; //X_AXIS + if (axis == 0) move = 50; //X_AXIS else move = 50; //Y_AXIS current_position_init = current_position[axis]; @@ -8010,7 +8010,7 @@ static bool lcd_selfcheck_pulleys(int axis) plan_buffer_line_curposXYZE(200); st_synchronize(); if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents - else st_current_set(0, tmp_motor_loud[0]); //set motor current back + else st_current_set(0, tmp_motor_loud[0]); //set motor current back current_position[axis] = current_position[axis] - move; plan_buffer_line_curposXYZE(50); st_synchronize(); @@ -8128,7 +8128,7 @@ static bool lcd_selfcheck_check_heater(bool _isbed) }*/ if(_counter%5 == 0) serialecho_temperatures(); //show temperatures once in two seconds - } while (_docycle); + } while (_docycle); target_temperature[0] = 0; target_temperature_bed = 0; @@ -8169,9 +8169,9 @@ static bool lcd_selfcheck_check_heater(bool _isbed) static void lcd_selftest_error(TestError testError, const char *_error_1, const char *_error_2) { lcd_beeper_quick_feedback(); - + FORCE_BL_ON_END; - + target_temperature[0] = 0; target_temperature_bed = 0; manage_heater(); @@ -8645,9 +8645,9 @@ static bool check_file(const char* filename) { get_command(); result = check_commands(); } - + menu_progressbar_finish(); - + cmdqueue_serial_disabled = false; card.printingHasFinished(); @@ -8688,7 +8688,7 @@ static void menu_action_sdfile(const char* filename) eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, card.dir_names[i][j]); } } - + //filename is just a pointer to card.filename, which changes everytime you try to open a file by filename. So you can't use filename directly //to open a file. Instead, the cached filename in cmd is used as that one is static for the whole lifetime of this function. if (!check_file(cmd + 4)) { @@ -8769,15 +8769,15 @@ static void lcd_send_status() { static void lcd_connect_printer() { lcd_update_enable(false); lcd_clear(); - + int i = 0; int t = 0; - lcd_puts_at_P(0, 0, _i("Connect printer to")); + lcd_puts_at_P(0, 0, _i("Connect printer to")); lcd_puts_at_P(0, 1, _i("monitoring or hold")); lcd_puts_at_P(0, 2, _i("the knob to continue")); while (no_response) { i++; - t++; + t++; delay_keep_alive(100); proc_commands(); if (t == 10) { @@ -8785,7 +8785,7 @@ static void lcd_connect_printer() { t = 0; } if (READ(BTN_ENC)) { //if button is not pressed - i = 0; + i = 0; lcd_puts_at_P(0, 3, PSTR(" ")); } if (i!=0) lcd_puts_at_P((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\xFF"); @@ -9104,7 +9104,7 @@ void UserECool_toggle(){ bool UserECoolEnabled(){ // We enable E-cool mode for non-farm prints IFF the experimental menu is visible AND the EEPROM_ECOOL variable has // a value of the universal answer to all problems of the universe - return ( eeprom_read_byte((uint8_t *)EEPROM_ECOOL_ENABLE) == EEPROM_ECOOL_MAGIC_NUMBER ) + return ( eeprom_read_byte((uint8_t *)EEPROM_ECOOL_ENABLE) == EEPROM_ECOOL_MAGIC_NUMBER ) && ( eeprom_read_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY) == 1 ); } @@ -9120,7 +9120,7 @@ void lcd_experimental_menu() #ifdef EXTRUDER_ALTFAN_DETECT MENU_ITEM_TOGGLE_P(_N("ALTFAN det."), altfanOverride_get()?_T(MSG_OFF):_T(MSG_ON), altfanOverride_toggle);////MSG_MENU_ALTFAN c=18 #endif //EXTRUDER_ALTFAN_DETECT - + #ifdef TMC2130 MENU_ITEM_TOGGLE_P(_N("E-cool mode"), UserECoolEnabled()?_T(MSG_ON):_T(MSG_OFF), UserECool_toggle);////MSG_MENU_ECOOL c=18 #endif