From 5e58f1e273bffc3af8eac0a2208737a49e92bb19 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 27 Apr 2013 17:07:55 +0200 Subject: [PATCH] Fix battery status reading, add "fully charged" Commit 438c501fae2486f1520eb485c14662c3a632fd2c introduced support for HID++ 1.0 battery information. That accidentally selected the third parameter instead of the second one. This commit fixes that and additionally adds a "fully charged" status too that was found on the K800. --- lib/logitech/unifying_receiver/hidpp10.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/logitech/unifying_receiver/hidpp10.py b/lib/logitech/unifying_receiver/hidpp10.py index a7af40e6..e70e1fb9 100644 --- a/lib/logitech/unifying_receiver/hidpp10.py +++ b/lib/logitech/unifying_receiver/hidpp10.py @@ -95,13 +95,14 @@ def get_battery(device): reply = get_register(device, 'battery_status', 0x07) if reply: level = ord(reply[:1]) - battery_status = ord(reply[2:3]) + battery_status = ord(reply[1:2]) 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 'fully charged' if battery_status == 0x22 else 'discharging') return charge, status