diff --git a/src/input/InputBroker.cpp b/src/input/InputBroker.cpp index 36aaea3db..c588a9a0f 100644 --- a/src/input/InputBroker.cpp +++ b/src/input/InputBroker.cpp @@ -18,18 +18,18 @@ void InputBroker::registerSource(Observable *source) } #ifdef HAS_FREE_RTOS -void InputBroker::requestPollSoon(InputPollable *pollable, bool fromIsr) +void InputBroker::requestPollSoon(InputPollable *pollable) { - if (fromIsr) { + if (xPortInIsrContext() == pdTRUE) { xQueueSendFromISR(pollSoonQueue, &pollable, NULL); } else { xQueueSend(pollSoonQueue, &pollable, 0); } } -void InputBroker::queueInputEvent(const InputEvent *event, bool fromIsr) +void InputBroker::queueInputEvent(const InputEvent *event) { - if (fromIsr) { + if (xPortInIsrContext() == pdTRUE) { xQueueSendFromISR(inputEventQueue, event, NULL); } else { xQueueSend(inputEventQueue, event, portMAX_DELAY); diff --git a/src/input/InputBroker.h b/src/input/InputBroker.h index f4d1eb606..192bd7e8b 100644 --- a/src/input/InputBroker.h +++ b/src/input/InputBroker.h @@ -60,8 +60,8 @@ class InputBroker : public Observable void registerSource(Observable *source); void injectInputEvent(const InputEvent *event) { handleInputEvent(event); } #ifdef HAS_FREE_RTOS - void requestPollSoon(InputPollable *pollable, bool fromIsr); - void queueInputEvent(const InputEvent *event, bool fromIsr); + void requestPollSoon(InputPollable *pollable); + void queueInputEvent(const InputEvent *event); void processInputEventQueue(); #endif diff --git a/src/input/TCA8418KeyboardBase.cpp b/src/input/TCA8418KeyboardBase.cpp index 6fd59dde2..a5ecbd0a0 100644 --- a/src/input/TCA8418KeyboardBase.cpp +++ b/src/input/TCA8418KeyboardBase.cpp @@ -102,7 +102,7 @@ void TCA8418KeyboardBase::reset() void TCA8418KeyboardBase::attachInterruptHandler() { interruptInstance = this; - auto interruptHandler = []() { interruptInstance->notifyObservers(true); }; + auto interruptHandler = []() { interruptInstance->notifyObservers(interruptInstance); }; attachInterrupt(KB_INT, interruptHandler, FALLING); } @@ -126,8 +126,8 @@ int TCA8418KeyboardBase::beforeLightSleep(void *unused) int TCA8418KeyboardBase::afterLightSleep(esp_sleep_wakeup_cause_t cause) { attachInterruptHandler(); - this->notifyObservers(false); // Trigger a one-off poll in case a keypress woke us - return 0; // Indicates success + this->notifyObservers(this); // Trigger a one-off poll in case a keypress woke us + return 0; // Indicates success } #endif // ARCH_ESP32 diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp index 28f0867e6..2aae45399 100644 --- a/src/input/kbI2cBase.cpp +++ b/src/input/kbI2cBase.cpp @@ -130,7 +130,7 @@ void KbI2cBase::pollOnce() } if (e.inputEvent != INPUT_BROKER_NONE) { LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar); - inputBroker->queueInputEvent(&e, false); + inputBroker->queueInputEvent(&e); } } #endif @@ -637,11 +637,11 @@ void KbI2cBase::toggleBacklight(bool on) #endif } -int KbI2cBase::onNotify(bool fromIsr) +int KbI2cBase::onNotify(KbInterruptObservable *src) { // Called from interrupt context, request polling after exiting the ISR #ifdef KB_INT - inputBroker->requestPollSoon(this, fromIsr); + inputBroker->requestPollSoon(this); #endif return 0; } \ No newline at end of file diff --git a/src/input/kbI2cBase.h b/src/input/kbI2cBase.h index 379072c4a..ddc174e9c 100644 --- a/src/input/kbI2cBase.h +++ b/src/input/kbI2cBase.h @@ -20,7 +20,7 @@ class KbI2cBase : public Observable, virtual void pollOnce() override; protected: - virtual int onNotify(bool fromIsr) override; + virtual int onNotify(KbInterruptObservable *src) override; virtual int32_t runOnce() override; private: diff --git a/src/input/kbInterrupt.h b/src/input/kbInterrupt.h index c9595b2c0..2f6c84a9f 100644 --- a/src/input/kbInterrupt.h +++ b/src/input/kbInterrupt.h @@ -2,10 +2,10 @@ #include "Observer.h" -class KbInterruptObservable : public Observable +class KbInterruptObservable : public Observable { }; -class KbInterruptObserver : public Observer +class KbInterruptObserver : public Observer { }; \ No newline at end of file