refactored servostate (#341)
* refactored servostate * Bump pxt-core to 0.10.1
This commit is contained in:
		@@ -36,6 +36,6 @@
 | 
				
			|||||||
    "semantic-ui-less": "^2.2.4"
 | 
					    "semantic-ui-less": "^2.2.4"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "pxt-core": "0.9.5"
 | 
					    "pxt-core": "0.10.1"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,6 @@ namespace pxsim {
 | 
				
			|||||||
        radioState: RadioState;
 | 
					        radioState: RadioState;
 | 
				
			||||||
        // TODO: not singletons
 | 
					        // TODO: not singletons
 | 
				
			||||||
        neopixelState: NeoPixelState;
 | 
					        neopixelState: NeoPixelState;
 | 
				
			||||||
        servosState: MicroServosState;
 | 
					 | 
				
			||||||
        fileSystem: FileSystemState;
 | 
					        fileSystem: FileSystemState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        constructor() {
 | 
					        constructor() {
 | 
				
			||||||
@@ -53,7 +52,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);
 | 
				
			||||||
@@ -62,12 +67,7 @@ namespace pxsim {
 | 
				
			|||||||
            this.builtinParts["lightsensor"] = this.lightSensorState = new LightSensorState();
 | 
					            this.builtinParts["lightsensor"] = this.lightSensorState = new LightSensorState();
 | 
				
			||||||
            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["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();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 = value;
 | 
				
			||||||
        state.setAngle(value);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    export function servoSetPulse(pinId: number, micros: number) {
 | 
					    export function servoSetPulse(pinId: number, micros: number) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user