Skip to content

Commit 86f5023

Browse files
committed
Removed the Button members used in the dataViewSelect, distributedLogging and home classes; they are no longer neccessary due to the user-interface-base#v0.0.15 drawComponent changes
1 parent 8526163 commit 86f5023

3 files changed

Lines changed: 177 additions & 202 deletions

File tree

dataViewSelect.ts

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ namespace microdata {
1313
* A graph of the recorded data
1414
*/
1515
export class DataViewSelect extends CursorSceneWithPriorPage {
16-
private resetDataLoggerBtn: Button
17-
private dataViewBtn: Button
18-
private graphViewBtn: Button
1916
private dataloggerEmpty: boolean
2017

2118
constructor(app: AppInterface) {
@@ -49,56 +46,56 @@ namespace microdata {
4946
}
5047

5148
const y = Screen.HEIGHT * 0.234 // y = 30 on an Arcade Shield of height 128 pixels
49+
50+
this.navigator.setBtns([[
51+
new Button({
52+
parent: null,
53+
style: ButtonStyles.Transparent,
54+
icon: "largeDisk",
55+
ariaId: "View Data",
56+
x: -50,
57+
y,
58+
onClick: () => {
59+
this.app.popScene()
60+
this.app.pushScene(new TabularDataViewer(this.app, function () {this.app.popScene(); this.app.pushScene(new DataViewSelect(this.app))}))
61+
},
62+
}),
5263

53-
this.dataViewBtn = new Button({
54-
parent: null,
55-
style: ButtonStyles.Transparent,
56-
icon: "largeDisk",
57-
ariaId: "View Data",
58-
x: -50,
59-
y,
60-
onClick: () => {
61-
this.app.popScene()
62-
this.app.pushScene(new TabularDataViewer(this.app, function () {this.app.popScene(); this.app.pushScene(new DataViewSelect(this.app))}))
63-
},
64-
})
65-
66-
this.graphViewBtn = new Button({
67-
parent: null,
68-
style: ButtonStyles.Transparent,
69-
icon: "linear_graph_1",
70-
ariaId: "View Graph",
71-
x: 0,
72-
y,
73-
onClick: () => {
74-
this.app.popScene()
75-
this.app.pushScene(new GraphGenerator(this.app))
76-
},
77-
})
78-
79-
this.resetDataLoggerBtn = new Button({
80-
parent: null,
81-
style: ButtonStyles.Transparent,
82-
icon: "largeSettingsGear",
83-
ariaId: "Reset Datalogger",
84-
x: 50,
85-
y,
86-
onClick: () => {
87-
datalogger.deleteLog()
88-
this.dataloggerEmpty = true
89-
90-
control.onEvent(
91-
ControllerButtonEvent.Pressed,
92-
controller.A.id,
93-
() => {
94-
this.app.popScene()
95-
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
96-
}
97-
)
98-
},
99-
})
64+
new Button({
65+
parent: null,
66+
style: ButtonStyles.Transparent,
67+
icon: "linear_graph_1",
68+
ariaId: "View Graph",
69+
x: 0,
70+
y,
71+
onClick: () => {
72+
this.app.popScene()
73+
this.app.pushScene(new GraphGenerator(this.app))
74+
},
75+
}),
10076

101-
this.navigator.setBtns([[this.dataViewBtn, this.graphViewBtn, this.resetDataLoggerBtn]])
77+
new Button({
78+
parent: null,
79+
style: ButtonStyles.Transparent,
80+
icon: "largeSettingsGear",
81+
ariaId: "Reset Datalogger",
82+
x: 50,
83+
y,
84+
onClick: () => {
85+
datalogger.deleteLog()
86+
this.dataloggerEmpty = true
87+
88+
control.onEvent(
89+
ControllerButtonEvent.Pressed,
90+
controller.A.id,
91+
() => {
92+
this.app.popScene()
93+
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.RecordingConfigSelect))
94+
}
95+
)
96+
},
97+
})
98+
]])
10299
}
103100

