From 5e7af872b5e5a705b16e3e042e0dc72d019b14d0 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Mon, 7 Aug 2017 10:19:38 -0700 Subject: [PATCH] Add setLights shadow block --- libs/core/_locales/core-jsdoc-strings.json | 1 + libs/core/_locales/core-strings.json | 3 ++- libs/core/buttons.ts | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 05790ac2..a9ba7ca1 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -20,6 +20,7 @@ "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.getPattern": "Pattern block.", "output.setLights": "Set lights.", "screen.clear": "Clear screen and reset font to normal.", "screen.doubleIcon": "Double size of an icon.", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 5744a682..05383711 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -16,7 +16,8 @@ "input.remoteTopLeft|block": "remote top-left", "input.remoteTopRight|block": "remote top-right", "input|block": "input", - "output.setLights|block": "set lights %pattern", + "output.getPattern|block": "%pattern", + "output.setLights|block": "set lights %pattern=led_pattern", "output|block": "output", "screen|block": "screen", "serial|block": "serial", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 7811bad5..beecdc88 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -216,8 +216,8 @@ namespace output { /** * Set lights. */ - //% blockId=setLights block="set lights %pattern" - export function setLights(pattern: LightsPattern): void { + //% blockId=setLights block="set lights %pattern=led_pattern" + export function setLights(pattern: number): void { if (currPattern === pattern) return currPattern = pattern @@ -225,4 +225,15 @@ namespace output { cmd[0] = pattern + 48 input.internal.getBtnsMM().write(cmd) } + + + /** + * Pattern block. + */ + //% blockId=led_pattern block="%pattern" + //% shim=TD_ID colorSecondary="#6e9a36" + //% blockHidden=true + export function getPattern(pattern: LightsPattern): number { + return pattern; + } }