diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index fcb6a76156c374..c8a99b45ac1a5d 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -27,10 +27,6 @@ #include -#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) -#include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS - #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED @@ -146,8 +142,10 @@ Identify gIdentify = { #endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER } // namespace + bool BaseApplication::sIsProvisioned = false; -bool BaseApplication::mIsFactoryResetTriggered = false; +bool BaseApplication::sIsFactoryResetTriggered = false; +LEDWidget * BaseApplication::sAppActionLed = nullptr; #ifdef DIC_ENABLE namespace { @@ -280,7 +278,7 @@ void BaseApplication::FunctionEventHandler(AppEvent * aEvent) { VerifyOrReturn(aEvent->Type == AppEvent::kEventType_Timer); // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT, - if (!mIsFactoryResetTriggered) + if (!sIsFactoryResetTriggered) { StartFactoryResetSequence(); } @@ -411,7 +409,8 @@ void BaseApplication::LightEventHandler() #endif // CHIP_CONFIG_ENABLE_ICD_SERVER -#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) +#if defined(ENABLE_WSTK_LEDS) +#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917)) // Update the status LED if factory reset has not been initiated. // // If system has "full connectivity", keep the LED On constantly. @@ -424,13 +423,18 @@ void BaseApplication::LightEventHandler() // the LEDs at an even rate of 100ms. // // Otherwise, blink the LED ON for a very short time. - if (!mIsFactoryResetTriggered) + if (!sIsFactoryResetTriggered) { ActivateStatusLedPatterns(); } sStatusLED.Animate(); -#endif // ENABLE_WSTK_LEDS && SL_CATALOG_SIMPLE_LED_LED1_PRESENT +#endif // SL_CATALOG_SIMPLE_LED_LED1_PRESENT + if (sAppActionLed) + { + sAppActionLed->Animate(); + } +#endif // ENABLE_WSTK_LEDS } void BaseApplication::ButtonHandler(AppEvent * aEvent) @@ -448,7 +452,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) } else { - if (mIsFactoryResetTriggered) + if (sIsFactoryResetTriggered) { CancelFactoryResetSequence(); } @@ -531,7 +535,7 @@ void BaseApplication::StartFactoryResetSequence() // cancel, if required. StartFunctionTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); - mIsFactoryResetTriggered = true; + sIsFactoryResetTriggered = true; #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 StartStatusLEDTimer(); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER @@ -551,9 +555,9 @@ void BaseApplication::CancelFactoryResetSequence() #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 StopStatusLEDTimer(); #endif - if (mIsFactoryResetTriggered) + if (sIsFactoryResetTriggered) { - mIsFactoryResetTriggered = false; + sIsFactoryResetTriggered = false; SILABS_LOG("Factory Reset has been Canceled"); } } diff --git a/examples/platform/silabs/BaseApplication.h b/examples/platform/silabs/BaseApplication.h index 67a44ee4e2954e..7b31f233d920a4 100644 --- a/examples/platform/silabs/BaseApplication.h +++ b/examples/platform/silabs/BaseApplication.h @@ -36,6 +36,10 @@ #include #include +#if defined(ENABLE_WSTK_LEDS) +#include "LEDWidget.h" +#endif // ENABLE_WSTK_LEDS + #ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER #include #endif @@ -71,7 +75,8 @@ class BaseApplication BaseApplication() = default; virtual ~BaseApplication(){}; static bool sIsProvisioned; - static bool mIsFactoryResetTriggered; + static bool sIsFactoryResetTriggered; + static LEDWidget * sAppActionLed; /** * @brief Create AppTask task and Event Queue @@ -81,6 +86,20 @@ class BaseApplication */ CHIP_ERROR StartAppTask(TaskFunction_t taskFunction); + /** + * @brief Links the application specific led to the baseApplication context + * in order to synchronize both LED animations. + * Some apps may not have an application led or no animation patterns. + * + * @param appLed Pointer to the configure LEDWidget for the application defined LED + */ + void LinkAppLed(LEDWidget * appLed) { sAppActionLed = appLed; } + + /** + * @brief Remove the app Led linkage form the baseApplication context + */ + void UnlinkAppLed() { sAppActionLed = nullptr; } + /** * @brief PostEvent function that add event to AppTask queue for processing * diff --git a/examples/window-app/silabs/src/AppTask.cpp b/examples/window-app/silabs/src/AppTask.cpp index 8021688a892385..e8b5cc332bfc2f 100644 --- a/examples/window-app/silabs/src/AppTask.cpp +++ b/examples/window-app/silabs/src/AppTask.cpp @@ -23,8 +23,6 @@ #include "WindowManager.h" -#include "LEDWidget.h" - #include #include #include @@ -39,20 +37,10 @@ #include -#if !defined(BRD2704A) -#define LIGHT_LED 1 -#else -#define LIGHT_LED 0 -#endif - using namespace chip; using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceLayer::Silabs; -namespace { -LEDWidget sLightLED; -} - using namespace chip::TLV; using namespace ::chip::DeviceLayer; @@ -82,23 +70,6 @@ CHIP_ERROR AppTask::Init() appError(err); } - sLightLED.Init(LIGHT_LED); - -// Update the LCD with the Stored value. Show QR Code if not provisioned -#ifdef DISPLAY_ENABLED - -#ifdef QR_CODE_ENABLED -#ifdef SL_WIFI - if (!ConnectivityMgr().IsWiFiStationProvisioned()) -#else - if (!ConnectivityMgr().IsThreadProvisioned()) -#endif /* !SL_WIFI */ - { - GetLCD().ShowQRCode(true); - } -#endif // QR_CODE_ENABLED -#endif - return err; } diff --git a/examples/window-app/silabs/src/WindowManager.cpp b/examples/window-app/silabs/src/WindowManager.cpp index c69b45e6cc59bf..309fb393565990 100644 --- a/examples/window-app/silabs/src/WindowManager.cpp +++ b/examples/window-app/silabs/src/WindowManager.cpp @@ -42,7 +42,6 @@ #ifdef DISPLAY_ENABLED #include -SilabsLCD slLCD; #endif #include @@ -602,8 +601,6 @@ CHIP_ERROR WindowManager::Init() { chip::DeviceLayer::PlatformMgr().LockChipStack(); - ConfigurationMgr().LogDeviceConfig(); - // Timers mLongPressTimer = new Timer(LONG_PRESS_TIMEOUT, OnLongPressTimeout, this); @@ -614,10 +611,7 @@ CHIP_ERROR WindowManager::Init() // Initialize LEDs LEDWidget::InitGpio(); mActionLED.Init(APP_ACTION_LED); - -#ifdef DISPLAY_ENABLED - slLCD.Init(); -#endif + AppTask::GetAppTask().LinkAppLed(&mActionLED); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); @@ -637,13 +631,11 @@ void WindowManager::UpdateLED() Cover & cover = GetCover(); if (mResetWarning) { - SILABS_LOG("---- UPDATE ACTION LED mResetWarning") mActionLED.Set(false); mActionLED.Blink(500); } else { - SILABS_LOG("******* UPDATE ACTION LED NORMAL") // Action LED NPercent100ths current; LimitStatus liftLimit = LimitStatus::Intermediate; @@ -664,12 +656,10 @@ void WindowManager::UpdateLED() } else if (LimitStatus::IsUpOrOpen == liftLimit) { - SILABS_LOG("---- UPDATE ACTION LED IsUpOrOpen") mActionLED.Set(true); } else if (LimitStatus::IsDownOrClose == liftLimit) { - SILABS_LOG("---- UPDATE ACTION LED IsDownOrClose") mActionLED.Set(false); } else @@ -698,7 +688,7 @@ void WindowManager::UpdateLCD() if (!tilt.IsNull() && !lift.IsNull()) { - LcdPainter::Paint(slLCD, type, lift.Value(), tilt.Value(), mIcon); + LcdPainter::Paint(AppTask::GetAppTask().GetLCD(), type, lift.Value(), tilt.Value(), mIcon); } } #endif // DISPLAY_ENABLED