moving blocks around

This commit is contained in:
Peli de Halleux 2018-01-04 08:25:02 -08:00
parent be398d84ee
commit b7cdc7d0fe
3 changed files with 30 additions and 8 deletions

View File

@ -52,9 +52,10 @@
"control.raiseEvent": "Announce that an event happened to registered handlers.", "control.raiseEvent": "Announce that an event happened to registered handlers.",
"control.raiseEvent|param|src": "ID of the Component that generated the event", "control.raiseEvent|param|src": "ID of the Component that generated the event",
"control.raiseEvent|param|value": "Component specific code indicating the cause of the event.", "control.raiseEvent|param|value": "Component specific code indicating the cause of the event.",
"motors.Motor.angle": "Gets motor ration angle.", "motors.Motor.angle": "Gets motor angle.",
"motors.Motor.clearCount": "Clears the motor count", "motors.Motor.clearCounts": "Clears the motor count",
"motors.Motor.speed": "Gets motor actual speed.", "motors.Motor.speed": "Gets motor actual speed.",
"motors.Motor.tacho": "Gets motor tachometer count.",
"motors.Motor.toString": "Returns the status of the motor", "motors.Motor.toString": "Returns the status of the motor",
"motors.MotorBase.isReady": "Returns a value indicating if the motor is still running a previous command.", "motors.MotorBase.isReady": "Returns a value indicating if the motor is still running a previous command.",
"motors.MotorBase.move": "Moves the motor by a number of rotations, degress or seconds", "motors.MotorBase.move": "Moves the motor by a number of rotations, degress or seconds",

View File

@ -47,7 +47,9 @@
"control.raiseEvent|block": "raise event|from %src|with value %value", "control.raiseEvent|block": "raise event|from %src|with value %value",
"control|block": "control", "control|block": "control",
"motors.Motor.angle|block": "%motor|angle", "motors.Motor.angle|block": "%motor|angle",
"motors.Motor.clearCounts|block": "%motor|clear counts",
"motors.Motor.speed|block": "%motor|speed", "motors.Motor.speed|block": "%motor|speed",
"motors.Motor.tacho|block": "%motor|tacho",
"motors.MotorBase.move|block": "move %motor|for %value|%unit|at %speed|%", "motors.MotorBase.move|block": "move %motor|for %value|%unit|at %speed|%",
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready", "motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
"motors.MotorBase.setBrake|block": "set %motor|brake %brake", "motors.MotorBase.setBrake|block": "set %motor|brake %brake",

View File

@ -109,7 +109,7 @@ namespace motors {
* Stops all motors * Stops all motors
*/ */
//% blockId=motorStopAll block="stop all motors" //% blockId=motorStopAll block="stop all motors"
//% weight=97 //% weight=5
//% group="Motion" //% group="Motion"
export function stopAllMotors() { export function stopAllMotors() {
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0) const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
@ -258,7 +258,7 @@ namespace motors {
/** /**
* Returns a value indicating if the motor is still running a previous command. * Returns a value indicating if the motor is still running a previous command.
*/ */
//% //% group="Sensors"
isReady(): boolean { isReady(): boolean {
this.init(); this.init();
const buf = mkCmd(this._port, DAL.opOutputTest, 2); const buf = mkCmd(this._port, DAL.opOutputTest, 2);
@ -278,6 +278,7 @@ namespace motors {
* @param timeOut optional maximum pausing time in milliseconds * @param timeOut optional maximum pausing time in milliseconds
*/ */
//% blockId=motorPauseUntilRead block="%motor|pause until ready" //% blockId=motorPauseUntilRead block="%motor|pause until ready"
//% weight=97
//% group="Motion" //% group="Motion"
pauseUntilReady(timeOut?: number) { pauseUntilReady(timeOut?: number) {
pauseUntil(() => this.isReady(), timeOut); pauseUntil(() => this.isReady(), timeOut);
@ -330,7 +331,8 @@ namespace motors {
* @param motor the port which connects to the motor * @param motor the port which connects to the motor
*/ */
//% blockId=motorSpeed block="%motor|speed" //% blockId=motorSpeed block="%motor|speed"
//% weight=72 blockGap=8 //% weight=72
//% blockGap=8
//% group="Sensors" //% group="Sensors"
speed(): number { speed(): number {
this.init(); this.init();
@ -338,7 +340,7 @@ namespace motors {
} }
/** /**
* Gets motor ration angle. * Gets motor angle.
* @param motor the port which connects to the motor * @param motor the port which connects to the motor
*/ */
//% blockId=motorTachoCount block="%motor|angle" //% blockId=motorTachoCount block="%motor|angle"
@ -349,11 +351,28 @@ namespace motors {
return getMotorData(this._port).count; return getMotorData(this._port).count;
} }
/**
* Gets motor tachometer count.
* @param motor the port which connects to the motor
*/
//% blockId=motorTachoCount block="%motor|tacho"
//% weight=69
//% blockGap=8
//% group="Sensors"
tacho(): number {
this.init();
return getMotorData(this._port).tachoCount;
}
/** /**
* Clears the motor count * Clears the motor count
*/ */
//% group="Motion" //% blockId=motorClearCount block="%motor|clear counts"
clearCount() { //% weight=68
//% blockGap=8
//% group="Sensors"
clearCounts() {
this.init(); this.init();
const b = mkCmd(this._port, DAL.opOutputClearCount, 0) const b = mkCmd(this._port, DAL.opOutputClearCount, 0)
writePWM(b) writePWM(b)