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,24 +709,7 @@ void softReset()
#endif
// 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);
static void factory_reset_stats(){
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
@ -744,17 +727,31 @@ static void factory_reset(char level)
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
static void factory_reset(char level)
{
lcd_clear();
Sound_MakeCustom(100,0,false);
switch (level) {
lcd_menu_statistics();
case 0: // Level 0: Language reset
lang_reset();
break;
// Level 2: Prepare for shipping
case 2:
//lcd_puts_P(PSTR("Factory RESET"));
//lcd_puts_at_P(1,2,PSTR("Shipping prep"));
case 1: //Level 1: Reset statistics
factory_reset_stats();
lcd_menu_statistics();
break;
case 2: // Level 2: Prepare for shipping
factory_reset_stats();
// [[fallthrough]] // there is no break intentionally
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.
@ -763,51 +760,29 @@ static void factory_reset(char level)
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
fsensor_enable();
fsensor_autoload_set(true);
#endif //FILAMENT_SENSOR
Sound_MakeCustom(100,0,false);
//_delay_ms(2000);
break;
// Level 3: erase everything, whole EEPROM will be set to 0xFF
case 3:
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"));
Sound_MakeCustom(100,0,false);
er_progress = 0;
lcd_puts_at_P(3, 3, PSTR(" "));
uint16_t er_progress = 0;
lcd_set_cursor(3, 3);
lcd_space(6);
lcd_set_cursor(3, 3);
lcd_print(er_progress);
// Erase EEPROM
for (int i = 0; i < 4096; i++) {
for (uint16_t 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_space(6);
lcd_set_cursor(3, 3);
lcd_print(er_progress);
lcd_puts_P(PSTR("%"));
@ -815,18 +790,17 @@ static void factory_reset(char level)
}
softReset();
}break;
break;
case 4:
#ifdef SNMM
case 5:
bowden_menu();
break;
#endif
default:
break;
}
}
extern "C" {
@ -857,10 +831,8 @@ void factory_reset()
{
lcd_clear();
lcd_puts_P(PSTR("Factory RESET"));
SET_OUTPUT(BEEPER);
if(eSoundMode!=e_SOUND_MODE_SILENT)
WRITE(BEEPER, HIGH);
@ -869,18 +841,17 @@ void factory_reset()
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;
}
}

View File

@ -6136,15 +6136,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