Skip to content

Commit 7744365

Browse files
committed
Do a full reinitialization of the TFT for pybadge
1 parent 2999a02 commit 7744365

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

pybadge/ugame.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,40 @@
2121
K_SELECT = 0x08
2222

2323
# re-initialize the display for correct rotation and RGB mode
24+
25+
_TFT_INIT = (
26+
b"\x01\x80\x96" # SWRESET and Delay 150ms
27+
b"\x11\x80\xff" # SLPOUT and Delay
28+
b"\xb1\x03\x01\x2C\x2D" # _FRMCTR1
29+
b"\xb2\x03\x01\x2C\x2D" # _FRMCTR2
30+
b"\xb3\x06\x01\x2C\x2D\x01\x2C\x2D" # _FRMCTR3
31+
b"\xb4\x01\x07" # _INVCTR line inversion
32+
b"\xc0\x03\xa2\x02\x84" # _PWCTR1 GVDD = 4.7V, 1.0uA
33+
b"\xc1\x01\xc5" # _PWCTR2 VGH=14.7V, VGL=-7.35V
34+
b"\xc2\x02\x0a\x00" # _PWCTR3 Opamp current small, Boost frequency
35+
b"\xc3\x02\x8a\x2a"
36+
b"\xc4\x02\x8a\xee"
37+
b"\xc5\x01\x0e" # _VMCTR1 VCOMH = 4V, VOML = -1.1V
38+
b"\x20\x00" # _INVOFF
39+
b"\x36\x01\xa8" # _MADCTL
40+
# 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie,
41+
# fix on VTL
42+
b"\x3a\x01\x05" # COLMOD - 16bit color
43+
b"\xe0\x10\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10" # _GMCTRP1 Gamma
44+
b"\xe1\x10\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10" # _GMCTRN1
45+
b"\x13\x80\x0a" # _NORON
46+
b"\x29\x80\x64" # _DISPON
47+
)
2448
displayio.release_displays()
2549
_tft_spi = busio.SPI(clock=board.TFT_SCK, MOSI=board.TFT_MOSI)
2650
_tft_spi.try_lock()
2751
_tft_spi.configure(baudrate=24000000)
2852
_tft_spi.unlock()
2953
_fourwire = displayio.FourWire(_tft_spi, command=board.TFT_DC,
30-
chip_select=board.TFT_CS)
31-
display = displayio.Display(_fourwire, b'\x36\x01\xa8', width=160, height=128,
54+
chip_select=board.TFT_CS, reset=board.TFT_RST)
55+
display = displayio.Display(_fourwire, _TFT_INIT, width=160, height=128,
3256
rotation=0, backlight_pin=board.TFT_LITE)
57+
del _TFT_INIT
3358
display.auto_brightness = True
3459

3560
buttons = gamepadshift.GamePadShift(

0 commit comments

Comments
 (0)