Mercurial > ~darius > hgwebdir.cgi > epro
comparison epro.py @ 26:3090d8bf4242
Fix temperature decoding.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 21 Dec 2021 15:05:32 +1030 |
parents | 60ead9b5fc1b |
children | 8b8efc343b0c |
comparison
equal
deleted
inserted
replaced
25:64d0d5aaf329 | 26:3090d8bf4242 |
---|---|
137 MSGNAME = "Battery Temperature" | 137 MSGNAME = "Battery Temperature" |
138 LEN = 3 | 138 LEN = 3 |
139 | 139 |
140 def __init__(self, dstadr, srcadr, devid, msgtype, data): | 140 def __init__(self, dstadr, srcadr, devid, msgtype, data): |
141 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data) | 141 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data) |
142 self.temp = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 10.0 | 142 self.temp = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x03) << 14) / 10.0 |
143 if data[2] & 0x40: | 143 if data[0] & 0x40: |
144 self.temp *= -1 | 144 self.temp *= -1 |
145 if self.temp < -20: | 145 if self.temp < -20: |
146 self.temp = None | 146 self.temp = None |
147 | 147 |
148 def __repr__(self): | 148 def __repr__(self): |