diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 2f47f98d..fbb8c331 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -3,6 +3,16 @@ "ButtonEvent.Down|block": "down", "ButtonEvent.LongClick|block": "long click", "ButtonEvent.Up|block": "up", + "LightsPattern.GreenFlash|block": "Flashing Green", + "LightsPattern.GreenPulse|block": "Pulsing Green", + "LightsPattern.Green|block": "Green", + "LightsPattern.Off|block": "Off", + "LightsPattern.OrangeFlash|block": "Flashing Orange", + "LightsPattern.OrangePulse|block": "Pulsing Orange", + "LightsPattern.Orange|block": "Orange", + "LightsPattern.RedFlash|block": "Flashing Red", + "LightsPattern.RedPulse|block": "Pulsing Red", + "LightsPattern.Red|block": "Red", "control.raiseEvent|block": "raise event|from %src|with value %value", "control|block": "control", "input.buttonDown|block": "button down", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index f125bf0f..cb09159c 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -3,15 +3,35 @@ * Patterns for lights under the buttons. */ const enum LightsPattern { + //% block=Off enumval=0 + //% blockIdentity=output.getPattern Off = 0, + //% block=Green enumval=1 + //% blockIdentity=output.getPattern Green = 1, + //% block=Red enumval=2 + //% blockIdentity=output.getPattern Red = 2, + //% block=Orange enumval=3 + //% blockIdentity=output.getPattern Orange = 3, + //% block="Flashing Green" enumval=4 + //% blockIdentity=output.getPattern GreenFlash = 4, + //% block="Flashing Red" enumval=5 + //% blockIdentity=output.getPattern RedFlash = 5, + //% block="Flashing Orange" enumval=6 + //% blockIdentity=output.getPattern OrangeFlash = 6, + //% block="Pulsing Green" enumval=7 + //% blockIdentity=output.getPattern GreenPulse = 7, + //% block="Pulsing Red" enumval=8 + //% blockIdentity=output.getPattern RedPulse = 8, + //% block="Pulsing Orange" enumval=9 + //% blockIdentity=output.getPattern OrangePulse = 9, } @@ -238,7 +258,7 @@ namespace output { */ //% blockId=led_pattern block="%pattern" //% shim=TD_ID colorSecondary="#6e9a36" - //% blockHidden=true + //% blockHidden=true useEnumVal=1 pattern.fieldOptions.decompileLiterals=1 export function getPattern(pattern: LightsPattern): number { return pattern; } diff --git a/libs/core/output.ts b/libs/core/output.ts index ec168af1..8aa1f231 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -15,6 +15,7 @@ enum OutputType { namespace output { let pwmMM: MMap let motorMM: MMap + let currentSpeed: number[] = [] const enum MotorDataOff { TachoCounts = 0, // int32 @@ -32,6 +33,12 @@ namespace output { stop(Output.ALL) + currentSpeed[Output.A] = -1; + currentSpeed[Output.B] = -1; + currentSpeed[Output.C] = -1; + currentSpeed[Output.D] = -1; + currentSpeed[Output.ALL] = -1; + let buf = output.createBuffer(1) buf[0] = DAL.opProgramStart writePWM(buf) @@ -65,10 +72,11 @@ namespace output { export function turn(out: Output, ms: number, useBrake = false) { // TODO: use current power / speed configuration output.step(out, { - power: 100, + speed: 100, step1: 0, step2: ms, step3: 0, + useSteps: false, useBrake: useBrake }) } @@ -92,6 +100,7 @@ namespace output { //% blockId=output_start block="turn motor %out|on" //% weight=95 group="Motors" export function start(out: Output) { + if (currentSpeed[out] == -1) setSpeed(out, 50) let b = mkCmd(out, DAL.opOutputStart, 0) writePWM(b) } @@ -154,6 +163,7 @@ namespace output { //% weight=81 group="Motors" //% speed.min=-100 speed.max=100 export function setSpeed(out: Output, speed: number) { + currentSpeed[out] = speed; let b = mkCmd(out, DAL.opOutputSpeed, 1) b.setNumber(NumberFormat.Int8LE, 2, Math.clamp(-100, 100, speed)) writePWM(b) diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 7549596c..f32fb730 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -94,6 +94,7 @@ namespace screen { */ //% blockId=screen_drawText block="print %text| at x: %x| y: %y" //% weight=99 group="Screen" blockNamespace=output inlineInputMode="inline" + //% x.min=0 x.max=178 y.min=0 y.max=128 export function drawText(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 y |= 0 diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index a2adb82d..46848df3 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -1,11 +1,11 @@ //% color="#D42878" -//% groups="['Brick buttons']" +//% groups='["Brick buttons"]' namespace input { } //% color="#8AC044" weight=90 icon="\uf185" -//% groups="['Lights', 'Screen', Motors']" +//% groups='["Lights", "Screen", "Motors"]' namespace output { }