-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
33 lines (33 loc) · 919 Bytes
/
main.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
let timeStill = 0;
input.onButtonPressed(Button.A, function () {
basic.clearScreen();
serial.writeLine("Total time still: " + timeStill + "\n");
});
input.onButtonPressed(Button.B, function () {
basic.clearScreen();
serial.writeLine(
"Probability of shake: " + ml.getCertainty(ml.event.Shake) + "\n"
);
});
ml.onStart(ml.event.Shake, function () {
basic.showString("S");
});
ml.onStart(ml.event.Still, function () {
basic.showIcon(IconNames.Asleep);
});
ml.onStart(ml.event.DrawCircle, function () {
basic.showString("C");
});
ml.onStart(ml.event.Unknown, function () {
basic.clearScreen();
});
ml.onStop(ml.event.Shake, function () {
serial.writeLine("Stopped shaking" + "\n");
});
ml.onStopDetailed(ml.event.Still, function (duration) {
timeStill += duration;
});
basic.forever(function () {
serial.writeLine("Is Shake: " + ml.isDetected(ml.event.Shake) + "\n");
basic.pause(10000);
});