Skip to content

Commit aa44988

Browse files
committed
loggingModeSelection.ts: new scene to explain the 3 methods of logging; splitting the previous monolithic method.
1 parent 9b092b8 commit aa44988

1 file changed

Lines changed: 159 additions & 0 deletions

File tree

loggingModeSelection.ts

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
namespace microdata {
2+
import Screen = user_interface_base.Screen
3+
import CursorScene = user_interface_base.CursorScene
4+
import Button = user_interface_base.Button
5+
import ButtonStyles = user_interface_base.ButtonStyles
6+
import AppInterface = user_interface_base.AppInterface
7+
import CursorSceneEnum = user_interface_base.CursorSceneEnum
8+
import font = user_interface_base.font
9+
import Bounds = user_interface_base.Bounds
10+
11+
export class LoggingModeSelection extends CursorScene {
12+
constructor(app: AppInterface) {
13+
super(app)
14+
}
15+
16+
/* override */ startup() {
17+
super.startup()
18+
19+
const y = 36
20+
21+
this.navigator.setBtns([[
22+
new Button({
23+
parent: null,
24+
style: ButtonStyles.Transparent,
25+
icon: "edit_program",
26+
ariaId: "",
27+
x: -50,
28+
y,
29+
onClick: () => {
30+
this.app.popScene()
31+
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.LiveDataViewer))
32+
},
33+
}),
34+
35+
new Button({
36+
parent: null,
37+
style: ButtonStyles.Transparent,
38+
icon: "largeSettingsGear",
39+
ariaId: "",
40+
x: 0,
41+
y,
42+
onClick: () => {
43+
this.app.popScene()
44+
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
45+
},
46+
}),
47+
48+
new Button({
49+
parent: null,
50+
style: ButtonStyles.Transparent,
51+
icon: "largeDisk",
52+
ariaId: "",
53+
x: 50,
54+
y,
55+
onClick: () => {
56+
this.app.popScene()
57+
this.app.pushScene(new DataViewSelect(this.app))
58+
},
59+
})
60+
]])
61+
}
62+
63+
64+
draw() {
65+
Screen.fillRect(
66+
Screen.LEFT_EDGE,
67+
Screen.TOP_EDGE,
68+
Screen.WIDTH,
69+
Screen.HEIGHT,
70+
0xc
71+
)
72+
73+
this.navigator.drawComponents();
74+
super.draw()
75+
76+
const tutorialBounds = new Bounds({
77+
width: Screen.WIDTH - 8,
78+
height: (Screen.HEIGHT >> 1) + 8,
79+
left: -(Screen.WIDTH >> 1) + 3,
80+
top: -(Screen.HEIGHT >> 1) + 2
81+
});
82+
83+
const tutorialBoundsShadow = new Bounds({
84+
width: tutorialBounds.width + 2,
85+
height: tutorialBounds.height + 2,
86+
left: tutorialBounds.left,
87+
top: tutorialBounds.top
88+
});
89+
90+
const drawTutorialTips = (title: string, tips: string[]) => {
91+
tutorialBoundsShadow.fillRect(15)
92+
tutorialBounds.fillRect(6)
93+
94+
Screen.print(
95+
title,
96+
(tutorialBounds.left + (tutorialBounds.width >> 1)) - ((title.length * font.charWidth) >> 1),
97+
tutorialBounds.top + 4,
98+
15
99+
)
100+
101+
const tipsStartY = 15;
102+
const yDif = (i: number) =>
103+
(tips.length == 3)
104+
? i * (2 * font.charHeight)
105+
: i * ((tutorialBounds.height - 10) / tips.length)
106+
107+
for (let i = 0; i < tips.length; i++) {
108+
Screen.fillRect(
109+
tutorialBounds.left + 3,
110+
tutorialBounds.top + tipsStartY + yDif(i) + (font.charHeight >> 1),
111+
3,
112+
3,
113+
15
114+
)
115+
116+
Screen.print(
117+
tips[i],
118+
tutorialBounds.left + 9,
119+
tutorialBounds.top + tipsStartY + yDif(i) + 1,
120+
15
121+
)
122+
}
123+
}
124+
125+
switch (this.navigator.getCurrent().getIcon()) {
126+
case "edit_program": {
127+
const tips = [
128+
"Log at a regular rate.",
129+
"Logs are kept on-device.",
130+
"Good choice for typical\nexperiments."
131+
];
132+
drawTutorialTips("Interval Mode", tips)
133+
134+
break;
135+
};
136+
137+
case "largeSettingsGear": {
138+
const tips = [
139+
"Log a sudden change in\nacceleration.",
140+
"Or when temperature\nreaches a certain value."
141+
];
142+
drawTutorialTips("Event Mode", tips)
143+
break;
144+
};
145+
146+
case "largeDisk": {
147+
const tips = [
148+
"Only log when I press\nthe A button.",
149+
"Good for experiments\nwith special conditions.",
150+
];
151+
drawTutorialTips("Stopwatch Mode", tips)
152+
break;
153+
}
154+
155+
default: break;
156+
}
157+
}
158+
}
159+
}

0 commit comments

Comments
 (0)