Set Loud Sound Threshold field picker
Jaqster opened this issue · 1 comments
Jaqster commented
ganicke commented
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
.