|
41 | 41 | LC709203F_CMD_INITRSOC = const(0x07)
|
42 | 42 | LC709203F_CMD_CELLVOLTAGE = const(0x09)
|
43 | 43 | LC709203F_CMD_CELLITE = const(0x0F)
|
| 44 | +LC709203F_CMD_CELLTEMPERATURE = const(0x08) |
| 45 | +LC709203F_CMD_THERMISTORB = const(0x06) |
| 46 | +LC709203F_CMD_STATUSBIT = const(0x16) |
44 | 47 |
|
45 | 48 |
|
46 | 49 | class CV:
|
@@ -121,6 +124,18 @@ def cell_percent(self):
|
121 | 124 | """Returns percentage of cell capacity"""
|
122 | 125 | return self._read_word(LC709203F_CMD_CELLITE) / 10
|
123 | 126 |
|
| 127 | + @property |
| 128 | + def cell_temperature(self): |
| 129 | + """Returns the temperature of the cell""" |
| 130 | + return self._read_word(LC709203F_CMD_CELLTEMPERATURE) / 10 - 273.15 |
| 131 | + |
| 132 | + @cell_temperature.setter |
| 133 | + def cell_temperature(self, value): |
| 134 | + """Sets the temperature in the LC709203F""" |
| 135 | + if self.thermistor_enable: |
| 136 | + raise AttributeError("temperature can only be set in i2c mode") |
| 137 | + self._write_word(LC709203F_CMD_CELLTEMPERATURE, int(value + 273.15) * 10) |
| 138 | + |
124 | 139 | @property
|
125 | 140 | def ic_version(self):
|
126 | 141 | """Returns read-only chip version"""
|
@@ -159,6 +174,28 @@ def pack_size(self, size):
|
159 | 174 | raise AttributeError("pack_size must be a PackSize")
|
160 | 175 | self._write_word(LC709203F_CMD_APA, size)
|
161 | 176 |
|
| 177 | + @property |
| 178 | + def thermistor_bconstant(self): |
| 179 | + """Returns the thermistor B-constant""" |
| 180 | + return self._read_word(LC709203F_CMD_THERMISTORB) |
| 181 | + |
| 182 | + @thermistor_bconstant.setter |
| 183 | + def thermistor_bconstant(self, bconstant): |
| 184 | + """Sets the thermistor B-constant""" |
| 185 | + self._write_word(LC709203F_CMD_THERMISTORB, bconstant) |
| 186 | + |
| 187 | + @property |
| 188 | + def thermistor_enable(self): |
| 189 | + """Returns the current temperature source""" |
| 190 | + return self._read_word(LC709203F_CMD_STATUSBIT) |
| 191 | + |
| 192 | + @thermistor_enable.setter |
| 193 | + def thermistor_enable(self, status): |
| 194 | + """Sets the temperature source to Tsense""" |
| 195 | + if not status in (True, False): |
| 196 | + raise AttributeError("thermistor_enable must be True or False") |
| 197 | + self._write_word(LC709203F_CMD_STATUSBIT, status) |
| 198 | + |
162 | 199 | # pylint: disable=no-self-use
|
163 | 200 | def _generate_crc(self, data):
|
164 | 201 | """8-bit CRC algorithm for checking data"""
|
|
0 commit comments