diff options
author | Alan Aguiar <alanjas@hotmail.com> | 2013-10-16 01:22:25 (GMT) |
---|---|---|
committer | Alan Aguiar <alanjas@hotmail.com> | 2013-10-16 01:22:25 (GMT) |
commit | 1bd020d21533f928d0c8b6d48ac04d66f6a1aee4 (patch) | |
tree | 3d57253255fe998d7535b3336613178f595a5813 /pybot/drivers/hotplug/temp.py | |
parent | 52fd3338d859c3b4084c74ca068d8ee045cae110 (diff) |
Diffstat (limited to 'pybot/drivers/hotplug/temp.py')
-rw-r--r-- | pybot/drivers/hotplug/temp.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pybot/drivers/hotplug/temp.py b/pybot/drivers/hotplug/temp.py new file mode 100644 index 0000000..7fa55a1 --- /dev/null +++ b/pybot/drivers/hotplug/temp.py @@ -0,0 +1,19 @@ + +import math + +RD_VERSION = 0x00 +GET_VALUE = 0x01 + +VCC = 65536 + +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) + volt = (raw[1] + raw[2] * 256) * 5.0 / VCC + return math.floor(volt * 1000.0) / 10 + |