kopia lustrzana https://github.com/peterhinch/micropython-samples
ds3231_port.py Change name of twos_complement: single underscore.
rodzic
2a0bd63ab8
commit
0db03bdec5
|
@ -132,7 +132,7 @@ class DS3231:
|
|||
return ratio * factor
|
||||
|
||||
|
||||
def __twos_complement(self, input_value: int, num_bits: int) -> int:
|
||||
def _twos_complement(self, input_value: int, num_bits: int) -> int:
|
||||
mask = 2 ** (num_bits - 1)
|
||||
return -(input_value & mask) + (input_value & ~mask)
|
||||
|
||||
|
@ -140,4 +140,4 @@ class DS3231:
|
|||
def get_temperature(self):
|
||||
t = self.ds3231.readfrom_mem(DS3231_I2C_ADDR, 0x11, 2)
|
||||
i = t[0] << 8 | t[1]
|
||||
return self.__twos_complement(i >> 6, 10) * 0.25
|
||||
return self._twos_complement(i >> 6, 10) * 0.25
|
||||
|
|
Ładowanie…
Reference in New Issue