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

Commit

Permalink
no-jacdac-version <- feature/no-arcade-shield-mode (#6)
Browse files Browse the repository at this point in the history
* Base commit for noArcadeShieldMode.ts, temporarily tabbed out the code that switches between noArcadeShield and arcadeShield mode within app.ts on account of the binary size being too big now.

* sensors.ts: renamed getNormalisedNthReading & buffer to getNthHeightNormalisedReading. Added getNormalisedReading - which returns the sensors output normalised to 0 and 1. Added additional documentation. Updated liveDataViewer and graphGenerator - which use these methods, as appropriate.

* noArcadeShield: showSensorIcon(), dynamicSensorSeectionLoop, added magnet and radio.

* noArcadeShieldMode.ts: adjusted dynamicSensorSelectionLoop to have a small wait inbetween dynamicInfo loops - to solve threading bug where the leds would remain the same since the selectionLoop thread would hog resources.

* noArcadeShieldMode: Added conformation to selection, implemented b button (bugged). Completed sensorSelection & looping. Need to modify sensorScheduling for uncapped measurement qty; will be custom implementation within .log() of noArcadeShieldMode. Issue with latency after pressing A button remains.

* Fixed B button issue.

* Completed all noArcadeShieldMode features.

* Removed confirm selection, improved latency issue with switching leds somewhat.

* noArcadeShieldMode.ts: drastically improved cycling latency via new incremental wait function.

* noArcadeShieldMode: fixed latency issues + enabled cancelling of recording + simplified waits + cut unused variables.

* noArcadeShieldMode: thorough documentation complete.

* unbinding A & B button. Entry to this class is now via noArcadeShieldMode; which used A & B.

* noArcadeShieldModeForMakecode created: code can be used within the MakeCode editor; all sensor dependencies are within this file. Does not interact with other code.
  • Loading branch information
KierPalin authored Sep 20, 2024
1 parent da44696 commit 4c2a01b
Show file tree
Hide file tree
Showing 8 changed files with 872 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ namespace microcode {

this.sceneManager = new SceneManager()
datalogger.includeTimestamp(FlashLogTimeStampFormat.None)

if (screenhelpers.displayPresent())
this.pushScene(new Home(this))
else
new DistributedLoggingProtocol(this, false);
new NoArcadeShieldMode(this);
}

public pushScene(scene: Scene) {
Expand Down
7 changes: 7 additions & 0 deletions distributedLogging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ namespace microcode {
constructor(app: App, arcadeShieldIsConnected: boolean, callbackObj?: ITargetDataLoggedCallback) {
this.app = app;

//--------------
// Unbind A & B:
//--------------

input.onButtonPressed(1, () => {});
input.onButtonPressed(2, () => {});

//------------------------------------------------------
// Variables used by both the Commander and the Targets:
//------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions generateGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ namespace microcode {
// Unbind all controls - since .processReadings() may take some time if there are an immense amount of readings:
// Pressing a button during this early stage of processing may crash:
control.onEvent(ControllerButtonEvent.Pressed, controller.up.id, () => {});
control.onEvent(ControllerButtonEvent.Pressed,controller.down.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed,controller.left.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed,controller.right.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed,controller.A.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed,controller.B.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed, controller.down.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed, controller.left.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed, controller.right.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed, controller.A.id,() => {});
control.onEvent(ControllerButtonEvent.Pressed, controller.B.id,() => {});

this.lowestPeriod = 0;
this.greatestPeriod = 0;
Expand Down
18 changes: 9 additions & 9 deletions liveDataViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ namespace microcode {
this.sensors.forEach((sensor) => sensor.setBufferSize(140));

const sensor = this.sensors[this.oscSensorIndex];
this.oscXCoordinate = Math.round(sensor.getNormalisedBufferLength() / 2);
this.oscReading = sensor.getNthNormalisedReading(this.oscXCoordinate);
this.oscXCoordinate = Math.round(sensor.getHeightNormalisedBufferLength() / 2);
this.oscReading = sensor.getNthHeightNormalisedReading(this.oscXCoordinate);
;
this.windowLeftBuffer = 0;
this.windowRightBuffer = 0;
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace microcode {

else if (this.guiState == GUI_STATE.ZOOMED_IN) {
this.oscSensorIndex = Math.max(0, this.oscSensorIndex - 1)
this.oscReading = this.sensors[this.oscSensorIndex].getNthNormalisedReading(this.oscXCoordinate)
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
}

this.sensors.forEach((sensor) => sensor.normaliseDataBuffer(this.windowBotBuffer - (2 * this.yScrollOffset) + (Screen.HEIGHT * 0.0625))) // 8
Expand Down Expand Up @@ -236,7 +236,7 @@ namespace microcode {

else if (this.guiState == GUI_STATE.ZOOMED_IN) {
this.oscSensorIndex = Math.min(this.oscSensorIndex + 1, this.sensors.length - 1)
this.oscReading = this.sensors[this.oscSensorIndex].getNthNormalisedReading(this.oscXCoordinate)
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
}
}
)
Expand All @@ -247,7 +247,7 @@ namespace microcode {
() => {
if (this.guiState == GUI_STATE.ZOOMED_IN && this.oscXCoordinate > 0) {
this.oscXCoordinate -= 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthNormalisedReading(this.oscXCoordinate)
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
this.update() // For fast response to the above change
}
}
Expand All @@ -257,9 +257,9 @@ namespace microcode {
ControllerButtonEvent.Pressed,
controller.right.id,
() => {
if (this.guiState == GUI_STATE.ZOOMED_IN && this.oscXCoordinate < this.sensors[this.oscSensorIndex].getNormalisedBufferLength() - 1) {
if (this.guiState == GUI_STATE.ZOOMED_IN && this.oscXCoordinate < this.sensors[this.oscSensorIndex].getHeightNormalisedBufferLength() - 1) {
this.oscXCoordinate += 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthNormalisedReading(this.oscXCoordinate)
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)

this.update() // For fast response to the above change
}
Expand Down Expand Up @@ -340,7 +340,7 @@ namespace microcode {
)

// Draw the latest reading on the right-hand side as a Ticker if at no-zoom:
if (this.guiState != GUI_STATE.ZOOMED_IN && sensor.getNormalisedBufferLength() > 0) {
if (this.guiState != GUI_STATE.ZOOMED_IN && sensor.getHeightNormalisedBufferLength() > 0) {
const fromY = this.windowBotBuffer - 2 * this.yScrollOffset + (Screen.HEIGHT * 0.078125) // 10

const reading = sensor.getReading()
Expand Down Expand Up @@ -540,7 +540,7 @@ namespace microcode {
)

// End:
const end: string = (this.sensors[0].numberOfReadings + this.sensors[0].getNormalisedBufferLength()).toString()
const end: string = (this.sensors[0].numberOfReadings + this.sensors[0].getHeightNormalisedBufferLength()).toString()
screen().print(
end,
Screen.WIDTH - this.windowRightBuffer - (end.length * font.charWidth) - 1,
Expand Down
Loading

0 comments on commit 4c2a01b

Please sign in to comment.