Skip to content

Commit

Permalink
[EFR32] Window Covering app modified to compile on boards without LCD. (
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs authored and isiu-apple committed Sep 16, 2022
1 parent 0620812 commit 4227e7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions examples/window-app/efr32/include/WindowAppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <string>
#include <task.h>
#include <timers.h>
#ifdef DISPLAY_ENABLED
#include <LcdPainter.h>
#endif

class WindowAppImpl : public WindowApp
{
Expand Down Expand Up @@ -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
};
21 changes: 15 additions & 6 deletions examples/window-app/efr32/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
*/

#include <AppConfig.h>
#include <LcdPainter.h>
#include <WindowAppImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/window-covering-server/window-covering-server.h>
#include <app/server/OnboardingCodesUtil.h>
#include <lcd.h>
#include <lib/core/CHIPError.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -37,6 +35,11 @@
#include "wfx_host_events.h"
#endif

#ifdef DISPLAY_ENABLED
#include <LcdPainter.h>
SilabsLCD slLCD;
#endif

#define APP_TASK_STACK_SIZE (4096)
#define APP_TASK_PRIORITY 2
#define APP_EVENT_QUEUE_SIZE 10
Expand Down Expand Up @@ -129,16 +132,16 @@ StaticQueue_t sAppEventQueueStruct;

WindowAppImpl WindowAppImpl::sInstance;

#ifdef DISPLAY_ENABLED
SilabsLCD slLCD;
#endif

WindowApp & WindowApp::Instance()
{
return WindowAppImpl::sInstance;
}

#ifdef DISPLAY_ENABLED
WindowAppImpl::WindowAppImpl() : mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) {}
#else
WindowAppImpl::WindowAppImpl() {}
#endif

void WindowAppImpl::OnTaskCallback(void * parameter)
{
Expand All @@ -147,8 +150,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()
Expand Down Expand Up @@ -331,6 +336,7 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event)
case EventId::BLEConnectionsChanged:
UpdateLEDs();
break;
#ifdef DISPLAY_ENABLED
case EventId::CoverTypeChange:
UpdateLCD();
break;
Expand All @@ -344,6 +350,7 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event)
mIcon = mTiltMode ? LcdIcon::Tilt : LcdIcon::Lift;
UpdateLCD();
break;
#endif
default:
break;
}
Expand Down Expand Up @@ -433,10 +440,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
Expand Down

0 comments on commit 4227e7a

Please sign in to comment.