Quick fix for Inkplate 5

master
Robert Sorić 2023-11-24 09:15:02 +01:00
parent 103e107195
commit 1e89648446
2 changed files with 5 additions and 4 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ board_config_*.py
init.mpf
lib
.vscode
i2c_scanner.py

View File

@ -103,7 +103,7 @@ class _Inkplate:
cls.GPIO0_PUP.digitalWrite(0)
cls.VBAT_EN = gpioPin(cls._PCAL6416A, 9, modeOUTPUT)
cls.VBAT_EN.digitalWrite(1)
cls.VBAT_EN.digitalWrite(0)
cls.SD_ENABLE = gpioPin(cls._PCAL6416A, 10, modeOUTPUT)
cls.SD_ENABLE.digitalWrite(0)
@ -157,18 +157,19 @@ class _Inkplate:
# Read the battery voltage. Note that the result depends on the ADC calibration, and be a bit off.
@classmethod
def read_battery(cls):
cls.VBAT_EN.digitalWrite(0)
cls.VBAT_EN.digitalWrite(1)
# Probably don't need to delay since Micropython is slow, but we do it anyway
time.sleep_ms(5)
value = cls.VBAT.read()
print(value)
cls.VBAT_EN.digitalWrite(1)
cls.VBAT_EN.digitalWrite(0)
result = (value / 4095.0) * 1.1 * 3.548133892 * 2
return result
# Read panel temperature. I varies +- 2 degree
@classmethod
def read_temperature(cls):
# start temperature measurement and wait 5 ms
cls._i2c.writeto_mem(TPS65186_addr, 0x0D, bytes((0x80,)))
time.sleep_ms(5)
@ -176,7 +177,6 @@ class _Inkplate:
# request temperature data from panel
cls._i2c.writeto(TPS65186_addr, bytearray((0x00,)))
cls._temperature = cls._i2c.readfrom(TPS65186_addr, 1)
# convert data from bytes to integer
cls.temperatureInt = int.from_bytes(cls._temperature, "big", True)
return cls.temperatureInt