Skip to content

Commit

Permalink
simplified condition for Time-To-Go/Soc
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Apr 27, 2023
1 parent bc91973 commit 83668b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,22 +498,14 @@ def publish_dbus(self):
except:
pass

# Update TimeToSoC
# Update TimeToGo and/or TimeToSoC
try:
if (
self.battery.capacity is not None
and (TIME_TO_GO_ENABLE or len(TIME_TO_SOC_POINTS) > 0)
and (
(
# update only once in same second
int(time()) != self.battery.time_to_soc_update
and
# update only every x seconds
int(time()) % TIME_TO_SOC_RECALCULATE_EVERY == 0
)
or
# update on first run
self.battery.time_to_soc_update == 0
int(time()) - self.battery.time_to_soc_update
>= TIME_TO_SOC_RECALCULATE_EVERY
)
):
self.battery.time_to_soc_update = int(time())
Expand Down
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/mnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from struct import *

# from test_max17853 import *#{these two lines are mutually}
from util_max17853 import * # {exclusive. use test for testing}
# from util_max17853 import * # {exclusive. use test for testing}


class MNBProtection(Protection):
Expand Down

0 comments on commit 83668b6

Please sign in to comment.