Skip to content

Commit 91c0779

Browse files
committed
Elevate "system reset after X minutes" to system menu option
1 parent ef4c95e commit 91c0779

File tree

1 file changed

+60
-59
lines changed

1 file changed

+60
-59
lines changed

Firmware/RTK_Everywhere/menuSystem.ino

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,24 @@ void menuSystem()
167167

168168
systemPrintln("----- Settings -----");
169169

170-
if (present.beeper == true)
170+
systemPrint("a) Automatic device reboot in minutes: ");
171+
if (settings.rebootMinutes == 0)
172+
systemPrintln("Disabled");
173+
else
171174
{
172-
systemPrint("a) Audible Prompts: ");
173-
systemPrintf("%s\r\n", settings.enableBeeper ? "Enabled" : "Disabled");
175+
int days;
176+
int hours;
177+
int minutes;
178+
179+
const int minutesInADay = 60 * 24;
180+
181+
minutes = settings.rebootMinutes;
182+
days = minutes / minutesInADay;
183+
minutes -= days * minutesInADay;
184+
hours = minutes / 60;
185+
minutes -= hours * 60;
186+
187+
systemPrintf("%d (%d days %d:%02d)\r\n", settings.rebootMinutes, days, hours, minutes);
174188
}
175189

176190
systemPrint("b) Set Bluetooth Mode: ");
@@ -204,6 +218,12 @@ void menuSystem()
204218
systemPrintln("f) Display microSD Files");
205219
}
206220

221+
if (present.beeper == true)
222+
{
223+
systemPrint("g) Enable Beeper: ");
224+
systemPrintf("%s\r\n", settings.enableBeeper ? "Enabled" : "Disabled");
225+
}
226+
207227
systemPrintln("h) Debug hardware");
208228

209229
systemPrintln("n) Debug network");
@@ -230,9 +250,38 @@ void menuSystem()
230250

231251
byte incoming = getUserInputCharacterNumber();
232252

233-
if (incoming == 'a' && present.beeper == true)
253+
if (incoming == 'a')
234254
{
235-
settings.enableBeeper ^= 1;
255+
// We use millis (uint32_t) to measure the reboot interval. 4294967000 is just less than (2^32 - 1)
256+
systemPrint("Enter uptime minutes before reboot, Disabled = 0, Reboot range (1 - 4294967): ");
257+
int rebootMinutes = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
258+
if ((rebootMinutes != INPUT_RESPONSE_GETNUMBER_EXIT) && (rebootMinutes != INPUT_RESPONSE_GETNUMBER_TIMEOUT))
259+
{
260+
if (rebootMinutes < 1 || rebootMinutes > 4294967) // Disable the reboot
261+
{
262+
settings.rebootMinutes = 0;
263+
systemPrintln("Reset is disabled");
264+
}
265+
else
266+
{
267+
int days;
268+
int hours;
269+
int minutes;
270+
271+
const int minutesInADay = 60 * 24;
272+
273+
// Set the reboot time
274+
settings.rebootMinutes = rebootMinutes;
275+
276+
minutes = settings.rebootMinutes;
277+
days = minutes / minutesInADay;
278+
minutes -= days * minutesInADay;
279+
hours = minutes / 60;
280+
minutes -= hours * 60;
281+
282+
systemPrintf("Reboot after uptime reaches %d days %d:%02d\r\n", days, hours, minutes);
283+
}
284+
}
236285
}
237286
else if (incoming == 'b')
238287
{
@@ -262,6 +311,10 @@ void menuSystem()
262311
{
263312
printFileList();
264313
}
314+
else if (incoming == 'g' && present.beeper == true)
315+
{
316+
settings.enableBeeper ^= 1;
317+
}
265318
else if (incoming == 'h')
266319
menuDebugHardware();
267320
else if (incoming == 'n')
@@ -750,33 +803,14 @@ void menuDebugSoftware()
750803
systemPrint("31) Print duplicate states: ");
751804
systemPrintf("%s\r\n", settings.enablePrintDuplicateStates ? "Enabled" : "Disabled");
752805

753-
systemPrint("32) Automatic device reboot in minutes: ");
754-
if (settings.rebootMinutes == 0)
755-
systemPrintln("Disabled");
756-
else
757-
{
758-
int days;
759-
int hours;
760-
int minutes;
761-
762-
const int minutesInADay = 60 * 24;
763-
764-
minutes = settings.rebootMinutes;
765-
days = minutes / minutesInADay;
766-
minutes -= days * minutesInADay;
767-
hours = minutes / 60;
768-
minutes -= hours * 60;
769-
770-
systemPrintf("%d (%d days %d:%02d)\r\n", settings.rebootMinutes, days, hours, minutes);
771-
}
772-
773806
systemPrintf("33) Print boot times: %s\r\n", settings.printBootTimes ? "Enabled" : "Disabled");
774807

775808
systemPrintf("34) Print partition table: %s\r\n", settings.printPartitionTable ? "Enabled" : "Disabled");
776809

777810
// Debug
778811

779-
systemPrintf("40) Print LittleFS and settings management: %s\r\n", settings.debugSettings ? "Enabled" : "Disabled");
812+
systemPrintf("40) Print LittleFS and settings management: %s\r\n",
813+
settings.debugSettings ? "Enabled" : "Disabled");
780814

781815
// Tasks
782816
systemPrint("50) Task Highwater Reporting: ");
@@ -823,39 +857,6 @@ void menuDebugSoftware()
823857
settings.enablePrintStates ^= 1;
824858
else if (incoming == 31)
825859
settings.enablePrintDuplicateStates ^= 1;
826-
else if (incoming == 32)
827-
{
828-
// We use millis (uint32_t) to measure the reboot interval. 4294967000 is just less than (2^32 - 1)
829-
systemPrint("Enter uptime minutes before reboot, Disabled = 0, Reboot range (1 - 4294967): ");
830-
int rebootMinutes = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
831-
if ((rebootMinutes != INPUT_RESPONSE_GETNUMBER_EXIT) && (rebootMinutes != INPUT_RESPONSE_GETNUMBER_TIMEOUT))
832-
{
833-
if (rebootMinutes < 1 || rebootMinutes > 4294967) // Disable the reboot
834-
{
835-
settings.rebootMinutes = 0;
836-
systemPrintln("Reset is disabled");
837-
}
838-
else
839-
{
840-
int days;
841-
int hours;
842-
int minutes;
843-
844-
const int minutesInADay = 60 * 24;
845-
846-
// Set the reboot time
847-
settings.rebootMinutes = rebootMinutes;
848-
849-
minutes = settings.rebootMinutes;
850-
days = minutes / minutesInADay;
851-
minutes -= days * minutesInADay;
852-
hours = minutes / 60;
853-
minutes -= hours * 60;
854-
855-
systemPrintf("Reboot after uptime reaches %d days %d:%02d\r\n", days, hours, minutes);
856-
}
857-
}
858-
}
859860
else if (incoming == 33)
860861
settings.printBootTimes ^= 1;
861862
else if (incoming == 34)

0 commit comments

Comments
 (0)