Skip to content

Commit b3a753b

Browse files
committed
feat: light up red led to indicate low battery
1 parent e901154 commit b3a753b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void showBatteryState();
6868
void breathLEDAnimation();
6969
float getBatteryVoltage();
7070
int getBatteryPercentage();
71+
void showLowBatteryWarning();
7172
void checkBattery();
7273

7374
void setup() {
@@ -271,6 +272,10 @@ void showBatteryState() {
271272
Serial.println(result);
272273
u8g2.sendBuffer();
273274

275+
if (batteryPercentage < 20) {
276+
showLowBatteryWarning();
277+
}
278+
274279
delay(100);
275280
}
276281

@@ -382,6 +387,16 @@ void checkBattery() {
382387
}
383388
}
384389

390+
/**
391+
* Blink LED to indicate that battery is low
392+
*
393+
*/
394+
void showLowBatteryWarning() {
395+
tp.DotStar_SetPower(true);
396+
tp.DotStar_SetBrightness(5);
397+
tp.DotStar_SetPixelColor(255, 0, 0);
398+
}
399+
385400
/**
386401
* Update previousMillis' value to reset idle timer
387402
*

0 commit comments

Comments
 (0)