fixing dal board

This commit is contained in:
Peli de Halleux 2017-01-12 23:05:29 -08:00
parent 167ba57d2b
commit 975b995f09
2 changed files with 9 additions and 10 deletions

View File

@ -16,7 +16,6 @@ namespace pxsim {
neopixelState: NeoPixelState; neopixelState: NeoPixelState;
rgbLedState: number; rgbLedState: number;
speakerState: SpeakerState; speakerState: SpeakerState;
servosState: MicroServosState;
fileSystem: FileSystemState; fileSystem: FileSystemState;
constructor() { constructor() {
@ -55,7 +54,13 @@ namespace pxsim {
0, 0,
DAL.MICROBIT_ID_IO_P19, DAL.MICROBIT_ID_IO_P19,
DAL.MICROBIT_ID_IO_P20 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["radio"] = this.radioState = new RadioState(runtime);
this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime); this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime);
@ -65,12 +70,7 @@ namespace pxsim {
this.builtinParts["compass"] = this.compassState = new CompassState(); this.builtinParts["compass"] = this.compassState = new CompassState();
this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState(); this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState();
this.builtinParts["speaker"] = this.speakerState = new SpeakerState(); this.builtinParts["speaker"] = this.speakerState = new SpeakerState();
this.builtinParts["microservo"] = this.servosState = new MicroServosState({ this.builtinParts["microservo"] = this.edgeConnectorState;
"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.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView(); this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView();
this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView(); this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView();

View File

@ -76,8 +76,7 @@ namespace pxsim.pins {
if (!pin) return; if (!pin) return;
analogSetPeriod(pinId, 20000); analogSetPeriod(pinId, 20000);
const state = board().servosState.servoState(pinId); pin.servoAngle = Math.max(0, Math.min(180, value));
state.setAngle(value);
} }
export function servoSetPulse(pinId: number, micros: number) { export function servoSetPulse(pinId: number, micros: number) {