formatting

This commit is contained in:
Dave ID 2026-02-04 11:08:56 +01:00
parent ee75345684
commit d192043853
2 changed files with 4 additions and 4 deletions

View File

@ -17,8 +17,9 @@ void BatteryPercentageRingBuffer::update(uint8_t v) {
was_charging = false; was_charging = false;
} }
// Buffer was reintilialized with readout values while charging (can be too high values), reinit with new readout after charging // Buffer was reintilialized with readout values while charging (can be too high values), reinit with new readout
if (was_charging){ // after charging
if (was_charging) {
init(v); init(v);
was_charging = false; was_charging = false;
} }
@ -34,7 +35,6 @@ void BatteryPercentageRingBuffer::update(uint8_t v) {
} }
uint8_t BatteryPercentageRingBuffer::evaluate() { uint8_t BatteryPercentageRingBuffer::evaluate() {
uint8_t new_val = (sum + MAX_SAMPLES / 2) / MAX_SAMPLES; uint8_t new_val = (sum + MAX_SAMPLES / 2) / MAX_SAMPLES;
// Battery percentage should not increase when not charging so we just cap it to be lower than the last value // Battery percentage should not increase when not charging so we just cap it to be lower than the last value

View File

@ -14,7 +14,7 @@ struct BatteryPercentageRingBuffer {
uint8_t head = 0; uint8_t head = 0;
uint16_t sum = 0; uint16_t sum = 0;
uint8_t prev_val = 161; uint8_t prev_val = 161;
bool was_charging =false; bool was_charging = false;
void init(uint8_t value); void init(uint8_t value);
void update(uint8_t value); void update(uint8_t value);