Skip to content

Commit 0c430d7

Browse files
committed
Add external power detection
1 parent 53ffd19 commit 0c430d7

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
@@ -542,6 +542,9 @@ uint16_t failedParserMessages_NMEA = 0;
542542
unsigned long btLastByteReceived = 0; //Track when last BT transmission was received.
543543
const long btMinEscapeTime = 2000; //Bluetooth serial traffic must stop this amount before an escape char is recognized
544544
uint8_t btEscapeCharsReceived = 0; //Used to enter command mode
545+
546+
bool externalPowerConnected = false; //Goes true when a high voltage is seen on power control pin
547+
545548
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
546549
/*
547550
+---------------------------------------+ +----------+

Firmware/RTK_Surveyor/System.ino

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

313313
char tempStr[25];
314-
if (battChangeRate > 0)
314+
if (battChangeRate >= -0.01)
315+
{
315316
snprintf(tempStr, sizeof(tempStr), "C");
317+
externalPowerConnected = true;
318+
}
316319
else
320+
{
317321
snprintf(tempStr, sizeof(tempStr), "Disc");
322+
externalPowerConnected = false;
323+
}
324+
318325
systemPrintf(" %sharging: %0.02f%%/hr ", tempStr, battChangeRate);
319326

320327
if (battLevel < 10)
@@ -394,7 +401,7 @@ bool createTestFile()
394401
{
395402
if (SD_MMC.exists(testFileName))
396403
SD_MMC.remove(testFileName);
397-
return (!SD_MMC.exists(testFileName));
404+
return (!SD_MMC.exists(testFileName));
398405
}
399406
#endif
400407
}

0 commit comments

Comments
 (0)