104101
draw() {
@@ -118,9 +115,7 @@ namespace microdata {
118115

119116
else {
120117
screen().printCenter("Recorded Data Options", 5)
121-
this.resetDataLoggerBtn.draw()
122-
this.dataViewBtn.draw()
123-
this.graphViewBtn.draw()
118+
this.navigator.drawComponents();
124119
}
125120

126121
super.draw()

distributedLogging.ts

Lines changed: 76 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,6 @@ namespace microdata {
551551

552552
private targetIDCache: number[]
553553

554-
private targetMicrobitsBtn: Button
555-
private startLoggingBtn: Button
556-
private startStreamingBtn: Button
557-
private showDataBtn: Button
558-
559554
constructor(app: AppInterface, sensors?: Sensor[], configs?: RecordingConfig[]) {
560555
super(app)
561556
this.uiState = UI_STATE.SHOWING_OPTIONS
@@ -603,83 +598,82 @@ namespace microdata {
603598

604599
const y = Screen.HEIGHT * 0.234 // y = 30 on an Arcade Shield of height 128 pixels
605600

606-
this.targetMicrobitsBtn = new Button({
607-
parent: null,
608-
style: ButtonStyles.Transparent,
609-
icon: "largeSettingsGear",
610-
ariaId: "See connected Microbits",
611-
x: -60,
612-
y,
613-
onClick: () => {
614-
if (DistributedLoggingScreen.streamingDone) {
615-
this.uiState = UI_STATE.SHOWING_CONNECTED_MICROBITS
616-
this.cursor.visible = false
617-
this.targetIDCache = []
618-
619-
// Start timeout:
620-
// Continually request the target ids; so that new incoming targets appear on the list as it is displayed, and outgoing targets leave it, in real-time:
621-
control.inBackground(() => {
622-
while (this.uiState == UI_STATE.SHOWING_CONNECTED_MICROBITS) {
623-
this.targetIDCache = this.distributedLogger.commanderRequestTargetIDs()
624-
basic.pause(MESSAGE_LATENCY_MS * 2)
625-
}
626-
})
627-
}
628-
},
629-
})
630-
631-
this.startLoggingBtn = new Button({
632-
parent: null,
633-
style: ButtonStyles.Transparent,
634-
icon: "radio_set_group",
635-
ariaId: "Start logging",
636-
x: -20,
637-
y,
638-
onClick: () => {
639-
if (DistributedLoggingScreen.streamingDone) {
640-
DistributedLoggingScreen.streamDataBack = false
641-
642-
this.app.popScene()
643-
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.DistributedLogging))
644-
}
645-
}
646-
})
647-
648-
this.startStreamingBtn = new Button({
649-
parent: null,
650-
style: ButtonStyles.Transparent,
651-
icon: "radio_set_group",
652-
ariaId: "Start streaming",
653-
x: 20,
654-
y,
655-
onClick: () => {
656-
if (DistributedLoggingScreen.streamingDone) {
657-
DistributedLoggingScreen.streamDataBack = true
658-
659-
this.app.popScene()
660-
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.DistributedLogging))
661-
}
662-
},
663-
flipIcon: true
664-
})
665-
666-
this.showDataBtn = new Button({
667-
parent: null,
668-
style: ButtonStyles.Transparent,
669-
icon: "largeDisk",
670-
ariaId: "View real-time data",
671-
x: 60,
672-
y,
673-
onClick: () => {
674-
if (DistributedLoggingScreen.showTabularData) {
675-
this.app.popScene();
676-
this.app.pushScene(new TabularDataViewer(this.app, function () {this.app.popScene(); this.app.pushScene(new DistributedLoggingScreen(this.app))}));
601+
this.navigator.setBtns([[
602+
new Button({
603+
parent: null,
604+
style: ButtonStyles.Transparent,
605+
icon: "largeSettingsGear",
606+
ariaId: "See connected Microbits",
607+
x: -60,
608+
y,
609+
onClick: () => {
610+
if (DistributedLoggingScreen.streamingDone) {
611+
this.uiState = UI_STATE.SHOWING_CONNECTED_MICROBITS
612+
this.cursor.visible = false
613+
this.targetIDCache = []
614+
615+
// Start timeout:
616+
// Continually request the target ids; so that new incoming targets appear on the list as it is displayed, and outgoing targets leave it, in real-time:
617+
control.inBackground(() => {
618+
while (this.uiState == UI_STATE.SHOWING_CONNECTED_MICROBITS) {
619+
this.targetIDCache = this.distributedLogger.commanderRequestTargetIDs()
620+
basic.pause(MESSAGE_LATENCY_MS * 2)
621+
}
622+
})
623+
}
624+
},
625+
}),
626+
627+
new Button({
628+
parent: null,
629+
style: ButtonStyles.Transparent,
630+
icon: "radio_set_group",
631+
ariaId: "Start logging",
632+
x: -20,
633+
y,
634+
onClick: () => {
635+
if (DistributedLoggingScreen.streamingDone) {
636+
DistributedLoggingScreen.streamDataBack = false
637+
638+
this.app.popScene()
639+
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.DistributedLogging))
640+
}
677641
}
678-
},
679-
})
680-
681-
const btns: Button[] = [this.targetMicrobitsBtn, this.startLoggingBtn, this.startStreamingBtn, this.showDataBtn]
682-
this.navigator.setBtns([btns])
642+
}),
643+
644+
new Button({
645+
parent: null,
646+
style: ButtonStyles.Transparent,
647+
icon: "radio_set_group",
648+
ariaId: "Start streaming",
649+
x: 20,
650+
y,
651+
onClick: () => {
652+
if (DistributedLoggingScreen.streamingDone) {
653+
DistributedLoggingScreen.streamDataBack = true
654+
655+
this.app.popScene()
656+
this.app.pushScene(new SensorSelect(this.app, CursorSceneEnum.DistributedLogging))
657+
}
658+
},
659+
flipIcon: true
660+
}),
661+
662+
new Button({
663+
parent: null,
664+
style: ButtonStyles.Transparent,
665+
icon: "largeDisk",
666+
ariaId: "View real-time data",
667+
x: 60,
668+
y,
669+
onClick: () => {
670+
if (DistributedLoggingScreen.showTabularData) {
671+
this.app.popScene();
672+
this.app.pushScene(new TabularDataViewer(this.app, function () {this.app.popScene(); this.app.pushScene(new DistributedLoggingScreen(this.app))}));
673+
}
674+
},
675+
})
676+
]])
683677
}
684678

685679
draw() {
@@ -708,11 +702,7 @@ namespace microdata {
708702
2
709703
)
710704

711-
this.targetMicrobitsBtn.draw()
712-
this.startLoggingBtn.draw()
713-
this.startStreamingBtn.draw()
714-
this.showDataBtn.draw()
715-
705+
this.navigator.drawComponents();
716706
break;
717707
}
718708

0 commit comments

Comments
 (0)