Skip to content

Commit 94aff4f

Browse files
committed
update APIs and editors
1 parent 3d71f9d commit 94aff4f

File tree

1 file changed

+27
-52
lines changed

1 file changed

+27
-52
lines changed

latest-revision/latest-revision-main.md

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -78,55 +78,6 @@ In an effort to ensure the greatest degree of continuity for teachers, users wil
7878

7979
This means that you can use MakeCode or the online Python Editor as you always have, to use all of the features that are common to both version of the BBC micro:bit: Display, buttons, motion sensing, gestures like shake, light sensing, and even the Music blocks.
8080

81-
## Feature availability
82-
83-
These are the V2 features and whether we expect them to work as expected ✅ or not 🛑, or there are issues still to be fixed 🔶.
84-
85-
| **Feature** | **Codal** | **MakeCode** | **MakeCode Simulator** | **MicroPython** |
86-
| ---------------- | --------- | ------------ | ---------------------- | --------------- |
87-
| Microphone |||||
88-
| Speaker ||| 🛑 ||
89-
| Logo touch |||||
90-
| Power management ||| 🛑 ||
91-
| Sound emoji |||||
92-
93-
## Feature API availability
94-
95-
These are the V2 specific APIs and whether we expect them to work as expected ✅ or not 🛑, or there are issues still to be fixed 🔶.
96-
97-
{% include alert-info.html content="It is important that we work with the community to establish how these APIs work. As such they are subject to change as we get feedback and iterate on them.
98-
When they are finalised, we will notify people via the [DAL, Editors and Devices](https://microbit.us14.list-manage.com/subscribe?u=e1c30f24b90ff3d70275cfff2&id=25403c7650) newsletter." %}
99-
100-
### MakeCode APIs
101-
102-
| API | Blocks | Status | GitHub Issues |
103-
| --------------------------------------------------- | -------------------- | --------------------- | ------------- |
104-
| On loud/quiet sound `input.onSound(SoundType.Loud)` - Triggers after a transition from quiet-loud/loud-quiet, so 'on quiet' will trigger after a loud sound but not continuously | ![on loud sound](/docs/latest-revision/assets/makecode-blocks/loudsound.png){: width="125"} || |
105-
| Set pin touch type `pins.touchSetType(TouchTarget.P0, TouchType.Resistive)`- capacitive/resistive - Logo is capacitive, large pins are resistive by default. | ![set touch type](/docs/latest-revision/assets/makecode-blocks/pin-mode.png){: width="650"} || |
106-
| On Logo pressed `input.onLogoPressed()` | ![logo pressed](/docs/latest-revision/assets/makecode-blocks/onLogoPressed.png){: width="125"} || |
107-
| On logo released `input.onLogoReleased()` | ![logo released](/docs/latest-revision/assets/makecode-blocks/onLogoReleased.png){: width="125"} || |
108-
| Logo is pressed `input.logoIsPressed()` | ![logo is pressed](/docs/latest-revision/assets/makecode-blocks/logoIsPressed.png){: width="150"} || |
109-
| Set on-board speaker On/Off `music.setOnBoardSpeakerEnable(false)` - Edge connector will still output sound | ![speaker disabled](/docs/latest-revision/assets/makecode-blocks/speakerDisabled.png){: width="650"} || |
110-
| Set sound threshold level `input.setSoundThreshold(SoundType.Loud, 128)` - 0-255 threshold for triggering a 'loud' or 'quiet' sound | ![sound threshold](/docs/latest-revision/assets/makecode-blocks/setSoundThreshold.png){: width="650"} || |
111-
| Sound level - returns a filtered 'noise level' not raw microphone samples, useful for eg. 'how noisy is my classroom?' `input.soundLevel()` | ![sound level](/docs/latest-revision/assets/makecode-blocks/soundLevel.png){: width="125"} | 🔶 On battery, the 'soundLevel' reported for quiet sounds is higher than the level reported on USB. |[codal-microbit#131](https://github.com/microbit-foundation/codal-microbit/issues/131) |
112-
| Play sound `soundExpression.giggle.play()`/`soundExpression.giggle.playUntilDone()` - Play from a selection of pre-defined sound emoji | ![play sound](/docs/latest-revision/assets/makecode-blocks/playSound.png){: width="650"} || |
113-
114-
### Python APIs
115-
116-
| API | Usage | Status | GitHub Issues |
117-
| ------------------------------------------ | ------------ | ---------------------------- | ------------- |
118-
| play sound expression (giggle, happy, hello, mysterious, sad, slide, soaring, spring, twinkle, yawn) | `audio.play("hello")`|| |
119-
| Choose music/pitch output pin | `music.play(music.JUMP_UP, pin=microbit.pin_speaker, wait=True)` || |
120-
| Stop music on pin | `music.stop(pin=microbit.pin_speaker)` || |
121-
| Set the volume 0-255 | `microbit.set_volume(128)` || |
122-
| Get current sound loud/quiet |`microbit.microphone.current_sound()` || |
123-
| Check current sound == loud/quiet | `microbit.microphone.current_sound() == microbit.microphone.LOUD` || |
124-
| Check if a loud/quiet sound occurred since the last call to was_sound() | `microbit.microphone.was_sound(microbit.microphone.LOUD)` || |
125-
| Get history of sounds since last call to get_sounds() | `microbit.microphone.get_sounds()` || |
126-
| Set threshold for sound 0-255 | `microbit.microphone.set_threshold(microbit.microphone.LOUD, 128)` || |
127-
| Get current sound level in range 0-255 | `microbit.microphone.sound_level()` || |
128-
| Logo is touched | `microbit.pin_logo.is_touched()` || |
129-
13081
## How do I use the new features?
13182

13283
The **speaker** works in the same way you would expect when you connect up your headphones or an external speaker to the micro:bit. By default, the sound output will be on both the speaker and Edge connector.
@@ -135,12 +86,12 @@ The **logo touch** is implemented in the same way as touching a pin on the edge
13586

13687
To access the features of the latest revision only (eg. to output sound only on the speaker and not the edge connector), you will need to add additional code to your programs. This ensures that the default editor experience continues to work for everyone, regardless of the board revision.
13788

138-
Features that are common to all board variants will work in the same way they always have. For example, you will be able to use the same blocks in MakeCode to use the acceleromater on any board revision.
89+
Features that are common to all board variants will work in the same way they always have. For example, you will be able to use the same blocks in MakeCode to use the accelerometer on any board revision.
13990

14091
### Makecode
141-
You can use the latest board revision in the beta editor [https://makecode.microbit.org/beta](https://makecode.microbit.org/beta) alongside the current revision.
92+
You can use the latest board revision in the live micro:bit editor [https://makecode.microbit.org](https://makecode.microbit.org) alongside the current revision.
14293

143-
#### Using the new features in MakeCode beta
94+
#### Using the new features in MakeCode
14495

14596
The Microphone and Logo touch features can be found in the Input menu
14697

@@ -161,6 +112,30 @@ You can use the latest board revision and APIs in the Python beta editor:
161112

162113
![Copy main.py](/docs/latest-revision/assets/copy-main-py-mu.gif){: width="600"}
163114

115+
#### Using the new features in Python
116+
117+
We are currently working on updates to MicroPython documentation, but you can find Python APIs by searching via the REPL for example:
118+
119+
```Python
120+
import microbit
121+
dir(microbit)
122+
```
123+
### Python APIs
124+
125+
| API | Usage |
126+
|--------------------------------------------|--------------|
127+
| play sound expression (giggle, happy, hello, mysterious, sad, slide, soaring, spring, twinkle, yawn) | `audio.play("hello")`|
128+
| Choose music/pitch output pin | `music.play(music.JUMP_UP, pin=microbit.pin_speaker, wait=True)` |
129+
| Stop music on pin | `music.stop(pin=microbit.pin_speaker)` |
130+
| Set the volume 0-255 | `microbit.set_volume(128)` |
131+
| Get current sound loud/quiet |`microbit.microphone.current_sound()` |
132+
| Check current sound == loud/quiet | `microbit.microphone.current_sound() == microbit.microphone.LOUD` |
133+
| Check if a loud/quiet sound occurred since the last call to was_sound() | `microbit.microphone.was_sound(microbit.microphone.LOUD)` |
134+
| Get history of sounds since last call to get_sounds() | `microbit.microphone.get_sounds()` |
135+
| Set threshold for sound 0-255 | `microbit.microphone.set_threshold(microbit.microphone.LOUD, 128)` |
136+
| Get current sound level in range 0-255 | `microbit.microphone.sound_level()` |
137+
| Logo is touched | `microbit.pin_logo.is_touched()` |
138+
164139
## Universal Hex Format
165140

166141
The editors and apps are compatible with and will let you download and flash a file to any micro:bit revision. This is called a **Universal Hex** file. A clear indication that you are working with this format is that a compiled .hex file will be ~1.8Mb as opposed to ~700Kb in size.

0 commit comments

Comments
 (0)