-
Notifications
You must be signed in to change notification settings - Fork 3
/
home.ts
155 lines (140 loc) · 5.42 KB
/
home.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
namespace microcode {
export class Home extends CursorScene {
private liveDataBtn: Button
private recordDataBtn: Button
private distributedLoggingBtn: Button
private viewBtn: Button
constructor(app: App) {super(app)}
/* override */ startup() {
super.startup()
const y = Screen.HEIGHT * 0.234 // y = 30 on an Arcade Shield of height 128 pixels
const sensorSelectTutorialOpts = {
tips: [
{text: "Pick your sensors\non the next\nscreen."},
{text: "Use UP and DOWN\nto scroll.\nTry it now!"},
{text: "Use A to select a\nsensor.", keywords: [" A "], keywordColors: [6]},
{text: "Select DONE to\nconfirm your\nchoices.", keywords: [" DONE "], keywordColors: [7]},
{text: "Press A to continue!", keywords: [" A "], keywordColors: [6]}, // Red
],
backFn: () => {
this.app.popScene()
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.LiveDataViewer))
},
}
this.liveDataBtn = new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "linear_graph_1",
ariaId: "Real-time Data",
x: -58,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.LiveDataViewer))
},
})
this.recordDataBtn = new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "edit_program",
ariaId: "Log Data",
x: -20,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
},
})
this.distributedLoggingBtn = new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "radio_set_group",
ariaId: "Command Mode",
x: 20,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new DistributedLoggingScreen(this.app))
},
})
this.viewBtn = new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "largeDisk",
ariaId: "View Data",
x: 58,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new DataViewSelect(this.app))
},
})
const btns: Button[] = [this.liveDataBtn, this.recordDataBtn, this.distributedLoggingBtn, this.viewBtn]
this.navigator.addButtons(btns)
}
private drawVersion() {
const font = bitmaps.font5
Screen.print(
"v1.5",
Screen.RIGHT_EDGE - font.charWidth * "v1.5".length,
Screen.BOTTOM_EDGE - font.charHeight - 2,
0xb,
font
)
}
private yOffset = -Screen.HEIGHT >> 1
draw() {
Screen.fillRect(
Screen.LEFT_EDGE,
Screen.TOP_EDGE,
Screen.WIDTH,
Screen.HEIGHT,
0xc
)
this.yOffset = Math.min(0, this.yOffset + 2)
const t = control.millis()
const dy = this.yOffset == 0 ? (Math.idiv(t, 800) & 1) - 1 : 0
const margin = 2
const OFFSET = (Screen.HEIGHT >> 1) - wordLogo.height - margin
const y = Screen.TOP_EDGE + OFFSET //+ dy
Screen.drawTransparentImage(
wordLogo,
Screen.LEFT_EDGE + ((Screen.WIDTH - wordLogo.width) >> 1)// + dy
,
y + this.yOffset
)
Screen.drawTransparentImage(
microbitLogo,
Screen.LEFT_EDGE +
((Screen.WIDTH - microbitLogo.width) >> 1) + dy
,
y - wordLogo.height + this.yOffset + margin
)
if (!this.yOffset) {
const tagline = resolveTooltip("Data Science!")
Screen.print(
tagline,
Screen.LEFT_EDGE +
((Screen.WIDTH + wordLogo.width) >> 1)
+ dy
-
microcode.font.charWidth * tagline.length,
Screen.TOP_EDGE +
OFFSET +
wordLogo.height +
dy +
this.yOffset +
1,
0xb,
microcode.font
)
}
this.liveDataBtn.draw()
this.recordDataBtn.draw()
this.distributedLoggingBtn.draw()
this.viewBtn.draw()
this.drawVersion()
super.draw()
}
}
}