Add get speed block

This commit is contained in:
Sam El-Husseini 2017-08-08 13:02:11 -07:00
parent bdc8c1c62c
commit 65dd4617f1
3 changed files with 19 additions and 6 deletions

View File

@ -20,6 +20,8 @@
"input.remoteTopRight": "Remote top-right button.",
"output.createBuffer": "Create a new zero-initialized 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|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
"output.setLights": "Set lights.",

View File

@ -16,6 +16,7 @@
"input.remoteTopLeft|block": "remote top-left",
"input.remoteTopRight|block": "remote top-right",
"input|block": "input",
"output.getCurrentSpeed|block": "motor %out|speed",
"output.getPattern|block": "%pattern",
"output.setLights|block": "set status light %pattern=led_pattern",
"output.setPower|block": "set motor %out| power to %power",

View File

@ -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.
* @param out the output connection that the motor is connected to