Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs]Make changes to the window manager class so its static constructor do… #33473

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/window-app/silabs/include/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WindowManager
typedef void (*Callback)(Timer & timer);

Timer(uint32_t timeoutInMs, Callback callback, void * context);
~Timer();

void Start();
void Stop();
Expand Down Expand Up @@ -155,7 +156,7 @@ class WindowManager

LEDWidget mActionLED;
#ifdef DISPLAY_ENABLED
Timer mIconTimer;
LcdIcon mIcon = LcdIcon::None;
Timer * mIconTimer = nullptr;
LcdIcon mIcon = LcdIcon::None;
#endif
};
26 changes: 20 additions & 6 deletions examples/window-app/silabs/src/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ WindowManager::Timer::Timer(uint32_t timeoutInMs, Callback callback, void * cont
}
}

WindowManager::Timer::~Timer()
{
if (mHandler)
{
osTimerDelete(mHandler);
mHandler = nullptr;
}
}

void WindowManager::Timer::Stop()
{
mIsActive = false;
Expand All @@ -538,11 +547,7 @@ WindowManager & WindowManager::Instance()
return WindowManager::sWindow;
}

#ifdef DISPLAY_ENABLED
WindowManager::WindowManager() : mIconTimer(LCD_ICON_TIMEOUT, OnIconTimeout, this) {}
#else
WindowManager::WindowManager() {}
#endif

void WindowManager::OnIconTimeout(WindowManager::Timer & timer)
{
Expand All @@ -556,6 +561,9 @@ CHIP_ERROR WindowManager::Init()
{
chip::DeviceLayer::PlatformMgr().LockChipStack();

#ifdef DISPLAY_ENABLED
mIconTimer = new Timer(LCD_ICON_TIMEOUT, OnIconTimeout, this);
#endif
// Timers
mLongPressTimer = new Timer(LONG_PRESS_TIMEOUT, OnLongPressTimeout, this);

Expand Down Expand Up @@ -768,13 +776,19 @@ void WindowManager::GeneralEventHandler(AppEvent * aEvent)
window->UpdateLCD();
break;
case AppEvent::kEventType_CoverChange:
window->mIconTimer.Start();
if (window->mIconTimer != nullptr)
{
window->mIconTimer->Start();
}
window->mIcon = (window->GetCover().mEndpoint == 1) ? LcdIcon::One : LcdIcon::Two;
window->UpdateLCD();
break;
case AppEvent::kEventType_TiltModeChange:
ChipLogDetail(AppServer, "App control mode changed to %s", window->mTiltMode ? "Tilt" : "Lift");
window->mIconTimer.Start();
if (window->mIconTimer != nullptr)
{
window->mIconTimer->Start();
}
window->mIcon = window->mTiltMode ? LcdIcon::Tilt : LcdIcon::Lift;
window->UpdateLCD();
break;
Expand Down
Loading