Skip to content

Commit 36356bd

Browse files
committed
Add automatic power off for startup with 5% or less. Issue #83
1 parent 0eb5082 commit 36356bd

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void beginSD()
172172
//Max current is 200mA average across 1s, peak 300mA
173173
delay(10);
174174

175-
if(settings.spiFrequency > 16)
175+
if (settings.spiFrequency > 16)
176176
{
177177
Serial.println(("Error: SPI Frequency out of range. Default to 16MHz"));
178178
settings.spiFrequency = 16;
@@ -309,13 +309,13 @@ void beginFS()
309309
if (online.fs == false)
310310
{
311311
Serial.println("Starting FS");
312-
312+
313313
if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)) {
314314
log_d("Error: LittleFS not online");
315315
return;
316316
}
317317
online.fs = true;
318-
}
318+
}
319319
}
320320

321321
void beginDisplay()
@@ -472,6 +472,21 @@ void beginFuelGauge()
472472

473473
Serial.println(F("MAX17048 configuration complete"));
474474

475+
checkBatteryLevels(); //Force check so you see battery level immediately at power on
476+
477+
//Check to see if we are dangerously low
478+
if (battLevel < 5) //5%
479+
{
480+
Serial.println("Battery too low. Please charge. Shutting down...");
481+
482+
if (online.display == true)
483+
displayMessage("Charge Battery", 0);
484+
485+
delay(2000);
486+
487+
powerDown(false); //Don't display 'Shutting Down'
488+
}
489+
475490
online.battery = true;
476491
}
477492

@@ -549,9 +564,9 @@ void beginSystemState()
549564
//Setup TM2 time stamp input as need
550565
void beginExternalTriggers()
551566
{
552-
if(online.gnss == false)
567+
if (online.gnss == false)
553568
return;
554-
569+
555570
UBX_CFG_TP5_data_t timePulseParameters;
556571

557572
if (i2cGNSS.getTimePulseParameters(&timePulseParameters) == false)

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ void powerOnCheck()
88
#endif
99

1010
powerPressedStartTime = millis();
11+
1112
while (digitalRead(pin_powerSenseAndControl) == LOW)
1213
{
1314
delay(10);

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ void setup()
427427
beginUART2(); //Start UART2 on core 0, used to receive serial from ZED and pass out over SPP
428428

429429
beginFuelGauge(); //Configure battery fuel guage monitor
430-
checkBatteryLevels(); //Force check so you see battery level immediately at power on
431430

432431
configureGNSS(); //Configure ZED module
433432

0 commit comments

Comments
 (0)