diff --git a/app.ts b/app.ts index c164440..ca0ebcd 100644 --- a/app.ts +++ b/app.ts @@ -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) { diff --git a/noArcadeShieldMode.ts b/noArcadeShieldMode.ts new file mode 100644 index 0000000..73ec86a --- /dev/null +++ b/noArcadeShieldMode.ts @@ -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 [] + } + } + } +} \ No newline at end of file diff --git a/pxt.json b/pxt.json index 504e428..550f1cb 100644 --- a/pxt.json +++ b/pxt.json @@ -49,7 +49,8 @@ "dataRecorder.ts", "tabularDataViewer.ts", "generateGraph.ts", - "distributedLogging.ts" + "distributedLogging.ts", + "noArcadeShieldMode.ts" ], "testFiles": [], "targetVersions": {