forked from KierPalin/MicroData
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
84 lines (70 loc) · 2.62 KB
/
app.ts
File metadata and controls
84 lines (70 loc) · 2.62 KB
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
namespace microdata {
import AppInterface = user_interface_base.AppInterface
import Scene = user_interface_base.Scene
import SceneManager = user_interface_base.SceneManager
/**
* Used to control the flow between scenes,
* The SensorSelect scene is used to set the sensors before the RecordData, DistributedLogging and LiveDataViewer scenes
* This enum may be passed to the constructors of these scenes so that they can dynamically control this flow.
*
*/
export enum MicroDataSceneEnum {
LiveDataViewer,
SensorSelect,
RecordingConfigSelect,
RecordData,
DistributedLogging
}
// Auto-save slot
export const SAVESLOT_AUTO = "sa"
export interface SavedState {
progdef: any
version?: string
}
// application configuration
// user_interface_base.getIcon = (id) => Icons..get(id)
user_interface_base.getIcon = (id) => microdata.Icons.get(id)
user_interface_base.resolveTooltip = (ariaId: string) => ariaId
/**
* If an Arcade Shield is not present when starting MicroData that Microbit will enter DistributedLoggingProtocol.
* It will show a :) on its LEDs and try to become a Target - where it will receive radio commands from a Commander Microbit (one with an Arcade Shield)
*/
export class App implements AppInterface {
sceneManager: SceneManager
constructor() {
// One interval delay to ensure all static constructors have executed.
basic.pause(10)
reportEvent("app.start")
this.sceneManager = new SceneManager()
datalogger.includeTimestamp(FlashLogTimeStampFormat.None)
// datalogger.deleteLog(datalogger.DeleteType.Fast)
// for (let i = 0; i < 400; i++) {
// datalogger.log(
// datalogger.createCV("Sensor", "testtest"),
// datalogger.createCV("Time (ms)", i * 1000),
// datalogger.createCV("Reading", (i * 43) % 5000),
// datalogger.createCV("Event", "N/A")
// )
// basic.pause(1)
// }
// this.pushScene(new microdata.TabularDataViewer(this, () => {}));
const arcadeShieldConnected = shieldhelpers.shieldPresent();
if (arcadeShieldConnected)
this.pushScene(new microdata.Home(this));
else
new HeadlessMode();
}
public pushScene(scene: Scene) {
this.sceneManager.pushScene(scene)
}
public popScene() {
this.sceneManager.popScene()
}
public save(slot: string, buffer: Buffer): boolean {
return true;
}
public load(slot: string): Buffer {
return Buffer.create(0)
}
}
}