Mercurial > templog
annotate web/test.py @ 547:7689af9f56a8
Update to bottle 0.12.8
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 27 May 2015 22:17:39 +0800 |
parents | 83c83014e5e3 |
children |
rev | line source |
---|---|
335 | 1 #!/usr/bin/env python |
2 import time | |
381
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
3 import struct |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
4 import sys |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
5 import binascii |
335 | 6 |
381
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
7 def convert_ds18b20_12bit(reading): |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
8 value = struct.unpack('>h', binascii.unhexlify(reading))[0] |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
9 return value * 0.0625 |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
10 |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
11 if __name__ == '__main__': |
83c83014e5e3
report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents:
335
diff
changeset
|
12 print convert_ds18b20_12bit(sys.argv[1]) |