hidpp10: split reg07 (battery) parsing so it can be reused
This commit is contained in:
parent
0f80901bce
commit
d8e469a33a
|
@ -96,6 +96,9 @@ def get_battery(device):
|
|||
if reply:
|
||||
level = ord(reply[:1])
|
||||
battery_status = ord(reply[1:2])
|
||||
return parse_battery_reply(level, battery_status)
|
||||
|
||||
def parse_battery_reply(level, battery_status):
|
||||
charge = (90 if level == 7 # full
|
||||
else 50 if level == 5 # good
|
||||
else 20 if level == 3 # low
|
||||
|
|
Loading…
Reference in New Issue