Errors on any battery stopped display of all battery information

This commit is contained in:
Sean E. Russell 2021-01-26 13:15:27 -06:00
parent 273f572a87
commit 67831ac97c
2 changed files with 6 additions and 1 deletions

View File

@ -91,6 +91,9 @@ func (b *BatteryWidget) update() {
}
}
for i, battery := range batteries {
if battery.Full == 0.0 {
continue
}
id := makeID(i)
perc := battery.Current / battery.Full
percentFull := math.Abs(perc) * 100.0

View File

@ -49,7 +49,6 @@ func (b *BatteryGauge) update() {
log.Printf("error setting up batteries: %v", err)
errLogged = true
}
return
}
if len(bats) < 1 {
b.Label = fmt.Sprintf("N/A")
@ -60,6 +59,9 @@ func (b *BatteryGauge) update() {
charging := "%d%% ⚡%s"
rate := 0.0
for _, bat := range bats {
if bat.Full == 0.0 {
continue
}
mx += bat.Full
cu += bat.Current
if rate < bat.ChargeRate {