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

Commit

Permalink
liveDataViewer.ts: improved zoom in mode: can hold down left or right…
Browse files Browse the repository at this point in the history
… instead of needing to press multiple times.
  • Loading branch information
KierPalin committed Nov 7, 2024
1 parent 4be56a4 commit b8b9aa0
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions liveDataViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,26 @@ namespace microcode {
ControllerButtonEvent.Pressed,
controller.left.id,
() => {
if (this.guiState == GUI_STATE.ZOOMED_IN && this.oscXCoordinate > 0) {
this.oscXCoordinate -= 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
this.update() // For fast response to the above change
if (this.guiState == GUI_STATE.ZOOMED_IN) {
// this.oscXCoordinate -= 1
// this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
// this.update() // For fast response to the above change

let tick = true;
control.onEvent(
ControllerButtonEvent.Released,
controller.left.id,
() => tick = false
)

let isFirstTick = true
while (tick && this.oscXCoordinate > 0) {
this.oscXCoordinate -= 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
basic.pause(isFirstTick ? 100 : 33)
isFirstTick = false
}
control.onEvent(ControllerButtonEvent.Released, controller.left.id, () => { })
}
}
)
Expand All @@ -257,11 +273,21 @@ namespace microcode {
ControllerButtonEvent.Pressed,
controller.right.id,
() => {
if (this.guiState == GUI_STATE.ZOOMED_IN && this.oscXCoordinate < this.sensors[this.oscSensorIndex].getHeightNormalisedBufferLength() - 1) {
this.oscXCoordinate += 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)

this.update() // For fast response to the above change
if (this.guiState == GUI_STATE.ZOOMED_IN) {
let tick = true;
control.onEvent(
ControllerButtonEvent.Released,
controller.right.id,
() => tick = false
)
let isFirstTick = true
while (tick && this.oscXCoordinate < this.sensors[this.oscSensorIndex].getHeightNormalisedBufferLength() - 1) {
this.oscXCoordinate += 1
this.oscReading = this.sensors[this.oscSensorIndex].getNthHeightNormalisedReading(this.oscXCoordinate)
basic.pause(isFirstTick ? 100 : 33)
isFirstTick = false
}
control.onEvent(ControllerButtonEvent.Released, controller.right.id, () => { })
}
}
)
Expand Down

0 comments on commit b8b9aa0

Please sign in to comment.