Merge pull request #23 from Lekensteyn/hid10-battery
Parse battery status of HID++ 1.0 devices
This commit is contained in:
commit
a3599b53bb
|
@ -94,8 +94,16 @@ def get_battery(device):
|
||||||
|
|
||||||
reply = get_register(device, 'battery_status', 0x07)
|
reply = get_register(device, 'battery_status', 0x07)
|
||||||
if reply:
|
if reply:
|
||||||
battery_status = ord(reply[:1])
|
level = ord(reply[:1])
|
||||||
_log.info("%s: battery status %02X", device, battery_status)
|
battery_status = ord(reply[2:3])
|
||||||
|
charge = (90 if level == 7 # full
|
||||||
|
else 50 if level == 5 # good
|
||||||
|
else 20 if level == 3 # low
|
||||||
|
else 5 if level == 1 # critical
|
||||||
|
else 0 ) # wtf?
|
||||||
|
status = ('charging' if battery_status == 0x25
|
||||||
|
else 'discharging')
|
||||||
|
return charge, status
|
||||||
|
|
||||||
|
|
||||||
def get_serial(device):
|
def get_serial(device):
|
||||||
|
|
Loading…
Reference in New Issue