From 18fefa2a440917f466d944b021c888abf1d4205c Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 27 Oct 2017 11:01:11 -0700 Subject: [PATCH 1/7] output -> motors --- libs/core/_locales/core-jsdoc-strings.json | 32 +++++++++--------- libs/core/_locales/core-strings.json | 39 ++++++++++++---------- libs/core/buttons.ts | 2 +- libs/core/output.ts | 4 +-- libs/core/screen.ts | 4 +-- libs/core/test.ts | 4 +-- libs/ev3/ns.ts | 2 +- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index c7c1731e..1a8a6dde 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -56,24 +56,24 @@ "input.remoteButtonCenter": "Remote beacon (center) button.", "input.remoteButtonTopLeft": "Remote top-left button.", "input.remoteButtonTopRight": "Remote top-right button.", - "output.Motor.clearCount": "Clears the motor count", - "output.Motor.count": "Gets motor step count.", - "output.Motor.on": "Power on or off the motor.", - "output.Motor.reset": "Resets the motor.", - "output.Motor.setBrake": "Sets the automatic brake on or off when the motor is off", - "output.Motor.setBrake|param|brake": "a value indicating if the motor should break when off", - "output.Motor.setPower": "Sets the motor power level from ``-100`` to ``100``.", - "output.Motor.setPower|param|power": "the desired speed to use. eg: 50", - "output.Motor.setReversed": "Reverses the motor polarity", - "output.Motor.speed": "Gets motor actual speed.", - "output.Motor.tachoCount": "Gets motor tacho count.", + "motors.Motor.clearCount": "Clears the motor count", + "motors.Motor.count": "Gets motor step count.", + "motors.Motor.on": "Power on or off the motor.", + "motors.Motor.reset": "Resets the motor.", + "motors.Motor.setBrake": "Sets the automatic brake on or off when the motor is off", + "motors.Motor.setBrake|param|brake": "a value indicating if the motor should break when off", + "motors.Motor.setPower": "Sets the motor power level from ``-100`` to ``100``.", + "motors.Motor.setPower|param|power": "the desired speed to use. eg: 50", + "motors.Motor.setReversed": "Reverses the motor polarity", + "motors.Motor.speed": "Gets motor actual speed.", + "motors.Motor.tachoCount": "Gets motor tacho count.", + "motors.pattern": "Pattern block.", + "motors.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green", + "motors.setStatusLight": "Set lights.", + "motors.setStatusLight|param|pattern": "the lights pattern to use.", + "motors.stopAllMotors": "Stops all motors", "output.createBuffer": "Create a new zero-initialized buffer.", "output.createBuffer|param|size": "number of bytes in the buffer", - "output.pattern": "Pattern block.", - "output.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green", - "output.setStatusLight": "Set lights.", - "output.setStatusLight|param|pattern": "the lights pattern to use.", - "output.stopAllMotors": "Stops all motors", "screen.clear": "Clear screen and reset font to normal.", "screen.doubleIcon": "Double size of an icon.", "screen.drawIcon": "Draw an icon on the screen.", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index b706cfb0..b2c3b3c1 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -82,32 +82,35 @@ "input.ultrasonic3|block": "ultrasonic sensor 3", "input.ultrasonic4|block": "ultrasonic sensor 4", "input|block": "input", - "output.Motor.count|block": "%motor|count", - "output.Motor.on|block": "%motor|%onOrOff", - "output.Motor.setBrake|block": "%motor|set brake %brake", - "output.Motor.setPower|block": "%motor|set power to %speed", - "output.Motor.setReversed|block": "%motor|set reversed %reversed", - "output.Motor.speed|block": "%motor|speed", - "output.Motor.tachoCount|block": "%motor|tacho count", - "output.largeMotorA|block": "large motor A", - "output.largeMotorB|block": "large motor B", - "output.largeMotorC|block": "large motor C", - "output.largeMotorD|block": "large motor D", - "output.mediumMotorA|block": "medium motor A", - "output.mediumMotorB|block": "medium motor B", - "output.mediumMotorC|block": "medium motor C", - "output.mediumMotorD|block": "medium motor D", - "output.pattern|block": "%pattern", - "output.setStatusLight|block": "set status light %pattern=led_pattern", - "output.stopAllMotors|block": "stop all motors", + "motors.Motor.count|block": "%motor|count", + "motors.Motor.on|block": "%motor|%onOrOff", + "motors.Motor.setBrake|block": "%motor|set brake %brake", + "motors.Motor.setPower|block": "%motor|set power to %speed", + "motors.Motor.setReversed|block": "%motor|set reversed %reversed", + "motors.Motor.speed|block": "%motor|speed", + "motors.Motor.tachoCount|block": "%motor|tacho count", + "motors.largeMotorA|block": "large motor A", + "motors.largeMotorB|block": "large motor B", + "motors.largeMotorC|block": "large motor C", + "motors.largeMotorD|block": "large motor D", + "motors.mediumMotorA|block": "medium motor A", + "motors.mediumMotorB|block": "medium motor B", + "motors.mediumMotorC|block": "medium motor C", + "motors.mediumMotorD|block": "medium motor D", + "motors.pattern|block": "%pattern", + "motors.setStatusLight|block": "set status light %pattern=led_pattern", + "motors.stopAllMotors|block": "stop all motors", + "motors|block": "motors", "output|block": "output", "screen.print|block": "print %text| at x: %x| y: %y", "screen.setPixel|block": "set pixel %on| at x: %x| y: %y", "screen|block": "screen", "serial|block": "serial", + "{id:category}Brick": "Brick", "{id:category}Control": "Control", "{id:category}Input": "Input", "{id:category}MMap": "MMap", + "{id:category}Motors": "Motors", "{id:category}Output": "Output", "{id:category}Screen": "Screen", "{id:category}Serial": "Serial", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 75fe9477..c7a6eb67 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -226,7 +226,7 @@ namespace control { } } -namespace output { +namespace motors { let currPattern: LightsPattern /** diff --git a/libs/core/output.ts b/libs/core/output.ts index 44ff689d..3454768c 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -17,7 +17,7 @@ enum OutputType { MiniTacho = 8, } -namespace output { +namespace motors { let pwmMM: MMap let motorMM: MMap @@ -53,7 +53,7 @@ namespace output { } function mkCmd(out: Output, cmd: number, addSize: number) { - const b = createBuffer(2 + addSize) + const b = output.createBuffer(2 + addSize) b.setNumber(NumberFormat.UInt8LE, 0, cmd) b.setNumber(NumberFormat.UInt8LE, 1, out) return b diff --git a/libs/core/screen.ts b/libs/core/screen.ts index bf85567f..7acc36fa 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -85,7 +85,7 @@ namespace screen { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y" - //% weight=98 group="Brick" blockNamespace=output + //% weight=98 group="Brick" blockNamespace=brick //% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff export function setPixel(on: boolean, x: number, y: number) { x |= 0 @@ -101,7 +101,7 @@ namespace screen { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_print block="print %text| at x: %x| y: %y" - //% weight=99 group="Brick" blockNamespace=output inlineInputMode="inline" + //% weight=99 group="Brick" blockNamespace=brick inlineInputMode="inline" //% x.min=0 x.max=178 y.min=0 y.max=128 export function print(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 diff --git a/libs/core/test.ts b/libs/core/test.ts index 6be67450..6f957b3a 100644 --- a/libs/core/test.ts +++ b/libs/core/test.ts @@ -2,7 +2,7 @@ screen.clear() screen.print("PXT!", 10, 30, Draw.Quad) screen.drawRect(40, 40, 20, 10, Draw.Fill) -output.setStatusLight(LightsPattern.Orange) +motors.setStatusLight(LightsPattern.Orange) screen.drawIcon(100, 50, screen.doubleIcon(screen.heart), Draw.Double | Draw.Transparent) @@ -12,7 +12,7 @@ input.buttonEnter.onEvent(ButtonEvent.Click, () => { input.buttonLeft.onEvent(ButtonEvent.Click, () => { screen.drawRect(10, 70, 20, 10, Draw.Fill) - output.setStatusLight(LightsPattern.Red) + motors.setStatusLight(LightsPattern.Red) screen.setFont(screen.microbitFont()) }) diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index a1065794..11552433 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -5,7 +5,7 @@ namespace input { //% color="#8AC044" weight=90 icon="\uf185" //% groups='["Motors", "Brick"]' -namespace output { +namespace motors { } //% color="#DF5014" weight=80 From dfe2fe3cff0ebdc3b04437c7dffdf33388cf7891 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 27 Oct 2017 11:05:04 -0700 Subject: [PATCH 2/7] brick refactoring --- libs/core/_locales/core-jsdoc-strings.json | 16 ++++++++-------- libs/core/_locales/core-strings.json | 5 +++-- libs/core/screen.ts | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 1a8a6dde..a2abf878 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -10,6 +10,14 @@ "MMap.slice": "Read a range of bytes into a buffer.", "MMap.write": "Perform write(2) on the underlaying file", "TouchSensorEvent": "Touch sensor interactions", + "brick.print": "Show text on the screen.", + "brick.print|param|text": "the text to print on the screen, eg: \"Hello world\"", + "brick.print|param|x": "the starting position's x coordinate, eg: 0", + "brick.print|param|y": "the starting position's x coordinate, eg: 0", + "brick.setPixel": "Sets a pixel on or off", + "brick.setPixel|param|on": "a value indicating if the pixel should be on or off", + "brick.setPixel|param|x": "the starting position's x coordinate, eg: 0", + "brick.setPixel|param|y": "the starting position's x coordinate, eg: 0", "control": "Program controls and events.", "control.allocateNotifyEvent": "Allocates the next user notification event", "control.deviceFirmwareVersion": "Determine the version of system software currently running.", @@ -77,14 +85,6 @@ "screen.clear": "Clear screen and reset font to normal.", "screen.doubleIcon": "Double size of an icon.", "screen.drawIcon": "Draw an icon on the screen.", - "screen.print": "Show text on the screen.", - "screen.print|param|text": "the text to print on the screen, eg: \"Hello world\"", - "screen.print|param|x": "the starting position's x coordinate, eg: 0", - "screen.print|param|y": "the starting position's x coordinate, eg: 0", - "screen.setPixel": "Sets a pixel on or off", - "screen.setPixel|param|on": "a value indicating if the pixel should be on or off", - "screen.setPixel|param|x": "the starting position's x coordinate, eg: 0", - "screen.setPixel|param|y": "the starting position's x coordinate, eg: 0", "serial": "Reading and writing data over a serial connection.", "serial.writeDmesg": "Send DMESG debug buffer over serial." } \ No newline at end of file diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index b2c3b3c1..253544e1 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -30,6 +30,9 @@ "TouchSensorEvent.Bumped|block": "bumped", "TouchSensorEvent.Pressed|block": "pressed", "TouchSensorEvent.Released|block": "released", + "brick.print|block": "print %text| at x: %x| y: %y", + "brick.setPixel|block": "set pixel %on| at x: %x| y: %y", + "brick|block": "brick", "control.raiseEvent|block": "raise event|from %src|with value %value", "control|block": "control", "input.Button.isPressed|block": "%button|is pressed", @@ -102,8 +105,6 @@ "motors.stopAllMotors|block": "stop all motors", "motors|block": "motors", "output|block": "output", - "screen.print|block": "print %text| at x: %x| y: %y", - "screen.setPixel|block": "set pixel %on| at x: %x| y: %y", "screen|block": "screen", "serial|block": "serial", "{id:category}Brick": "Brick", diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 7acc36fa..a3a925d8 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -1,4 +1,4 @@ -namespace screen { +namespace brick { //% shim=screen::_setPixel function _setPixel(p0: uint32, p1: uint32, mode: Draw): void { } @@ -85,7 +85,7 @@ namespace screen { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y" - //% weight=98 group="Brick" blockNamespace=brick + //% weight=98 group="Brick" //% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff export function setPixel(on: boolean, x: number, y: number) { x |= 0 @@ -101,7 +101,7 @@ namespace screen { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_print block="print %text| at x: %x| y: %y" - //% weight=99 group="Brick" blockNamespace=brick inlineInputMode="inline" + //% weight=99 group="Brick" inlineInputMode="inline" //% x.min=0 x.max=178 y.min=0 y.max=128 export function print(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 @@ -127,7 +127,7 @@ namespace screen { iconBuf.fill(0, 2) else iconBuf.write(2, currFont.data.slice(idx, charSize)) - drawIcon(x, y, iconBuf, mode) + screen.drawIcon(x, y, iconBuf, mode) x += double * currFont.charWidth } } From 84b98a27888667e9f9a7bff94d5acb8ec76b962b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sat, 28 Oct 2017 09:13:02 -0700 Subject: [PATCH 3/7] brick namespace --- libs/core/_locales/core-jsdoc-strings.json | 83 ++++++++-------- libs/core/_locales/core-strings.json | 107 +++++++++++---------- libs/core/buttons.ts | 32 +++--- libs/core/color.ts | 10 +- libs/core/gyro.ts | 6 +- libs/core/input.ts | 2 +- libs/core/ir.ts | 20 ++-- libs/core/ns.ts | 8 +- libs/core/test.ts | 16 +-- libs/core/touch.ts | 10 +- libs/core/ultrasonic.ts | 6 +- libs/ev3/ns.ts | 8 +- 12 files changed, 158 insertions(+), 150 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index a2abf878..846a4582 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -10,6 +10,18 @@ "MMap.slice": "Read a range of bytes into a buffer.", "MMap.write": "Perform write(2) on the underlaying file", "TouchSensorEvent": "Touch sensor interactions", + "brick.Button": "Generic button class, for device buttons and sensors.", + "brick.Button.isPressed": "Check if button is currently pressed or not.", + "brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.", + "brick.Button.onEvent|param|body": "code to run when the event is raised", + "brick.Button.wasPressed": "See if the button was pressed again since the last time you checked.", + "brick.buttonDown": "Down button on the EV3 Brick.", + "brick.buttonEnter": "Enter button on the EV3 Brick.", + "brick.buttonLeft": "Left button on the EV3 Brick.", + "brick.buttonRight": "Right button on the EV3 Brick.", + "brick.buttonUp": "Up button on the EV3 Brick.", + "brick.pattern": "Pattern block.", + "brick.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green", "brick.print": "Show text on the screen.", "brick.print|param|text": "the text to print on the screen, eg: \"Hello world\"", "brick.print|param|x": "the starting position's x coordinate, eg: 0", @@ -18,6 +30,8 @@ "brick.setPixel|param|on": "a value indicating if the pixel should be on or off", "brick.setPixel|param|x": "the starting position's x coordinate, eg: 0", "brick.setPixel|param|y": "the starting position's x coordinate, eg: 0", + "brick.setStatusLight": "Set lights.", + "brick.setStatusLight|param|pattern": "the lights pattern to use.", "control": "Program controls and events.", "control.allocateNotifyEvent": "Allocates the next user notification event", "control.deviceFirmwareVersion": "Determine the version of system software currently running.", @@ -26,44 +40,6 @@ "control.raiseEvent": "Announce that an event happened to registered handlers.", "control.raiseEvent|param|src": "ID of the Component that generated the event", "control.raiseEvent|param|value": "Component specific code indicating the cause of the event.", - "input": "Respond to and read data from buttons and sensors.", - "input.Button": "Generic button class, for device buttons and sensors.", - "input.Button.isPressed": "Check if button is currently pressed or not.", - "input.Button.onEvent": "Do something when a button or sensor is clicked, up or down.", - "input.Button.onEvent|param|body": "code to run when the event is raised", - "input.Button.wasPressed": "See if the button was pressed again since the last time you checked.", - "input.ColorSensor.ambientLight": "Get current ambient light value from the color sensor.", - "input.ColorSensor.color": "Get the current color from the color sensor.", - "input.ColorSensor.onColorDetected": "Registers code to run when the given color is detected", - "input.ColorSensor.onColorDetected|param|color": "the color to dtect", - "input.ColorSensor.onColorDetected|param|handler": "the code to run when detected", - "input.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.", - "input.GyroSensor.angle": "Get the current angle from the gyroscope.", - "input.GyroSensor.rate": "Get the current rotation rate from the gyroscope.", - "input.InfraredSensor.onObjectNear": "Registers code to run when an object is getting near.", - "input.InfraredSensor.onObjectNear|param|handler": "the code to run when detected", - "input.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)", - "input.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.", - "input.RemoteInfraredBeaconButton.isPressed": "Check if a remote button is currently pressed or not.", - "input.RemoteInfraredBeaconButton.onEvent": "Do something when a button or sensor is clicked, up or down", - "input.RemoteInfraredBeaconButton.onEvent|param|body": "code to run when the event is raised", - "input.RemoteInfraredBeaconButton.wasPressed": "See if the remote button was pressed again since the last time you checked.", - "input.TouchSensor.isTouched": "Check if touch sensor is touched.", - "input.TouchSensor.onEvent": "Do something when a touch sensor is touched...", - "input.TouchSensor.onEvent|param|body": "code to run when the event is raised", - "input.UltraSonicSensor.distance": "Gets the distance from the sonar in millimeters", - "input.UltraSonicSensor.onObjectNear": "Registers code to run when the given color is close", - "input.UltraSonicSensor.onObjectNear|param|handler": "the code to run when detected", - "input.buttonDown": "Down button on the EV3 Brick.", - "input.buttonEnter": "Enter button on the EV3 Brick.", - "input.buttonLeft": "Left button on the EV3 Brick.", - "input.buttonRight": "Right button on the EV3 Brick.", - "input.buttonUp": "Up button on the EV3 Brick.", - "input.remoteButtonBottomLeft": "Remote bottom-left button.", - "input.remoteButtonBottomRight": "Remote bottom-right button.", - "input.remoteButtonCenter": "Remote beacon (center) button.", - "input.remoteButtonTopLeft": "Remote top-left button.", - "input.remoteButtonTopRight": "Remote top-right button.", "motors.Motor.clearCount": "Clears the motor count", "motors.Motor.count": "Gets motor step count.", "motors.Motor.on": "Power on or off the motor.", @@ -75,16 +51,39 @@ "motors.Motor.setReversed": "Reverses the motor polarity", "motors.Motor.speed": "Gets motor actual speed.", "motors.Motor.tachoCount": "Gets motor tacho count.", - "motors.pattern": "Pattern block.", - "motors.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green", - "motors.setStatusLight": "Set lights.", - "motors.setStatusLight|param|pattern": "the lights pattern to use.", "motors.stopAllMotors": "Stops all motors", "output.createBuffer": "Create a new zero-initialized buffer.", "output.createBuffer|param|size": "number of bytes in the buffer", "screen.clear": "Clear screen and reset font to normal.", "screen.doubleIcon": "Double size of an icon.", "screen.drawIcon": "Draw an icon on the screen.", + "sensors.ColorSensor.ambientLight": "Get current ambient light value from the color sensor.", + "sensors.ColorSensor.color": "Get the current color from the color sensor.", + "sensors.ColorSensor.onColorDetected": "Registers code to run when the given color is detected", + "sensors.ColorSensor.onColorDetected|param|color": "the color to dtect", + "sensors.ColorSensor.onColorDetected|param|handler": "the code to run when detected", + "sensors.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.", + "sensors.GyroSensor.angle": "Get the current angle from the gyroscope.", + "sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.", + "sensors.InfraredSensor.onObjectNear": "Registers code to run when an object is getting near.", + "sensors.InfraredSensor.onObjectNear|param|handler": "the code to run when detected", + "sensors.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)", + "sensors.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.", + "sensors.RemoteInfraredBeaconButton.isPressed": "Check if a remote button is currently pressed or not.", + "sensors.RemoteInfraredBeaconButton.onEvent": "Do something when a button or sensor is clicked, up or down", + "sensors.RemoteInfraredBeaconButton.onEvent|param|body": "code to run when the event is raised", + "sensors.RemoteInfraredBeaconButton.wasPressed": "See if the remote button was pressed again since the last time you checked.", + "sensors.TouchSensor.isTouched": "Check if touch sensor is touched.", + "sensors.TouchSensor.onEvent": "Do something when a touch sensor is touched...", + "sensors.TouchSensor.onEvent|param|body": "code to run when the event is raised", + "sensors.UltraSonicSensor.distance": "Gets the distance from the sonar in millimeters", + "sensors.UltraSonicSensor.onObjectNear": "Registers code to run when the given color is close", + "sensors.UltraSonicSensor.onObjectNear|param|handler": "the code to run when detected", + "sensors.remoteButtonBottomLeft": "Remote bottom-left button.", + "sensors.remoteButtonBottomRight": "Remote bottom-right button.", + "sensors.remoteButtonCenter": "Remote beacon (center) button.", + "sensors.remoteButtonTopLeft": "Remote top-left button.", + "sensors.remoteButtonTopRight": "Remote top-right button.", "serial": "Reading and writing data over a serial connection.", "serial.writeDmesg": "Send DMESG debug buffer over serial." } \ No newline at end of file diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 253544e1..fb4badc4 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -30,61 +30,21 @@ "TouchSensorEvent.Bumped|block": "bumped", "TouchSensorEvent.Pressed|block": "pressed", "TouchSensorEvent.Released|block": "released", + "brick.Button.isPressed|block": "%button|is pressed", + "brick.Button.onEvent|block": "on %button|%event", + "brick.Button.wasPressed|block": "%button|was pressed", + "brick.buttonDown|block": "button down", + "brick.buttonEnter|block": "button enter", + "brick.buttonLeft|block": "button left", + "brick.buttonRight|block": "button right", + "brick.buttonUp|block": "button up", + "brick.pattern|block": "%pattern", "brick.print|block": "print %text| at x: %x| y: %y", "brick.setPixel|block": "set pixel %on| at x: %x| y: %y", + "brick.setStatusLight|block": "set status light %pattern=led_pattern", "brick|block": "brick", "control.raiseEvent|block": "raise event|from %src|with value %value", "control|block": "control", - "input.Button.isPressed|block": "%button|is pressed", - "input.Button.onEvent|block": "on %button|%event", - "input.Button.wasPressed|block": "%button|was pressed", - "input.ColorSensor.ambientLight|block": "%color| ambient light", - "input.ColorSensor.color|block": "%color| color", - "input.ColorSensor.onColorDetected|block": "on %sensor|detected %color", - "input.ColorSensor.reflectedLight|block": "%color| reflected light", - "input.GyroSensor.angle|block": "%sensor|angle", - "input.GyroSensor.rate|block": "%sensor|rotation rate", - "input.InfraredSensor.onObjectNear|block": "on %sensor|object near", - "input.InfraredSensor.proximity|block": "%infrared|proximity", - "input.InfraredSensor.remoteCommand|block": "%infrared|remote command", - "input.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed", - "input.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event", - "input.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed", - "input.TouchSensor.isTouched|block": "%sensor|is touched", - "input.TouchSensor.onEvent|block": "on %sensor|%event", - "input.UltraSonicSensor.distance|block": "%sensor|distance", - "input.UltraSonicSensor.onObjectNear|block": "on %sensor|object near", - "input.buttonDown|block": "brick button down", - "input.buttonEnter|block": "brick button enter", - "input.buttonLeft|block": "brick button left", - "input.buttonRight|block": "brick button right", - "input.buttonUp|block": "brick button up", - "input.color1|block": "color sensor 1", - "input.color2|block": "color sensor 2", - "input.color3|block": "color sensor 3", - "input.color4|block": "color sensor 4", - "input.gyro1|block": "gyro sensor 1", - "input.gyro2|block": "gyro sensor 2", - "input.gyro3|block": "gyro sensor 3", - "input.gyro4|block": "gyro sensor 4", - "input.infraredSensor1|block": "infrared sensor 1", - "input.infraredSensor2|block": "infrared sensor 2", - "input.infraredSensor3|block": "infrared sensor 3", - "input.infraredSensor4|block": "infrared sensor 4", - "input.remoteButtonBottomLeft|block": "remote button bottom-left", - "input.remoteButtonBottomRight|block": "remote button bottom-right", - "input.remoteButtonCenter|block": "remote button center", - "input.remoteButtonTopLeft|block": "remote button top-left", - "input.remoteButtonTopRight|block": "remote button top-right", - "input.touchSensor1|block": "touch sensor 1", - "input.touchSensor2|block": "touch sensor 2", - "input.touchSensor3|block": "touch sensor 3", - "input.touchSensor4|block": "touch sensor 4", - "input.ultrasonic1|block": "ultrasonic sensor 1", - "input.ultrasonic2|block": "ultrasonic sensor 2", - "input.ultrasonic3|block": "ultrasonic sensor 3", - "input.ultrasonic4|block": "ultrasonic sensor 4", - "input|block": "input", "motors.Motor.count|block": "%motor|count", "motors.Motor.on|block": "%motor|%onOrOff", "motors.Motor.setBrake|block": "%motor|set brake %brake", @@ -100,25 +60,66 @@ "motors.mediumMotorB|block": "medium motor B", "motors.mediumMotorC|block": "medium motor C", "motors.mediumMotorD|block": "medium motor D", - "motors.pattern|block": "%pattern", - "motors.setStatusLight|block": "set status light %pattern=led_pattern", "motors.stopAllMotors|block": "stop all motors", "motors|block": "motors", "output|block": "output", "screen|block": "screen", + "sensors.ColorSensor.ambientLight|block": "%color| ambient light", + "sensors.ColorSensor.color|block": "%color| color", + "sensors.ColorSensor.onColorDetected|block": "on %sensor|detected %color", + "sensors.ColorSensor.reflectedLight|block": "%color| reflected light", + "sensors.GyroSensor.angle|block": "%sensor|angle", + "sensors.GyroSensor.rate|block": "%sensor|rotation rate", + "sensors.InfraredSensor.onObjectNear|block": "on %sensor|object near", + "sensors.InfraredSensor.proximity|block": "%infrared|proximity", + "sensors.InfraredSensor.remoteCommand|block": "%infrared|remote command", + "sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed", + "sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event", + "sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed", + "sensors.TouchSensor.isTouched|block": "%sensor|is touched", + "sensors.TouchSensor.onEvent|block": "on %sensor|%event", + "sensors.UltraSonicSensor.distance|block": "%sensor|distance", + "sensors.UltraSonicSensor.onObjectNear|block": "on %sensor|object near", + "sensors.color1|block": "color sensor 1", + "sensors.color2|block": "color sensor 2", + "sensors.color3|block": "color sensor 3", + "sensors.color4|block": "color sensor 4", + "sensors.gyro1|block": "gyro sensor 1", + "sensors.gyro2|block": "gyro sensor 2", + "sensors.gyro3|block": "gyro sensor 3", + "sensors.gyro4|block": "gyro sensor 4", + "sensors.infraredSensor1|block": "infrared sensor 1", + "sensors.infraredSensor2|block": "infrared sensor 2", + "sensors.infraredSensor3|block": "infrared sensor 3", + "sensors.infraredSensor4|block": "infrared sensor 4", + "sensors.remoteButtonBottomLeft|block": "remote button bottom-left", + "sensors.remoteButtonBottomRight|block": "remote button bottom-right", + "sensors.remoteButtonCenter|block": "remote button center", + "sensors.remoteButtonTopLeft|block": "remote button top-left", + "sensors.remoteButtonTopRight|block": "remote button top-right", + "sensors.touchSensor1|block": "touch sensor 1", + "sensors.touchSensor2|block": "touch sensor 2", + "sensors.touchSensor3|block": "touch sensor 3", + "sensors.touchSensor4|block": "touch sensor 4", + "sensors.ultrasonic1|block": "ultrasonic sensor 1", + "sensors.ultrasonic2|block": "ultrasonic sensor 2", + "sensors.ultrasonic3|block": "ultrasonic sensor 3", + "sensors.ultrasonic4|block": "ultrasonic sensor 4", + "sensors|block": "sensors", "serial|block": "serial", "{id:category}Brick": "Brick", "{id:category}Control": "Control", - "{id:category}Input": "Input", "{id:category}MMap": "MMap", "{id:category}Motors": "Motors", "{id:category}Output": "Output", "{id:category}Screen": "Screen", + "{id:category}Sensors": "Sensors", "{id:category}Serial": "Serial", "{id:group}Brick": "Brick", "{id:group}Color Sensor": "Color Sensor", "{id:group}Gyro Sensor": "Gyro Sensor", "{id:group}Infrared Sensor": "Infrared Sensor", + "{id:group}Light": "Light", "{id:group}Motors": "Motors", "{id:group}Remote Infrared Beacon": "Remote Infrared Beacon", "{id:group}Touch Sensor": "Touch Sensor", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index c7a6eb67..e4791751 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -47,7 +47,7 @@ const enum ButtonEvent { Down = 4, } -namespace input { +namespace brick { /** * Generic button class, for device buttons and sensors. */ @@ -87,7 +87,7 @@ namespace input { //% block="%button|is pressed" //% blockId=buttonIsPressed //% parts="brick" - //% blockNamespace=input + //% blockNamespace=brick //% weight=81 blockGap=8 //% group="Brick" isPressed() { @@ -102,7 +102,7 @@ namespace input { //% block="%button|was pressed" //% blockId=buttonWasPressed //% parts="brick" - //% blockNamespace=input + //% blockNamespace=brick //% weight=80 blockGap=8 //% group="Brick" wasPressed() { @@ -120,7 +120,7 @@ namespace input { //% help=input/button/on-event //% blockId=buttonEvent block="on %button|%event" //% parts="brick" - //% blockNamespace=input + //% blockNamespace=brick //% weight=99 blockGap=8 //% group="Brick" onEvent(ev: ButtonEvent, body: () => void) { @@ -129,7 +129,7 @@ namespace input { } } -namespace input { +namespace brick { let btnsMM: MMap let buttons: DevButton[] @@ -155,7 +155,7 @@ namespace input { btnsMM = control.mmap("/dev/lms_ui", DAL.NUM_BUTTONS, 0) if (!btnsMM) control.fail("no buttons?") buttons = [] - input.internal.unsafePollForChanges(50, readButtons, (prev, curr) => { + sensors.internal.unsafePollForChanges(50, readButtons, (prev, curr) => { if (curr & DAL.BUTTON_ID_ESCAPE) control.reset() for (let b of buttons) @@ -180,31 +180,31 @@ namespace input { /** * Enter button on the EV3 Brick. */ - //% whenUsed block="brick button enter" weight=95 fixedInstance + //% whenUsed block="button enter" weight=95 fixedInstance export const buttonEnter: Button = new DevButton(DAL.BUTTON_ID_ENTER) /** * Left button on the EV3 Brick. */ - //% whenUsed block="brick button left" weight=95 fixedInstance + //% whenUsed block="button left" weight=95 fixedInstance export const buttonLeft: Button = new DevButton(DAL.BUTTON_ID_LEFT) /** * Right button on the EV3 Brick. */ - //% whenUsed block="brick button right" weight=94 fixedInstance + //% whenUsed block="button right" weight=94 fixedInstance export const buttonRight: Button = new DevButton(DAL.BUTTON_ID_RIGHT) /** * Up button on the EV3 Brick. */ - //% whenUsed block="brick button up" weight=95 fixedInstance + //% whenUsed block="button up" weight=95 fixedInstance export const buttonUp: Button = new DevButton(DAL.BUTTON_ID_UP) /** * Down button on the EV3 Brick. */ - //% whenUsed block="brick button down" weight=95 fixedInstance + //% whenUsed block="button down" weight=95 fixedInstance export const buttonDown: Button = new DevButton(DAL.BUTTON_ID_DOWN) } @@ -215,7 +215,7 @@ namespace control { */ export function deviceFirmwareVersion(): string { let buf = output.createBuffer(6) - input.internal.getBtnsMM().read(buf) + brick.internal.getBtnsMM().read(buf) let r = "" for (let i = 0; i < buf.length; ++i) { let c = buf[i] @@ -226,7 +226,7 @@ namespace control { } } -namespace motors { +namespace brick { let currPattern: LightsPattern /** @@ -234,14 +234,14 @@ namespace motors { * @param pattern the lights pattern to use. */ //% blockId=setLights block="set status light %pattern=led_pattern" - //% weight=100 group="Brick" + //% weight=100 group="Light" export function setStatusLight(pattern: number): void { if (currPattern === pattern) return currPattern = pattern let cmd = output.createBuffer(2) cmd[0] = pattern + 48 - input.internal.getBtnsMM().write(cmd) + brick.internal.getBtnsMM().write(cmd) } @@ -250,7 +250,7 @@ namespace motors { * @param pattern the lights pattern to use. eg: LightsPattern.Green */ //% blockId=led_pattern block="%pattern" - //% shim=TD_ID colorSecondary="#6e9a36" + //% shim=TD_ID colorSecondary="#6e9a36" group="Light" //% blockHidden=true useEnumVal=1 pattern.fieldOptions.decompileLiterals=1 export function pattern(pattern: LightsPattern): number { return pattern; diff --git a/libs/core/color.ts b/libs/core/color.ts index 27303f51..b334d4a6 100644 --- a/libs/core/color.ts +++ b/libs/core/color.ts @@ -27,7 +27,7 @@ const enum ColorSensorColor { Brown, } -namespace input { +namespace sensors { //% fixedInstances export class ColorSensor extends internal.UartSensor { @@ -62,7 +62,7 @@ namespace input { //% block="on %sensor|detected %color" //% blockId=colorOnColorDetected //% parts="colorsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=100 blockGap=8 //% group="Color Sensor" onColorDetected(color: ColorSensorColor, handler: () => void) { @@ -80,7 +80,7 @@ namespace input { //% block="%color| ambient light" //% blockId=colorGetAmbient //% parts="colorsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Color Sensor" ambientLight() { @@ -96,7 +96,7 @@ namespace input { //% block="%color| reflected light" //% blockId=colorGetReflected //% parts="colorsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=64 blockGap=8 //% group="Color Sensor" reflectedLight(): number { @@ -112,7 +112,7 @@ namespace input { //% block="%color| color" //% blockId=colorGetColor //% parts="colorsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=66 blockGap=8 //% group="Color Sensor" color(): ColorSensorColor { diff --git a/libs/core/gyro.ts b/libs/core/gyro.ts index 3f0b5ed8..74de5b20 100644 --- a/libs/core/gyro.ts +++ b/libs/core/gyro.ts @@ -4,7 +4,7 @@ const enum GyroSensorMode { Rate = 1, } -namespace input { +namespace sensors { //% fixedInstances export class GyroSensor extends internal.UartSensor { constructor(port: number) { @@ -27,7 +27,7 @@ namespace input { //% block="%sensor|angle" //% blockId=gyroGetAngle //% parts="gyroscope" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Gyro Sensor" angle() { @@ -43,7 +43,7 @@ namespace input { //% block="%sensor|rotation rate" //% blockId=gyroGetRate //% parts="gyroscope" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Gyro Sensor" rate() { diff --git a/libs/core/input.ts b/libs/core/input.ts index 386b0238..6ea02ea3 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -1,4 +1,4 @@ -namespace input.internal { +namespace sensors.internal { //% shim=pxt::unsafePollForChanges export function unsafePollForChanges( periodMs: number, diff --git a/libs/core/ir.ts b/libs/core/ir.ts index 837d01bb..ea4dae04 100644 --- a/libs/core/ir.ts +++ b/libs/core/ir.ts @@ -21,7 +21,7 @@ const enum IrRemoteButton { BottomRight = 0x10, } -namespace input { +namespace sensors { function mapButton(v: number) { switch (v) { case 0: return IrRemoteButton.None @@ -50,7 +50,7 @@ namespace input { if (buttons == null) { buttons = [] for (let i = 0; i < 5; ++i) { - buttons.push(new RemoteInfraredBeaconButton(new Button())) + buttons.push(new RemoteInfraredBeaconButton(new brick.Button())) } // make sure sensors are up @@ -71,8 +71,8 @@ namespace input { //% fixedInstances export class RemoteInfraredBeaconButton extends control.Component { - private button: Button; - constructor(button: Button) { + private button: brick.Button; + constructor(button: brick.Button) { super(); this.button = button; } @@ -89,7 +89,7 @@ namespace input { //% block="%button|is pressed" //% blockId=remoteButtonIsPressed //% parts="remote" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=81 blockGap=8 //% group="Remote Infrared Beacon" isPressed() { @@ -104,7 +104,7 @@ namespace input { //% block="%button|was pressed" //% blockId=remotebuttonWasPressed //% parts="remote" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=80 blockGap=8 //% group="Remote Infrared Beacon" wasPressed() { @@ -120,7 +120,7 @@ namespace input { //% help=input/remote-infrared-beacon/on-event //% blockId=remotebuttonEvent block="on %button|%event" //% parts="remote" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=99 blockGap=8 //% group="Remote Infrared Beacon" onEvent(ev: ButtonEvent, body: () => void) { @@ -189,7 +189,7 @@ namespace input { //% block="on %sensor|object near" //% blockId=infraredOnObjectNear //% parts="infraredsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=100 blockGap=8 //% group="Infrared Sensor" onObjectNear(handler: () => void) { @@ -210,7 +210,7 @@ namespace input { //% block="%infrared|proximity" //% blockId=infraredGetProximity //% parts="infrared" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Infrared Sensor" proximity() { @@ -226,7 +226,7 @@ namespace input { //% block="%infrared|remote command" //% blockId=infraredGetRemoteCommand //% parts="infrared" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Infrared Sensor" remoteCommand() { diff --git a/libs/core/ns.ts b/libs/core/ns.ts index ee9b5613..49cb7bb1 100644 --- a/libs/core/ns.ts +++ b/libs/core/ns.ts @@ -1,5 +1,9 @@ +//% weight=100 +namespace brick { + +} //% color="#B4009E" weight=98 icon="\uf192" -//% groups='["Brick", "Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]' -namespace input { +//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]' +namespace sensors { } diff --git a/libs/core/test.ts b/libs/core/test.ts index 6f957b3a..8853f89b 100644 --- a/libs/core/test.ts +++ b/libs/core/test.ts @@ -6,42 +6,42 @@ motors.setStatusLight(LightsPattern.Orange) screen.drawIcon(100, 50, screen.doubleIcon(screen.heart), Draw.Double | Draw.Transparent) -input.buttonEnter.onEvent(ButtonEvent.Click, () => { +sensors.buttonEnter.onEvent(ButtonEvent.Click, () => { screen.clear() }) -input.buttonLeft.onEvent(ButtonEvent.Click, () => { +sensors.buttonLeft.onEvent(ButtonEvent.Click, () => { screen.drawRect(10, 70, 20, 10, Draw.Fill) motors.setStatusLight(LightsPattern.Red) screen.setFont(screen.microbitFont()) }) -input.buttonRight.onEvent(ButtonEvent.Click, () => { +sensors.buttonRight.onEvent(ButtonEvent.Click, () => { screen.print("Right!", 10, 60) }) -input.buttonDown.onEvent(ButtonEvent.Click, () => { +sensors.buttonDown.onEvent(ButtonEvent.Click, () => { screen.print("Down! ", 10, 60) }) -input.buttonUp.onEvent(ButtonEvent.Click, () => { +sensors.buttonUp.onEvent(ButtonEvent.Click, () => { screen.print("Up! ", 10, 60) }) let num = 0 -input.touchSensor1.onEvent(TouchSensorEvent.Bumped, () => { +sensors.touchSensor1.onEvent(TouchSensorEvent.Bumped, () => { screen.print("Click! " + num, 10, 60) num++ }) -input.remoteButtonTopLeft.onEvent(ButtonEvent.Click, () => { +sensors.remoteButtonTopLeft.onEvent(ButtonEvent.Click, () => { screen.print("TOPLEFT " + num, 10, 60) num++ }) -input.remoteButtonTopRight.onEvent(ButtonEvent.Down, () => { +sensors.remoteButtonTopRight.onEvent(ButtonEvent.Down, () => { screen.print("TOPRIGH " + num, 10, 60) num++ }) diff --git a/libs/core/touch.ts b/libs/core/touch.ts index 626f438f..c603fae4 100644 --- a/libs/core/touch.ts +++ b/libs/core/touch.ts @@ -12,15 +12,15 @@ const enum TouchSensorEvent { Released = 3, } -namespace input { +namespace sensors { //% fixedInstances export class TouchSensor extends internal.AnalogSensor { - private button: Button; + private button: brick.Button; constructor(port: number) { super(port) - this.button = new Button(); + this.button = new brick.Button(); } _query() { @@ -43,7 +43,7 @@ namespace input { //% block="%sensor|is touched" //% blockId=touchIsTouched //% parts="touch" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=81 blockGap=8 //% group="Touch Sensor" isTouched() { @@ -59,7 +59,7 @@ namespace input { //% help=input/touch/on-event //% blockId=touchEvent block="on %sensor|%event" //% parts="touch" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=99 blockGap=8 //% group="Touch Sensor" onEvent(ev: TouchSensorEvent, body: () => void) { diff --git a/libs/core/ultrasonic.ts b/libs/core/ultrasonic.ts index b14894ee..559d4c1e 100644 --- a/libs/core/ultrasonic.ts +++ b/libs/core/ultrasonic.ts @@ -5,7 +5,7 @@ const enum PromixityEvent { ObjectDetected = 2 } -namespace input { +namespace sensors { //% fixedInstances export class UltraSonicSensor extends internal.UartSensor { @@ -40,7 +40,7 @@ namespace input { //% block="on %sensor|object near" //% blockId=ultrasonicOnObjectClose //% parts="infraredsensor" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=100 blockGap=8 //% group="Ultrasonic Sensor" onObjectNear(handler: () => void) { @@ -61,7 +61,7 @@ namespace input { //% block="%sensor|distance" //% blockId=sonarGetDistance //% parts="ultrasonic" - //% blockNamespace=input + //% blockNamespace=sensors //% weight=65 blockGap=8 //% group="Ultrasonic Sensor" distance() { diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index 11552433..d44148ad 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -1,6 +1,10 @@ -//% color="#D42878" -namespace input { +//% color="#D42878" weight=100 +namespace brick { +} + +//% color="#D42878" weight=95 +namespace sensors { } //% color="#8AC044" weight=90 icon="\uf185" From 7c2ea7c40631754fbfe63859031b843669829c2b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sat, 28 Oct 2017 09:20:34 -0700 Subject: [PATCH 4/7] fixing more groups --- libs/core/_locales/core-strings.json | 1 + libs/core/buttons.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index fb4badc4..7f842603 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -116,6 +116,7 @@ "{id:category}Sensors": "Sensors", "{id:category}Serial": "Serial", "{id:group}Brick": "Brick", + "{id:group}Buttons": "Buttons", "{id:group}Color Sensor": "Color Sensor", "{id:group}Gyro Sensor": "Gyro Sensor", "{id:group}Infrared Sensor": "Infrared Sensor", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index e4791751..b92c3f39 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -89,7 +89,7 @@ namespace brick { //% parts="brick" //% blockNamespace=brick //% weight=81 blockGap=8 - //% group="Brick" + //% group="Buttons" isPressed() { return this._isPressed } @@ -104,7 +104,7 @@ namespace brick { //% parts="brick" //% blockNamespace=brick //% weight=80 blockGap=8 - //% group="Brick" + //% group="Buttons" wasPressed() { const r = this._wasPressed this._wasPressed = false @@ -122,7 +122,7 @@ namespace brick { //% parts="brick" //% blockNamespace=brick //% weight=99 blockGap=8 - //% group="Brick" + //% group="Buttons" onEvent(ev: ButtonEvent, body: () => void) { control.onEvent(this._id, ev, body) } From c8c45be057502fe197133003600ab376ac2c37f7 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 30 Oct 2017 09:51:18 -0700 Subject: [PATCH 5/7] fixing brick groups --- libs/core/_locales/core-strings.json | 2 +- libs/core/screen.ts | 4 ++-- libs/ev3/ns.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 7f842603..c43033cd 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -115,7 +115,6 @@ "{id:category}Screen": "Screen", "{id:category}Sensors": "Sensors", "{id:category}Serial": "Serial", - "{id:group}Brick": "Brick", "{id:group}Buttons": "Buttons", "{id:group}Color Sensor": "Color Sensor", "{id:group}Gyro Sensor": "Gyro Sensor", @@ -123,6 +122,7 @@ "{id:group}Light": "Light", "{id:group}Motors": "Motors", "{id:group}Remote Infrared Beacon": "Remote Infrared Beacon", + "{id:group}Screen": "Screen", "{id:group}Touch Sensor": "Touch Sensor", "{id:group}Ultrasonic Sensor": "Ultrasonic Sensor" } \ No newline at end of file diff --git a/libs/core/screen.ts b/libs/core/screen.ts index a3a925d8..3613150c 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -85,7 +85,7 @@ namespace brick { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y" - //% weight=98 group="Brick" + //% weight=98 group="Screen" //% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff export function setPixel(on: boolean, x: number, y: number) { x |= 0 @@ -101,7 +101,7 @@ namespace brick { * @param y the starting position's x coordinate, eg: 0 */ //% blockId=screen_print block="print %text| at x: %x| y: %y" - //% weight=99 group="Brick" inlineInputMode="inline" + //% weight=99 group="Screen" inlineInputMode="inline" blockGap=8 //% x.min=0 x.max=178 y.min=0 y.max=128 export function print(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index d44148ad..d429cb02 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -1,5 +1,6 @@ //% color="#D42878" weight=100 +//% groups='["Light", "Buttons", "Screen"]' namespace brick { } @@ -8,7 +9,6 @@ namespace sensors { } //% color="#8AC044" weight=90 icon="\uf185" -//% groups='["Motors", "Brick"]' namespace motors { } From c7d36a5e8201aed1a846408458555c06e67e2783 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 30 Oct 2017 09:55:36 -0700 Subject: [PATCH 6/7] moving motors up --- libs/ev3/ns.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index d429cb02..36ab258f 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -4,12 +4,13 @@ namespace brick { } -//% color="#D42878" weight=95 -namespace sensors { + +//% color="#8AC044" weight=95 icon="\uf185" +namespace motors { } -//% color="#8AC044" weight=90 icon="\uf185" -namespace motors { +//% color="#D42878" weight=90 +namespace sensors { } //% color="#DF5014" weight=80 From c4a9b4a3810954de3cfc45058cb51cf8ab238e22 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 30 Oct 2017 09:58:00 -0700 Subject: [PATCH 7/7] updated brick color --- libs/ev3/ns.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index 36ab258f..f1348216 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -1,5 +1,5 @@ -//% color="#D42878" weight=100 +//% color="#00A5C8" weight=100 //% groups='["Light", "Buttons", "Screen"]' namespace brick { }