Skip to content

Commit 3551796

Browse files
committed
Display the uptime in the system menu
1 parent 69aea7e commit 3551796

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const int FIRMWARE_VERSION_MINOR = 3;
4545
#define IDLE_COUNT_PER_SECOND 196289
4646
#define IDLE_TIME_DISPLAY_SECONDS 5
4747
#define MAX_IDLE_TIME_COUNT (IDLE_TIME_DISPLAY_SECONDS * IDLE_COUNT_PER_SECOND)
48+
#define MILLISECONDS_IN_A_SECOND 1000
49+
#define MILLISECONDS_IN_A_MINUTE (60 * MILLISECONDS_IN_A_SECOND)
50+
#define MILLISECONDS_IN_AN_HOUR (60 * MILLISECONDS_IN_A_MINUTE)
51+
#define MILLISECONDS_IN_A_DAY (24 * MILLISECONDS_IN_AN_HOUR)
4852

4953
//Hardware connections
5054
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -426,6 +430,9 @@ uint32_t cpuIdleCount[MAX_CPU_CORES];
426430
TaskHandle_t idleTaskHandle[MAX_CPU_CORES];
427431
uint32_t cpuLastIdleDisplayTime;
428432

433+
uint64_t uptime;
434+
uint32_t previousMilliseconds;
435+
429436
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
430437

431438
void setup()
@@ -484,7 +491,7 @@ void setup()
484491
void loop()
485492
{
486493
uint32_t delayTime;
487-
494+
uint32_t currentMilliseconds;
488495

489496
if (online.gnss == true)
490497
{
@@ -524,6 +531,13 @@ void loop()
524531
if (settings.enablePrintIdleTime)
525532
printIdleTimes();
526533

534+
//Monitor the days in uptime
535+
currentMilliseconds = millis();
536+
uptime = (uptime & 0xffffffff00000000ull) | currentMilliseconds;
537+
if (currentMilliseconds < previousMilliseconds)
538+
uptime += 0x100000000ull;
539+
previousMilliseconds = currentMilliseconds;
540+
527541
//A small delay prevents panic if no other I2C or functions are called
528542
delay(10);
529543
}

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ void menuSystem()
6565
//Display MAC address
6666
char macAddress[5];
6767
sprintf(macAddress, "%02X%02X", unitMACAddress[4], unitMACAddress[5]);
68-
6968
Serial.print(F("Bluetooth ("));
7069
Serial.print(macAddress);
7170
Serial.print(F("): "));
@@ -103,6 +102,36 @@ void menuSystem()
103102
}
104103
Serial.println();
105104

105+
//Display the uptime
106+
uint64_t uptimeMilliseconds = uptime;
107+
uint32_t uptimeDays = 0;
108+
while (uptimeMilliseconds >= MILLISECONDS_IN_A_DAY) {
109+
uptimeMilliseconds -= MILLISECONDS_IN_A_DAY;
110+
uptimeDays += 1;
111+
}
112+
byte uptimeHours = 0;
113+
while (uptimeMilliseconds >= MILLISECONDS_IN_AN_HOUR) {
114+
uptimeMilliseconds -= MILLISECONDS_IN_AN_HOUR;
115+
uptimeHours += 1;
116+
}
117+
byte uptimeMinutes = 0;
118+
while (uptimeMilliseconds >= MILLISECONDS_IN_A_MINUTE) {
119+
uptimeMilliseconds -= MILLISECONDS_IN_A_MINUTE;
120+
uptimeMinutes += 1;
121+
}
122+
byte uptimeSeconds = 0;
123+
while (uptimeMilliseconds >= MILLISECONDS_IN_A_SECOND) {
124+
uptimeMilliseconds -= MILLISECONDS_IN_A_SECOND;
125+
uptimeSeconds += 1;
126+
}
127+
Serial.print(F("Uptime: "));
128+
Serial.printf("%d %02d:%02d:%02d.%03ld\r\n",
129+
uptimeDays,
130+
uptimeHours,
131+
uptimeMinutes,
132+
uptimeSeconds,
133+
uptimeMilliseconds);
134+
106135
if (settings.enableSD == true)
107136
{
108137
Serial.println(F("f) Display microSD Files"));

0 commit comments

Comments
 (0)