From ae50374d55d61c2efae1f99cf5f7ed4b6e837f2f Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Wed, 29 Jun 2022 14:12:07 +0200 Subject: [PATCH] Prevent analog button from working. If analog input selected. --- usermods/audioreactive/audio_reactive.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index dd1c3bdc2..1aebf5dbf 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -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. * Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.