Skip to content

Commit 0f80198

Browse files
authored
Add audio pin ref page (#5766)
* fix help path for 'resume' * add ref page for 'set-audio-pin-enabled'
1 parent 87593b1 commit 0f80198

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# set Audio Pin Enabled
2+
3+
Enable a pin on the edge connector to output audio.
4+
5+
```sig
6+
pins.setAudioPinEnabled(false)
7+
```
8+
9+
You can enable the @boardname@ to output audio to a pin on the edge connector.
10+
11+
### ~ hint
12+
13+
#### micro:bit V2 speaker
14+
15+
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.
16+
17+
### ~
18+
19+
## Parameters
20+
21+
* **enabled**: audio is output to a pin is enabled if `true`, disabled if `false`.
22+
23+
## Example
24+
25+
Enable audio output to a pin on the edge connector and play a tone for the "A4" note at pin **P0** for 1 second.
26+
27+
```blocks
28+
pins.setAudioPinEnabled(false)
29+
pins.setAudioPin(AnalogPin.P0)
30+
let frequency = 440
31+
let duration = 1000
32+
pins.analogPitch(frequency, duration)
33+
```
34+
35+
## See also
36+
37+
[@boardname@ pins](/device/pins), [set audio pin](/reference/pins/set-audio-pin),
38+
[analog set pitch pin](/reference/pins/analog-set-pitch-pin)

docs/reference/pins/set-audio-pin.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ pins.analogPitch(frequency, duration)
3131

3232
## See also
3333

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

libs/core/game.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ namespace game {
305305
* Resumes the game rendering engine
306306
*/
307307
//% blockId=game_resume block="resume"
308-
//% advanced=true blockGap=8 help=game/resumeP
308+
//% advanced=true blockGap=8 help=game/resume
309309
export function resume(): void {
310310
_paused = false;
311311
plot();

libs/core/pins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ namespace pins {
696696
*/
697697
//% blockId=pin_set_audio_pin_enabled
698698
//% block="set audio pin enabled $enabled"
699-
//% weight=0
699+
//% weight=0 help=pins/set-audio-pin-enabled
700700
void setAudioPinEnabled(bool enabled) {
701701
edgeConnectorSoundDisabled = !enabled;
702702
#if MICROBIT_CODAL

libs/core/shims.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ declare namespace pins {
10001000
*/
10011001
//% blockId=pin_set_audio_pin_enabled
10021002
//% block="set audio pin enabled $enabled"
1003-
//% weight=0 shim=pins::setAudioPinEnabled
1003+
//% weight=0 help=pins/set-audio-pin-enabled shim=pins::setAudioPinEnabled
10041004
function setAudioPinEnabled(enabled: boolean): void;
10051005
}
10061006

0 commit comments

Comments
 (0)