Prevent analog button from working.

If analog input selected.
This commit is contained in:
Blaz Kristan 2022-06-29 14:12:07 +02:00
parent d2705f033d
commit ae50374d55

View File

@ -981,6 +981,24 @@ class AudioReactive : public Usermod {
} }
/**
* handleButton() can be used to override default button behaviour. Returning true
* will prevent button working in a default way.
*/
bool handleButton(uint8_t b) {
yield();
// crude way of determining if audio input is analog
// better would be for AudioSource to implement getType()
if (enabled
&& dmType == 0 && audioPin>=0
&& (buttonType[b] == BTN_TYPE_ANALOG || buttonType[b] == BTN_TYPE_ANALOG_INVERTED)
) {
return true;
}
return false;
}
/* /*
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API. * addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI. * Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.