Skip to content

Commit

Permalink
cherry pick mb updates 7.0.12to7.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Amerlander committed Aug 19, 2024
1 parent 7fc3600 commit 6162390
Show file tree
Hide file tree
Showing 52 changed files with 1,268 additions and 516 deletions.
2 changes: 1 addition & 1 deletion docs/courses.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Tutorials, lessons, and mini-courses about programming and computing.
}, {
"name": "Networking with the Calliope mini",
"description": "A series of activities to teach the basics of computer networks.",
"url": "https://microbit.nominetresearch.uk/",
"url": "https://www.digitaltechnologieshub.edu.au/search/networking-with-the-micro-bit/",
"imageUrl": "/static/courses/networking-book.png"
}, {
"name": "SparkFun Videos",
Expand Down
2 changes: 1 addition & 1 deletion docs/projects/hot-potato.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ input.onButtonPressed(Button.A, function () {

## {Step 5}

Inside the ``||loops:while||`` loop, add code to ``||variables:decrease||`` the timer ``||loops:every second||``.
Inside the ``||loops:while||`` loop, add code to ``||variables:decrease||`` the timer for every ``||basic:pause||`` of one second.

```blocks
let timer = 0
Expand Down
14 changes: 7 additions & 7 deletions docs/projects/level.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Level

## Introduction @unplugged
## Is it level? @unplugged

Is your table flat? Use the @boardname@ as a level!

![A level drawing](/static/mb/projects/level.png)


## Step 1
## {Step 1}

Make a variable ``||variables:x||`` and store the ``||input:acceleration x||`` value
in the ``||basic:forever||`` loop.
Expand All @@ -19,7 +19,7 @@ basic.forever(function() {
})
```

## Step 2
## {Step 2}

Make another variable ``||variables:y||`` and store the ``||input:acceleration y||`` value.

Expand All @@ -31,7 +31,7 @@ basic.forever(function() {
})
```

## Step 3
## {Step 3}

Add a code to test ``||logic:if||`` the ``||Math:absolute value||`` of ``||variables:x||`` is ``||logic:greater than||`` ``32``.
If it is true, ``||basic:show an icon||`` to tell you that the @boardname@ is not flat, ``||logic:else||`` show nothing, for now.
Expand All @@ -49,7 +49,7 @@ basic.forever(function() {
})
```

## Step 4
## {Step 4}

Add an ``||logic:else if||`` to check that the ``||Math:absolute value||`` of ``||variables:y||`` is ``||logic:greater than||`` ``32``.
If it is true, ``||basic:show an icon||`` that tells you the @boardname@ is not flat.
Expand All @@ -69,7 +69,7 @@ basic.forever(function() {
})
```

## Step 5
## {Step 5}

The code under the ``||logic:else||`` will run if both acceleration ``x`` and ``y`` are small, which happens when the @boardname@ is laying flat. Add code to ``||basic:show a happy image||``.

Expand All @@ -88,7 +88,7 @@ basic.forever(function() {
})
```

## Step 6
## {Step 6}

If you have a @boardname@ connected, click ``|Download|`` to transfer your code!
Try it out on a table, counter, or window sill in your house!
Expand Down
2 changes: 1 addition & 1 deletion docs/projects/plot-acceleration.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ basic.forever(function() {

## Other sensors

You can use this block for pretty much any kind of data. Try it out! Plot the ``||input:light level||`` inside the ``||loops:forever||`` instead. Play with the light sensor in the simulator.
You can use this block for pretty much any kind of data. Try it out! Plot the ``||input:light level||`` inside the ``||basic:forever||`` instead. Play with the light sensor in the simulator.

```blocks
basic.forever(function() {
Expand Down
16 changes: 8 additions & 8 deletions docs/projects/stopwatch.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Stopwatch

## Introduction @unplugged
## Time is ticking! @unplugged

![A @boardname@ stopwatch toon image](/static/mb/projects/stopwatch.png)

This project turns the @boardname@ into a simple stopwatch. Pressing **A** starts the timer. Pressing **B** displays the elapsed seconds.

## Step 1
## {Step 1}

Use an event to run code when ``||input:button A is pressed||``.

Expand All @@ -15,7 +15,7 @@ input.onButtonPressed(Button.A, function () {
})
```

## Step 2
## {Step 2}

Add code to store the current ``||input:running time||``
in a variable ``||variables:start||``. This is the start time.
Expand All @@ -27,7 +27,7 @@ input.onButtonPressed(Button.A, function () {
})
```

## Step 3
## {Step 3}

Add an event to run code when ``||input:button B is pressed||``.

Expand All @@ -36,7 +36,7 @@ input.onButtonPressed(Button.B, function () {
})
```

## Step 4
## {Step 4}

Add code to compute the difference between the ``||input:running time||``
and ``||variables:value||`` time. This is the elapsed millisecond since pressing button A.
Expand All @@ -48,7 +48,7 @@ input.onButtonPressed(Button.B, function () {
})
```

## Step 5
## {Step 5}

Add code to ``||basic:show||`` the number of milliseconds ``||variables:elapsed||``.
Use ``||Math:integer division||`` to divide ``||variables:elapsed||`` by ``1000`` and get seconds.
Expand All @@ -61,11 +61,11 @@ input.onButtonPressed(Button.B, function () {
})
```

## Step 6
## {Step 6}

Try your program in the simulator. Press **A** to start the stopwatch and press **B** to get the current elapsed time. You can press **B** multiple times.

## Step 7
## {Step 7}

If you have a @boardname@ connected, click ``|Download|`` to transfer your code!

Expand Down
3 changes: 1 addition & 2 deletions docs/reference/basic/show-leds.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ on and `.` means an LED that is turned off.

## See also

[plot leds](/reference/basic/plot-leds), [show animation](/reference/basic/show-animation)

[show icon](/reference/basic/show-icon)
5 changes: 2 additions & 3 deletions docs/reference/basic/show-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ If `value` is `NaN` (not a number), `?` is displayed.

## Other show functions

* Use [show string](/reference/basic/show-string) to show a [String](/types/string) with letters on the screen.
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
Use [show string](/reference/basic/show-string) to show a [String](/types/string) with letters on the screen.

## See also

[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/types/number), [math](/blocks/math)
[show string](/reference/basic/show-string), [Number](/types/number), [math](/blocks/math)

6 changes: 2 additions & 4 deletions docs/reference/basic/show-string.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ basic.showString(s)

## Other show functions

* Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).

## See also

[String](/types/string), [show number](/reference/basic/show-number), [show animation](/reference/basic/show-animation)

[String](/types/string), [show number](/reference/basic/show-number)
2 changes: 1 addition & 1 deletion docs/reference/game/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {

## See also

[Image](/reference/images/image), [show animation](/reference/basic/show-animation), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image)
[Image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image)

2 changes: 1 addition & 1 deletion docs/reference/images/create-big-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
[image](/reference/images/image),
[create image](/reference/images/create-image),
[show image](/reference/images/show-image),
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
[scroll image](/reference/images/scroll-image)
9 changes: 4 additions & 5 deletions docs/reference/images/create-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
# . # . #
. . # . .
. . # . .
`).showImage(0);
`).showImage(0)
});
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
images.createImage(`
Expand All @@ -41,14 +41,13 @@ input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
# . # . #
. # # # .
. . # . .
`).showImage(0);
});
`).showImage(0)
})
```

