on/off field editors on motors

This commit is contained in:
Peli de Halleux 2017-10-24 15:03:21 -07:00
parent 1330a0fb82
commit 334d5aca9a
3 changed files with 12 additions and 12 deletions

View File

@ -47,6 +47,9 @@
"output.getCurrentSpeed|param|out": "the output connection that the motor is connected to",
"output.pattern": "Pattern block.",
"output.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
"output.powerMotor": "Switch the motor on or off.",
"output.powerMotor|param|on": "1 to turn the motor on, 0 to turn it off",
"output.powerMotor|param|out": "the output connection that the motor is connected to",
"output.setPower": "Set motor power.",
"output.setPower|param|out": "the output connection that the motor is connected to",
"output.setPower|param|power": "the desired power to use. eg: 100",
@ -55,9 +58,6 @@
"output.setSpeed|param|speed": "the desired speed to use. eg: 100",
"output.setStatusLight": "Set lights.",
"output.setStatusLight|param|pattern": "the lights pattern to use.",
"output.switchMotor": "Switch the motor on or off.",
"output.switchMotor|param|on": "1 to turn the motor on, 0 to turn it off",
"output.switchMotor|param|out": "the output connection that the motor is connected to",
"output.turn": "Turn a motor on for a specified number of milliseconds.",
"output.turn|param|ms": "the number of milliseconds to turn the motor on, eg: 500",
"output.turn|param|out": "the output connection that the motor is connected to",

View File

@ -46,11 +46,11 @@
"input|block": "input",
"output.getCurrentSpeed|block": "motor %out|speed",
"output.pattern|block": "%pattern",
"output.powerMotor|block": "power motor %out|%on",
"output.setPower|block": "set motor %out| power to %power",
"output.setSpeed|block": "set motor %out| speed to %speed",
"output.setStatusLight|block": "set status light %pattern=led_pattern",
"output.switchMotor|block": "turn motor %out|%on",
"output.turn|block": "turn motor %out| on for %ms|milliseconds",
"output.turn|block": "turn motor %out| on for %ms=timePicker|milliseconds",
"output|block": "output",
"screen.print|block": "print %text| at x: %x| y: %y",
"screen|block": "screen",

View File

@ -67,7 +67,7 @@ namespace output {
* @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
*/
//% blockId=output_turn block="turn motor %out| on for %ms|milliseconds"
//% blockId=output_turn block="turn motor %out| on for %ms=timePicker|milliseconds"
//% weight=100 group="Motors"
export function turn(out: Output, ms: number, useBrake = false) {
// TODO: use current power / speed configuration
@ -87,14 +87,14 @@ namespace output {
* @param out the output connection that the motor is connected to
* @param on 1 to turn the motor on, 0 to turn it off
*/
//% blockId=output_switch block="turn motor %out|%on"
//% blockId=outputMotorPowerOnOff block="power motor %out|%on"
//% weight=90 group="Motors"
//% on.fieldEditor="toggle"
export function switchMotor(out: Output, on: number, useBrake = false) {
if (on == 0) {
output.stop(out, useBrake);
} else {
//% on.fieldEditor="toggleonoff"
export function powerMotor(out: Output, on: boolean, useBrake = false) {
if (on) {
output.start(out);
} else {
output.stop(out, useBrake);
}
}