@@ -251,7 +251,7 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
251
251
SilabsLCD::Screen_e screen;
252
252
slLCD.GetScreen (screen);
253
253
VerifyOrReturn (screen == SilabsLCD::Screen_e::QRCodeScreen);
254
- slLCD. SetScreen (SilabsLCD::Screen_e::DemoScreen);
254
+ BaseApplication::PostUpdateDisplayEvent (SilabsLCD::Screen_e::DemoScreen);
255
255
#endif // QR_CODE_ENABLED
256
256
#endif // DISPLAY_ENABLED
257
257
}
@@ -597,8 +597,6 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
597
597
// - Cycle LCD screen
598
598
CancelFunctionTimer ();
599
599
600
- AppTask::GetAppTask ().UpdateDisplay ();
601
-
602
600
#ifdef SL_WIFI
603
601
if (!ConnectivityMgr ().IsWiFiStationProvisioned ())
604
602
#else
@@ -622,17 +620,14 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
622
620
PlatformMgr ().ScheduleWork ([](intptr_t ) { ICDNotifier::GetInstance ().NotifyNetworkActivityNotification (); });
623
621
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
624
622
}
625
- }
626
- }
627
- }
628
623
629
- void BaseApplication::UpdateDisplay ()
630
- {
631
- OutputQrCode (false );
624
+ // Print the QR Code
625
+ OutputQrCode (false );
632
626
#ifdef DISPLAY_ENABLED
633
- UpdateLCDStatusScreen ();
634
- slLCD.CycleScreens ();
635
- #endif
627
+ PostUpdateDisplayEvent (SilabsLCD::Screen_e::CycleScreen);
628
+ #endif // DISPLAY_ENABLED
629
+ }
630
+ }
636
631
}
637
632
638
633
void BaseApplication::CancelFunctionTimer ()
@@ -793,14 +788,37 @@ SilabsLCD & BaseApplication::GetLCD(void)
793
788
return slLCD;
794
789
}
795
790
796
- void BaseApplication::UpdateLCDStatusScreen ( bool withChipStackLock )
791
+ void BaseApplication::PostUpdateDisplayEvent (SilabsLCD::Screen_e screen )
797
792
{
798
- SilabsLCD::DisplayStatus_t status;
799
- bool enabled, attached;
800
- if (withChipStackLock)
793
+ AppEvent event;
794
+ event.Type = AppEvent::kEventType_LCD ;
795
+ event.LCDEvent .screen = screen;
796
+ event.Handler = AppTask::GetAppTask ().UpdateDisplayHandler ;
797
+ BaseApplication::PostEvent (&event);
798
+ }
799
+
800
+ void BaseApplication::UpdateDisplayHandler (AppEvent * aEvent)
801
+ {
802
+ VerifyOrReturn (aEvent->Type == AppEvent::kEventType_LCD );
803
+ SilabsLCD::Screen_e screen = aEvent->LCDEvent .screen ;
804
+ if (screen == SilabsLCD::Screen_e::StatusScreen)
801
805
{
802
- chip::DeviceLayer::PlatformMgr (). LockChipStack ();
806
+ UpdateLCDStatusScreen ();
803
807
}
808
+ (screen == SilabsLCD::Screen_e::CycleScreen) ? AppTask::GetAppTask ().UpdateDisplay () : AppTask::GetLCD ().SetScreen (screen);
809
+ }
810
+
811
+ void BaseApplication::UpdateDisplay ()
812
+ {
813
+ UpdateLCDStatusScreen ();
814
+ slLCD.CycleScreens ();
815
+ }
816
+
817
+ void BaseApplication::UpdateLCDStatusScreen ()
818
+ {
819
+ SilabsLCD::DisplayStatus_t status;
820
+ bool enabled, attached;
821
+ chip::DeviceLayer::PlatformMgr ().LockChipStack ();
804
822
#ifdef SL_WIFI
805
823
enabled = ConnectivityMgr ().IsWiFiStationEnabled ();
806
824
attached = ConnectivityMgr ().IsWiFiStationConnected ();
@@ -825,10 +843,7 @@ void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
825
843
? SilabsLCD::ICDMode_e::SIT
826
844
: SilabsLCD::ICDMode_e::LIT;
827
845
#endif
828
- if (withChipStackLock)
829
- {
830
- chip::DeviceLayer::PlatformMgr ().UnlockChipStack ();
831
- }
846
+ chip::DeviceLayer::PlatformMgr ().UnlockChipStack ();
832
847
slLCD.SetStatus (status);
833
848
}
834
849
#endif
@@ -935,8 +950,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
935
950
// Update the LCD screen with SSID and connected state
936
951
if (screen == SilabsLCD::Screen_e::StatusScreen)
937
952
{
938
- BaseApplication::UpdateLCDStatusScreen (false );
939
- AppTask::GetLCD ().SetScreen (screen);
953
+ PostUpdateDisplayEvent (SilabsLCD::Screen_e::StatusScreen);
940
954
}
941
955
#endif // DISPLAY_ENABLED
942
956
0 commit comments