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

[SL-UP] Adding app event for the LCD update #368

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions examples/lighting-app/silabs/include/AppEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct AppEvent
enum AppEventTypes
{
kEventType_Button = 0,
kEventType_LCD,
kEventType_Timer,
kEventType_Light,
kEventType_Install,
Expand Down
36 changes: 22 additions & 14 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
SilabsLCD::Screen_e screen;
slLCD.GetScreen(screen);
VerifyOrReturn(screen == SilabsLCD::Screen_e::QRCodeScreen);
slLCD.SetScreen(SilabsLCD::Screen_e::DemoScreen);
AppEvent event;
event.Type = AppEvent::kEventType_LCD;
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
BaseApplication::PostEvent(&event);
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED
}
Expand Down Expand Up @@ -597,8 +600,6 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
// - Cycle LCD screen
CancelFunctionTimer();

AppTask::GetAppTask().UpdateDisplay();

#ifdef SL_WIFI
if (!ConnectivityMgr().IsWiFiStationProvisioned())
#else
Expand All @@ -622,10 +623,21 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
}

AppEvent event;
event.Type = AppEvent::kEventType_LCD;
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
PostEvent(&event);
}
}
}

void BaseApplication::UpdateDisplayHandler(AppEvent * aEvent)
{
VerifyOrReturn(aEvent->Type == AppEvent::kEventType_LCD);
AppTask::GetAppTask().UpdateDisplay();
}

void BaseApplication::UpdateDisplay()
{
OutputQrCode(false);
Expand Down Expand Up @@ -793,14 +805,11 @@ SilabsLCD & BaseApplication::GetLCD(void)
return slLCD;
}

void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
void BaseApplication::UpdateLCDStatusScreen()
{
SilabsLCD::DisplayStatus_t status;
bool enabled, attached;
if (withChipStackLock)
{
chip::DeviceLayer::PlatformMgr().LockChipStack();
}
chip::DeviceLayer::PlatformMgr().LockChipStack();
#ifdef SL_WIFI
enabled = ConnectivityMgr().IsWiFiStationEnabled();
attached = ConnectivityMgr().IsWiFiStationConnected();
Expand All @@ -825,10 +834,7 @@ void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
? SilabsLCD::ICDMode_e::SIT
: SilabsLCD::ICDMode_e::LIT;
#endif
if (withChipStackLock)
{
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
slLCD.SetStatus(status);
}
#endif
Expand Down Expand Up @@ -935,8 +941,10 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
// Update the LCD screen with SSID and connected state
if (screen == SilabsLCD::Screen_e::StatusScreen)
{
BaseApplication::UpdateLCDStatusScreen(false);
AppTask::GetLCD().SetScreen(screen);
AppEvent event;
event.Type = AppEvent::kEventType_LCD;
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
PostEvent(&event);
}
#endif // DISPLAY_ENABLED

Expand Down
10 changes: 9 additions & 1 deletion examples/platform/silabs/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,15 @@ class BaseApplication
*/
static SilabsLCD & GetLCD(void);

static void UpdateLCDStatusScreen(bool withChipStackLock = true);
static void UpdateLCDStatusScreen();

/**
* @brief LCD Event processing function
* Update the LCD status based on the screen
*
* @param aEvent post event being processed
*/
static void UpdateDisplayHandler(AppEvent * aEvent);
#endif

/**
Expand Down
Loading