diff --git a/libs/microbit-radio/shims.d.ts b/libs/microbit-radio/shims.d.ts index 1d27d7b7..5a85fbff 100644 --- a/libs/microbit-radio/shims.d.ts +++ b/libs/microbit-radio/shims.d.ts @@ -46,8 +46,7 @@ declare namespace radio { * @param index index of the number to read from 0 to 3. 1 eg */ //% help=radio/received-number-at - //% weight=45 debug=true - //% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt + //% weight=45 debug=true shim=radio::receivedNumberAt function receivedNumberAt(index: number): number; /** diff --git a/libs/microbit/music.ts b/libs/microbit/music.ts index 75709fa5..2a87e741 100644 --- a/libs/microbit/music.ts +++ b/libs/microbit/music.ts @@ -135,7 +135,7 @@ namespace music { */ //% help=music/play-tone weight=90 //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 - //% parts="speaker" + //% parts="headphone" export function playTone(frequency: number, ms: number): void { pins.analogSetPitchPin(AnalogPin.P0); pins.analogPitch(frequency, ms); @@ -147,7 +147,7 @@ namespace music { */ //% help=music/ring-tone weight=80 //% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8 - //% parts="speaker" + //% parts="headphone" export function ringTone(frequency: number): void { pins.analogSetPitchPin(AnalogPin.P0); pins.analogPitch(frequency, 0); @@ -159,7 +159,7 @@ namespace music { */ //% help=music/rest weight=79 //% blockId=device_rest block="rest(ms)|%duration=device_beat" - //% parts="speaker" + //% parts="headphone" export function rest(ms: number): void { playTone(0, ms); } @@ -171,7 +171,6 @@ namespace music { */ //% weight=50 help=music/note-frequency //% blockId=device_note block="%note" - //% parts="speaker" //% shim=TD_ID export function noteFrequency(name: Note): number { return name; @@ -186,7 +185,6 @@ namespace music { */ //% help=music/beat weight=49 //% blockId=device_beat block="%fraction|beat" - //% parts="speaker" export function beat(fraction?: BeatFraction): number { init(); if (fraction == null) fraction = BeatFraction.Whole; @@ -203,7 +201,6 @@ namespace music { */ //% help=music/tempo weight=40 //% blockId=device_tempo block="tempo (bpm)" blockGap=8 - //% parts="speaker" export function tempo(): number { init(); return beatsPerMinute; @@ -215,7 +212,6 @@ namespace music { */ //% help=music/change-tempo weight=39 //% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8 - //% parts="speaker" export function changeTempoBy(bpm: number): void { init(); setTempo(beatsPerMinute + bpm); @@ -227,7 +223,6 @@ namespace music { */ //% help=music/set-tempo weight=38 //% blockId=device_set_tempo block="set tempo to (bpm)|%value" - //% parts="speaker" export function setTempo(bpm: number): void { init(); if (bpm > 0) { diff --git a/libs/microbit/parts/headphone.svg b/libs/microbit/parts/headphone.svg new file mode 100644 index 00000000..fa4fc1e0 --- /dev/null +++ b/libs/microbit/parts/headphone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libs/microbit/pxt.json b/libs/microbit/pxt.json index d7b15adb..be53b812 100644 --- a/libs/microbit/pxt.json +++ b/libs/microbit/pxt.json @@ -29,6 +29,7 @@ "buffer.cpp", "pxtparts.json", "parts/speaker.svg", + "parts/headphone.svg", "_locales/fr/microbit-jsdoc-strings.json" ], "public": true, diff --git a/libs/microbit/pxtparts.json b/libs/microbit/pxtparts.json index 63cf9a5e..4afc3f78 100644 --- a/libs/microbit/pxtparts.json +++ b/libs/microbit/pxtparts.json @@ -101,10 +101,32 @@ {"pinIndices": [5, 6, 7, 8, 9]} ] }, + "headphone": { + "numberOfPins": 2, + "visual": { + "image": "parts/headphone.svg", + "width": 142, + "height": 180, + "pinDistance": 20, + "pinLocations": [ + {"x": 17, "y": 11}, + {"x": 55, "y": 50} + ] + }, + "pinDefinitions": [ + {"target": "P0", "style": "croc", "orientation": "Y"}, + {"target": "ground", "style": "croc", "orientation": "Y"} + ], + "instantiation": {"kind": "singleton"}, + "assembly": [ + {"part": true, "pinIndices": [0]}, + {"pinIndices": [1]} + ] + }, "speaker": { "numberOfPins": 2, "visual": { - "image": "/parts/speaker.svg", + "image": "parts/speaker.svg", "width": 500, "height": 500, "pinDistance": 70,