@@ -251,11 +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
- AppEvent event;
255
- event.Type = AppEvent::kEventType_LCD ;
256
- event.LCDEvent .screen = reinterpret_cast <void *>(static_cast <uintptr_t >(SilabsLCD::Screen_e::DemoScreen));
257
- event.Handler = AppTask::GetAppTask ().UpdateDisplayHandler ;
258
- BaseApplication::PostEvent (&event);
254
+ BaseApplication::PostUpdateDisplayEvent (SilabsLCD::Screen_e::DemoScreen);
259
255
#endif // QR_CODE_ENABLED
260
256
#endif // DISPLAY_ENABLED
261
257
}
@@ -625,31 +621,15 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
625
621
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
626
622
}
627
623
628
- AppEvent event;
629
- event. Type = AppEvent:: kEventType_LCD ;
630
- event. LCDEvent . screen = reinterpret_cast < void *>( static_cast < uintptr_t >(SilabsLCD::Screen_e::CycleScreen));
631
- event. Handler = AppTask::GetAppTask (). UpdateDisplayHandler ;
632
- PostEvent (&event);
624
+ // Print the QR Code
625
+ OutputQrCode ( false ) ;
626
+ # ifdef DISPLAY_ENABLED
627
+ PostUpdateDisplayEvent (SilabsLCD::Screen_e::CycleScreen) ;
628
+ # endif // DISPLAY_ENABLED
633
629
}
634
630
}
635
631
}
636
632
637
- void BaseApplication::UpdateDisplayHandler (AppEvent * aEvent)
638
- {
639
- VerifyOrReturn (aEvent->Type == AppEvent::kEventType_LCD );
640
- SilabsLCD::Screen_e screen = static_cast <SilabsLCD::Screen_e>(reinterpret_cast <uintptr_t >(aEvent->LCDEvent .screen ));
641
- (screen == SilabsLCD::Screen_e::CycleScreen) ? AppTask::GetAppTask ().UpdateDisplay () : AppTask::GetLCD ().SetScreen (screen);
642
- }
643
-
644
- void BaseApplication::UpdateDisplay ()
645
- {
646
- OutputQrCode (false );
647
- #ifdef DISPLAY_ENABLED
648
- UpdateLCDStatusScreen ();
649
- slLCD.CycleScreens ();
650
- #endif
651
- }
652
-
653
633
void BaseApplication::CancelFunctionTimer ()
654
634
{
655
635
if (osTimerStop (sFunctionTimer ) == osError)
@@ -808,6 +788,32 @@ SilabsLCD & BaseApplication::GetLCD(void)
808
788
return slLCD;
809
789
}
810
790
791
+ void BaseApplication::PostUpdateDisplayEvent (SilabsLCD::Screen_e screen)
792
+ {
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)
805
+ {
806
+ UpdateLCDStatusScreen ();
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
+
811
817
void BaseApplication::UpdateLCDStatusScreen ()
812
818
{
813
819
SilabsLCD::DisplayStatus_t status;
@@ -944,11 +950,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
944
950
// Update the LCD screen with SSID and connected state
945
951
if (screen == SilabsLCD::Screen_e::StatusScreen)
946
952
{
947
- AppEvent event;
948
- event.Type = AppEvent::kEventType_LCD ;
949
- event.LCDEvent .screen = reinterpret_cast <void *>(static_cast <uintptr_t >(SilabsLCD::Screen_e::StatusScreen));
950
- event.Handler = AppTask::GetAppTask ().UpdateDisplayHandler ;
951
- PostEvent (&event);
953
+ PostUpdateDisplayEvent (SilabsLCD::Screen_e::StatusScreen);
952
954
}
953
955
#endif // DISPLAY_ENABLED
954
956
0 commit comments