diff --git a/libs/core/music.cpp b/libs/core/music.cpp index 5b31c50e..3311cc19 100644 --- a/libs/core/music.cpp +++ b/libs/core/music.cpp @@ -1,9 +1,28 @@ #include "ksbit.h" namespace music { + /** + * Plays a tone through ``speaker`` for the given duration. + * @param frequency pitch of the tone to play in Hertz (Hz) + * @param ms tone duration in milliseconds (ms) + */ + //% 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" 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); + } } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index affa3b2d..6f5f91fd 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -535,15 +535,6 @@ declare namespace music { //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 //% parts="speaker" 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 {