From 975b995f09c2f87a1438750b65e08d79c2df3d8f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 12 Jan 2017 23:05:29 -0800 Subject: [PATCH] fixing dal board --- sim/dalboard.ts | 16 ++++++++-------- sim/state/edgeconnector.ts | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index be877da2..c0c7a154 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -16,7 +16,6 @@ namespace pxsim { neopixelState: NeoPixelState; rgbLedState: number; speakerState: SpeakerState; - servosState: MicroServosState; fileSystem: FileSystemState; constructor() { @@ -55,7 +54,13 @@ namespace pxsim { 0, DAL.MICROBIT_ID_IO_P19, DAL.MICROBIT_ID_IO_P20 - ] + ], + servos: { + "P0": DAL.MICROBIT_ID_IO_P0, + "P1": DAL.MICROBIT_ID_IO_P1, + "P2": DAL.MICROBIT_ID_IO_P2, + "P3": DAL.MICROBIT_ID_IO_P3 + } }); this.builtinParts["radio"] = this.radioState = new RadioState(runtime); this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime); @@ -65,12 +70,7 @@ namespace pxsim { this.builtinParts["compass"] = this.compassState = new CompassState(); this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState(); this.builtinParts["speaker"] = this.speakerState = new SpeakerState(); - this.builtinParts["microservo"] = this.servosState = new MicroServosState({ - "P0": DAL.MICROBIT_ID_IO_P0, - "P1": DAL.MICROBIT_ID_IO_P1, - "P2": DAL.MICROBIT_ID_IO_P2, - "P3": DAL.MICROBIT_ID_IO_P3 - }); + this.builtinParts["microservo"] = this.edgeConnectorState; this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView(); this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView(); diff --git a/sim/state/edgeconnector.ts b/sim/state/edgeconnector.ts index 06577223..46d1f72f 100644 --- a/sim/state/edgeconnector.ts +++ b/sim/state/edgeconnector.ts @@ -76,8 +76,7 @@ namespace pxsim.pins { if (!pin) return; analogSetPeriod(pinId, 20000); - const state = board().servosState.servoState(pinId); - state.setAngle(value); + pin.servoAngle = Math.max(0, Math.min(180, value)); } export function servoSetPulse(pinId: number, micros: number) {