From db4ed6daf3118722af75e2d6e70055959571723f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 18 Jan 2018 16:43:16 -0800 Subject: [PATCH] fixing a bunch of snippets --- docs/SUMMARY.md | 36 ++++++++++++++++++- docs/about.md | 22 +++++------- docs/coding/reversing-the-robot-1.md | 4 +-- docs/coding/reversing-the-robot-2.md | 6 ++-- docs/coding/reversing-the-robot-3.md | 6 ++-- docs/coding/roaming-1.md | 12 +++---- docs/coding/roaming-2.md | 12 +++---- docs/examples/happy-unhappy.md | 4 +-- docs/maker/intruder-detector.md | 6 ++-- docs/maker/puppet.md | 12 +++---- docs/maker/security-gadget.md | 4 +-- docs/maker/sound-machine.md | 4 +-- docs/maker/sound-of-color.md | 6 ++-- .../sensors/color-sensor/ambient-light.md | 4 +-- .../reference/sensors/color-sensor/color.md | 4 +-- .../sensors/color-sensor/reflected-light.md | 4 +-- .../docs/reference/sensors/touch-sensor.md | 6 ++-- .../sensors/touch-sensor/is-pressed.md | 6 ++-- .../sensors/touch-sensor/on-event.md | 4 +-- .../sensors/touch-sensor/was-pressed.md | 6 ++-- 20 files changed, 93 insertions(+), 75 deletions(-) diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 95b39581..bdd6b09e 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,6 +1,40 @@ # @extends -## Lessons #Lessons +## Projects #projects + +* [Maker](/maker) + * [Sound Machine](/maker/sound-machine) + * [Sound of Color](/maker/sound-of-color) + * [Security Gadget](/maker/security-gadget) + * [Intruder detector](/maker/intruder-detector) + * [Puppet](/maker/puppet) + +* [Coding](/coding) + * [Three Point Turn 1](/coding/three-point-turn-1) + * [Three Point Turn 2](/coding/three-point-turn-2) + * [Three Point Turn 3](/coding/three-point-turn-3) + * [Reversing the robot 1](/coding/reversing-the-robot-1) + * [Reversing the robot 2](/coding/reversing-the-robot-2) + * [Reversing the robot 3](/coding/reversing-the-robot-3) + * [Light the way 1](/coding/light-the-way-1) + * [Light the way 2](/coding/light-the-way-2) + * [Light the way 3](/coding/light-the-way-3) + * [Traffic Lights 1](/coding/traffic-lights-1) + * [Traffic Lights 2](/coding/traffic-lights-2) + * [Traffic Lights 3](/coding/traffic-lights-3) + * [Reverse Beeper 1](/coding/reverse-beeper-1) + * [Reverse Beeper 2](/coding/reverse-beeper-2) + * [Reverse Beeper 3](/coding/reverse-beeper-3) + * [Ignition 1](/coding/ignition-1) + * [Ignition 2](/coding/ignition-2) + * [Ignition 3](/coding/ignition-3) + * [Cruise Control 1](/coding/cruise-control-1) + * [Cruise Control 2](/coding/cruise-control-2) + * [Cruise Control 3](/coding/cruise-control-3) + * [Roaming 1](/coding/roaming-1) + * [Roaming 2](/coding/roaming-2) + +## Lessons #lessons * [Lessons](/lessons) * [Make it move](/lessons/make-it-move) diff --git a/docs/about.md b/docs/about.md index 511ca72d..ac2d9dcc 100644 --- a/docs/about.md +++ b/docs/about.md @@ -6,14 +6,14 @@ Welcome to the **Microsoft MakeCode** editor for the **@boardname@**! You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser: -```block -input.buttonA.onEvent(ButtonEvent.Click, () => { - light.showRing(`blue blue blue blue blue blue blue blue blue blue`) +```blocks +brick.buttonEnter.onEvent(ButtonEvent.Click, () => { + motors.largeA.setSpeed(50) }) ``` ```typescript -input.buttonA.onEvent(ButtonEvent.Click, () => { - light.showRing(`blue blue blue blue blue blue blue blue blue blue`) +brick.buttonEnter.onEvent(ButtonEvent.Click, () => { + motors.largeA.setSpeed(50) }) ``` @@ -22,10 +22,10 @@ The editor work in [most modern browsers](/browsers), work [offline](/offline) o ## [Compile and Flash: Your Program!](/device/usb) When you have your code ready, you connect your @boardname@ to a computer via a USB cable -**then press the reset button** so it appears as a mounted drive (named **CPLAYBOOT**). +so it appears as a mounted drive (named **EV3**). Compilation to machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the binary -program to a **.uf2** file, which you then copy to the **CPLAYBOOT** drive, which flashes the device with the new program. +program to a **.uf2** file, which you then copy to the **EV3** drive, which flashes the device with the new program. ## Simulator: Test Your Code @@ -33,11 +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 -loops.forever(() => { - light.pixels.showAnimation(light.animation(LightAnimation.Rainbow), 1000) +brick.buttonEnter.onEvent(ButtonEvent.Click, () => { + motors.largeA.setSpeed(50) }) ``` - -```package -light -``` diff --git a/docs/coding/reversing-the-robot-1.md b/docs/coding/reversing-the-robot-1.md index a56d5fe4..0da01850 100644 --- a/docs/coding/reversing-the-robot-1.md +++ b/docs/coding/reversing-the-robot-1.md @@ -3,10 +3,10 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Click, function () { motors.largeBC.setSpeed(50) - sensors.touchSensor1.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) motors.largeBC.setSpeed(0) loops.pause(1000) - brick.setLight(LightsPattern.OrangeFlash) + brick.setLight(BrickLight.OrangeFlash) motors.largeBC.setSpeed(-50) loops.pause(2000) motors.largeBC.setSpeed(0) diff --git a/docs/coding/reversing-the-robot-2.md b/docs/coding/reversing-the-robot-2.md index dbc7283c..2088c2b0 100644 --- a/docs/coding/reversing-the-robot-2.md +++ b/docs/coding/reversing-the-robot-2.md @@ -2,12 +2,12 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Click, function () { - sensors.touchSensor1.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) motors.largeBC.setSpeed(50) - sensors.touchSensor2.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch2.pauseUntil(TouchSensorEvent.Pressed) motors.largeBC.setSpeed(0) loops.pause(1000) - brick.setLight(LightsPattern.OrangeFlash) + brick.setLight(BrickLight.OrangeFlash) motors.largeBC.setSpeed(-50) loops.pause(2000) motors.largeBC.setSpeed(0) diff --git a/docs/coding/reversing-the-robot-3.md b/docs/coding/reversing-the-robot-3.md index 883bd9d8..4cf6ff32 100644 --- a/docs/coding/reversing-the-robot-3.md +++ b/docs/coding/reversing-the-robot-3.md @@ -3,14 +3,14 @@ ```blocks brick.buttonEnter.onEvent(ButtonEvent.Click, function () { brick.showImage(images.eyesSleeping) - sensors.touchSensor1.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch1.pauseUntil(TouchSensorEvent.Pressed) brick.showImage(images.eyesNeutral) motors.largeBC.setSpeed(50) - sensors.touchSensor2.pauseUntil(TouchSensorEvent.Pressed) + sensors.touch2.pauseUntil(TouchSensorEvent.Pressed) brick.showImage(images.eyesTiredMiddle) motors.largeBC.setSpeed(0) loops.pause(1000) - brick.setLight(LightsPattern.OrangeFlash) + brick.setLight(BrickLight.OrangeFlash) brick.showImage(images.eyesDizzy) motors.largeBC.setSpeed(-50) loops.pause(2000) diff --git a/docs/coding/roaming-1.md b/docs/coding/roaming-1.md index 8d622159..f11293be 100644 --- a/docs/coding/roaming-1.md +++ b/docs/coding/roaming-1.md @@ -19,17 +19,13 @@ loops.pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { - motors.largeC.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeC.pauseUntilReady() + motors.largeC.setSpeed(50, 360, MoveUnit.Degrees) } else if (d == 3) { - motors.largeB.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeB.pauseUntilReady() + motors.largeB.setSpeed(50, 360, MoveUnit.Degrees) } else if (d == 4) { - motors.largeBC.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeBC.pauseUntilReady() + motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees) } else { - motors.largeBC.setSpeedFor(-50, 360, MoveUnit.Degrees) - motors.largeBC.pauseUntilReady() + motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees) } } music.playSoundEffectUntilDone(sounds.communicationGameOver) diff --git a/docs/coding/roaming-2.md b/docs/coding/roaming-2.md index dcae460f..106d3950 100644 --- a/docs/coding/roaming-2.md +++ b/docs/coding/roaming-2.md @@ -23,17 +23,13 @@ loops.pause(1000) music.playSoundEffectUntilDone(sounds.communicationGo) for (let d of drive) { if (d == 1) { - motors.largeC.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeC.pauseUntilReady() + motors.largeC.setSpeed(50, 360, MoveUnit.Degrees) } else if (d == 3) { - motors.largeB.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeB.pauseUntilReady() + motors.largeB.setSpeed(50, 360, MoveUnit.Degrees) } else if (d == 4) { - motors.largeBC.setSpeedFor(50, 360, MoveUnit.Degrees) - motors.largeBC.pauseUntilReady() + motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees) } else { - motors.largeBC.setSpeedFor(-50, 360, MoveUnit.Degrees) - motors.largeBC.pauseUntilReady() + motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees) } } music.playSoundEffectUntilDone(sounds.communicationGameOver) diff --git a/docs/examples/happy-unhappy.md b/docs/examples/happy-unhappy.md index b799a97d..4e85acdf 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.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { brick.showImage(images.expressionsBigSmile) }) -sensors.touchSensor1.onEvent(TouchSensorEvent.Released, function () { +sensors.touch1.onEvent(TouchSensorEvent.Released, function () { brick.showImage(images.expressionsSick) }) ``` \ No newline at end of file diff --git a/docs/maker/intruder-detector.md b/docs/maker/intruder-detector.md index 7e4bed07..2beb97bd 100644 --- a/docs/maker/intruder-detector.md +++ b/docs/maker/intruder-detector.md @@ -2,10 +2,8 @@ This program will activate an alarm when an object moves in front of the Ultrasonic Sensor. -TODO support for event when value changes - ```blocks -input.ultrasonic4.onObjectNear(function () { - music.playSoundUntilDone(music.sounds(Sounds.PowerUp)) +sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () { + music.playSoundEffectUntilDone(sounds.informationActivate) }) ``` \ No newline at end of file diff --git a/docs/maker/puppet.md b/docs/maker/puppet.md index 231c2e95..be86c0fd 100644 --- a/docs/maker/puppet.md +++ b/docs/maker/puppet.md @@ -4,14 +4,12 @@ Use this program with the Programmable Brick and Large Motor. ```blocks loops.forever(function () { - output.largeMotorA.setPower(30) - output.largeMotorA.on(true) + motors.largeA.setSpeed(30) loops.pause(100) - output.largeMotorA.on(false) - music.playSoundUntilDone(music.sounds(Sounds.PowerUp)) - output.largeMotorA.setPower(-30) - output.largeMotorA.on(true) + motors.largeA.stop() + music.playSoundEffectUntilDone(sounds.animalsCatPurr) + motors.largeA.setSpeed(-30) loops.pause(100) - output.largeMotorA.on(false) + motors.largeA.stop() }) ``` diff --git a/docs/maker/security-gadget.md b/docs/maker/security-gadget.md index c926fc6a..f08bd724 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 -input.touchSensor1.onEvent(TouchSensorEvent.Released, function () { - music.playSoundUntilDone(music.sounds(Sounds.PowerUp)) +sensors.touch1.onEvent(TouchSensorEvent.Released, function () { + music.playSoundEffectUntilDone(sounds.informationActivate); }) ``` \ No newline at end of file diff --git a/docs/maker/sound-machine.md b/docs/maker/sound-machine.md index 0e59174e..30f81e6d 100644 --- a/docs/maker/sound-machine.md +++ b/docs/maker/sound-machine.md @@ -4,9 +4,9 @@ This example program combined with the small model will make a beat and rhythm o ```blocks loops.forever(function () { - output.motorA.on(50) + motors.largeA.setSpeed(50) loops.pause(200) - output.motorA.on(100) + motors.largeA.setSpeed(100) loops.pause(200) }) ``` \ No newline at end of file diff --git a/docs/maker/sound-of-color.md b/docs/maker/sound-of-color.md index 4cfec1e1..746e983a 100644 --- a/docs/maker/sound-of-color.md +++ b/docs/maker/sound-of-color.md @@ -3,13 +3,13 @@ This program will play different sounds when the wheel is rotated. The sound is determined by which color is placed in front of the color Sensor. ```blocks -input.color3.onColorDetected(ColorSensorColor.Blue, function () { +sensors.color3.onColorDetected(ColorSensorColor.Blue, function () { music.playTone(Note.G4, music.beat(BeatFraction.Half)) }) -input.color3.onColorDetected(ColorSensorColor.Red, function () { +sensors.color3.onColorDetected(ColorSensorColor.Red, function () { music.playTone(Note.C5, music.beat(BeatFraction.Half)) }) -input.color3.onColorDetected(ColorSensorColor.Green, function () { +sensors.color3.onColorDetected(ColorSensorColor.Green, function () { music.playTone(Note.D5, music.beat(BeatFraction.Half)) }) ``` \ No newline at end of file diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md b/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md index cc48c745..f9984bbb 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/ambient-light.md @@ -3,9 +3,9 @@ ```blocks loops.forever(function () { if (sensors.color1.ambientLight() > 20) { - brick.setStatusLight(LightsPattern.Green) + brick.setLight(BrickLight.Green) } else { - brick.setStatusLight(LightsPattern.Orange) + brick.setLight(BrickLight.Orange) } }) ``` \ No newline at end of file diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/color.md b/libs/color-sensor/docs/reference/sensors/color-sensor/color.md index f3fe99f9..221c04f9 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/color.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/color.md @@ -3,9 +3,9 @@ ```blocks loops.forever(function () { if (sensors.color1.color() == ColorSensorColor.Green) { - brick.setStatusLight(LightsPattern.Green) + brick.setLight(BrickLight.Green) } else { - brick.setStatusLight(LightsPattern.Orange) + brick.setLight(BrickLight.Orange) } }) ``` \ No newline at end of file diff --git a/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md b/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md index e772654a..7afeb8cf 100644 --- a/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md +++ b/libs/color-sensor/docs/reference/sensors/color-sensor/reflected-light.md @@ -3,9 +3,9 @@ ```blocks loops.forever(function () { if (sensors.color1.reflectedLight() > 20) { - brick.setStatusLight(LightsPattern.Green) + brick.setLight(BrickLight.Green) } else { - brick.setStatusLight(LightsPattern.Orange) + brick.setLight(BrickLight.Orange) } }) ``` \ No newline at end of file diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor.md index 7de9e8bc..44565555 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor.md @@ -1,11 +1,11 @@ # Touch Sensor ```cards -sensors.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () { +sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () { brick.showImage(images.expressionsBigSmile) }) -sensors.touchSensor1.isPressed(); -sensors.touchSensor1.wasPressed(); +sensors.touch1.isPressed(); +sensors.touch1.wasPressed(); ``` ## See Also diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md index 7a1d9d21..2c222120 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor/is-pressed.md @@ -2,10 +2,10 @@ ```blocks loops.forever(function () { - if (sensors.touchSensor1.isPressed()) { - brick.setStatusLight(LightsPattern.Green) + if (sensors.touch1.isPressed()) { + brick.setLight(BrickLight.Green) } else { - brick.setStatusLight(LightsPattern.Orange) + brick.setLight(BrickLight.Orange) } }) ``` \ No newline at end of file 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 2dedf566..fc6d013a 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.touchSensor1.onEvent(TouchSensorEvent.Released, function () { }) +sensors.touch1.onEvent(TouchSensorEvent.Released, function () { }) ``` # Parameters @@ -10,7 +10,7 @@ sensors.touchSensor1.onEvent(TouchSensorEvent.Released, function () { }) ```blocks -sensors.touchSensor1.onEvent(TouchSensorEvent.Released, function () { +sensors.touch1.onEvent(TouchSensorEvent.Released, function () { brick.showImage(images.expressionsSick) }) ``` diff --git a/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md b/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md index 70b94772..2efe7b90 100644 --- a/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md +++ b/libs/touch-sensor/docs/reference/sensors/touch-sensor/was-pressed.md @@ -2,10 +2,10 @@ ```blocks loops.forever(function () { - if (sensors.touchSensor1.wasPressed()) { - brick.setStatusLight(LightsPattern.Green) + if (sensors.touch1.wasPressed()) { + brick.setLight(BrickLight.Green) } else { - brick.setStatusLight(LightsPattern.Orange) + brick.setLight(BrickLight.Orange) } }) ``` \ No newline at end of file