Skip to content

Commit 4b69252

Browse files
fri3d expander: revert commit 3cd5a6c
Otherwise the voltage measurements and config register don't work. After reverting, voltage measurement, analog inputs, debug led, LCD backlight (not yet in UI) all work fine.
1 parent ed195ef commit 4b69252

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

internal_filesystem/lib/drivers/fri3d/expander.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# registers
99
_EXPANDER_REG_INPUTS = const(0x04)
1010
_EXPANDER_REG_ANALOG = const(0x06)
11-
_EXPANDER_REG_LCD_BRIGHTNESS = const(0x10)
12-
_EXPANDER_REG_DEBUG_LED = const(0x12)
13-
_EXPANDER_REG_CONFIG = const(0x14)
11+
_EXPANDER_REG_LCD_BRIGHTNESS = const(0x12)
12+
_EXPANDER_REG_DEBUG_LED = const(0x14)
13+
_EXPANDER_REG_CONFIG = const(0x16)
1414

1515
_EXPANDER_I2CADDR_DEFAULT = const(0x50)
1616

@@ -38,10 +38,9 @@ def __init__(
3838
def int_callback(self, p):
3939
self.i2c.readfrom_mem_into(self.address, _EXPANDER_REG_INPUTS, self._rx_mv)
4040

41-
@property
42-
def analog(self) -> tuple[int, int, int, int, int]:
43-
"""Read the analog inputs: ain1, battery_monitor, usb_monitor, joystick_y, joystick_x"""
44-
return self._read("<HHHHH", _EXPANDER_REG_ANALOG, 10)
41+
def analog(self) -> tuple[int, int, int, int, int, int]:
42+
"""Read the analog inputs: ain1, ain0, battery_monitor, usb_monitor, joystick_y, joystick_x"""
43+
return self._read("<HHHHHH", _EXPANDER_REG_ANALOG, 12)
4544

4645
@property
4746
def digital(
@@ -77,10 +76,10 @@ def debug_led(self, value: int):
7776
self._write(_EXPANDER_REG_DEBUG_LED, struct.pack("<H", value))
7877

7978
@property
80-
def config(self) -> tuple[bool, bool, bool, bool, bool, bool]:
81-
"""Read the configuration bits: ain0_pd, lora_reset, remap, reboot, lcd_reset, aux_power"""
79+
def config(self) -> tuple[bool, bool, bool]:
80+
"""Read the configuration bits: reboot, lcd_reset, aux_power"""
8281
config = self._read("B", _EXPANDER_REG_CONFIG, 1)[0]
83-
return tuple([bool(int(digit)) for digit in "{:08b}".format(config)[2:]])
82+
return tuple([bool(int(digit)) for digit in "{:08b}".format(config)[5:]])
8483

8584
@config.setter
8685
def config(self, value: int):

0 commit comments

Comments
 (0)