Skip to content

Commit 3960e92

Browse files
committed
sensorSelection tutorial
1 parent aa44988 commit 3960e92

4 files changed

Lines changed: 39 additions & 18 deletions

File tree

app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace microdata {
2323
export class App implements AppInterface {
2424
sceneManager: SceneManager
2525

26+
// 592f5876341a87f651392aae3755815370276fe8
2627
constructor() {
2728
// One interval delay to ensure all static constructors have executed.
2829
basic.pause(10)

home.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ namespace microdata {
4040
y,
4141
onClick: () => {
4242
this.app.popScene()
43-
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
43+
// this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
44+
this.app.pushScene(new LoggingModeSelection(this.app))
4445
},
4546
}),
4647

pxt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"radio": "*",
88
"microphone": "*",
99
"datalogger": "*",
10-
"user-interface-base": "github:microbit-apps/user-interface-base#592f5876341a87f651392aae3755815370276fe8",
10+
"user-interface-base": "github:microbit-apps/user-interface-base#v0.0.19",
1111
"jacdac": "github:microsoft/pxt-jacdac#v1.9.28",
1212
"jacdac-light-level": "github:microsoft/pxt-jacdac/light-level#v1.9.28",
1313
"jacdac-soil-moisture": "github:microsoft/pxt-jacdac/soil-moisture#v1.9.28",
@@ -27,6 +27,7 @@
2727
"liveDataViewer.ts",
2828
"dataViewSelect.ts",
2929
"loggingConfig.ts",
30+
"LoggingModeSelection.ts",
3031
"sensorSelect.ts",
3132
"dataRecorder.ts",
3233
"tabularDataViewer.ts",

sensorSelect.ts

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace microdata {
3737
private nextSceneEnum: CursorSceneEnum
3838
private jacdacSensorSelected: boolean
3939
private tutorialHintIndex: number;
40+
private userHasPressedABtn: boolean;
4041

4142
constructor(app: AppInterface, nextSceneEnum: CursorSceneEnum) {
4243
super(app, function () {
@@ -49,6 +50,7 @@ namespace microdata {
4950
this.nextSceneEnum = nextSceneEnum;
5051
this.jacdacSensorSelected = false;
5152
this.tutorialHintIndex = 0;
53+
this.userHasPressedABtn = false;
5254
}
5355

5456
/* override */ startup() {
@@ -190,13 +192,25 @@ namespace microdata {
190192
this.navigator.setBtns(this.btns)
191193
}
192194

193-
194195
private overrideControllerButtonBindings() {
196+
const tutorialTextCountDownTimer = () => {
197+
control.inBackground(() => {
198+
basic.pause(4000)
199+
this.tutorialHintIndex = 3
200+
basic.pause(4000)
201+
this.tutorialHintIndex = NUMBER_OF_TUTORIAL_HINTS
202+
})
203+
}
204+
195205
control.onEvent(
196206
ControllerButtonEvent.Pressed,
197207
controller.right.id,
198208
() => {
199-
if (this.tutorialHintIndex == 0)
209+
if (this.userHasPressedABtn && this.tutorialHintIndex <= 1) {
210+
this.tutorialHintIndex = 2
211+
tutorialTextCountDownTimer()
212+
}
213+
else if (this.tutorialHintIndex == 0)
200214
this.tutorialHintIndex = 1
201215
this.moveCursor(CursorDir.Right)
202216
}
@@ -205,7 +219,11 @@ namespace microdata {
205219
ControllerButtonEvent.Pressed,
206220
controller.up.id,
207221
() => {
208-
if (this.tutorialHintIndex == 0)
222+
if (this.userHasPressedABtn && this.tutorialHintIndex <= 1) {
223+
this.tutorialHintIndex = 2
224+
tutorialTextCountDownTimer()
225+
}
226+
else if (this.tutorialHintIndex == 0)
209227
this.tutorialHintIndex = 1
210228
this.moveCursor(CursorDir.Up)
211229
}
@@ -214,7 +232,11 @@ namespace microdata {
214232
ControllerButtonEvent.Pressed,
215233
controller.down.id,
216234
() => {
217-
if (this.tutorialHintIndex == 0)
235+
if (this.userHasPressedABtn && this.tutorialHintIndex <= 1) {
236+
this.tutorialHintIndex = 2
237+
tutorialTextCountDownTimer()
238+
}
239+
else if (this.tutorialHintIndex == 0)
218240
this.tutorialHintIndex = 1
219241
this.moveCursor(CursorDir.Down)
220242
}
@@ -223,31 +245,26 @@ namespace microdata {
223245
ControllerButtonEvent.Pressed,
224246
controller.left.id,
225247
() => {
226-
if (this.tutorialHintIndex == 0)
248+
if (this.userHasPressedABtn && this.tutorialHintIndex <= 1) {
249+
this.tutorialHintIndex = 2
250+
tutorialTextCountDownTimer()
251+
}
252+
else if (this.tutorialHintIndex == 0)
227253
this.tutorialHintIndex = 1
228254
this.moveCursor(CursorDir.Left)
229255
}
230256
)
231257

232-
const click = () => this.cursor.click()
233-
const tutorialTextCountDownTimer = () => {
234-
control.inBackground(() => {
235-
basic.pause(4000)
236-
this.tutorialHintIndex = 3
237-
basic.pause(4000)
238-
this.tutorialHintIndex = 4
239-
})
240-
}
241-
242258
control.onEvent(
243259
ControllerButtonEvent.Pressed,
244260
controller.A.id,
245261
() => {
262+
this.userHasPressedABtn = true;
246263
if (this.tutorialHintIndex == 1) {
247264
this.tutorialHintIndex = 2
248265
tutorialTextCountDownTimer()
249266
}
250-
click
267+
this.cursor.click()
251268
}
252269
)
253270
}
@@ -287,6 +304,7 @@ namespace microdata {
287304
super.draw()
288305

289306
if (TUTORIAL_MODE) {
307+
basic.showNumber(this.cursor.navigator.)
290308
const drawTutorialTextBox = () => {
291309
Screen.fillRect(
292310
Screen.LEFT_EDGE,

0 commit comments

Comments
 (0)