updated api to align with labview
This commit is contained in:
parent
54cb076002
commit
a4164470d8
@ -55,6 +55,7 @@
|
|||||||
"motors.Motor.speed|block": "%motor|speed",
|
"motors.Motor.speed|block": "%motor|speed",
|
||||||
"motors.Motor.tacho|block": "%motor|tacho",
|
"motors.Motor.tacho|block": "%motor|tacho",
|
||||||
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
|
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
|
||||||
|
"motors.MotorBase.reset|block": "%motors|reset",
|
||||||
"motors.MotorBase.setBrake|block": "set %motor|brake %brake",
|
"motors.MotorBase.setBrake|block": "set %motor|brake %brake",
|
||||||
"motors.MotorBase.setReversed|block": "set %motor|reversed %reversed",
|
"motors.MotorBase.setReversed|block": "set %motor|reversed %reversed",
|
||||||
"motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%",
|
"motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%",
|
||||||
|
@ -111,7 +111,7 @@ namespace motors {
|
|||||||
* Stops all motors
|
* Stops all motors
|
||||||
*/
|
*/
|
||||||
//% blockId=motorStopAll block="stop all motors"
|
//% blockId=motorStopAll block="stop all motors"
|
||||||
//% weight=5
|
//% weight=1
|
||||||
//% group="Move"
|
//% group="Move"
|
||||||
export function stopAllMotors() {
|
export function stopAllMotors() {
|
||||||
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
||||||
@ -198,7 +198,9 @@ namespace motors {
|
|||||||
/**
|
/**
|
||||||
* Resets the motor(s).
|
* Resets the motor(s).
|
||||||
*/
|
*/
|
||||||
//%
|
//% weight=5
|
||||||
|
//% group="Move"
|
||||||
|
//% blockId=motorReset block="%motors|reset"
|
||||||
reset() {
|
reset() {
|
||||||
this.init();
|
this.init();
|
||||||
reset(this._port);
|
reset(this._port);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"sensors.GyroSensor.angle": "Get the current angle from the gyroscope.",
|
"sensors.GyroSensor.angle": "Get the current angle from the gyroscope.",
|
||||||
"sensors.GyroSensor.calibrate": "Forces a calibration of the gyro. Must be called when the sensor is completely still.",
|
"sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
|
||||||
"sensors.GyroSensor.rotationRate": "Get the current rotation rate from the gyroscope."
|
"sensors.GyroSensor.reset": "Forces a calibration of the gyro. Must be called when the sensor is completely still."
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"sensors.GyroSensor.angle|block": "%sensor|angle",
|
"sensors.GyroSensor.angle|block": "%sensor|angle",
|
||||||
"sensors.GyroSensor.calibrate|block": "%sensor|calibrate",
|
"sensors.GyroSensor.rate|block": "%sensor|rate",
|
||||||
"sensors.GyroSensor.rotationRate|block": "%sensor|rotation rate",
|
"sensors.GyroSensor.reset|block": "%sensor|reset",
|
||||||
"sensors.gyro1|block": "gyro 1",
|
"sensors.gyro1|block": "gyro 1",
|
||||||
"sensors.gyro2|block": "gyro 2",
|
"sensors.gyro2|block": "gyro 2",
|
||||||
"sensors.gyro3|block": "gyro 3",
|
"sensors.gyro3|block": "gyro 3",
|
||||||
|
@ -45,15 +45,15 @@ namespace sensors {
|
|||||||
* Get the current rotation rate from the gyroscope.
|
* Get the current rotation rate from the gyroscope.
|
||||||
* @param sensor the gyroscope to query the request
|
* @param sensor the gyroscope to query the request
|
||||||
*/
|
*/
|
||||||
//% help=input/gyro/rotation-rate
|
//% help=input/gyro/rate
|
||||||
//% block="%sensor|rotation rate"
|
//% block="%sensor|rate"
|
||||||
//% blockId=gyroGetRate
|
//% blockId=gyroGetRate
|
||||||
//% parts="gyroscope"
|
//% parts="gyroscope"
|
||||||
//% blockNamespace=sensors
|
//% blockNamespace=sensors
|
||||||
//% sensor.fieldEditor="ports"
|
//% sensor.fieldEditor="ports"
|
||||||
//% weight=65 blockGap=8
|
//% weight=65 blockGap=8
|
||||||
//% group="Gyro Sensor"
|
//% group="Gyro Sensor"
|
||||||
rotationRate(): number {
|
rate(): number {
|
||||||
if (this.calibrating)
|
if (this.calibrating)
|
||||||
pauseUntil(() => !this.calibrating, 2000);
|
pauseUntil(() => !this.calibrating, 2000);
|
||||||
|
|
||||||
@ -65,14 +65,14 @@ namespace sensors {
|
|||||||
* Forces a calibration of the gyro. Must be called when the sensor is completely still.
|
* Forces a calibration of the gyro. Must be called when the sensor is completely still.
|
||||||
*/
|
*/
|
||||||
//% help=input/gyro/calibrate
|
//% help=input/gyro/calibrate
|
||||||
//% block="%sensor|calibrate"
|
//% block="%sensor|reset"
|
||||||
//% blockId=gyroCalibrate
|
//% blockId=gyroReset
|
||||||
//% parts="gyroscope"
|
//% parts="gyroscope"
|
||||||
//% blockNamespace=sensors
|
//% blockNamespace=sensors
|
||||||
//% sensor.fieldEditor="ports"
|
//% sensor.fieldEditor="ports"
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
//% group="Gyro Sensor"
|
//% group="Gyro Sensor"
|
||||||
calibrate(): void {
|
reset(): void {
|
||||||
if (this.calibrating) return; // already in calibration mode
|
if (this.calibrating) return; // already in calibration mode
|
||||||
|
|
||||||
this.calibrating = true;
|
this.calibrating = true;
|
||||||
@ -90,6 +90,8 @@ namespace sensors {
|
|||||||
this.setMode(GyroSensorMode.Angle);
|
this.setMode(GyroSensorMode.Angle);
|
||||||
else
|
else
|
||||||
this.setMode(GyroSensorMode.Rate);
|
this.setMode(GyroSensorMode.Rate);
|
||||||
|
// give it more time to settle
|
||||||
|
loops.pause(500);
|
||||||
this.calibrating = false;
|
this.calibrating = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user