diff --git a/docs/contact.md b/docs/contact.md index 0908eff4..107530f3 100644 --- a/docs/contact.md +++ b/docs/contact.md @@ -2,4 +2,4 @@ * Have a question, or running into an issue? Check out the [micro:bit Support Forums](https://support.microbit.org/). * Want to get involved with the micro:bit developer community? [Get involved here](https://tech.microbit.org/get-involved/where-to-find/). -* Think you've found a bug on MakeCode for micro:bit? File it [here](https://github.com/Microsoft/pxt-microbit/issues/new?labels=bug). \ No newline at end of file +* Think you've found a bug on MakeCode for micro:bit? File it [here](https://github.com/Microsoft/pxt-microbit/issues/new?template=bug_report.md). diff --git a/docs/device/pins.md b/docs/device/pins.md index f77013e8..5dc9631e 100644 --- a/docs/device/pins.md +++ b/docs/device/pins.md @@ -41,7 +41,7 @@ Unlike the three large pins that are dedicated to being used for external connec * **pin 3**: GPIO shared with LED Col 1 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off. * **pin 4**: GPIO shared with LED Col 2 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off. -* **pin 5**: GPIO shared with Button A. This lets you trigger or detect a button "A" click externally. This pin has a pull-up resistor, which means that by default it is at voltage of 3V. To replace button A on the micro:bit with an external button, connect one end of the external button to pin 4 and the other end to GND. When the button is pressed, the voltage on pin 4 is pulled down to 0, which generates a button click event. +* **pin 5**: GPIO shared with Button A. This lets you trigger or detect a button "A" click externally. This pin has a pull-up resistor, which means that by default it is at voltage of 3V. To replace button A on the micro:bit with an external button, connect one end of the external button to pin 5 and the other end to GND. When the button is pressed, the voltage on pin 5 is pulled down to 0, which generates a button click event. * **pin 6**: GPIO shared with LED Col 9 of the LED screen; can be used for digital I/O when the LED screen is turned off. * **pin 7**: GPIO shared with LED Col 8 of the LED screen; can be used for digital I/O when the LED screen is turned off. * **pin 8**: Dedicated GPIO, for sending and sensing digital signals. diff --git a/docs/device/screen.md b/docs/device/screen.md index fac371d6..52f6812d 100644 --- a/docs/device/screen.md +++ b/docs/device/screen.md @@ -1,7 +1,5 @@ # LED screen -The micro:bit LED screen - ```sim basic.showLeds(` # . # . # @@ -12,7 +10,7 @@ The micro:bit LED screen `); ``` -The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down). +The micro:bit LED screen has 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down). In the screen above, we created a checkerboard pattern using the LEDs. ## Which LED? @@ -35,7 +33,7 @@ Here are the x, y coordinates for the LEDs in the 5X5 grid: `(0,4)` `(1,4)` `(2,4)` `(3,4)` `(4,4)` -The x, y coordinates for the LED in the centre of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows. +The x, y coordinates for the LED in the center of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows. ## Check your understanding @@ -71,11 +69,11 @@ if(led.point(0,0)) { ## Display images, strings and numbers -Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text/numbers on screen using the [show number](/reference/basic/show-number)/[show string](/reference/basic/show-string) function. +Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text and numbers on screen using the [show number](/reference/basic/show-number) and [show string](/reference/basic/show-string) functions. ## The display buffer -The micro:bit runtime keeps an in-memory representation of the state of all 25 LEDS. This state is known as the "display buffer" and controls which LEDS are on and which are off. The plot/unplot/point functions access the display buffer directly. On the other hand, the functions that show an image, number or string overwrite the buffer completely. To illustrate, first try running this code sequence +The micro:bit runtime keeps a representation of the state of all 25 LEDS in memory. This state is known as the "display buffer" and controls which LEDs are on and which are off. The plot, unplot, and point functions access the display buffer directly. On the other hand, the functions that show an image, number, or string overwrite the buffer completely. To illustrate this, first try running this code sequence ```blocks basic.showString("d") @@ -86,15 +84,14 @@ You will see the letter "d" displayed as well as the LED in position `0,0` lit u ```blocks led.plot(0, 0) -basic.showString("d", 150) +basic.showString("d") ``` You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer. - ## Pins: P3, P4, P6, P7, P9, P10 -These pins are coupled to the LED matrix display, and also it’s associated ambient light sensing mode. +These pins are coupled to the LED matrix display and also to the display's associated ambient light sensing mode. To disable the display driver feature (which will automatically disable the light sensing feature) use the function [led.enable](/reference/led/enable). More information at http://tech.microbit.org/hardware/edgeconnector_ds/ . diff --git a/docs/device/simulator.md b/docs/device/simulator.md index e517e900..f1f99a0d 100644 --- a/docs/device/simulator.md +++ b/docs/device/simulator.md @@ -1,7 +1,7 @@ # Simulator -The JavaScript simulator allows to test and execute most BBC micro:bit programs in the browser. -It allows to emulate sensor data or user interactions. +The JavaScript simulator allows you to test and execute most BBC micro:bit programs in the browser. +It allows you to emulate sensor data or user interactions. ```sim input.onButtonPressed(Button.A, () => { @@ -22,4 +22,4 @@ input.onPinPressed(TouchPin.P2, () => { input.temperature() input.compassHeading() input.lightLevel() -``` \ No newline at end of file +``` diff --git a/docs/examples/radio-dashboard.md b/docs/examples/radio-dashboard.md index d99c4f3a..d4291cbf 100644 --- a/docs/examples/radio-dashboard.md +++ b/docs/examples/radio-dashboard.md @@ -4,7 +4,7 @@ /** * Radio monitoring dashboard * - * Each radio client is represented by a dot on the screen. + * Each radio client is represented by a dot on the screen. * Once a client is registered, it will stay at the same pixel location * forever. * @@ -31,16 +31,16 @@ const clients: Client[] = []; /* lazy allocate sprite */ function getClient(id: number): Client { - // needs an id to track radio client identity + // needs an id to track radio client's identity if (!id) return undefined; - // look for cache clients + // look for cached clients for (const client of clients) if (client.id == id) return client; const n = clients.length; - if (n == 24) // out of pixels + if (n == 24) // out of pixels return undefined; const client: Client = { id: id, @@ -87,4 +87,4 @@ game.addScore(1) ```package radio -``` \ No newline at end of file +``` diff --git a/docs/lessons/counter/challenges.md b/docs/lessons/counter/challenges.md index c2edef8b..515027a7 100644 --- a/docs/lessons/counter/challenges.md +++ b/docs/lessons/counter/challenges.md @@ -31,7 +31,7 @@ input.onButtonPressed(Button.B, () => { }) ``` -## Challenge 3 +## Challenge 2 Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`. diff --git a/docs/lessons/game-counter/challenges.md b/docs/lessons/game-counter/challenges.md index 9b61dbfb..fe791c79 100644 --- a/docs/lessons/game-counter/challenges.md +++ b/docs/lessons/game-counter/challenges.md @@ -31,7 +31,7 @@ input.onButtonPressed(Button.B, () => { ``` -## Challenge 3 +## Challenge 2 Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`. diff --git a/docs/lessons/night-light/challenges.md b/docs/lessons/night-light/challenges.md index cfa680bc..7d2771ef 100644 --- a/docs/lessons/night-light/challenges.md +++ b/docs/lessons/night-light/challenges.md @@ -46,6 +46,6 @@ input.onButtonPressed(Button.B, () => { ``` -## Challenge 3 +## Challenge 2 Add an event handler with `on shake` to change the LED brightness back to a `255`. diff --git a/docs/lessons/snowflake-fall/challenges.md b/docs/lessons/snowflake-fall/challenges.md index 77bf278a..1311c993 100644 --- a/docs/lessons/snowflake-fall/challenges.md +++ b/docs/lessons/snowflake-fall/challenges.md @@ -62,7 +62,7 @@ basic.forever(() => { * Run your program and see if it works. -## Challenge 3 +## Challenge 2 Add a fourth frame to the current animation... or make it your own! diff --git a/docs/projects/fireflies.md b/docs/projects/fireflies.md index 6f503c0a..a9dc61ea 100644 --- a/docs/projects/fireflies.md +++ b/docs/projects/fireflies.md @@ -82,14 +82,18 @@ basic.forever(() => { }) ``` -When a firefly receives a radio packet, it increments its clock by one: +When a firefly receives a radio packet +**and** it is not sending packet +, it increments its clock by one: ```block // the clock ticker let clock = 0 radio.onReceivedNumber(function (receivedNumber) { // advance clock to catch up neighbors - clock += 1 + if (clock < 8) { + clock += 1 + } }) ``` diff --git a/docs/projects/guitar/lightsensor.md b/docs/projects/guitar/lightsensor.md index 77767b30..4a54f8d7 100644 --- a/docs/projects/guitar/lightsensor.md +++ b/docs/projects/guitar/lightsensor.md @@ -79,7 +79,7 @@ music.playTone(261, music.beat(BeatFraction.Half)) ## ~ ## Step 3: Multiply Frequency using Math blocks - ```blocks +```blocks input.onButtonPressed(Button.A, () => { music.playTone(261 * 2, music.beat(BeatFraction.Half)) }) diff --git a/docs/projects/karel.md b/docs/projects/karel.md index 43ec09fa..8800a16a 100644 --- a/docs/projects/karel.md +++ b/docs/projects/karel.md @@ -11,7 +11,7 @@ Help Karel make LED art! ![](/static/mb/projects/karel/hi.png "Hi") The goal of this activity is to download the JavaScript code given below onto a @boardname@. -Then USE the program to introduce new students to the @boardname@. +Then use the program to introduce new students to the @boardname@. Students will not do the coding this time. They will be the users who get familiar with the board. ## How to play @@ -95,6 +95,8 @@ Thanks for playing with Karel the LED! Copy this code into the JavaScript editor and then download it to the board. +**Note:** For this project you need to manually copy the code and insert it into the JavaScript view of the editor. + ```typescript /** * Karel the LED diff --git a/docs/projects/magic-button-trick.md b/docs/projects/magic-button-trick.md index 0729f6ab..0300972b 100644 --- a/docs/projects/magic-button-trick.md +++ b/docs/projects/magic-button-trick.md @@ -98,6 +98,8 @@ input.onButtonPressed(Button.B, () => { Now you just need to program your own @boardname@ and practice the trick a few times before performing for your friends. Try asking your friends to click the buttons after you have switched the labels and the trick won't work for them because they don't have a hidden magnet in their hand! +Remember, that as we are using @boardname@'s compass, it will need to be [calibrated](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass-what-does-it-mean-when-the-micro-bit-says-draw-a-circle-or-tilt) each time we flash the program or run it for the first time. + ## About the authors -This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can checkout their [MicroMonsters](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) tutorials channel on YouTube for more projects. \ No newline at end of file +This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can checkout their [MicroMonsters](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) tutorials channel on YouTube for more projects. diff --git a/docs/projects/plant-watering.md b/docs/projects/plant-watering.md index 23561597..bc829f3a 100644 --- a/docs/projects/plant-watering.md +++ b/docs/projects/plant-watering.md @@ -20,7 +20,7 @@ This is a follow up of the **[soil moisture project](/projects/soil-moisture)**. * 1 @boardname@ with battery pack and batteries * 2 long nails or silver * 2 crocodile clips -* 1 micro servo + 3 female-to-croc clips +* 1 micro servo + 3 male-to-croc clips * 1 ice cream wooden stick * 2 elastics * 1 clear tape roll diff --git a/docs/reference/basic/show-string.md b/docs/reference/basic/show-string.md index 009ee6fa..80d831a9 100644 --- a/docs/reference/basic/show-string.md +++ b/docs/reference/basic/show-string.md @@ -1,6 +1,6 @@ # Show String -Show a sting on the [LED screen](/device/screen). It will slide left if it is bigger than the screen. +Show a string on the [LED screen](/device/screen). It will scroll to left if it's bigger than the screen. ```sig basic.showString("Hello!") diff --git a/docs/reference/bluetooth/advertise-uid-buffer.md b/docs/reference/bluetooth/advertise-uid-buffer.md index 8966e5d9..f4219e85 100644 --- a/docs/reference/bluetooth/advertise-uid-buffer.md +++ b/docs/reference/bluetooth/advertise-uid-buffer.md @@ -1,4 +1,4 @@ -# Avertise UID Buffer +# Advertise UID Buffer Advertises a UID via the Eddystone protocol over Bluetooth. diff --git a/docs/reference/bluetooth/advertise-uid.md b/docs/reference/bluetooth/advertise-uid.md index 9b0efc83..710b677d 100644 --- a/docs/reference/bluetooth/advertise-uid.md +++ b/docs/reference/bluetooth/advertise-uid.md @@ -1,4 +1,4 @@ -# Avertise UID +# Advertise UID Advertises a UID via the Eddystone protocol over Bluetooth. diff --git a/docs/reference/bluetooth/advertise-url.md b/docs/reference/bluetooth/advertise-url.md index 04973597..45a687f1 100644 --- a/docs/reference/bluetooth/advertise-url.md +++ b/docs/reference/bluetooth/advertise-url.md @@ -1,4 +1,4 @@ -# Avertise Url +# Advertise Url Advertises a URL via the Eddystone protocol over Bluetooth. diff --git a/docs/reference/devices/on-notified.md b/docs/reference/devices/on-notified.md index d96c34aa..8f86bb19 100644 --- a/docs/reference/devices/on-notified.md +++ b/docs/reference/devices/on-notified.md @@ -1,4 +1,4 @@ -# On Signal Strength Changed +# On Notified Register code to run when the signal strength of the paired device changes. @@ -8,8 +8,6 @@ Register code to run when the signal strength of the paired device changes. ## ~ - - ```sig devices.onNotified(MesDeviceInfo.IncomingCall, () => {}) ``` diff --git a/docs/reference/devices/tell-camera-to.md b/docs/reference/devices/tell-camera-to.md index 31c0bda1..3870d785 100644 --- a/docs/reference/devices/tell-camera-to.md +++ b/docs/reference/devices/tell-camera-to.md @@ -21,47 +21,47 @@ devices.tellCameraTo(MesCameraEvent.TakePhoto) To tell the connected device to take a picture: +```blocks +devices.tellCameraTo(MesCameraEvent.TakePhoto) +``` + +To tell the connected device to start recording a video: + ```blocks devices.tellCameraTo(MesCameraEvent.StartVideoCapture) ``` -To tell the connected device to start recording a video +To tell the connected device to stop recording a video: ```blocks devices.tellCameraTo(MesCameraEvent.StopVideoCapture) ``` -To tell the connected device to stop recording a video +To tell the connected device to toggle front-rear: ```blocks devices.tellCameraTo(MesCameraEvent.ToggleFrontRear) ``` -To tell the connected device to toggle front-rear +To tell the connected device to launch photo mode: ```blocks devices.tellCameraTo(MesCameraEvent.LaunchPhotoMode) ``` -To tell the connected device to launch photo mode - -```blocks -devices.tellCameraTo(MesCameraEvent.LaunchPhotoMode) -``` - -To tell the connected device to launch video mode +To tell the connected device to launch video mode: ```blocks devices.tellCameraTo(MesCameraEvent.LaunchVideoMode) ``` -To tell the connected device to stop photo mode +To tell the connected device to stop photo mode: ```blocks devices.tellCameraTo(MesCameraEvent.StopPhotoMode) ``` -To tell the connected device to stop video mode +To tell the connected device to stop video mode: ```blocks devices.tellCameraTo(MesCameraEvent.StopVideoMode) diff --git a/docs/reference/input/rotation.md b/docs/reference/input/rotation.md index 979f6fab..85da572a 100644 --- a/docs/reference/input/rotation.md +++ b/docs/reference/input/rotation.md @@ -19,7 +19,7 @@ check how the @boardname@ is moving. ## Returns -* a [number](/types/number) that means how much the microbit is tilted in the direction you say, from `-180` to `180` degrees +* a [number](/types/number) that means how much the microbit is tilted in the direction you say; for `Rotation.Pitch` from `-90` to `90` degrees and for `Rotation.Roll` from `-180` to `180` degrees. ## Example: @boardname@ leveler diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index e839c70d..84bb93b3 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -191,7 +191,7 @@ "basic.showAnimation": "Shows a sequence of LED screens as an animation.", "basic.showAnimation|param|interval": "time in milliseconds between each redraw", "basic.showAnimation|param|leds": "pattern of LEDs to turn on/off", - "basic.showArrow": "Shows an arrow on screent", + "basic.showArrow": "Draws an arrow on the LED screen", "basic.showArrow|param|direction": "the direction of the arrow", "basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.", "basic.showIcon": "Draws the selected icon on the LED screen", @@ -513,4 +513,4 @@ "serial.writeValue": "Write a name:value pair as a line to the serial port.", "serial.writeValue|param|name": "name of the value stream, eg: x", "serial.writeValue|param|value": "to write" -} \ No newline at end of file +} diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index e3b818b5..ab196a1f 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -326,8 +326,8 @@ "pins.analogWritePin|block": "analog write|pin %name|to %value", "pins.digitalReadPin|block": "digital read|pin %name", "pins.digitalWritePin|block": "digital write|pin %name|to %value", - "pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof|repeated %repeat", - "pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof|repeated %repeat", + "pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format|repeated %repeat", + "pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format|repeated %repeat", "pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh", "pins.onPulsed|block": "on|pin %pin|pulsed %pulse", "pins.pulseDuration|block": "pulse duration (µs)", diff --git a/libs/core/icons.ts b/libs/core/icons.ts index 23bf9ccf..2e8cff7a 100644 --- a/libs/core/icons.ts +++ b/libs/core/icons.ts @@ -189,7 +189,7 @@ namespace basic { } /** - * Shows an arrow on screent + * Draws an arrow on the LED screen * @param direction the direction of the arrow * @param interval the amount of time (milliseconds) to show the icon. Default is 600. */ diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index d6e5d5b5..ad7fea9a 100644 --- a/libs/core/pins.cpp +++ b/libs/core/pins.cpp @@ -381,9 +381,9 @@ namespace pins { * Write bytes to a 7-bit I2C `address`. */ //% - void i2cWriteBuffer(int address, Buffer buf, bool repeat = false) + int void i2cWriteBuffer(int address, Buffer buf, bool repeat = false) { - uBit.i2c.write(address << 1, (char*)buf->data, buf->length, repeat); + return uBit.i2c.write(address << 1, (char*)buf->data, buf->length, repeat); } SPI* spi = NULL; diff --git a/libs/core/pins.ts b/libs/core/pins.ts index bb1ee981..3613c965 100644 --- a/libs/core/pins.ts +++ b/libs/core/pins.ts @@ -22,7 +22,7 @@ namespace pins { * Read one number from 7-bit I2C address. */ //% help=pins/i2c-read-number blockGap=8 advanced=true - //% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof|repeated %repeat" weight=7 + //% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format|repeated %repeat" weight=7 export function i2cReadNumber(address: number, format: NumberFormat, repeated?: boolean): number { let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), repeated) return buf.getNumber(format, 0) @@ -32,7 +32,7 @@ namespace pins { * Write one number to a 7-bit I2C address. */ //% help=pins/i2c-write-number blockGap=8 advanced=true - //% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof|repeated %repeat" weight=6 + //% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format|repeated %repeat" weight=6 export function i2cWriteNumber(address: number, value: number, format: NumberFormat, repeated?: boolean): void { let buf = createBuffer(pins.sizeOf(format)) buf.setNumber(format, 0, value) diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 36288cf8..56124c4d 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -728,7 +728,7 @@ declare namespace pins { * Write bytes to a 7-bit I2C `address`. */ //% repeat.defl=0 shim=pins::i2cWriteBuffer - function i2cWriteBuffer(address: int32, buf: Buffer, repeat?: boolean): void; + function i2cWriteBuffer(address: int32, buf: Buffer, repeat?: boolean): int32; /** * Write to the SPI slave and return the response