Skip to content

Commit

Permalink
Removed mName and mTimeout attributes from WindowManager::Timer struc…
Browse files Browse the repository at this point in the history
…t to reduce memory occupancy
  • Loading branch information
andygallay-silabs committed Jun 14, 2023
1 parent b285b3a commit 4949817
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 1 addition & 4 deletions examples/window-app/silabs/include/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ class WindowManager
{
typedef void (*Callback)(Timer & timer);

Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context);
Timer(uint32_t timeoutInMs, Callback callback, void * context);

void Start();
void Stop();
void Timeout();

const char * mName = nullptr;
uint32_t mTimeoutInMs = 0;
Callback mCallback = nullptr;
void * mContext = nullptr;
bool mIsActive = false;

TimerHandle_t mHandler = nullptr;
void IsrStart();

private:
static void TimerCallback(TimerHandle_t xTimer);
Expand Down
14 changes: 7 additions & 7 deletions examples/window-app/silabs/src/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ void WindowManager::OnLongPressTimeout(WindowManager::Timer & timer)
void WindowManager::Cover::Init(chip::EndpointId endpoint)
{
mEndpoint = endpoint;
mLiftTimer = new Timer("Timer:Lift", COVER_LIFT_TILT_TIMEOUT, OnLiftTimeout, this);
mTiltTimer = new Timer("Timer:Tilt", COVER_LIFT_TILT_TIMEOUT, OnTiltTimeout, this);
mLiftTimer = new Timer(COVER_LIFT_TILT_TIMEOUT, OnLiftTimeout, this);
mTiltTimer = new Timer(COVER_LIFT_TILT_TIMEOUT, OnTiltTimeout, this);

// Preset Lift attributes
Attributes::InstalledOpenLimitLift::Set(endpoint, LIFT_OPEN_LIMIT);
Expand Down Expand Up @@ -595,10 +595,10 @@ void WindowManager::Cover::CallbackOperationalStateSet(intptr_t arg)
// Timers
//------------------------------------------------------------------------------

WindowManager::Timer::Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context) :
mName(name), mTimeoutInMs(timeoutInMs), mCallback(callback), mContext(context)
WindowManager::Timer::Timer(uint32_t timeoutInMs, Callback callback, void * context) :
mCallback(callback), mContext(context)
{
mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel
mHandler = xTimerCreate("", // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(timeoutInMs), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
Expand Down Expand Up @@ -637,7 +637,7 @@ WindowManager & WindowManager::Instance()
}

#ifdef DISPLAY_ENABLED
WindowManager::WindowManager() : mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) {}
WindowManager::WindowManager() : mIconTimer(LCD_ICON_TIMEOUT, OnIconTimeout, this) {}
#else
WindowManager::WindowManager() {}
#endif
Expand All @@ -657,7 +657,7 @@ CHIP_ERROR WindowManager::Init()
ConfigurationMgr().LogDeviceConfig();

// Timers
mLongPressTimer = new Timer("Timer:LongPress", LONG_PRESS_TIMEOUT, OnLongPressTimeout, this);
mLongPressTimer = new Timer(LONG_PRESS_TIMEOUT, OnLongPressTimeout, this);

// Coverings
mCoverList[0].Init(WINDOW_COVER_ENDPOINT1);
Expand Down

0 comments on commit 4949817

Please sign in to comment.