From 164beb16e11b8c62f5ca40df403fa889dbaf65e9 Mon Sep 17 00:00:00 2001 From: paradajz <2544094+paradajz@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:14:00 +0100 Subject: [PATCH] analog/buttons: make sure analog buttons are forcefully refreshed if requested --- src/firmware/application/io/analog/Analog.cpp | 1 + .../application/io/buttons/Buttons.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/firmware/application/io/analog/Analog.cpp b/src/firmware/application/io/analog/Analog.cpp index 81576870b..e580850dc 100644 --- a/src/firmware/application/io/analog/Analog.cpp +++ b/src/firmware/application/io/analog/Analog.cpp @@ -100,6 +100,7 @@ void Analog::updateSingle(size_t index, bool forceRefresh) { analogDescriptor_t descriptor; fillAnalogDescriptor(index, descriptor); + descriptor.event.forcedRefresh = true; descriptor.newValue = _lastValue[index]; descriptor.oldValue = _lastValue[index]; diff --git a/src/firmware/application/io/buttons/Buttons.cpp b/src/firmware/application/io/buttons/Buttons.cpp index bc1a6b92a..afbfb0360 100644 --- a/src/firmware/application/io/buttons/Buttons.cpp +++ b/src/firmware/application/io/buttons/Buttons.cpp @@ -45,8 +45,22 @@ Buttons::Buttons(HWA& hwa, buttonDescriptor_t descriptor; fillButtonDescriptor(index, descriptor); - // event.value in this case contains state information only - processButton(index, event.value, descriptor); + if (!event.forcedRefresh) + { + // event.value in this case contains state information only + processButton(index, event.value, descriptor); + } + else + { + if (descriptor.type == type_t::LATCHING) + { + sendMessage(index, latchingState(index), descriptor); + } + else + { + sendMessage(index, state(index), descriptor); + } + } }); MIDIDispatcher.listen(messaging::eventType_t::TOUCHSCREEN_BUTTON,