Skip to content

Commit f03d1df

Browse files
committed
Move SPI initialization outside the display driver
1 parent 21bc8b2 commit f03d1df

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

st7735r.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ class ST7735R:
77

88
def __init__(self, spi, dc, rotation=0x06):
99
self.spi = spi
10-
spi.try_lock()
1110
self.dc = dc
1211
self.dc.switch_to_output(value=1)
13-
spi.configure()
1412
for command, data, delay in (
1513
(b'\x01', b'', 120),
1614
(b'\x11', b'', 120),
@@ -36,7 +34,6 @@ def __init__(self, spi, dc, rotation=0x06):
3634
):
3735
self.write(command, data)
3836
time.sleep(delay / 1000)
39-
spi.configure(baudrate=24000000, polarity=0, phase=0)
4037
self.dc.value = 0
4138

4239
def block(self, x0, y0, x1, y1):

ugame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
dc = digitalio.DigitalInOut(board.DC)
2323
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI)
24+
spi.try_lock()
25+
spi.configure(baudrate=24000000, polarity=0, phase=0)
2426
display = st7735r.ST7735R(spi, dc, 0b101)
2527
buttons = gamepad.GamePad(
2628
digitalio.DigitalInOut(board.X),

0 commit comments

Comments
 (0)