Skip to content

Commit 266e948

Browse files
committed
Add external power detection
1 parent 251b88c commit 266e948

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ uint16_t failedParserMessages_NMEA = 0;
512512
unsigned long btLastByteReceived = 0; //Track when last BT transmission was received.
513513
const long btMinEscapeTime = 2000; //Bluetooth serial traffic must stop this amount before an escape char is recognized
514514
uint8_t btEscapeCharsReceived = 0; //Used to enter command mode
515+
516+
bool externalPowerConnected = false; //Goes true when a high voltage is seen on power control pin
517+
515518
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
516519
/*
517520
+---------------------------------------+ +----------+

Firmware/RTK_Surveyor/System.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,17 @@ void checkBatteryLevels()
250250
systemPrintf("Batt (%d%%): Voltage: %0.02fV", battLevel, battVoltage);
251251

252252
char tempStr[25];
253-
if (battChangeRate > 0)
253+
if (battChangeRate >= -0.01)
254+
{
254255
sprintf(tempStr, "C");
256+
externalPowerConnected = true;
257+
}
255258
else
259+
{
256260
sprintf(tempStr, "Disc");
261+
externalPowerConnected = false;
262+
}
263+
257264
systemPrintf(" %sharging: %0.02f%%/hr ", tempStr, battChangeRate);
258265

259266
if (battLevel < 10)
@@ -333,7 +340,7 @@ bool createTestFile()
333340
{
334341
if (SD_MMC.exists(testFileName))
335342
SD_MMC.remove(testFileName);
336-
return (!SD_MMC.exists(testFileName));
343+
return (!SD_MMC.exists(testFileName));
337344
}
338345
#endif
339346
}

0 commit comments

Comments
 (0)