Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Base commit for noArcadeShieldMode.ts, temporarily tabbed out the cod…
Browse files Browse the repository at this point in the history
…e that switches between noArcadeShield and arcadeShield mode within app.ts on account of the binary size being too big now.
  • Loading branch information
KierPalin committed Sep 8, 2024
1 parent 2c4a81f commit e19b651
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 8 deletions.
16 changes: 9 additions & 7 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ namespace microcode {
reportEvent("app.start")

this.sceneManager = new SceneManager()

datalogger.includeTimestamp(FlashLogTimeStampFormat.None)

const arcadeShieldConnected = screenhelpers.displayPresent();
if (arcadeShieldConnected)
this.pushScene(new Home(this))
else
new DistributedLoggingProtocol(this, false);

// if (screenhelpers.displayPresent())
// this.pushScene(new Home(this))
// else
// new NoArcadeShieldMode(this)


if (!screenhelpers.displayPresent())
new NoArcadeShieldMode(this);
}

public pushScene(scene: Scene) {
Expand Down
142 changes: 142 additions & 0 deletions noArcadeShieldMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
namespace microcode {
const enum SENSOR_SELECTION {
ACCELERATION,
TEMPERATURE,
LIGHT
}

const SHOW_EACH_SENSOR_FOR_MS: number = 1000;

export class NoArcadeShieldMode {
private app: App;
private currentUISensor: SENSOR_SELECTION;
private loopThroughSensorSelection: boolean;

constructor(app: App) {
this.app = app;
this.currentUISensor = SENSOR_SELECTION.ACCELERATION;
this.loopThroughSensorSelection = true

control.onEvent(DAL.DEVICE_BUTTON_EVT_DOWN, DAL.DEVICE_ID_BUTTON_A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .
`)

this.loopThroughSensorSelection = false
this.log();
})

this.showSensorSelection();
// new DistributedLoggingProtocol(app, false);
}


private showSensorSelection() {
control.inBackground(() => {

})

control.inBackground(() => {
while (this.loopThroughSensorSelection) {
switch (this.currentUISensor) {
case SENSOR_SELECTION.ACCELERATION:
basic.showLeds(`
# # # . .
# # . . .
# . # . .
. . . # .
. . . . .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS / 3)

basic.showLeds(`
. . # . .
. . # . .
# # # # #
. # # # .
. . # . .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS / 3)

basic.showLeds(`
. . # . .
. . # # .
# # # # #
. . # # .
. . # . .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS / 3)

this.currentUISensor = SENSOR_SELECTION.TEMPERATURE
break;

case SENSOR_SELECTION.TEMPERATURE:
basic.showLeds(`
# . . . .
. . # # .
. # . . .
. # . . .
. . # # .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS)

this.currentUISensor = SENSOR_SELECTION.LIGHT
break;

case SENSOR_SELECTION.LIGHT:
basic.showLeds(`
. . . . .
. . # . .
. . # . .
. . . . .
. . # . .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS / 2)

basic.showLeds(`
. . # . .
. # # # .
. # # # .
. . . . .
. . # . .
`)
basic.pause(SHOW_EACH_SENSOR_FOR_MS / 2)

this.currentUISensor = SENSOR_SELECTION.ACCELERATION
break;

default:
break;
}
} // end of while (this.displaying)
return;
})
}

private log() {
const sensors = this.uiSelectionToSensors();

basic.showString(sensors[0].getName())
}

private uiSelectionToSensors(): Sensor[] {
switch (this.currentUISensor) {
case SENSOR_SELECTION.ACCELERATION:
return [new AccelerometerXSensor(), new AccelerometerYSensor(), new AccelerometerZSensor()]

case SENSOR_SELECTION.TEMPERATURE:
return [new TemperatureSensor()]

case SENSOR_SELECTION.LIGHT:
return [new LightSensor()]

default:
return []
}
}
}
}
3 changes: 2 additions & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"dataRecorder.ts",
"tabularDataViewer.ts",
"generateGraph.ts",
"distributedLogging.ts"
"distributedLogging.ts",
"noArcadeShieldMode.ts"
],
"testFiles": [],
"targetVersions": {
Expand Down

0 comments on commit e19b651

Please sign in to comment.