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 #endif
// Factory reset function static void factory_reset_stats(){
// 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_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 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_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_FAIL, 0);
eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_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; break;
// Level 2: Prepare for shipping case 1: //Level 1: Reset statistics
case 2: factory_reset_stats();
//lcd_puts_P(PSTR("Factory RESET")); lcd_menu_statistics();
//lcd_puts_at_P(1,2,PSTR("Shipping prep")); 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. // Force language selection at the next boot up.
lang_reset(); lang_reset();
// Force the "Follow calibration flow" message at the next boot up. // Force the "Follow calibration flow" message at the next boot up.
@ -763,51 +760,29 @@ static void factory_reset(char level)
farm_mode = false; farm_mode = false;
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); 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);
//_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
case 3:
lcd_puts_P(PSTR("Factory RESET")); lcd_puts_P(PSTR("Factory RESET"));
lcd_puts_at_P(1, 2, PSTR("ERASING all data")); lcd_puts_at_P(1, 2, PSTR("ERASING all data"));
uint16_t er_progress = 0;
Sound_MakeCustom(100,0,false); lcd_set_cursor(3, 3);
er_progress = 0; lcd_space(6);
lcd_puts_at_P(3, 3, PSTR(" "));
lcd_set_cursor(3, 3); lcd_set_cursor(3, 3);
lcd_print(er_progress); lcd_print(er_progress);
// Erase EEPROM // Erase EEPROM
for (int i = 0; i < 4096; i++) { for (uint16_t i = 0; i < 4096; i++) {
eeprom_update_byte((uint8_t*)i, 0xFF); eeprom_update_byte((uint8_t*)i, 0xFF);
if (i % 41 == 0) { if (i % 41 == 0) {
er_progress++; er_progress++;
lcd_puts_at_P(3, 3, PSTR(" ")); lcd_set_cursor(3, 3);
lcd_space(6);
lcd_set_cursor(3, 3); lcd_set_cursor(3, 3);
lcd_print(er_progress); lcd_print(er_progress);
lcd_puts_P(PSTR("%")); lcd_puts_P(PSTR("%"));
@ -815,18 +790,17 @@ static void factory_reset(char level)
} }
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,10 +831,8 @@ 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);
@ -869,18 +841,17 @@ void factory_reset()
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