From 9f1c15990db0d70e218fbf825f11269239323e8a Mon Sep 17 00:00:00 2001 From: Michael Rupp <95718139+mykrupp@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:19:35 -0500 Subject: [PATCH] Allow sample apps to override BaseApplication's default lcd screen (#31603) * Allow sample apps to override BaseApplication's default lcd screen * Restyled by whitespace * use virtual method in parent class --------- Co-authored-by: Restyled.io --- examples/platform/silabs/BaseApplication.cpp | 15 ++++++++++----- examples/platform/silabs/BaseApplication.h | 5 +++++ examples/platform/silabs/display/lcd.h | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index fadeaf954912e5..99acb26d9bd26e 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -458,11 +458,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) // - Cycle LCD screen CancelFunctionTimer(); - OutputQrCode(false); -#ifdef DISPLAY_ENABLED - UpdateLCDStatusScreen(); - slLCD.CycleScreens(); -#endif + AppTask::GetAppTask().UpdateDisplay(); #ifdef SL_WIFI if (!ConnectivityMgr().IsWiFiStationProvisioned()) @@ -493,6 +489,15 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) } } +void BaseApplication::UpdateDisplay() +{ + OutputQrCode(false); +#ifdef DISPLAY_ENABLED + UpdateLCDStatusScreen(); + slLCD.CycleScreens(); +#endif +} + void BaseApplication::CancelFunctionTimer() { if (xTimerStop(sFunctionTimer, pdMS_TO_TICKS(0)) == pdFAIL) diff --git a/examples/platform/silabs/BaseApplication.h b/examples/platform/silabs/BaseApplication.h index 0bde0e76f227a2..b38f0e58e1c305 100644 --- a/examples/platform/silabs/BaseApplication.h +++ b/examples/platform/silabs/BaseApplication.h @@ -105,6 +105,11 @@ class BaseApplication */ static void PostEvent(const AppEvent * event); + /** + * @brief Overridable function used to update display on button press + */ + virtual void UpdateDisplay(); + #ifdef DISPLAY_ENABLED /** * @brief Return LCD object diff --git a/examples/platform/silabs/display/lcd.h b/examples/platform/silabs/display/lcd.h index b6f3fc9a0669fc..703e72ab6ea61f 100644 --- a/examples/platform/silabs/display/lcd.h +++ b/examples/platform/silabs/display/lcd.h @@ -71,6 +71,7 @@ class SilabsLCD void SetScreen(Screen_e screen); void CycleScreens(void); void SetStatus(DisplayStatus_t & status); + void WriteStatus(); #ifdef QR_CODE_ENABLED void SetQRCode(uint8_t * str, uint32_t size); @@ -85,7 +86,6 @@ class SilabsLCD } DemoState_t; void WriteDemoUI(); - void WriteStatus(); #ifdef QR_CODE_ENABLED void WriteQRCode();