added headphone part
This commit is contained in:
parent
02cd0e1da3
commit
c90dfaa6e7
3
libs/microbit-radio/shims.d.ts
vendored
3
libs/microbit-radio/shims.d.ts
vendored
@ -46,8 +46,7 @@ declare namespace radio {
|
|||||||
* @param index index of the number to read from 0 to 3. 1 eg
|
* @param index index of the number to read from 0 to 3. 1 eg
|
||||||
*/
|
*/
|
||||||
//% help=radio/received-number-at
|
//% help=radio/received-number-at
|
||||||
//% weight=45 debug=true
|
//% weight=45 debug=true shim=radio::receivedNumberAt
|
||||||
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
|
|
||||||
function receivedNumberAt(index: number): number;
|
function receivedNumberAt(index: number): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +135,7 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/play-tone weight=90
|
//% help=music/play-tone weight=90
|
||||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
//% 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 {
|
export function playTone(frequency: number, ms: number): void {
|
||||||
pins.analogSetPitchPin(AnalogPin.P0);
|
pins.analogSetPitchPin(AnalogPin.P0);
|
||||||
pins.analogPitch(frequency, ms);
|
pins.analogPitch(frequency, ms);
|
||||||
@ -147,7 +147,7 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/ring-tone weight=80
|
//% help=music/ring-tone weight=80
|
||||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||||
//% parts="speaker"
|
//% parts="headphone"
|
||||||
export function ringTone(frequency: number): void {
|
export function ringTone(frequency: number): void {
|
||||||
pins.analogSetPitchPin(AnalogPin.P0);
|
pins.analogSetPitchPin(AnalogPin.P0);
|
||||||
pins.analogPitch(frequency, 0);
|
pins.analogPitch(frequency, 0);
|
||||||
@ -159,7 +159,7 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/rest weight=79
|
//% help=music/rest weight=79
|
||||||
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
||||||
//% parts="speaker"
|
//% parts="headphone"
|
||||||
export function rest(ms: number): void {
|
export function rest(ms: number): void {
|
||||||
playTone(0, ms);
|
playTone(0, ms);
|
||||||
}
|
}
|
||||||
@ -171,7 +171,6 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% weight=50 help=music/note-frequency
|
//% weight=50 help=music/note-frequency
|
||||||
//% blockId=device_note block="%note"
|
//% blockId=device_note block="%note"
|
||||||
//% parts="speaker"
|
|
||||||
//% shim=TD_ID
|
//% shim=TD_ID
|
||||||
export function noteFrequency(name: Note): number {
|
export function noteFrequency(name: Note): number {
|
||||||
return name;
|
return name;
|
||||||
@ -186,7 +185,6 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/beat weight=49
|
//% help=music/beat weight=49
|
||||||
//% blockId=device_beat block="%fraction|beat"
|
//% blockId=device_beat block="%fraction|beat"
|
||||||
//% parts="speaker"
|
|
||||||
export function beat(fraction?: BeatFraction): number {
|
export function beat(fraction?: BeatFraction): number {
|
||||||
init();
|
init();
|
||||||
if (fraction == null) fraction = BeatFraction.Whole;
|
if (fraction == null) fraction = BeatFraction.Whole;
|
||||||
@ -203,7 +201,6 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/tempo weight=40
|
//% help=music/tempo weight=40
|
||||||
//% blockId=device_tempo block="tempo (bpm)" blockGap=8
|
//% blockId=device_tempo block="tempo (bpm)" blockGap=8
|
||||||
//% parts="speaker"
|
|
||||||
export function tempo(): number {
|
export function tempo(): number {
|
||||||
init();
|
init();
|
||||||
return beatsPerMinute;
|
return beatsPerMinute;
|
||||||
@ -215,7 +212,6 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/change-tempo weight=39
|
//% help=music/change-tempo weight=39
|
||||||
//% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8
|
//% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8
|
||||||
//% parts="speaker"
|
|
||||||
export function changeTempoBy(bpm: number): void {
|
export function changeTempoBy(bpm: number): void {
|
||||||
init();
|
init();
|
||||||
setTempo(beatsPerMinute + bpm);
|
setTempo(beatsPerMinute + bpm);
|
||||||
@ -227,7 +223,6 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/set-tempo weight=38
|
//% help=music/set-tempo weight=38
|
||||||
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
||||||
//% parts="speaker"
|
|
||||||
export function setTempo(bpm: number): void {
|
export function setTempo(bpm: number): void {
|
||||||
init();
|
init();
|
||||||
if (bpm > 0) {
|
if (bpm > 0) {
|
||||||
|
1
libs/microbit/parts/headphone.svg
Normal file
1
libs/microbit/parts/headphone.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="142" height="180" viewBox="0 0 142 180"><rect ry=".3" rx="1" y="58.615" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><rect ry=".3" rx="1" y="32.043" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><path d="M.346 7.296c-.394.39-.31 4.797-.18 4.898l13.404 10.18c.117.12.337 4.76.73 4.368l5.506-5.56.01.01 6.51-6.444c.39-.392-4.25-.614-4.366-.73L11.777.612c-.1-.132-4.51-.215-4.898.18L4.087 3.636l-.01-.01-3.73 3.67z" fill="#b3b3b3"/><rect ry="6.85" rx="4.571" y="84.758" x="-20.128" height="75.571" width="39.643" transform="rotate(-45)"/><rect ry=".374" rx="1.038" y="29.442" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="55.939" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="82.392" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry="2.317" rx="2.183" y="158.876" x="-9.774" height="25.568" width="18.935" transform="rotate(-45)"/><path d="M128.588 128.82s14.97 11.165 7.547 26.35c-8.426 17.24-25.57 20.653-25.57 20.653" fill="none" stroke="#000" stroke-width="6.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -29,6 +29,7 @@
|
|||||||
"buffer.cpp",
|
"buffer.cpp",
|
||||||
"pxtparts.json",
|
"pxtparts.json",
|
||||||
"parts/speaker.svg",
|
"parts/speaker.svg",
|
||||||
|
"parts/headphone.svg",
|
||||||
"_locales/fr/microbit-jsdoc-strings.json"
|
"_locales/fr/microbit-jsdoc-strings.json"
|
||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
|
@ -101,10 +101,32 @@
|
|||||||
{"pinIndices": [5, 6, 7, 8, 9]}
|
{"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": {
|
"speaker": {
|
||||||
"numberOfPins": 2,
|
"numberOfPins": 2,
|
||||||
"visual": {
|
"visual": {
|
||||||
"image": "/parts/speaker.svg",
|
"image": "parts/speaker.svg",
|
||||||
"width": 500,
|
"width": 500,
|
||||||
"height": 500,
|
"height": 500,
|
||||||
"pinDistance": 70,
|
"pinDistance": 70,
|
||||||
|
Loading…
Reference in New Issue
Block a user