From 3668cdeb30eb95fb02f894decae2e1a95e399784 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 8 Feb 2021 17:27:32 +0100 Subject: [PATCH 1/2] Add Service prep. item into Factory reset upon request from our Service dept. - it is to do the same stuff like Shipping prep., but keep the printer's stats intact. Still, this has to be verified and may undergo some further changes. --- Firmware/Marlin_main.cpp | 191 +++++++++++++++++---------------------- Firmware/ultralcd.cpp | 6 +- 2 files changed, 84 insertions(+), 113 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6db1d277..db339124 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -711,124 +711,98 @@ void softReset() #endif +static void factory_reset_stats(){ + eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); + eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); + eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); + eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); + + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + + eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); +} + // Factory reset function // This function is used to erase parts or whole EEPROM memory which is used for storing calibration and and so on. // Level input parameter sets depth of reset -int er_progress = 0; static void factory_reset(char level) -{ +{ lcd_clear(); - switch (level) { - - // Level 0: Language reset - case 0: - Sound_MakeCustom(100,0,false); - lang_reset(); - break; - - //Level 1: Reset statistics - case 1: - Sound_MakeCustom(100,0,false); - eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); - eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + Sound_MakeCustom(100,0,false); + switch (level) { - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); - eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); - eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); + case 0: // Level 0: Language reset + lang_reset(); + break; - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + case 1: //Level 1: Reset statistics + factory_reset_stats(); + lcd_menu_statistics(); + break; - eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + case 2: // Level 2: Prepare for shipping + factory_reset_stats(); + // [[fallthrough]] // there is no break intentionally - - lcd_menu_statistics(); - - break; - - // Level 2: Prepare for shipping - case 2: - //lcd_puts_P(PSTR("Factory RESET")); - //lcd_puts_at_P(1,2,PSTR("Shipping prep")); - - // Force language selection at the next boot up. - lang_reset(); - // Force the "Follow calibration flow" message at the next boot up. - calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION); - eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard - farm_mode = false; - eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); - - eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); - eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); - - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); - eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); - eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); - - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); - - eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + case 4: // Level 4: Preparation after being serviced + // Force language selection at the next boot up. + lang_reset(); + // Force the "Follow calibration flow" message at the next boot up. + calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION); + eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard + farm_mode = false; + eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); #ifdef FILAMENT_SENSOR - fsensor_enable(); - fsensor_autoload_set(true); + fsensor_enable(); + fsensor_autoload_set(true); #endif //FILAMENT_SENSOR - Sound_MakeCustom(100,0,false); - //_delay_ms(2000); - break; + break; - // Level 3: erase everything, whole EEPROM will be set to 0xFF + case 3:{ // Level 3: erase everything, whole EEPROM will be set to 0xFF + lcd_puts_P(PSTR("Factory RESET")); + lcd_puts_at_P(1, 2, PSTR("ERASING all data")); + uint16_t er_progress = 0; + lcd_set_cursor(3, 3); + lcd_space(6); + lcd_set_cursor(3, 3); + lcd_print(er_progress); - case 3: - lcd_puts_P(PSTR("Factory RESET")); - lcd_puts_at_P(1, 2, PSTR("ERASING all data")); - - Sound_MakeCustom(100,0,false); - er_progress = 0; - lcd_puts_at_P(3, 3, PSTR(" ")); - lcd_set_cursor(3, 3); - lcd_print(er_progress); - - // Erase EEPROM - for (int i = 0; i < 4096; i++) { - eeprom_update_byte((uint8_t*)i, 0xFF); - - if (i % 41 == 0) { - er_progress++; - lcd_puts_at_P(3, 3, PSTR(" ")); - lcd_set_cursor(3, 3); - lcd_print(er_progress); - lcd_puts_P(PSTR("%")); - } + // Erase EEPROM + for (uint16_t i = 0; i < 4096; i++) { + eeprom_update_byte((uint8_t*)i, 0xFF); + if (i % 41 == 0) { + er_progress++; + lcd_set_cursor(3, 3); + lcd_space(6); + lcd_set_cursor(3, 3); + lcd_print(er_progress); + lcd_puts_P(PSTR("%")); } - softReset(); + + } + softReset(); + }break; - break; - case 4: - bowden_menu(); - break; - - default: - break; - } - - +#ifdef SNMM + case 5: + bowden_menu(); + break; +#endif + default: + break; + } } extern "C" { @@ -859,30 +833,27 @@ void factory_reset() { lcd_clear(); - lcd_puts_P(PSTR("Factory RESET")); - SET_OUTPUT(BEEPER); - if(eSoundMode!=e_SOUND_MODE_SILENT) - WRITE(BEEPER, HIGH); + if(eSoundMode!=e_SOUND_MODE_SILENT) + WRITE(BEEPER, HIGH); while (!READ(BTN_ENC)); WRITE(BEEPER, LOW); - - _delay_ms(2000); char level = reset_menu(); factory_reset(level); switch (level) { - case 0: _delay_ms(0); break; - case 1: _delay_ms(0); break; - case 2: _delay_ms(0); break; - case 3: _delay_ms(0); break; + case 0: + case 1: + case 2: + case 3: + case 4: _delay_ms(0); break; } } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d3686509..96e494ab 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6087,15 +6087,15 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite char reset_menu() { const uint8_t items_no = #ifdef SNMM - 5; + 6; #else - 4; + 5; #endif static int8_t first = 0; int8_t enc_dif = 0; char cursor_pos = 0; - const char *const item[items_no] PROGMEM = {PSTR("Language"), PSTR("Statistics"), PSTR("Shipping prep"), PSTR("All Data") + const char *const item[items_no] PROGMEM = {PSTR("Language"), PSTR("Statistics"), PSTR("Shipping prep"), PSTR("All Data"), PSTR("Service prep") #ifdef SNMM , PSTR("Bowden length") #endif From dbb0269bd4f832117c6248eb514f2cfbdd1b8122 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 17 Feb 2021 08:27:49 +0100 Subject: [PATCH 2/2] Make indentation consistent with surrounding code in factory_reset() --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index db339124..537c55cb 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -737,7 +737,7 @@ static void factory_reset_stats(){ static void factory_reset(char level) { lcd_clear(); - Sound_MakeCustom(100,0,false); + Sound_MakeCustom(100,0,false); switch (level) { case 0: // Level 0: Language reset