Merge pull request #3023 from DRracer/service-prep

Add Service prep. item into Factory reset
This commit is contained in:
DRracer 2021-02-17 10:43:08 +01:00 committed by GitHub
commit 7a84ad71dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 113 deletions

View file

@ -709,124 +709,98 @@ void softReset()
#endif #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 // Factory reset function
// This function is used to erase parts or whole EEPROM memory which is used for storing calibration and and so on. // 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 // Level input parameter sets depth of reset
int er_progress = 0;
static void factory_reset(char level) static void factory_reset(char level)
{ {
lcd_clear(); lcd_clear();
switch (level) { Sound_MakeCustom(100,0,false);
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);
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); case 0: // Level 0: Language reset
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); lang_reset();
eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); break;
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); case 1: //Level 1: Reset statistics
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); factory_reset_stats();
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); lcd_menu_statistics();
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); break;
eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); case 2: // Level 2: Prepare for shipping
eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); factory_reset_stats();
eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); // [[fallthrough]] // there is no break intentionally
eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
case 4: // Level 4: Preparation after being serviced
lcd_menu_statistics(); // Force language selection at the next boot up.
lang_reset();
break; // Force the "Follow calibration flow" message at the next boot up.
calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION);
// Level 2: Prepare for shipping eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard
case 2: farm_mode = false;
//lcd_puts_P(PSTR("Factory RESET")); eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
//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);
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
fsensor_enable(); fsensor_enable();
fsensor_autoload_set(true); fsensor_autoload_set(true);
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
Sound_MakeCustom(100,0,false); break;
//_delay_ms(2000);
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: // Erase EEPROM
lcd_puts_P(PSTR("Factory RESET")); for (uint16_t i = 0; i < 4096; i++) {
lcd_puts_at_P(1, 2, PSTR("ERASING all data")); eeprom_update_byte((uint8_t*)i, 0xFF);
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("%"));
}
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; #ifdef SNMM
case 4: case 5:
bowden_menu(); bowden_menu();
break; break;
#endif
default: default:
break; break;
} }
} }
extern "C" { extern "C" {
@ -857,30 +831,27 @@ void factory_reset()
{ {
lcd_clear(); lcd_clear();
lcd_puts_P(PSTR("Factory RESET")); lcd_puts_P(PSTR("Factory RESET"));
SET_OUTPUT(BEEPER); SET_OUTPUT(BEEPER);
if(eSoundMode!=e_SOUND_MODE_SILENT) if(eSoundMode!=e_SOUND_MODE_SILENT)
WRITE(BEEPER, HIGH); WRITE(BEEPER, HIGH);
while (!READ(BTN_ENC)); while (!READ(BTN_ENC));
WRITE(BEEPER, LOW); WRITE(BEEPER, LOW);
_delay_ms(2000); _delay_ms(2000);
char level = reset_menu(); char level = reset_menu();
factory_reset(level); factory_reset(level);
switch (level) { switch (level) {
case 0: _delay_ms(0); break; case 0:
case 1: _delay_ms(0); break; case 1:
case 2: _delay_ms(0); break; case 2:
case 3: _delay_ms(0); break; case 3:
case 4: _delay_ms(0); break;
} }
} }

View file

@ -6136,15 +6136,15 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite
char reset_menu() { char reset_menu() {
const uint8_t items_no = const uint8_t items_no =
#ifdef SNMM #ifdef SNMM
5; 6;
#else #else
4; 5;
#endif #endif
static int8_t first = 0; static int8_t first = 0;
int8_t enc_dif = 0; int8_t enc_dif = 0;
char cursor_pos = 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 #ifdef SNMM
, PSTR("Bowden length") , PSTR("Bowden length")
#endif #endif