microsoft/pxt-adafruit

Set Loud Sound Threshold field picker

Jaqster opened this issue · 1 comments

When using the Set Loud Sound Threshold block, the field picker values go from 0 to 100. Yet, in our documentation, it says the values go from 0 to 1023. Which one is right?

SetLoudSound

According to the function in the microphone lib I think it should be 0 - 255:

/**
* Sets the minimum threshold for a loud sound
*/
//% help=input/set-loud-sound-threshold
//% blockId=input_set_loud_sound_threshold block="set loud sound threshold %value"
//% parts="microphone"
//% value.min=1 value.max=100
//% group="More" weight=14 blockGap=8
void setLoudSoundThreshold(int value) {
    value = max(0, min(0xff, value));
    const int scaled = MICROPHONE_MIN + value * (MICROPHONE_MAX - MICROPHONE_MIN) / 0xff;
    getWMicrophone()->level.setHighThreshold(scaled);
}

I'll change it to that in my initial fix PR. The value.max attribute should be 255 instead of 100.