Skip to content

Commit 3c7cac6

Browse files
committed
Add setup for itsybitsy_m4_express
1 parent 08d06a9 commit 3c7cac6

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

itsybitsy_m4_express/stage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../stage.py

itsybitsy_m4_express/ugame.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
A helper module that initializes the display and buttons for the uGame
3+
game console. See https://hackaday.io/project/27629-game
4+
"""
5+
6+
import board
7+
import digitalio
8+
import gamepad
9+
import stage
10+
import displayio
11+
import busio
12+
13+
14+
K_X = 0x01
15+
K_DOWN = 0x02
16+
K_LEFT = 0x04
17+
K_RIGHT = 0x08
18+
K_UP = 0x10
19+
K_O = 0x20
20+
K_START = 0x40
21+
K_SELECT = 0x00
22+
23+
24+
_INIT_SEQUENCE = (
25+
b"\x01\x80\x96" # SWRESET and Delay 150ms
26+
b"\x11\x80\xff" # SLPOUT and Delay
27+
b"\xb1\x03\x01\x2C\x2D" # _FRMCTR1
28+
b"\xb2\x03\x01\x2C\x2D" # _FRMCTR2
29+
b"\xb3\x06\x01\x2C\x2D\x01\x2C\x2D" # _FRMCTR3
30+
b"\xb4\x01\x07" # _INVCTR line inversion
31+
b"\xc0\x03\xa2\x02\x84" # _PWCTR1 GVDD = 4.7V, 1.0uA
32+
b"\xc1\x01\xc5" # _PWCTR2 VGH=14.7V, VGL=-7.35V
33+
b"\xc2\x02\x0a\x00" # _PWCTR3 Opamp current small, Boost frequency
34+
b"\xc3\x02\x8a\x2a"
35+
b"\xc4\x02\x8a\xee"
36+
b"\xc5\x01\x0e" # _VMCTR1 VCOMH = 4V, VOML = -1.1V
37+
b"\x20\x00" # _INVOFF
38+
b"\x36\x01\x18" # _MADCTL bottom to top refresh
39+
# 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie,
40+
# fix on VTL
41+
b"\x3a\x01\x05" # COLMOD - 16bit color
42+
b"\xe0\x10\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10" # _GMCTRP1 Gamma
43+
b"\xe1\x10\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10" # _GMCTRN1
44+
b"\x13\x80\x0a" # _NORON
45+
b"\x29\x80\x64" # _DISPON
46+
)
47+
48+
displayio.release_displays()
49+
_tft_spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI)
50+
_tft_spi.try_lock()
51+
_tft_spi.configure(baudrate=24000000)
52+
_tft_spi.unlock()
53+
_fourwire = displayio.FourWire(_tft_spi, command=board.A3,
54+
chip_select=board.A2, reset=board.A4)
55+
display = displayio.Display(_fourwire, _INIT_SEQUENCE, width=160, height=128,
56+
rotation=0, backlight_pin=board.A5)
57+
display.auto_brightness = True
58+
59+
buttons = gamepad.GamePad(
60+
digitalio.DigitalInOut(board.SCL),
61+
digitalio.DigitalInOut(board.D12),
62+
digitalio.DigitalInOut(board.D11),
63+
digitalio.DigitalInOut(board.D9),
64+
digitalio.DigitalInOut(board.D10),
65+
digitalio.DigitalInOut(board.D7),
66+
digitalio.DigitalInOut(board.SDA),
67+
)
68+
69+
70+
class DummyAudio:
71+
def play(self, f, loop=False):
72+
pass
73+
74+
def stop(self):
75+
pass
76+
77+
def mute(self, mute):
78+
pass
79+
80+
81+
audio = DummyAudio()

pybadge/ugame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
K_UP = 0x40
1919
K_O = 0x01
2020
K_START = 0x04
21-
K_SECLECT = 0x08
21+
K_SELECT = 0x08
2222

2323
# re-initialize the display for correct rotation and RGB mode
2424
displayio.release_displays()

0 commit comments

Comments
 (0)