Cherry picked fixes from v0 to v1 (#1476)
* Fix example and do a few edits (#850) * Small fixes to the Karel project text (#862) * fix missing shadow type * add calibration info (#897) microbit-support:6348 User reported bug, but didn't realie micro:bit compass had to be calibrated on first run of the program. * Cherry pick adding various cross-editor compat APIs (#863) * fix nudge * Fix a typo ("screent") in the documentation (#1012) * Fix a typo "screent" -> "the LED screen" * Update showArrow doc string for consistency with other methods * Doc bugs found by xlators (#899) * Update rotation.md (#998) reflects actual behaviour of the board * fixed layout corruption (#1073) * Updating the new bug filer with the right link * Update challenges.md (#1325) For what I'm taught in school, 2 follows 1 😉😉. * Update simulator.md (#1209) * Update plant watering.md (#1264) the connection to servo are male not female * support for MIDI simulator in v0 (#1331) * Doc improvements (#1337) * update grammar in radio-dashboard sample code * Chanllenge 2 follows 1 I open all challenges.md without "Challenge 2" and review the file `grep -r "Challenge 2" -L | grep challenge | xargs -I@ code @` Changes to be committed: modified: docs/lessons/counter/challenges.md modified: docs/lessons/game-counter/challenges.md modified: docs/lessons/night-light/challenges.md modified: docs/lessons/snowflake-fall/challenges.md * Revert "support for MIDI simulator in v0 (#1331)" This reverts commit 30a9c411fb80762656e7a636feff8e77b7fd9e67. * Revert "Cherry pick adding various cross-editor compat APIs (#863)" This reverts commit 7308dbef23e9ee402bebb7e721d7014d8252c9e5. * Fixed pin needed to replace button A (#1385) * Cherry pick part of the signature update in in2cWriteBuffer (#863): 7308dbe
This commit is contained in:
parent
ffe59b9d89
commit
be7858cbed
@ -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).
|
||||
* 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).
|
||||
|
@ -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.
|
||||
|
@ -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/ .
|
||||
|
@ -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()
|
||||
```
|
||||
```
|
||||
|
@ -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
|
||||
```
|
||||
```
|
||||
|
@ -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`.
|
||||
|
||||
|
@ -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`.
|
||||
|
||||
|
@ -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`.
|
||||
|
@ -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!
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -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))
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
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.
|
||||
|
@ -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
|
||||
|
@ -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!")
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Avertise UID Buffer
|
||||
# Advertise UID Buffer
|
||||
|
||||
Advertises a UID via the Eddystone protocol over Bluetooth.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Avertise UID
|
||||
# Advertise UID
|
||||
|
||||
Advertises a UID via the Eddystone protocol over Bluetooth.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Avertise Url
|
||||
# Advertise Url
|
||||
|
||||
Advertises a URL via the Eddystone protocol over Bluetooth.
|
||||
|
||||
|
@ -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, () => {})
|
||||
```
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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)",
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
2
libs/core/shims.d.ts
vendored
2
libs/core/shims.d.ts
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user