Skip to content

Commit 4d16268

Browse files
committed
Use helper functions to print
1 parent 68575cf commit 4d16268

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,15 @@ void menuPointPerfectKeys()
5555
{
5656
long long gpsEpoch = thingstreamEpochToGPSEpoch(settings.pointPerfectCurrentKeyStart);
5757

58-
uint16_t keyGPSWeek;
59-
uint32_t keyGPSToW;
60-
unixEpochToWeekToW(unixEpoch, &keyGPSWeek, &keyGPSToW);
58+
gpsEpoch += (settings.pointPerfectCurrentKeyDuration / 1000) -
59+
1; // Add key duration back to the key start date to get key expiration
6160

62-
long expDay;
63-
long expMonth;
64-
long expYear;
65-
gpsWeekToWToDate(keyGPSWeek, keyGPSToW, &expDay, &expMonth, &expYear);
61+
systemPrintf("%s\r\n", printDateFromGPSEpoch(gpsEpoch));
6662

67-
systemPrintf("%02ld/%02ld/%ld\r\n", expDay, expMonth, expYear);
63+
if (settings.debugLBand == true)
64+
systemPrintf("settings.pointPerfectCurrentKeyDuration: %lld (%d)\r\n",
65+
settings.pointPerfectCurrentKeyDuration,
66+
settings.pointPerfectCurrentKeyDuration / (1000L * 60 * 60 * 24));
6867
}
6968
else
7069
systemPrintln("N/A");
@@ -81,16 +80,10 @@ void menuPointPerfectKeys()
8180
{
8281
long long gpsEpoch = thingstreamEpochToGPSEpoch(settings.pointPerfectNextKeyStart);
8382

84-
uint16_t keyGPSWeek;
85-
uint32_t keyGPSToW;
86-
unixEpochToWeekToW(unixEpoch, &keyGPSWeek, &keyGPSToW);
87-
88-
long expDay;
89-
long expMonth;
90-
long expYear;
91-
gpsWeekToWToDate(keyGPSWeek, keyGPSToW, &expDay, &expMonth, &expYear);
83+
gpsEpoch += (settings.pointPerfectNextKeyDuration /
84+
1000); // Add key duration back to the key start date to get key expiration
9285

93-
systemPrintf("%02ld/%02ld/%ld\r\n", expDay, expMonth, expYear);
86+
systemPrintf("%s\r\n", printDateFromGPSEpoch(gpsEpoch));
9487
}
9588
else
9689
systemPrintln("N/A");
@@ -122,8 +115,8 @@ void menuPointPerfectKeys()
122115
systemPrintln("Date invalid. Please try again.");
123116
}
124117

125-
dateToKeyStartDuration(expDay, expMonth, expYear, &settings.pointPerfectCurrentKeyStart,
126-
&settings.pointPerfectCurrentKeyDuration);
118+
dateToKeyStart(expDay, expMonth, expYear, &settings.pointPerfectCurrentKeyStart);
119+
127120

128121
// Calculate the next key expiration date
129122
if (settings.pointPerfectNextKeyStart == 0)
@@ -159,8 +152,7 @@ void menuPointPerfectKeys()
159152
systemPrintln("Date invalid. Please try again.");
160153
}
161154

162-
dateToKeyStartDuration(expDay, expMonth, expYear, &settings.pointPerfectNextKeyStart,
163-
&settings.pointPerfectNextKeyDuration);
155+
dateToKeyStart(expDay, expMonth, expYear, &settings.pointPerfectNextKeyStart);
164156
}
165157
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
166158
break;
@@ -852,9 +844,8 @@ long dateToUnixEpoch(uint8_t day, uint8_t month, uint16_t year)
852844
return (t_of_day);
853845
}
854846

855-
// Given a date, calculate and store the key start and duration
856-
void dateToKeyStartDuration(uint8_t expDay, uint8_t expMonth, uint16_t expYear, uint64_t *settingsKeyStart,
857-
uint64_t *settingsKeyDuration)
847+
// Given a date, calculate and return the key start in unixEpoch
848+
void dateToKeyStart(uint8_t expDay, uint8_t expMonth, uint16_t expYear, uint64_t *settingsKeyStart)
858849
{
859850
long long expireUnixEpoch = dateToUnixEpoch(expDay, expMonth, expYear);
860851

0 commit comments

Comments
 (0)