diff --git a/libs/base/shims.d.ts b/libs/base/shims.d.ts index e4a034a5..bf4a9a0f 100644 --- a/libs/base/shims.d.ts +++ b/libs/base/shims.d.ts @@ -70,7 +70,7 @@ declare namespace loops { * Repeats the code forever in the background. On each iteration, allows other codes to run. * @param body code to execute */ - //% help=loops/forever weight=100 blockGap=8 + //% help=loops/forever weight=100 //% blockId=forever block="forever" blockAllowMultiple=1 shim=loops::forever function forever(a: () => void): void; diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 4d8332d9..b3a7ac35 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -37,6 +37,9 @@ "output.start|param|out": "the output connection that the motor is connected to", "output.stop": "Turn motor off.", "output.stop|param|out": "the output connection that the motor is connected to", + "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 fbb8c331..dc64ae9c 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -33,6 +33,7 @@ "output.setSpeed|block": "set motor %out| speed to %speed", "output.start|block": "turn motor %out|on", "output.stop|block": "turn motor %out|off", + "output.switchMotor|block": "turn motor %out|%on", "output.turn|block": "turn motor %out| on for %ms|milliseconds", "output|block": "output", "screen.drawText|block": "print %text| at x: %x| y: %y", diff --git a/libs/core/output.ts b/libs/core/output.ts index 8aa1f231..10b31af7 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -81,12 +81,30 @@ namespace output { }) } + + /** + * Switch the motor on or off. + * @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" + //% weight=90 group="Motors" + //% on.fieldEditor="toggle" + export function switchMotor(out: Output, on: number, useBrake = false) { + if (on == 0) { + output.stop(out, useBrake); + } else { + output.start(out); + } + } + /** * Turn motor off. * @param out the output connection that the motor is connected to */ //% blockId=output_stop block="turn motor %out|off" //% weight=90 group="Motors" + //% deprecated=1 export function stop(out: Output, useBrake = false) { let b = mkCmd(out, DAL.opOutputStop, 1) b.setNumber(NumberFormat.UInt8LE, 2, useBrake ? 1 : 0) @@ -99,6 +117,7 @@ namespace output { */ //% blockId=output_start block="turn motor %out|on" //% weight=95 group="Motors" + //% deprecated=1 export function start(out: Output) { if (currentSpeed[out] == -1) setSpeed(out, 50) let b = mkCmd(out, DAL.opOutputStart, 0) diff --git a/theme/site/globals/site.variables b/theme/site/globals/site.variables index 8661c5ab..a8609a69 100644 --- a/theme/site/globals/site.variables +++ b/theme/site/globals/site.variables @@ -119,7 +119,7 @@ @editorToolsBackground: #fcfbfa; @blocklySvgColor: #ecf6ff; -@homeScreenBackground: #f4f7f9; +@homeScreenBackground: #EAEEEF; /*------------------- Full screen