diff options
Diffstat (limited to 'pybot/drivers/hotplug/button.py')
-rw-r--r-- | pybot/drivers/hotplug/button.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/pybot/drivers/hotplug/button.py b/pybot/drivers/hotplug/button.py index f714ecf..4bf99ee 100644 --- a/pybot/drivers/hotplug/button.py +++ b/pybot/drivers/hotplug/button.py @@ -1,19 +1,18 @@ RD_VERSION = 0x00 GET_VALUE = 0x01 +ERROR = -1 -f1 = { - 'name': 'getVersion', - 'call': RD_VERSION, - 'params': 0, - 'read': 3 -} +def getVersion(dev): + dev.send([RD_VERSION]) + raw = dev.read(3) + return raw[1] + raw[2] * 256 -f2 = { - 'name': 'getValue', - 'call': GET_VALUE, - 'params': 0, - 'read': 2 -} +def getValue(dev): + dev.send([GET_VALUE]) + raw = dev.read(2) + if not(raw[1] == 255): + return (1 - raw[1]) + else: + return ERROR -FUNCTIONS = [f1, f2] |