-
Notifications
You must be signed in to change notification settings - Fork 0
/
butext.py
67 lines (60 loc) · 1.4 KB
/
butext.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from m5stack import *
from m5ui import *
from uiflow import *
from numbers import Number
setScreenColor(0x000000)
i = None
c = None
p = None
image0 = M5Img(0, 0, "res/default.jpg", False)
label0 = M5TextBox(0, 0, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
# Display battery status
def battstat():
global i, c, p
if power.isCharging():
c = '(charging)'
else:
c = ''
label0.setText('')
label0.setText(str((str((power.getBatteryLevel())) + str(((str('% ') + str(c)))))))
# Next slide callback
def buttonA_wasPressed():
global i, c, p
i = (i if isinstance(i, Number) else 0) + 1
setScreenColor(0x000000)
if i==1:
image0.changeImg("res/askme.png")
elif i==2:
image0.changeImg("res/features.png")
elif i==3:
image0.changeImg("res/value2.png")
else:
image0.changeImg("res/rhblogo.png")
i = 0
pass
btnA.wasPressed(buttonA_wasPressed)
# Battery status callback
def buttonB_wasReleased():
global i, c, p
speaker.tone(2200, 100)
battstat()
pass
btnB.wasReleased(buttonB_wasReleased)
# Kernel panic callback
def buttonC_wasPressed():
global i, c, p
p = (p if isinstance(p, Number) else 0) + 1
if p==1:
setScreenColor(0x000000)
image0.changeImg("res/kpanic2.png")
else:
setScreenColor(0x2067b2)
image0.changeImg("res/bsod.png")
p = 0
pass
btnC.wasPressed(buttonC_wasPressed)
# Main
i = 0
p = 0
battstat()
image0.changeImg("res/rhblogo.png")