Skip to content

Commit

Permalink
Fixing crash when voltage was measured when no battery was plugged in
Browse files Browse the repository at this point in the history
  • Loading branch information
biologist79 committed Oct 30, 2021
1 parent adf41d8 commit 993b8d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ static void Led_Task(void *parameter) {
FastLED.show();
} else {
uint8_t numLedsToLight = ((float)vDiffCurrent / vDiffIndicatorRange) * NUM_LEDS;
if (numLedsToLight > NUM_LEDS) { // Can happen e.g. if no battery is connected
numLedsToLight = NUM_LEDS;
}
for (uint8_t led = 0; led < numLedsToLight; led++) {
if (((float)numLedsToLight / NUM_LEDS) >= 0.6) {
leds[Led_Address(led)] = CRGB::Green;
Expand Down
2 changes: 1 addition & 1 deletion src/revision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_H__
#define __REVISION_H__
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211028-1";
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211031-1";
#endif

0 comments on commit 993b8d7

Please sign in to comment.