fixing music simulator

This commit is contained in:
Peli de Halleux 2016-11-15 22:28:05 -08:00
parent 4be57eee9a
commit 903c0ec6bd
3 changed files with 12 additions and 22 deletions

View File

@ -8,21 +8,10 @@ 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="speaker" async
void playTone(int freqency, int ms) {
uBit.soundmotor.soundOn(freqency);
if(ms > 0) uBit.sleep(ms);
uBit.soundmotor.soundOff();
}
/**
* Plays a tone through ``speaker``.
* @param frequency pitch of the tone to play in Hertz (Hz)
*/
//% help=music/ring-tone weight=80
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
//% parts="speaker"
void ringTone(int frequency) {
playTone(frequency, 0);
}
}

View File

@ -140,6 +140,16 @@ namespace music {
playTone(0, ms);
}
/**
* Plays a tone through ``speaker``.
* @param frequency pitch of the tone to play in Hertz (Hz)
*/
//% help=music/ring-tone weight=80
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
//% parts="speaker" async
export function ringTone(frequency: number) {
playTone(frequency, 0);
}
/**
* Gets the frequency of a note.

11
libs/core/shims.d.ts vendored
View File

@ -554,17 +554,8 @@ declare 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" shim=music::playTone
//% parts="speaker" async shim=music::playTone
function playTone(freqency: number, ms: number): void;
/**
* Plays a tone through ``speaker``.
* @param frequency pitch of the tone to play in Hertz (Hz)
*/
//% help=music/ring-tone weight=80
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
//% parts="speaker" shim=music::ringTone
function ringTone(frequency: number): void;
}
declare namespace pins {