forked from KierPalin/MicroData
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataViewSelect.ts
More file actions
132 lines (116 loc) · 3.38 KB
/
dataViewSelect.ts
File metadata and controls
132 lines (116 loc) · 3.38 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
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
namespace microdata {
import Screen = user_interface_base.Screen
import CursorScene = user_interface_base.CursorScene
import Button = user_interface_base.Button
import ButtonStyles = user_interface_base.ButtonStyles
import AppInterface = user_interface_base.AppInterface
/**
* Choose between:
* Resetting Datalogger
* A tabular view of the recorded data
* Jacdac light experiment
*/
export class DataViewSelect extends CursorScene {
private dataloggerEmpty: boolean
constructor(app: AppInterface) {
super(app);
}
/* override */ startup() {
super.startup()
basic.pause(50);
// Includes the header:
this.dataloggerEmpty = datalogger.getNumberOfRows() <= 1
const y = Screen.HEIGHT * 0.234 // y = 30 on an Arcade Shield of height 128 pixels
let btns: Button[][] = [[]];
if (this.dataloggerEmpty) {
btns[0].push(new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "edit_program",
ariaId: "Log Data",
x: -50,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new SensorSelect(this.app, MicroDataSceneEnum.RecordingConfigSelect))
},
}))
} else {
btns[0].push(new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "largeDisk",
ariaId: "View Data",
x: -50,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new TabularDataViewer(this.app, () => { this.app.popScene(); this.app.pushScene(new DataViewSelect(this.app)) }))
}
}))
}
btns[0].push(new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "linear_graph_1",
ariaId: "Jacdac Light Experiment",
x: 0,
y,
onClick: () => {
this.app.popScene()
this.app.pushScene(new JacdacLightExperiment(this.app))
},
}))
btns[0].push(new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: "largeSettingsGear",
ariaId: "Reset Datalogger",
x: 50,
y,
onClick: () => {
datalogger.deleteLog()
this.dataloggerEmpty = true
context.onEvent(
ControllerButtonEvent.Pressed,
controller.A.id,
() => {
this.app.popScene()
this.app.pushScene(new SensorSelect(this.app, MicroDataSceneEnum.RecordingConfigSelect))
}
)
},
}))
this.navigator.setBtns(btns)
//---------
// Control:
//---------
context.onEvent(
ControllerButtonEvent.Pressed,
controller.B.id,
() => {
this.app.popScene()
this.app.pushScene(new Home(this.app))
}
)
}
draw() {
Screen.fillRect(
Screen.LEFT_EDGE,
Screen.TOP_EDGE,
Screen.WIDTH,
Screen.HEIGHT,
0xC
)
if (this.dataloggerEmpty) {
screen().printCenter("No data has been recorded", 5)
screen().printCenter("Log Data to collect some!", Screen.HALF_HEIGHT - 30)
}
else {
screen().printCenter("View Data, Experiment or Clear Data", 5)
}
this.navigator.drawComponents();
super.draw()
}
}
}