diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 52bc9c40..91ef5c7f 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -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", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index a46e3c0f..34e323a9 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -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", diff --git a/libs/core/output.ts b/libs/core/output.ts index 10b31af7..d84de427 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -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); } }