## See also

[image](/reference/images/image),
[create big image](/reference/images/create-big-image),
[show image](/reference/images/show-image),
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)

[scroll image](/reference/images/scroll-image)
2 changes: 1 addition & 1 deletion docs/reference/images/plot-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ img.plotFrame(1)

## See also

[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
[create image](/reference/images/create-image), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

2 changes: 1 addition & 1 deletion docs/reference/images/plot-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ img.plotImage(0)

## See also

[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
[create image](/reference/images/create-image), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

3 changes: 1 addition & 2 deletions docs/reference/images/scroll-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ basic.forever(() => {

## See also

[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [show animation](/reference/basic/show-animation)

[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image)
2 changes: 1 addition & 1 deletion docs/reference/images/show-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ img.showFrame(1)

## See also

[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
[create image](/reference/images/create-image), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

2 changes: 1 addition & 1 deletion docs/reference/images/show-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
[image](/reference/images/image),
[create image](/reference/images/create-image),
[create big image](/reference/images/create-big-image),
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
[scroll image](/reference/images/scroll-image)
3 changes: 1 addition & 2 deletions docs/reference/images/width.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ for (let i = 0; i < img2.width() / 5; i++) {

## See also

[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)

[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
4 changes: 2 additions & 2 deletions docs/reference/input/logo-is-pressed.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ basic.forever(function () {

[Calliope mini V2](/device/v2),
[on logo event](/reference/input/on-logo-event),
[pin is pressed](/referene/inpu/pin-is-pressed),
[touch set mode](/referene/inpu/touch-set-mode)
[pin is pressed](/reference/input/pin-is-pressed),
[touch set mode](/reference/pins/touch-set-mode)
40 changes: 40 additions & 0 deletions docs/reference/music/string-playable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# string Playable

Created a short melody of notes composed in a string.

```sig
music.stringPlayable("D F E A E A C B ", 120)
```

The **melody** is short series of notes composed in a string. The melody is played at a rate set by the **tempo** value you give. The melody string contains a sequence of notes formatted like this:

``"E B C5 A B G A F "``

The melody is shown in the ``||music:melody||`` block as note symbols which also appear in the Melody Editor.

```block
music.stringPlayable("E F G F E G B C5 ", 120)
```

The melodies are most often created in the Melody Editor from the block so that valid notes are chosen and the correct melody length is set.

## Parameters

* **melody**: a [string](/types/string) which contains the notes of the melody.
* **tempo**: a [number](/types/number) which is the rate to play the melody at in beats per minute.

## Returns

* a [playable](/types/playable) object that contains the **melody** and **tempo**.

## Example

Play the ``Mystery`` melody continuously.

```blocks
music.play(music.stringPlayable("E F G F E G B C5 ", 120), music.PlaybackMode.LoopingInBackground)
```

## See also

[tone playable](/reference/music/tone-playable)
29 changes: 29 additions & 0 deletions docs/reference/music/tone-playable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# tone Playable

Create a musical tone that will play for some amount of time.

```sig
music.tonePlayable(262, music.beat(BeatFraction.Whole))
```

## Parameters

* **note**: is the note frequency as a [number](/types/number) of [Hertz](https://wikipedia.org/wiki/Hertz) (how high or low the tone is, also known as _pitch_). If **note** is less or equal to zero, no sound is played.
* **duration**: is the [number](/types/number) of milliseconds (one-thousandth of a second) that the tone lasts for. If **duration** is negative or zero, the sound will play continuously.

## Returns

* a [playable](/types/playable) object that contains the tone.

## Example

Store the musical note 'C' in the variable `note` and play that note for 1000 milliseconds (one second).

```blocks
let note = music.noteFrequency(Note.C);
music.play(music.tonePlayable(note, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone)
```

## See also

[string playable](/reference/music/string-playable)
38 changes: 38 additions & 0 deletions docs/reference/pins/set-audio-pin-enabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# set Audio Pin Enabled

Enable a pin on the edge connector to output audio.

```sig
pins.setAudioPinEnabled(false)
```

You can enable the @boardname@ to output audio to a pin on the edge connector.

### ~ hint

#### micro:bit V2 speaker

With the [micro:bit V2](/device/v2) hardware, the built-in speaker will play (mirror) the same tones and music sent to the audio pin.

### ~

## Parameters

* **enabled**: audio is output to a pin is enabled if `true`, disabled if `false`.

## Example

Enable audio output to a pin on the edge connector and play a tone for the "A4" note at pin **P0** for 1 second.

```blocks
pins.setAudioPinEnabled(false)
pins.setAudioPin(AnalogPin.P0)
let frequency = 440
let duration = 1000
pins.analogPitch(frequency, duration)
```

## See also

[@boardname@ pins](/device/pins), [set audio pin](/reference/pins/set-audio-pin),
[analog set pitch pin](/reference/pins/analog-set-pitch-pin)
3 changes: 2 additions & 1 deletion docs/reference/pins/set-audio-pin.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ pins.analogPitch(frequency, duration)

## See also

[@boardname@ pins](/device/pins), [analog set pitch pin](/reference/pins/analog-set-pitch-pin)
[@boardname@ pins](/device/pins), [set audio pin enabled](/reference/pins/set-audio-pin-enabled),
[analog set pitch pin](/reference/pins/analog-set-pitch-pin)
Loading

0 comments on commit 6162390

Please sign in to comment.