diff --git a/docs/about.md b/docs/about.md index ac2d9dcc..be2095ff 100644 --- a/docs/about.md +++ b/docs/about.md @@ -7,12 +7,12 @@ Welcome to the **Microsoft MakeCode** editor for the **@boardname@**! You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser: ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, () => { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { motors.largeA.setSpeed(50) }) ``` ```typescript -brick.buttonEnter.onEvent(ButtonEvent.Click, () => { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { motors.largeA.setSpeed(50) }) ``` @@ -33,7 +33,7 @@ You can run your code using the micro:bit simulator, all within the confines of The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins. ```sim -brick.buttonEnter.onEvent(ButtonEvent.Click, () => { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { motors.largeA.setSpeed(50) }) ``` diff --git a/docs/coding/cruise-control-1.md b/docs/coding/cruise-control-1.md index f302e238..2b58db38 100644 --- a/docs/coding/cruise-control-1.md +++ b/docs/coding/cruise-control-1.md @@ -2,7 +2,7 @@ ```blocks let speed = 0; -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { if (speed < 100) speed = speed + 10; motors.largeBC.setSpeed(speed); diff --git a/docs/coding/cruise-control-2.md b/docs/coding/cruise-control-2.md index 95e0b99b..34cf6d55 100644 --- a/docs/coding/cruise-control-2.md +++ b/docs/coding/cruise-control-2.md @@ -2,12 +2,12 @@ ```blocks let speed = 0; -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { if (speed < 100) speed = speed + 10; motors.largeBC.setSpeed(speed); }) -sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch2.onEvent(ButtonEvent.Pressed, function () { if (speed > -100) speed = speed - 10; motors.largeBC.setSpeed(speed); diff --git a/docs/coding/cruise-control-3.md b/docs/coding/cruise-control-3.md index 95f1526e..0cdb0822 100644 --- a/docs/coding/cruise-control-3.md +++ b/docs/coding/cruise-control-3.md @@ -17,11 +17,11 @@ function update() { brick.showString("speed: " + speed, 1) motors.largeBC.setSpeed(speed) } -sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch2.onEvent(ButtonEvent.Pressed, function () { accelerate() update() }) -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { decelerate() update() }) diff --git a/docs/coding/ignition-1.md b/docs/coding/ignition-1.md index 81483010..b9d5fe0f 100644 --- a/docs/coding/ignition-1.md +++ b/docs/coding/ignition-1.md @@ -1,7 +1,7 @@ # Ignition Activity 1 ```blocks -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { brick.showImage(images.eyesDizzy) }) sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () { diff --git a/docs/coding/light-the-way-3.md b/docs/coding/light-the-way-3.md index a773e643..d2aa3798 100644 --- a/docs/coding/light-the-way-3.md +++ b/docs/coding/light-the-way-3.md @@ -7,7 +7,7 @@ sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () { brick.showImage(images.objectsLightOn) }) -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { brick.showImage(images.objectsLightOn); }) ``` \ No newline at end of file diff --git a/docs/coding/reversing-the-robot-1.md b/docs/coding/reversing-the-robot-1.md index 0da01850..30c36c86 100644 --- a/docs/coding/reversing-the-robot-1.md +++ b/docs/coding/reversing-the-robot-1.md @@ -1,9 +1,9 @@ # Reversing the robot Activity 1 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.setSpeed(50) - sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch1.pauseUntil(ButtonEvent.Pressed) motors.largeBC.setSpeed(0) loops.pause(1000) brick.setLight(BrickLight.OrangeFlash) diff --git a/docs/coding/reversing-the-robot-2.md b/docs/coding/reversing-the-robot-2.md index 2088c2b0..ca1c844c 100644 --- a/docs/coding/reversing-the-robot-2.md +++ b/docs/coding/reversing-the-robot-2.md @@ -1,10 +1,10 @@ # Reversing the robot Activity 2 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { - sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { + sensors.touch1.pauseUntil(ButtonEvent.Pressed) motors.largeBC.setSpeed(50) - sensors.touch2.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch2.pauseUntil(ButtonEvent.Pressed) motors.largeBC.setSpeed(0) loops.pause(1000) brick.setLight(BrickLight.OrangeFlash) diff --git a/docs/coding/reversing-the-robot-3.md b/docs/coding/reversing-the-robot-3.md index 4cf6ff32..b40eb432 100644 --- a/docs/coding/reversing-the-robot-3.md +++ b/docs/coding/reversing-the-robot-3.md @@ -1,12 +1,12 @@ # Reversing the robot Activity 3 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { brick.showImage(images.eyesSleeping) - sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch1.pauseUntil(ButtonEvent.Pressed) brick.showImage(images.eyesNeutral) motors.largeBC.setSpeed(50) - sensors.touch2.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch2.pauseUntil(ButtonEvent.Pressed) brick.showImage(images.eyesTiredMiddle) motors.largeBC.setSpeed(0) loops.pause(1000) diff --git a/docs/coding/roaming-1.md b/docs/coding/roaming-1.md index f11293be..689fb7d5 100644 --- a/docs/coding/roaming-1.md +++ b/docs/coding/roaming-1.md @@ -2,16 +2,16 @@ ```blocks let drive: number[] = [] -brick.buttonLeft.onEvent(ButtonEvent.Click, function () { +brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () { drive.push(1) }) -brick.buttonRight.onEvent(ButtonEvent.Click, function () { +brick.buttonRight.onEvent(ButtonEvent.Bumped, function () { drive.push(3) }) -brick.buttonUp.onEvent(ButtonEvent.Click, function () { +brick.buttonUp.onEvent(ButtonEvent.Bumped, function () { drive.push(4) }) -brick.buttonDown.onEvent(ButtonEvent.Click, function () { +brick.buttonDown.onEvent(ButtonEvent.Bumped, function () { drive.push(5) }) pauseUntil(() => drive.length >= 5) diff --git a/docs/coding/roaming-2.md b/docs/coding/roaming-2.md index 106d3950..f20c4cae 100644 --- a/docs/coding/roaming-2.md +++ b/docs/coding/roaming-2.md @@ -2,23 +2,23 @@ ```blocks let drive: number[] = [] -brick.buttonLeft.onEvent(ButtonEvent.Click, function () { +brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () { drive.push(1) music.playSoundEffectUntilDone(sounds.systemClick) }) -brick.buttonRight.onEvent(ButtonEvent.Click, function () { +brick.buttonRight.onEvent(ButtonEvent.Bumped, function () { drive.push(3) music.playSoundEffectUntilDone(sounds.systemClick) }) -brick.buttonUp.onEvent(ButtonEvent.Click, function () { +brick.buttonUp.onEvent(ButtonEvent.Bumped, function () { drive.push(4) music.playSoundEffectUntilDone(sounds.systemClick) }) -brick.buttonDown.onEvent(ButtonEvent.Click, function () { +brick.buttonDown.onEvent(ButtonEvent.Bumped, function () { drive.push(5) music.playSoundEffectUntilDone(sounds.systemClick) }) -brick.buttonEnter.pauseUntil(ButtonEvent.Click); +brick.buttonEnter.pauseUntil(ButtonEvent.Bumped); loops.pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { diff --git a/docs/coding/three-point-turn-1.md b/docs/coding/three-point-turn-1.md index c694a331..741d5715 100644 --- a/docs/coding/three-point-turn-1.md +++ b/docs/coding/three-point-turn-1.md @@ -1,7 +1,7 @@ # Three Point Turn Activity 1 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) loops.pause(1500) motors.largeBC.tank(-30, -75) diff --git a/docs/coding/three-point-turn-2.md b/docs/coding/three-point-turn-2.md index 4524afa0..ef2d81e2 100644 --- a/docs/coding/three-point-turn-2.md +++ b/docs/coding/three-point-turn-2.md @@ -1,7 +1,7 @@ # Three Point Turn Activity 2 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) loops.pause(1500) motors.largeBC.tank(-30, -75) diff --git a/docs/coding/three-point-turn-3.md b/docs/coding/three-point-turn-3.md index 7d0ed43e..ddc44dac 100644 --- a/docs/coding/three-point-turn-3.md +++ b/docs/coding/three-point-turn-3.md @@ -1,7 +1,7 @@ # Three Point Turn Activity 3 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(75, 30) loops.pause(1500) motors.largeBC.tank(-30, -75) diff --git a/docs/coding/traffic-lights-1.md b/docs/coding/traffic-lights-1.md index 588253a9..ffcfc3a1 100644 --- a/docs/coding/traffic-lights-1.md +++ b/docs/coding/traffic-lights-1.md @@ -1,7 +1,7 @@ # Traffic Lights Activity 1 ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { motors.largeBC.tank(20, 20) sensors.color3.pauseForColor(ColorSensorColor.Red) motors.largeBC.tank(0, 0) diff --git a/docs/examples/core-set/gyroboy-blocks.md b/docs/examples/core-set/gyroboy-blocks.md index bb56d0b1..71edd159 100644 --- a/docs/examples/core-set/gyroboy-blocks.md +++ b/docs/examples/core-set/gyroboy-blocks.md @@ -111,7 +111,7 @@ function stop() { motors.stopAllMotors() state = 0 moods.knockedOut.show(); - sensors.touch3.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch3.pauseUntil(ButtonEvent.Pressed) moods.neutral.show(); } sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () { diff --git a/docs/examples/core-set/gyroboy-labview.md b/docs/examples/core-set/gyroboy-labview.md index 8cef3309..b1296634 100644 --- a/docs/examples/core-set/gyroboy-labview.md +++ b/docs/examples/core-set/gyroboy-labview.md @@ -149,7 +149,7 @@ loops.forever(function () { brick.setLight(BrickLight.RedPulse); brick.showImage(images.eyesKnockedOut) music.playSoundEffect(sounds.movementsSpeedDown) - sensors.touch3.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch3.pauseUntil(ButtonEvent.Pressed) brick.setLight(BrickLight.Off); }) diff --git a/docs/examples/core-set/robotarm-labview.md b/docs/examples/core-set/robotarm-labview.md index d94df8ad..412a426c 100644 --- a/docs/examples/core-set/robotarm-labview.md +++ b/docs/examples/core-set/robotarm-labview.md @@ -11,7 +11,7 @@ function INI() { motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds); motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees); motors.largeC.setSpeed(50) - sensors.touch1.pauseUntil(TouchSensorEvent.Pressed); + sensors.touch1.pauseUntil(ButtonEvent.Pressed); motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations); } diff --git a/docs/examples/crane-labview.md b/docs/examples/crane-labview.md index 95e4af37..c1e6c22b 100644 --- a/docs/examples/crane-labview.md +++ b/docs/examples/crane-labview.md @@ -11,7 +11,7 @@ function INI() { motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds); motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees); motors.largeC.setSpeed(50) - sensors.touch1.pauseUntil(TouchSensorEvent.Pressed); + sensors.touch1.pauseUntil(ButtonEvent.Pressed); motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations); } diff --git a/docs/examples/gyro-boy-labview.md b/docs/examples/gyro-boy-labview.md index 1fa7a3e6..ef6b084a 100644 --- a/docs/examples/gyro-boy-labview.md +++ b/docs/examples/gyro-boy-labview.md @@ -149,7 +149,7 @@ loops.forever(function () { brick.setLight(BrickLight.RedPulse); brick.showImage(images.eyesKnockedOut) music.playSoundEffect(sounds.movementsSpeedDown) - sensors.touch3.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch3.pauseUntil(ButtonEvent.Pressed) brick.setLight(BrickLight.Off); }) diff --git a/docs/examples/happy-unhappy.md b/docs/examples/happy-unhappy.md index 4e85acdf..1da62cac 100644 --- a/docs/examples/happy-unhappy.md +++ b/docs/examples/happy-unhappy.md @@ -3,10 +3,10 @@ Use a touch sensor to make the brick happy. ```blocks -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { brick.showImage(images.expressionsBigSmile) }) -sensors.touch1.onEvent(TouchSensorEvent.Released, function () { +sensors.touch1.onEvent(ButtonEvent.Released, function () { brick.showImage(images.expressionsSick) }) ``` \ No newline at end of file diff --git a/docs/examples/line-follower-pid.md b/docs/examples/line-follower-pid.md index f2efb567..cbe40d98 100644 --- a/docs/examples/line-follower-pid.md +++ b/docs/examples/line-follower-pid.md @@ -44,7 +44,7 @@ loops.forever(function () { lasterror = error if (brick.buttonEnter.wasPressed()) { motors.largeBC.setSpeed(0) - brick.buttonDown.pauseUntil(ButtonEvent.Click) + brick.buttonDown.pauseUntil(ButtonEvent.Bumped) } }) ``` \ No newline at end of file diff --git a/docs/maker/security-gadget.md b/docs/maker/security-gadget.md index f08bd724..aec4adbe 100644 --- a/docs/maker/security-gadget.md +++ b/docs/maker/security-gadget.md @@ -3,7 +3,7 @@ This program will activate an alarm when an object is lifted from the Touch Sensor. ```blocks -sensors.touch1.onEvent(TouchSensorEvent.Released, function () { +sensors.touch1.onEvent(ButtonEvent.Released, function () { music.playSoundEffectUntilDone(sounds.informationActivate); }) ``` \ No newline at end of file diff --git a/docs/reference/brick.md b/docs/reference/brick.md index f2770e4f..aab6ec1b 100644 --- a/docs/reference/brick.md +++ b/docs/reference/brick.md @@ -15,10 +15,10 @@ brick.printPorts(); ## Buttons ```cards -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { }); -brick.buttonEnter.pauseUntil(ButtonEvent.Click); +brick.buttonEnter.pauseUntil(ButtonEvent.Bumped); brick.buttonEnter.isPressed() brick.buttonEnter.wasPressed() brick.setLight(BrickLight.Red); diff --git a/docs/reference/brick/button/on-event.md b/docs/reference/brick/button/on-event.md index fa59b752..138c25b2 100644 --- a/docs/reference/brick/button/on-event.md +++ b/docs/reference/brick/button/on-event.md @@ -3,7 +3,7 @@ Run some code when a button is clicked, pressed down, or released. ```sig -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { }); ``` @@ -15,7 +15,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Click, function () { Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`. ```block -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { brick.setLight(BrickLight.Orange); }); ``` @@ -38,13 +38,13 @@ Check for event on the ENTER button. Put a message on the screen when the button ```blocks brick.showString("ENTER is: UP", 1); -brick.buttonEnter.onEvent(ButtonEvent.Up, function () { +brick.buttonEnter.onEvent(ButtonEvent.Released, function () { brick.showString("ENTER is: UP ", 1); }); -brick.buttonEnter.onEvent(ButtonEvent.Down, function () { +brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () { brick.showString("ENTER is: DOWN ", 1); }); -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { brick.showString("ENTER was: CLICKED", 1); }); ``` diff --git a/docs/reference/brick/button/pause-until.md b/docs/reference/brick/button/pause-until.md index 9540d2c4..410c4973 100644 --- a/docs/reference/brick/button/pause-until.md +++ b/docs/reference/brick/button/pause-until.md @@ -3,7 +3,7 @@ Causes your program to wait until an event at a button happens. ```sig -brick.buttonEnter.pauseUntil(ButtonEvent.Click); +brick.buttonEnter.pauseUntil(ButtonEvent.Bumped); ``` ## Parameters @@ -23,7 +23,7 @@ brick.showString("We're going to wait", 1); brick.showString("for you to press and", 2); brick.showString("release the UP button", 3); waitTime = control.millis(); -brick.buttonUp.pauseUntil(ButtonEvent.Click); +brick.buttonUp.pauseUntil(ButtonEvent.Bumped); brick.clearScreen(); if (control.millis() - waitTime > 5000) { brick.showString("Ok, that took awhile!", 1) diff --git a/docs/reference/brick/button/was-pressed.md b/docs/reference/brick/button/was-pressed.md index 56454f99..7a2d33c9 100644 --- a/docs/reference/brick/button/was-pressed.md +++ b/docs/reference/brick/button/was-pressed.md @@ -33,7 +33,7 @@ Read about [touch sensors](/reference/sensors/touch-sensor) and using them as to Set the brick light to green if the `right` button was pressed before the `left` button. If not, the brick light is turned off when the `left` button is pressed. ```blocks -brick.buttonLeft.onEvent(ButtonEvent.Click, function() { +brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() { if (brick.buttonRight.wasPressed()) { brick.setLight(BrickLight.Green) } else { diff --git a/docs/reference/brick/show-string.md b/docs/reference/brick/show-string.md index 31331b61..59bafbf0 100644 --- a/docs/reference/brick/show-string.md +++ b/docs/reference/brick/show-string.md @@ -18,7 +18,7 @@ Show a greeting on the screen. Then, respond with another message when ENTER is ```blocks brick.showString("Hello, I dare you to", 1); brick.showString("press ENTER...", 2); -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { brick.showString("Hey! Don't push my", 4); brick.showString("buttons.", 5); }); diff --git a/docs/reference/brick/show-value.md b/docs/reference/brick/show-value.md index 1f71d16e..e1e7dc72 100644 --- a/docs/reference/brick/show-value.md +++ b/docs/reference/brick/show-value.md @@ -3,7 +3,7 @@ Show a name-value-pair on the screen at the line you select. ```sig -brick.showNumber("item", 0, 1); +brick.showValue("item", 0, 1); ``` Name-value-pairs are used to report data values to the screen. If you want to show the current temperature on the screen, you might use `"temp"` as the data name for the the value. @@ -19,7 +19,7 @@ Name-value-pairs are used to report data values to the screen. If you want to sh Show the current amount of ambient light detected by sensor 2. ```blocks -brick.buttonEnter.onEvent(ButtonEvent.Click, function () { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () { brick.showValue("color", sensors.color2.light(LightIntensityMode.Ambient), 1) }) ``` diff --git a/docs/static/configurations/chrome-version.png b/docs/static/configurations/chrome-version.png new file mode 100644 index 00000000..b7a4db67 Binary files /dev/null and b/docs/static/configurations/chrome-version.png differ diff --git a/docs/static/configurations/edge-version.png b/docs/static/configurations/edge-version.png new file mode 100644 index 00000000..f9c9095a Binary files /dev/null and b/docs/static/configurations/edge-version.png differ diff --git a/docs/static/configurations/firefox-version.png b/docs/static/configurations/firefox-version.png new file mode 100644 index 00000000..d9b5684c Binary files /dev/null and b/docs/static/configurations/firefox-version.png differ diff --git a/docs/static/configurations/ie-version.png b/docs/static/configurations/ie-version.png new file mode 100644 index 00000000..3fbc6e7c Binary files /dev/null and b/docs/static/configurations/ie-version.png differ diff --git a/docs/static/configurations/osx-version.png b/docs/static/configurations/osx-version.png new file mode 100644 index 00000000..9457d7e4 Binary files /dev/null and b/docs/static/configurations/osx-version.png differ diff --git a/docs/static/configurations/safari-version.png b/docs/static/configurations/safari-version.png new file mode 100644 index 00000000..70d1d871 Binary files /dev/null and b/docs/static/configurations/safari-version.png differ diff --git a/docs/static/configurations/windows-version.png b/docs/static/configurations/windows-version.png new file mode 100644 index 00000000..06847ede Binary files /dev/null and b/docs/static/configurations/windows-version.png differ diff --git a/docs/static/lego-logo-white.svg b/docs/static/lego-logo-white.svg new file mode 100644 index 00000000..45039fc5 --- /dev/null +++ b/docs/static/lego-logo-white.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index ecb933b9..dd5759db 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -9,9 +9,9 @@ "BrickLight.RedFlash|block": "red flash", "BrickLight.RedPulse|block": "red pulse", "BrickLight.Red|block": "red", - "ButtonEvent.Click|block": "click", - "ButtonEvent.Down|block": "down", - "ButtonEvent.Up|block": "up", + "ButtonEvent.Bumped|block": "bumped", + "ButtonEvent.Pressed|block": "pressed", + "ButtonEvent.Released|block": "released", "MoveUnit.Degrees|block": "degrees", "MoveUnit.MilliSeconds|block": "milliseconds", "MoveUnit.Rotations|block": "rotations", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index a1c6524b..47cc4095 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -29,14 +29,15 @@ const enum BrickLight { * User interaction on buttons */ const enum ButtonEvent { - //% block="click" - Click = 1, - //% block="up" - Up = 3, - //% block="down" - Down = 4, + //% block="pressed" + Pressed = 4, + //% block="bumped" + Bumped = 1, + //% block="released" + Released = 3, } + namespace brick { /** * Generic button class, for device buttons and sensors. @@ -62,12 +63,12 @@ namespace brick { if (curr) { this._wasPressed = true; this.downTime = control.millis() - control.raiseEvent(this._id, ButtonEvent.Down) + control.raiseEvent(this._id, ButtonEvent.Pressed) } else { - control.raiseEvent(this._id, ButtonEvent.Up) + control.raiseEvent(this._id, ButtonEvent.Released) const delta = control.millis() - this.downTime; if (delta < 500) - control.raiseEvent(this._id, ButtonEvent.Click) + control.raiseEvent(this._id, ButtonEvent.Bumped) } } diff --git a/libs/core/console.ts b/libs/core/console.ts index cb220ae3..5f0a6afe 100644 --- a/libs/core/console.ts +++ b/libs/core/console.ts @@ -66,8 +66,8 @@ namespace console.screen { if (!lines) { lines = []; console.addListener(log); - brick.buttonUp.onEvent(ButtonEvent.Click, () => scroll(-3)) - brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(3)) + brick.buttonUp.onEvent(ButtonEvent.Bumped, () => scroll(-3)) + brick.buttonDown.onEvent(ButtonEvent.Bumped, () => scroll(3)) } } diff --git a/libs/core/test.ts b/libs/core/test.ts index 516462b3..d050a8d5 100644 --- a/libs/core/test.ts +++ b/libs/core/test.ts @@ -6,25 +6,25 @@ brick.setLight(BrickLight.Orange) brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent) -brick.buttonEnter.onEvent(ButtonEvent.Click, () => { +brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => { screen.clear() }) -brick.buttonLeft.onEvent(ButtonEvent.Click, () => { +brick.buttonLeft.onEvent(ButtonEvent.Bumped, () => { brick.drawRect(10, 70, 20, 10, Draw.Fill) brick.setLight(BrickLight.Red) brick.setFont(brick.microbitFont()) }) -brick.buttonRight.onEvent(ButtonEvent.Click, () => { +brick.buttonRight.onEvent(ButtonEvent.Bumped, () => { brick.print("Right!", 10, 60) }) -brick.buttonDown.onEvent(ButtonEvent.Click, () => { +brick.buttonDown.onEvent(ButtonEvent.Bumped, () => { brick.print("Down! ", 10, 60) }) -brick.buttonUp.onEvent(ButtonEvent.Click, () => { +brick.buttonUp.onEvent(ButtonEvent.Bumped, () => { brick.print("Up! ", 10, 60) }) diff --git a/libs/touch-sensor/_locales/touch-sensor-jsdoc-strings.json b/libs/touch-sensor/_locales/touch-sensor-jsdoc-strings.json index 17eeba45..01b88843 100644 --- a/libs/touch-sensor/_locales/touch-sensor-jsdoc-strings.json +++ b/libs/touch-sensor/_locales/touch-sensor-jsdoc-strings.json @@ -1,5 +1,4 @@ { - "TouchSensorEvent": "Touch sensor interactions", "sensors.TouchSensor.isPressed": "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", diff --git a/libs/touch-sensor/_locales/touch-sensor-strings.json b/libs/touch-sensor/_locales/touch-sensor-strings.json index a94831c2..bd00d034 100644 --- a/libs/touch-sensor/_locales/touch-sensor-strings.json +++ b/libs/touch-sensor/_locales/touch-sensor-strings.json @@ -1,7 +1,4 @@ { - "TouchSensorEvent.Bumped|block": "bumped", - "TouchSensorEvent.Pressed|block": "pressed", - "TouchSensorEvent.Released|block": "released", "sensors.TouchSensor.isPressed|block": "%sensor|is pressed", "sensors.TouchSensor.onEvent|block": "on %sensor|%event", "sensors.TouchSensor.pauseUntil|block": "pause until %sensor|%event", diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor.md index 44565555..28e33cd3 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor.md @@ -1,7 +1,7 @@ # Touch Sensor ```cards -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { brick.showImage(images.expressionsBigSmile) }) sensors.touch1.isPressed(); diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor/on-event.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor/on-event.md index fc6d013a..6b87172b 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor/on-event.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor/on-event.md @@ -1,7 +1,7 @@ # On Event ```sig -sensors.touch1.onEvent(TouchSensorEvent.Released, function () { }) +sensors.touch1.onEvent(ButtonEvent.Released, function () { }) ``` # Parameters @@ -10,7 +10,7 @@ sensors.touch1.onEvent(TouchSensorEvent.Released, function () { }) ```blocks -sensors.touch1.onEvent(TouchSensorEvent.Released, function () { +sensors.touch1.onEvent(ButtonEvent.Released, function () { brick.showImage(images.expressionsSick) }) ``` diff --git a/libs/touch-sensor/test.ts b/libs/touch-sensor/test.ts index 53a7ea2c..1ac729aa 100644 --- a/libs/touch-sensor/test.ts +++ b/libs/touch-sensor/test.ts @@ -1,8 +1,8 @@ -sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(ButtonEvent.Pressed, function () { }) -sensors.touch2.onEvent(TouchSensorEvent.Bumped, function () { +sensors.touch2.onEvent(ButtonEvent.Bumped, function () { }) -sensors.touch3.onEvent(TouchSensorEvent.Released, function () { +sensors.touch3.onEvent(ButtonEvent.Released, function () { }) sensors.touch4.isPressed(); sensors.touch4.wasPressed(); diff --git a/libs/touch-sensor/touch.ts b/libs/touch-sensor/touch.ts index 2be12d78..088f8a0f 100644 --- a/libs/touch-sensor/touch.ts +++ b/libs/touch-sensor/touch.ts @@ -1,17 +1,5 @@ // keep TouchSensorEvent in sync with ButtonEvent -/** - * Touch sensor interactions - */ -const enum TouchSensorEvent { - //% block="pressed" - Pressed = 4, - //% block="bumped" - Bumped = 1, - //% block="released" - Released = 3, -} - namespace sensors { //% fixedInstances @@ -48,8 +36,8 @@ namespace sensors { //% sensor.fieldEditor="ports" //% weight=99 blockGap=8 //% group="Touch Sensor" - onEvent(ev: TouchSensorEvent, body: () => void) { - this.button.onEvent(ev, body) + onEvent(ev: ButtonEvent, body: () => void) { + this.button.onEvent(ev, body) } /** @@ -64,7 +52,7 @@ namespace sensors { //% sensor.fieldEditor="ports" //% weight=98 blockGap=8 //% group="Touch Sensor" - pauseUntil(ev: TouchSensorEvent) { + pauseUntil(ev: ButtonEvent) { this.button.pauseUntil(ev); } diff --git a/tests/colors.ts b/tests/colors.ts index 15d6d02f..f12988f6 100644 --- a/tests/colors.ts +++ b/tests/colors.ts @@ -1,7 +1,7 @@ tests.test("Detect color red", function () { brick.print("Point sensor to red", 0, 50) brick.print("and click enter", 0, 60) - brick.buttonEnter.pauseUntil(ButtonEvent.Click) + brick.buttonEnter.pauseUntil(ButtonEvent.Bumped) brick.clearScreen() let actualColor = sensors.color1.color() tests.assertClose("Color", actualColor, ColorSensorColor.Red, 0) @@ -10,7 +10,7 @@ tests.test("Detect color red", function () { tests.test("Bright ambient light", function () { brick.print("Point sensor to ceiling", 0, 50) brick.print("light and click enter", 0, 60) - brick.buttonEnter.pauseUntil(ButtonEvent.Click) + brick.buttonEnter.pauseUntil(ButtonEvent.Bumped) brick.clearScreen() let actualLight: number for (let i = 0; i < 4; i++) { @@ -24,7 +24,7 @@ tests.test("Bright reflected light", function () { brick.print("Point sensor to white", 0, 50) brick.print("desk surface", 0, 60) brick.print("and click enter", 0, 70) - brick.buttonEnter.pauseUntil(ButtonEvent.Click) + brick.buttonEnter.pauseUntil(ButtonEvent.Bumped) brick.clearScreen() let actualLight: number for (let i = 0; i < 4; i++) { diff --git a/tests/touch.ts b/tests/touch.ts index 238865b2..6abc069c 100644 --- a/tests/touch.ts +++ b/tests/touch.ts @@ -1,7 +1,7 @@ tests.test("Touch sensor pressed", function () { brick.print("Press touch sensor", 0, 50) brick.print("and click enter", 0, 60) - brick.buttonEnter.pauseUntil(ButtonEvent.Click) + brick.buttonEnter.pauseUntil(ButtonEvent.Bumped) brick.clearScreen() tests.assert("Pressed", sensors.touch1.isPressed()) }) \ No newline at end of file diff --git a/tests/ultrasonic.ts b/tests/ultrasonic.ts index f431496b..32bb95ab 100644 --- a/tests/ultrasonic.ts +++ b/tests/ultrasonic.ts @@ -3,7 +3,7 @@ tests.test("Ultrasonic sensor", function () { brick.print("one finger's length", 0, 60) brick.print("in front of sensor", 0, 70) brick.print("and click enter", 0, 80) - brick.buttonEnter.pauseUntil(ButtonEvent.Click) + brick.buttonEnter.pauseUntil(ButtonEvent.Bumped) brick.clearScreen() tests.assertClose("Distance", sensors.ultrasonic1.distance(), 7, 6) }) \ No newline at end of file