Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pybot/drivers/hotplug/res.py
diff options
context:
space:
mode:
Diffstat (limited to 'pybot/drivers/hotplug/res.py')
-rw-r--r--pybot/drivers/hotplug/res.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/pybot/drivers/hotplug/res.py b/pybot/drivers/hotplug/res.py
index db7e1c1..0dc43a9 100644
--- a/pybot/drivers/hotplug/res.py
+++ b/pybot/drivers/hotplug/res.py
@@ -2,18 +2,16 @@
RD_VERSION = 0x00
GET_VALUE = 0x01
-f1 = {
- 'name': 'getVersion',
- 'call': RD_VERSION,
- 'params': 0,
- 'read': 3
-}
+VCC = 65536
-f2 = {
- 'name': 'getValue',
- 'call': GET_VALUE,
- 'params': 0,
- 'read': 3
-}
+def getVersion(dev):
+ dev.send([RD_VERSION])
+ raw = dev.read(3)
+ return raw[1] + raw[2] * 256
+
+def getValue(dev):
+ dev.send([GET_VALUE])
+ raw = dev.read(3)
+ val = raw[1] + raw[2] * 256
+ return val * 6800.0 / (VCC - val)
-FUNCTIONS = [f1, f2]