diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index d9f29f2c..1536585a 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -52,9 +52,10 @@ "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|value": "Component specific code indicating the cause of the event.", - "motors.Motor.angle": "Gets motor ration angle.", - "motors.Motor.clearCount": "Clears the motor count", + "motors.Motor.angle": "Gets motor angle.", + "motors.Motor.clearCounts": "Clears the motor count", "motors.Motor.speed": "Gets motor actual speed.", + "motors.Motor.tacho": "Gets motor tachometer count.", "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.move": "Moves the motor by a number of rotations, degress or seconds", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 69588aab..84c9a753 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -47,7 +47,9 @@ "control.raiseEvent|block": "raise event|from %src|with value %value", "control|block": "control", "motors.Motor.angle|block": "%motor|angle", + "motors.Motor.clearCounts|block": "%motor|clear counts", "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.pauseUntilReady|block": "%motor|pause until ready", "motors.MotorBase.setBrake|block": "set %motor|brake %brake", diff --git a/libs/core/output.ts b/libs/core/output.ts index 700e9a73..a2287e14 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -109,7 +109,7 @@ namespace motors { * Stops all motors */ //% blockId=motorStopAll block="stop all motors" - //% weight=97 + //% weight=5 //% group="Motion" export function stopAllMotors() { 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. */ - //% + //% group="Sensors" isReady(): boolean { this.init(); const buf = mkCmd(this._port, DAL.opOutputTest, 2); @@ -278,6 +278,7 @@ namespace motors { * @param timeOut optional maximum pausing time in milliseconds */ //% blockId=motorPauseUntilRead block="%motor|pause until ready" + //% weight=97 //% group="Motion" pauseUntilReady(timeOut?: number) { pauseUntil(() => this.isReady(), timeOut); @@ -330,7 +331,8 @@ namespace motors { * @param motor the port which connects to the motor */ //% blockId=motorSpeed block="%motor|speed" - //% weight=72 blockGap=8 + //% weight=72 + //% blockGap=8 //% group="Sensors" speed(): number { this.init(); @@ -338,7 +340,7 @@ namespace motors { } /** - * Gets motor ration angle. + * Gets motor angle. * @param motor the port which connects to the motor */ //% blockId=motorTachoCount block="%motor|angle" @@ -349,11 +351,28 @@ namespace motors { 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 */ - //% group="Motion" - clearCount() { + //% blockId=motorClearCount block="%motor|clear counts" + //% weight=68 + //% blockGap=8 + //% group="Sensors" + clearCounts() { this.init(); const b = mkCmd(this._port, DAL.opOutputClearCount, 0) writePWM(b)