Skip to content

Commit 5a61c10

Browse files
committed
try to use Spi3Wire
1 parent 7701487 commit 5a61c10

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

internal_filesystem/lib/drivers/io_expander/tca9555.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def digital_write(self, pin, value):
6666
p = machine.Pin(pin, machine.Pin.OUT)
6767
p.value(value)
6868

69-
def digital_read(self, pin):
69+
def digital_read(self, pin: int):
7070
if pin & 0x40: # Pins with 0x40 bit set are controlled by TCA9555
7171
pin &= 0xBF
7272
# Ensure pin is set to input
@@ -79,3 +79,24 @@ def digital_read(self, pin):
7979
# Handle standard ESP32 pin
8080
p = machine.Pin(pin, machine.Pin.IN)
8181
return p.value()
82+
83+
84+
class TCA9555Pin:
85+
"""
86+
Minimal Pin-like wrapper for TCA9555 IO expander pins.
87+
Provides value() and __call__() for compatibility with bit-bang drivers.
88+
"""
89+
90+
def __init__(self, tca: TCA9555, pin: int, mode=machine.Pin.OUT):
91+
self.tca = tca
92+
self.pin = pin
93+
self.tca.pin_mode(pin, mode)
94+
95+
def value(self, v=None):
96+
if v is None:
97+
# No readback support for output-only pins
98+
return None
99+
self.tca.digital_write(self.pin, v)
100+
101+
def __call__(self, v=None):
102+
return self.value(v)

internal_filesystem/lib/mpos/board/squixl.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
print("squixl.py initialization")
22
"""
33
Hardware initialization for the SQUiXL device by "Unexpected Maker"
4-
https://unexpectedmaker.com/shop.html#!/SQUiXL/p/743870537
4+
https://squixl.io
55
66
https://github.com/UnexpectedMaker/SQUiXL-DevOS
77
https://github.com/UnexpectedMaker/SQUiXL-DevOS/blob/main/platformio/src/squixl.h
@@ -117,7 +117,7 @@
117117
import machine
118118
import mpos.ui
119119
from drivers.display.st7701s.st7701s import ST7701S
120-
from drivers.io_expander.tca9555 import TCA9555
120+
from drivers.io_expander.tca9555 import TCA9555, TCA9555Pin
121121
from micropython import const
122122

123123
# S3 IO
@@ -328,6 +328,16 @@ def lcd_reset(self):
328328

329329
try:
330330
print("squixl.py RGB parallel bus display initialization")
331+
332+
mosi_pin = TCA9555Pin(squixl.tca, SQUiXL.MOSI)
333+
clk_pin = TCA9555Pin(squixl.tca, SQUiXL.CLK)
334+
cs_pin = TCA9555Pin(squixl.tca, SQUiXL.CS)
335+
336+
# lvgl_micropython/api_drivers/common_api_drivers/frozen/other/spi3wire.py:
337+
from spi3wire import Spi3Wire
338+
339+
spi_3wire = Spi3Wire(mosi_pin=mosi_pin, clk_pin=clk_pin, cs_pin=cs_pin)
340+
331341
display_bus = lcd_bus.RGBBus(
332342
hsync=HSYNC,
333343
vsync=VSYNC,
@@ -345,8 +355,10 @@ def lcd_reset(self):
345355
print("squixl.py ST7701S() display initialization")
346356
mpos.ui.main_display = ST7701S(
347357
data_bus=display_bus,
358+
spi_3wire=spi_3wire,
348359
display_width=480,
349360
display_height=480,
361+
bus_shared_pins=False,
350362
set_params_func=squixl.set_params,
351363
)
352364
except Exception as e:

0 commit comments

Comments
 (0)