From 3969219a8a9ccea51bd3a043890d9f2242dee68b Mon Sep 17 00:00:00 2001 From: arun-silabs <141724790+arun-silabs@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:45:31 +0530 Subject: [PATCH] [Silabs] Fixed LCD animations for window-app (#29675) * Fixed LCD animations for window-app * Modified type conversion from (uint8_t *) to Uint8::from_char as mentioned in comments * As per comments, using BaseApplication to get provision state and updated UpdateLEDs() API. * Added sIsProvisioned as member variable in BaseApplication class. * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io --- examples/platform/silabs/BaseApplication.cpp | 24 +++++++++------- examples/platform/silabs/BaseApplication.h | 2 ++ .../window-app/silabs/include/WindowManager.h | 1 - .../window-app/silabs/src/WindowManager.cpp | 28 +------------------ 4 files changed, 17 insertions(+), 38 deletions(-) diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 5eb8a6886ea72f..e5b5c0ba58f2a3 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -114,8 +114,6 @@ app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::SlWiFiDriver::GetInstance())); #endif /* SL_WIFI */ -bool sIsProvisioned = false; - #if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER) bool sIsEnabled = false; bool sIsAttached = false; @@ -148,6 +146,7 @@ Identify gIdentify = { #endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER } // namespace +bool BaseApplication::sIsProvisioned = false; #ifdef DIC_ENABLE namespace { @@ -259,10 +258,10 @@ CHIP_ERROR BaseApplication::Init() PlatformMgr().AddEventHandler(OnPlatformEvent, 0); #ifdef SL_WIFI - sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); + BaseApplication::sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); #endif /* SL_WIFI */ #if CHIP_ENABLE_OPENTHREAD - sIsProvisioned = ConnectivityMgr().IsThreadProvisioned(); + BaseApplication::sIsProvisioned = ConnectivityMgr().IsThreadProvisioned(); #endif return err; @@ -375,7 +374,7 @@ bool BaseApplication::ActivateStatusLedPatterns() if (!isPatternSet) { // Apply different status feedbacks - if (sIsProvisioned && sIsEnabled) + if (BaseApplication::sIsProvisioned && sIsEnabled) { if (sIsAttached) { @@ -413,9 +412,9 @@ void BaseApplication::LightEventHandler() if (PlatformMgr().TryLockChipStack()) { #ifdef SL_WIFI - sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); - sIsEnabled = ConnectivityMgr().IsWiFiStationEnabled(); - sIsAttached = ConnectivityMgr().IsWiFiStationConnected(); + BaseApplication::sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); + sIsEnabled = ConnectivityMgr().IsWiFiStationEnabled(); + sIsAttached = ConnectivityMgr().IsWiFiStationConnected(); #endif /* SL_WIFI */ #if CHIP_ENABLE_OPENTHREAD sIsEnabled = ConnectivityMgr().IsThreadEnabled(); @@ -491,7 +490,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) #ifdef SL_WIFI if (!ConnectivityMgr().IsWiFiStationProvisioned()) #else - if (!sIsProvisioned) + if (!BaseApplication::sIsProvisioned) #endif /* !SL_WIFI */ { // Open Basic CommissioningWindow. Will start BLE advertisements @@ -722,7 +721,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t) { if (event->Type == DeviceEventType::kServiceProvisioningChange) { - sIsProvisioned = event->ServiceProvisioningChange.IsServiceProvisioned; + BaseApplication::sIsProvisioned = event->ServiceProvisioningChange.IsServiceProvisioned; } } @@ -752,3 +751,8 @@ void BaseApplication::OutputQrCode(bool refreshLCD) SILABS_LOG("Getting QR code failed!"); } } + +bool BaseApplication::getWifiProvisionStatus() +{ + return BaseApplication::sIsProvisioned; +} diff --git a/examples/platform/silabs/BaseApplication.h b/examples/platform/silabs/BaseApplication.h index b3a9db893183e5..8bf67836b9c47a 100644 --- a/examples/platform/silabs/BaseApplication.h +++ b/examples/platform/silabs/BaseApplication.h @@ -70,6 +70,7 @@ class BaseApplication public: BaseApplication() = default; virtual ~BaseApplication(){}; + static bool sIsProvisioned; /** * @brief Create AppTask task and Event Queue @@ -103,6 +104,7 @@ class BaseApplication * Turns off Status LED before stopping timer */ static void StopStatusLEDTimer(void); + static bool getWifiProvisionStatus(void); #ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER // Idenfiy server command callbacks. diff --git a/examples/window-app/silabs/include/WindowManager.h b/examples/window-app/silabs/include/WindowManager.h index 0249ddc5e67051..33121118c7b60c 100644 --- a/examples/window-app/silabs/include/WindowManager.h +++ b/examples/window-app/silabs/include/WindowManager.h @@ -160,7 +160,6 @@ class WindowManager LEDWidget mStatusLED; LEDWidget mActionLED; - #ifdef DISPLAY_ENABLED Timer mIconTimer; LcdIcon mIcon = LcdIcon::None; diff --git a/examples/window-app/silabs/src/WindowManager.cpp b/examples/window-app/silabs/src/WindowManager.cpp index c4358e13409225..46e883abe37dbc 100644 --- a/examples/window-app/silabs/src/WindowManager.cpp +++ b/examples/window-app/silabs/src/WindowManager.cpp @@ -657,30 +657,6 @@ void WindowManager::UpdateLEDs() } else { - if (mState.isWinking) - { - mStatusLED.Blink(200, 200); - } - else -#if CHIP_ENABLE_OPENTHREAD - if (mState.isThreadProvisioned && mState.isThreadEnabled) -#else - if (mState.isWiFiProvisioned && mState.isWiFiEnabled) -#endif - - { - - mStatusLED.Blink(950, 50); - } - else if (mState.haveBLEConnections) - { - mStatusLED.Blink(100, 100); - } - else - { - mStatusLED.Blink(50, 950); - } - // Action LED NPercent100ths current; LimitStatus liftLimit = LimitStatus::Intermediate; @@ -725,7 +701,7 @@ void WindowManager::UpdateLCD() #if CHIP_ENABLE_OPENTHREAD if (mState.isThreadProvisioned) #else - if (mState.isWiFiProvisioned) + if (BaseApplication::getWifiProvisionStatus()) #endif // CHIP_ENABLE_OPENTHREAD { Cover & cover = GetCover(); @@ -739,12 +715,10 @@ void WindowManager::UpdateLCD() Attributes::CurrentPositionTilt::Get(cover.mEndpoint, tilt); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); -#ifdef DISPLAY_ENABLED if (!tilt.IsNull() && !lift.IsNull()) { LcdPainter::Paint(slLCD, type, lift.Value(), tilt.Value(), mIcon); } -#endif } #endif // DISPLAY_ENABLED }