Skip to content

Commit 3d76287

Browse files
committed
Immediately do system reset if train button triggers factory defaults
1 parent 8677f99 commit 3d76287

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Firmware/LoRaSerial/System.ino

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,25 @@ void updateButton()
274274
//Update the LEDs
275275
deltaTime = millis() - pressedTime;
276276
buttonLeds(deltaTime);
277+
278+
//Check for reset to factory settings
279+
if (deltaTime >= trainButtonFactoryResetTime)
280+
{
281+
//Erase the EEPROM
282+
nvmErase();
283+
284+
//Reboot the radio
285+
commandReset();
286+
}
287+
277288
if (!buttonPressed)
278289
{
279290
//Button just released
280291
settings = originalSettings;
281292

282-
//Check for reset to factory settings
283-
if (deltaTime >= trainButtonFactoryResetTime)
284-
{
285-
//Erase the EEPROM
286-
nvmErase();
287-
288-
//Reboot the radio
289-
commandReset();
290-
}
291-
292293
//Starting training or exiting training via the button is only possible
293294
//when the radio is not in command mode!
294-
else if (!inCommandMode)
295+
if (!inCommandMode)
295296
{
296297
//Check for server training request
297298
if (deltaTime >= trainButtonServerTime)
@@ -342,7 +343,7 @@ void updateButton()
342343

343344
//Save the previous led state
344345
if (!inTraining)
345-
originalSettings = settings;
346+
originalSettings = settings;
346347
}
347348
}
348349

0 commit comments

Comments
 (0)