Factory reset at startup

pull/16/head
Łukasz Nidecki 2021-02-22 21:30:27 +01:00
parent 5c56456e3f
commit 4cb94db0bd
1 changed files with 19 additions and 1 deletions

View File

@ -386,6 +386,11 @@ void setup(){
#endif #endif
#ifdef ENABLE_PREFERENCES #ifdef ENABLE_PREFERENCES
int clear_preferences = 0;
if(digitalRead(BUTTON)==LOW){
clear_preferences = 1;
}
preferences.begin("cfg", false); preferences.begin("cfg", false);
aprsSymbolTable = preferences.getString(PREF_APRS_SYMBOL_TABLE); aprsSymbolTable = preferences.getString(PREF_APRS_SYMBOL_TABLE);
if (aprsSymbolTable.isEmpty()){ if (aprsSymbolTable.isEmpty()){
@ -446,7 +451,14 @@ void setup(){
preferences.putInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET, fix_beacon_interval/1000); preferences.putInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET, fix_beacon_interval/1000);
} }
fix_beacon_interval = preferences.getInt(PREF_APRS_FIXED_BEACON_PRESET) * 1000; fix_beacon_interval = preferences.getInt(PREF_APRS_FIXED_BEACON_PRESET) * 1000;
if (clear_preferences){
delay(1000);
if(digitalRead(BUTTON)==LOW){
clear_preferences = 2;
preferences.clear();
}
}
#endif #endif
for (int i=0;i<ANGLE_AVGS;i++) { // set average_course to "0" for (int i=0;i<ANGLE_AVGS;i++) { // set average_course to "0"
@ -476,7 +488,13 @@ void setup(){
if(!display.begin(SSD1306_SWITCHCAPVCC, SSD1306_ADDRESS)) { if(!display.begin(SSD1306_SWITCHCAPVCC, SSD1306_ADDRESS)) {
for(;;); // Don't proceed, loop forever for(;;); // Don't proceed, loop forever
} }
#ifdef ENABLE_PREFERENCES
if (clear_preferences == 2){
writedisplaytext("LoRa-APRS","","","Factory reset!!","","",0);
delay(3000);
ESP.restart();
}
#endif
writedisplaytext("LoRa-APRS","","Init:","Display OK!","","",1000); writedisplaytext("LoRa-APRS","","Init:","Display OK!","","",1000);
Tcall = prepareCallsign(String(CALLSIGN)); Tcall = prepareCallsign(String(CALLSIGN));