Mercurial > ~darius > hgwebdir.cgi > epro
comparison epro.py @ 7:3baca74482b6
Fix a few more incorrect sign bits
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 09 Jun 2021 14:56:56 +0930 |
parents | 2f7ee650e6fb |
children | 0a571da65068 |
comparison
equal
deleted
inserted
replaced
6:2f7ee650e6fb | 7:3baca74482b6 |
---|---|
84 LEN = 3 | 84 LEN = 3 |
85 | 85 |
86 def __init__(self, dstadr, srcadr, devid, msgtype, data): | 86 def __init__(self, dstadr, srcadr, devid, msgtype, data): |
87 super(AmpHours, self).__init__(dstadr, srcadr, devid, msgtype, data) | 87 super(AmpHours, self).__init__(dstadr, srcadr, devid, msgtype, data) |
88 self.amphrs = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 100.0 | 88 self.amphrs = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 100.0 |
89 if data[2] & 0x40: | 89 if data[0] & 0x40: |
90 self.amphrs *= -1 | 90 self.amphrs *= -1 |
91 | 91 |
92 def __repr__(self): | 92 def __repr__(self): |
93 s = super(AmpHours, self).__repr__() | 93 s = super(AmpHours, self).__repr__() |
94 s += ": %.2f Ah" % (self.amphrs) | 94 s += ": %.2f Ah" % (self.amphrs) |
116 LEN = 3 | 116 LEN = 3 |
117 | 117 |
118 def __init__(self, dstadr, srcadr, devid, msgtype, data): | 118 def __init__(self, dstadr, srcadr, devid, msgtype, data): |
119 super(TimeRemaining, self).__init__(dstadr, srcadr, devid, msgtype, data) | 119 super(TimeRemaining, self).__init__(dstadr, srcadr, devid, msgtype, data) |
120 self.time = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) | 120 self.time = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) |
121 if data[2] & 0x40: | 121 if data[0] & 0x40: |
122 self.time *= -1 | 122 self.time *= -1 |
123 | 123 |
124 def __repr__(self): | 124 def __repr__(self): |
125 s = super(TimeRemaining, self).__repr__() | 125 s = super(TimeRemaining, self).__repr__() |
126 s += ": %.2f min" % (self.time) | 126 s += ": %.2f min" % (self.time) |