From 8c5438892e703b951e31a45f7c95685adf823dbe Mon Sep 17 00:00:00 2001 From: Ricardo Casallas Date: Tue, 23 Aug 2022 09:50:06 -0400 Subject: [PATCH 1/2] [EFR32] Window Covering app modified to compile on boards without LCD. --- .../window-app/efr32/include/WindowAppImpl.h | 5 ++++ .../window-app/efr32/src/WindowAppImpl.cpp | 24 +++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/examples/window-app/efr32/include/WindowAppImpl.h b/examples/window-app/efr32/include/WindowAppImpl.h index a052838add1c89..8bfbe8ead0b7be 100644 --- a/examples/window-app/efr32/include/WindowAppImpl.h +++ b/examples/window-app/efr32/include/WindowAppImpl.h @@ -26,6 +26,9 @@ #include #include #include +#ifdef DISPLAY_ENABLED +#include +#endif class WindowAppImpl : public WindowApp { @@ -81,6 +84,8 @@ class WindowAppImpl : public WindowApp // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; +#ifdef DISPLAY_ENABLED Timer mIconTimer; LcdIcon mIcon = LcdIcon::None; +#endif }; diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index 8ccfa97ea098a7..cd2ccc8471060b 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -16,12 +16,10 @@ */ #include -#include #include #include #include #include -#include #include #include #include @@ -37,6 +35,11 @@ #include "wfx_host_events.h" #endif +#ifdef DISPLAY_ENABLED +#include +SilabsLCD slLCD; +#endif + #define APP_TASK_STACK_SIZE (4096) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 @@ -129,16 +132,17 @@ StaticQueue_t sAppEventQueueStruct; WindowAppImpl WindowAppImpl::sInstance; -#ifdef DISPLAY_ENABLED -SilabsLCD slLCD; -#endif - WindowApp & WindowApp::Instance() { return WindowAppImpl::sInstance; } -WindowAppImpl::WindowAppImpl() : mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) {} +WindowAppImpl::WindowAppImpl() +#ifdef DISPLAY_ENABLED + : + mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) +#endif +{} void WindowAppImpl::OnTaskCallback(void * parameter) { @@ -147,8 +151,10 @@ void WindowAppImpl::OnTaskCallback(void * parameter) void WindowAppImpl::OnIconTimeout(WindowApp::Timer & timer) { +#ifdef DISPLAY_ENABLED sInstance.mIcon = LcdIcon::None; sInstance.UpdateLCD(); +#endif } CHIP_ERROR WindowAppImpl::Init() @@ -331,6 +337,7 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event) case EventId::BLEConnectionsChanged: UpdateLEDs(); break; +#ifdef DISPLAY_ENABLED case EventId::CoverTypeChange: UpdateLCD(); break; @@ -344,6 +351,7 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event) mIcon = mTiltMode ? LcdIcon::Tilt : LcdIcon::Lift; UpdateLCD(); break; +#endif default: break; } @@ -433,10 +441,12 @@ void WindowAppImpl::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 } #ifdef QR_CODE_ENABLED else From 4f9f32770acfebc0ee5c4c41fff00effa1998ae5 Mon Sep 17 00:00:00 2001 From: Ricardo Casallas Date: Wed, 24 Aug 2022 08:24:08 -0400 Subject: [PATCH 2/2] Review comments applied. --- examples/window-app/efr32/src/WindowAppImpl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index cd2ccc8471060b..3f2cad957c068a 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -137,12 +137,11 @@ WindowApp & WindowApp::Instance() return WindowAppImpl::sInstance; } -WindowAppImpl::WindowAppImpl() #ifdef DISPLAY_ENABLED - : - mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) +WindowAppImpl::WindowAppImpl() : mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) {} +#else +WindowAppImpl::WindowAppImpl() {} #endif -{} void WindowAppImpl::OnTaskCallback(void * parameter) {