Skip to content

Commit a06555e

Browse files
committed
adding app event for the lcd
1 parent 4c36fe9 commit a06555e

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

examples/lighting-app/silabs/include/AppEvent.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct AppEvent
2727
enum AppEventTypes
2828
{
2929
kEventType_Button = 0,
30+
kEventType_LCD,
3031
kEventType_Timer,
3132
kEventType_Light,
3233
kEventType_Install,

examples/platform/silabs/BaseApplication.cpp

+22-14
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
251251
SilabsLCD::Screen_e screen;
252252
slLCD.GetScreen(screen);
253253
VerifyOrReturn(screen == SilabsLCD::Screen_e::QRCodeScreen);
254-
slLCD.SetScreen(SilabsLCD::Screen_e::DemoScreen);
254+
AppEvent event;
255+
event.Type = AppEvent::kEventType_LCD;
256+
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
257+
BaseApplication::PostEvent(&event);
255258
#endif // QR_CODE_ENABLED
256259
#endif // DISPLAY_ENABLED
257260
}
@@ -597,8 +600,6 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
597600
// - Cycle LCD screen
598601
CancelFunctionTimer();
599602

600-
AppTask::GetAppTask().UpdateDisplay();
601-
602603
#ifdef SL_WIFI
603604
if (!ConnectivityMgr().IsWiFiStationProvisioned())
604605
#else
@@ -622,10 +623,21 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
622623
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
623624
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
624625
}
626+
627+
AppEvent event;
628+
event.Type = AppEvent::kEventType_LCD;
629+
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
630+
PostEvent(&event);
625631
}
626632
}
627633
}
628634

635+
void BaseApplication::UpdateDisplayHandler(AppEvent * aEvent)
636+
{
637+
VerifyOrReturn(aEvent->Type == AppEvent::kEventType_LCD);
638+
AppTask::GetAppTask().UpdateDisplay();
639+
}
640+
629641
void BaseApplication::UpdateDisplay()
630642
{
631643
OutputQrCode(false);
@@ -793,14 +805,11 @@ SilabsLCD & BaseApplication::GetLCD(void)
793805
return slLCD;
794806
}
795807

796-
void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
808+
void BaseApplication::UpdateLCDStatusScreen()
797809
{
798810
SilabsLCD::DisplayStatus_t status;
799811
bool enabled, attached;
800-
if (withChipStackLock)
801-
{
802-
chip::DeviceLayer::PlatformMgr().LockChipStack();
803-
}
812+
chip::DeviceLayer::PlatformMgr().LockChipStack();
804813
#ifdef SL_WIFI
805814
enabled = ConnectivityMgr().IsWiFiStationEnabled();
806815
attached = ConnectivityMgr().IsWiFiStationConnected();
@@ -825,10 +834,7 @@ void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
825834
? SilabsLCD::ICDMode_e::SIT
826835
: SilabsLCD::ICDMode_e::LIT;
827836
#endif
828-
if (withChipStackLock)
829-
{
830-
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
831-
}
837+
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
832838
slLCD.SetStatus(status);
833839
}
834840
#endif
@@ -935,8 +941,10 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
935941
// Update the LCD screen with SSID and connected state
936942
if (screen == SilabsLCD::Screen_e::StatusScreen)
937943
{
938-
BaseApplication::UpdateLCDStatusScreen(false);
939-
AppTask::GetLCD().SetScreen(screen);
944+
AppEvent event;
945+
event.Type = AppEvent::kEventType_LCD;
946+
event.Handler = AppTask::GetAppTask().UpdateDisplayHandler;
947+
PostEvent(&event);
940948
}
941949
#endif // DISPLAY_ENABLED
942950

examples/platform/silabs/BaseApplication.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ class BaseApplication
138138
*/
139139
static SilabsLCD & GetLCD(void);
140140

141-
static void UpdateLCDStatusScreen(bool withChipStackLock = true);
141+
static void UpdateLCDStatusScreen();
142+
143+
/**
144+
* @brief LCD Event processing function
145+
* Update the LCD status based on the screen
146+
*
147+
* @param aEvent post event being processed
148+
*/
149+
static void UpdateDisplayHandler(AppEvent * aEvent);
142150
#endif
143151

144152
/**

0 commit comments

Comments
 (0)