Add get speed block
This commit is contained in:
parent
bdc8c1c62c
commit
65dd4617f1
@ -20,6 +20,8 @@
|
|||||||
"input.remoteTopRight": "Remote top-right button.",
|
"input.remoteTopRight": "Remote top-right button.",
|
||||||
"output.createBuffer": "Create a new zero-initialized buffer.",
|
"output.createBuffer": "Create a new zero-initialized buffer.",
|
||||||
"output.createBuffer|param|size": "number of bytes in the buffer",
|
"output.createBuffer|param|size": "number of bytes in the buffer",
|
||||||
|
"output.getCurrentSpeed": "Get motor speed.",
|
||||||
|
"output.getCurrentSpeed|param|out": "the output connection that the motor is connected to",
|
||||||
"output.getPattern": "Pattern block.",
|
"output.getPattern": "Pattern block.",
|
||||||
"output.getPattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
|
"output.getPattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
|
||||||
"output.setLights": "Set lights.",
|
"output.setLights": "Set lights.",
|
||||||
|
@ -16,13 +16,14 @@
|
|||||||
"input.remoteTopLeft|block": "remote top-left",
|
"input.remoteTopLeft|block": "remote top-left",
|
||||||
"input.remoteTopRight|block": "remote top-right",
|
"input.remoteTopRight|block": "remote top-right",
|
||||||
"input|block": "input",
|
"input|block": "input",
|
||||||
|
"output.getCurrentSpeed|block": "motor %out|speed",
|
||||||
"output.getPattern|block": "%pattern",
|
"output.getPattern|block": "%pattern",
|
||||||
"output.setLights|block": "set status light %pattern=led_pattern",
|
"output.setLights|block": "set status light %pattern=led_pattern",
|
||||||
"output.setPower|block": "set motor %out| power to %power",
|
"output.setPower|block": "set motor %out| power to %power",
|
||||||
"output.setSpeed|block": "set motor %out| speed to %speed",
|
"output.setSpeed|block": "set motor %out| speed to %speed",
|
||||||
"output.start|block": "turn motor %out| on",
|
"output.start|block": "turn motor %out|on",
|
||||||
"output.stop|block": "turn motor %out| off",
|
"output.stop|block": "turn motor %out|off",
|
||||||
"output.turn|block": "turn motor %out| on for %ms| milliseconds",
|
"output.turn|block": "turn motor %out| on for %ms|milliseconds",
|
||||||
"output|block": "output",
|
"output|block": "output",
|
||||||
"screen.drawText|block": "print %text| at x: %x| y: %y",
|
"screen.drawText|block": "print %text| at x: %x| y: %y",
|
||||||
"screen|block": "screen",
|
"screen|block": "screen",
|
||||||
|
@ -60,7 +60,7 @@ namespace output {
|
|||||||
* @param ms the number of milliseconds to turn the motor on, eg: 500
|
* @param ms the number of milliseconds to turn the motor on, eg: 500
|
||||||
* @param useBrake whether or not to use the brake, defaults to false
|
* @param useBrake whether or not to use the brake, defaults to false
|
||||||
*/
|
*/
|
||||||
//% blockId=output_turn block="turn motor %out| on for %ms| milliseconds"
|
//% blockId=output_turn block="turn motor %out| on for %ms|milliseconds"
|
||||||
//% weight=100 group="Motors"
|
//% weight=100 group="Motors"
|
||||||
export function turn(out: Output, ms: number, useBrake = false) {
|
export function turn(out: Output, ms: number, useBrake = false) {
|
||||||
// TODO: use current power / speed configuration
|
// TODO: use current power / speed configuration
|
||||||
@ -77,7 +77,7 @@ namespace output {
|
|||||||
* Turn motor off.
|
* Turn motor off.
|
||||||
* @param out the output connection that the motor is connected to
|
* @param out the output connection that the motor is connected to
|
||||||
*/
|
*/
|
||||||
//% blockId=output_stop block="turn motor %out| off"
|
//% blockId=output_stop block="turn motor %out|off"
|
||||||
//% weight=90 group="Motors"
|
//% weight=90 group="Motors"
|
||||||
export function stop(out: Output, useBrake = false) {
|
export function stop(out: Output, useBrake = false) {
|
||||||
let b = mkCmd(out, DAL.opOutputStop, 1)
|
let b = mkCmd(out, DAL.opOutputStop, 1)
|
||||||
@ -89,7 +89,7 @@ namespace output {
|
|||||||
* Turn motor on.
|
* Turn motor on.
|
||||||
* @param out the output connection that the motor is connected to
|
* @param out the output connection that the motor is connected to
|
||||||
*/
|
*/
|
||||||
//% blockId=output_start block="turn motor %out| on"
|
//% blockId=output_start block="turn motor %out|on"
|
||||||
//% weight=95 group="Motors"
|
//% weight=95 group="Motors"
|
||||||
export function start(out: Output) {
|
export function start(out: Output) {
|
||||||
let b = mkCmd(out, DAL.opOutputStart, 0)
|
let b = mkCmd(out, DAL.opOutputStart, 0)
|
||||||
@ -135,6 +135,16 @@ namespace output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get motor speed.
|
||||||
|
* @param out the output connection that the motor is connected to
|
||||||
|
*/
|
||||||
|
//% blockId=output_getCurrentSpeed block="motor %out|speed"
|
||||||
|
//% weight=70 group="Motors"
|
||||||
|
export function getCurrentSpeed(out: Output) {
|
||||||
|
return getMotorData(out).actualSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set motor speed.
|
* Set motor speed.
|
||||||
* @param out the output connection that the motor is connected to
|
* @param out the output connection that the motor is connected to
|
||||||
|
Loading…
Reference in New Issue
Block a user