Skip to content

Commit f508d4d

Browse files
committed
Fix stage for pygamer and pybadge on CP 7.0
Backlight handling is broken in displayio, so we handle it ourselves. The keypad now requires additional parameters. Swapped O and X keys on pybadge.
1 parent 2c89a32 commit f508d4d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

pybadge/ugame.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import keypad
77
import audioio
88
import audiocore
9+
import digitalio
10+
import supervisor
911

1012

11-
K_X = 0x01
12-
K_O = 0x02
13+
K_O = 0x01
14+
K_X = 0x02
1315
K_DOWN = 0x20
1416
K_LEFT = 0x80
1517
K_RIGHT = 0x10
@@ -48,7 +50,7 @@ class _Buttons:
4850
def __init__(self):
4951
self.keys = keypad.ShiftRegisterKeys(clock=board.BUTTON_CLOCK,
5052
data=board.BUTTON_OUT, latch=board.BUTTON_LATCH, key_count=8,
51-
interval=0.05)
53+
interval=0.05, value_when_pressed=True)
5254
self.last_state = 0
5355
self.event = keypad.Event(0, False)
5456
self.last_z_press = None
@@ -111,8 +113,10 @@ def mute(self, value=True):
111113
_fourwire = displayio.FourWire(_tft_spi, command=board.TFT_DC,
112114
chip_select=board.TFT_CS, reset=board.TFT_RST)
113115
display = displayio.Display(_fourwire, _TFT_INIT, width=160, height=128,
114-
rotation=0, backlight_pin=board.TFT_LITE,
115-
auto_refresh=False, auto_brightness=True)
116+
rotation=0, auto_refresh=False)
117+
# Work around broken backlight in CP 7.0
118+
_backlight = digitalio.DigitalInOut(board.TFT_LITE)
119+
_backlight.switch_to_output(value=1)
116120
del _TFT_INIT
117121
buttons = _Buttons()
118122
audio = _Audio(board.SPEAKER, board.SPEAKER_ENABLE)

pygamer/ugame.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import keypad
88
import audioio
99
import audiocore
10+
import supervisor
11+
import digitalio
1012

1113

1214
K_X = 0x01
@@ -49,7 +51,7 @@ class _Buttons:
4951
def __init__(self):
5052
self.keys = keypad.ShiftRegisterKeys(clock=board.BUTTON_CLOCK,
5153
data=board.BUTTON_OUT, latch=board.BUTTON_LATCH, key_count=4,
52-
interval=0.05)
54+
interval=0.05, value_when_pressed=True)
5355
self.last_state = 0
5456
self.event = keypad.Event(0, False)
5557
self.last_z_press = None
@@ -125,8 +127,10 @@ def mute(self, value=True):
125127
_fourwire = displayio.FourWire(_tft_spi, command=board.TFT_DC,
126128
chip_select=board.TFT_CS, reset=board.TFT_RST)
127129
display = displayio.Display(_fourwire, _TFT_INIT, width=160, height=128,
128-
rotation=0, backlight_pin=board.TFT_LITE,
129-
auto_refresh=False, auto_brightness=True)
130+
rotation=0, auto_refresh=False)
131+
# Work around broken backlight in CP 7.0
132+
_backlight = digitalio.DigitalInOut(board.TFT_LITE)
133+
_backlight.switch_to_output(value=1)
130134
del _TFT_INIT
131135
buttons = _Buttons()
132136
audio = _Audio(board.SPEAKER, board.SPEAKER_ENABLE)

0 commit comments

Comments
 (0)