updated gyrobox

This commit is contained in:
Peli de Halleux
2018-01-16 17:05:57 -08:00
parent f057964a50
commit e50c88008a
7 changed files with 35 additions and 25 deletions

View File

@ -23,7 +23,7 @@
"music.setTempo": "Set the tempo a number of beats per minute (bpm).",
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
"music.setVolume": "Set the output volume of the sound synthesizer.",
"music.setVolume|param|volume": "the volume 0...256, eg: 128",
"music.setVolume|param|volume": "the volume 0...100, eg: 50",
"music.stopAllSounds": "Play a tone through the speaker for some amount of time.",
"music.tempo": "Return the tempo in beats per minute (bpm).\nTempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play."
}

View File

@ -13,7 +13,7 @@
namespace music {
uint8_t currVolume = 2;
uint8_t currVolume = 50;
uint8_t *lmsSoundMMap;
int writeDev(void *data, int size) {
@ -25,16 +25,16 @@ int writeDev(void *data, int size) {
/**
* Set the output volume of the sound synthesizer.
* @param volume the volume 0...256, eg: 128
* @param volume the volume 0...100, eg: 50
*/
//% weight=96
//% blockId=synth_set_volume block="set volume %volume"
//% parts="speaker" blockGap=8
//% volume.min=0 volume.max=256
//% volume.min=0 volume.max=100
//% help=music/set-volume
//% weight=1
void setVolume(int volume) {
currVolume = max(0, min(100, volume * 100 / 256));
currVolume = max(0, min(100, volume));
}
#define SOUND_CMD_BREAK 0

View File

@ -3,12 +3,12 @@ declare namespace music {
/**
* Set the output volume of the sound synthesizer.
* @param volume the volume 0...256, eg: 128
* @param volume the volume 0...100, eg: 50
*/
//% weight=96
//% blockId=synth_set_volume block="set volume %volume"
//% parts="speaker" blockGap=8
//% volume.min=0 volume.max=256
//% volume.min=0 volume.max=100
//% help=music/set-volume
//% weight=1 shim=music::setVolume
function setVolume(volume: int32): void;