-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
51 lines (38 loc) · 1.11 KB
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import board
import busio
import displayio
import time
from adafruit_st7735r import ST7735R
from keyInput import KeyInput
from tetrisApp import Tetris
from galleryApp import Gallery
from bitmap import Bitmap
mosi_pin = board.GP11
clk_pin = board.GP10
reset_pin = board.GP17
cs_pin = board.GP18
dc_pin = board.GP16
displayio.release_displays()
spi = busio.SPI(clock=clk_pin, MOSI=mosi_pin)
display_bus = displayio.FourWire(spi, command=dc_pin, chip_select=cs_pin, reset=reset_pin)
display = ST7735R(display_bus, width=128, height=160, bgr = True,rotation=180)
bitmap = Bitmap()
root = displayio.Group()
root.append(bitmap.get_bitmap("images/main.bmp"))
display.show(root)
keyInput = KeyInput()
runApp = None
while True:
if keyInput.isPressedKey("A"):
runApp = Tetris()
if keyInput.isPressedKey("B"):
runApp = Gallery()
if runApp != None:
root.pop()
root.append(runApp.screen)
runApp.start()
if runApp.closed:
root.remove(runApp.screen)
root.append(bitmap.get_bitmap("images/main.bmp"))
runApp = None
time.sleep(0.1)