@@ -70,7 +70,7 @@ AppTask AppTask::sAppTask;
70
70
bool sFunctionButtonPressed = false ; // True when button0 is pressed, used to trigger factory reset
71
71
bool sActionButtonPressed = false ; // True when button1 is pressed, used to initiate toggle or level-up/down
72
72
bool sActionButtonSuppressed = false ; // True when both button0 and button1 are pressed, used to switch step direction
73
- bool sFunctionButtonSuppressed = false ; // True when both button0 and button1 are pressed
73
+ bool sIsButtonEventTriggered = false ; // True when button0 press event is posted to BaseApplication
74
74
75
75
CHIP_ERROR AppTask::Init ()
76
76
{
@@ -253,13 +253,13 @@ void AppTask::AppEventHandler(AppEvent * aEvent)
253
253
if (sActionButtonPressed )
254
254
{
255
255
sActionButtonSuppressed = true ;
256
- sFunctionButtonSuppressed = true ;
257
256
LightSwitchMgr::GetInstance ().changeStepMode ();
258
257
ChipLogProgress (AppServer, " Step direction changed. Current Step Direction : %s" ,
259
258
((LightSwitchMgr::GetInstance ().getStepMode () == StepModeEnum::kUp ) ? " kUp" : " kDown" ));
260
259
}
261
260
else
262
261
{
262
+ sIsButtonEventTriggered = true ;
263
263
// Post button press event to BaseApplication
264
264
AppEvent button_event = {};
265
265
button_event.Type = AppEvent::kEventType_Button ;
@@ -270,16 +270,16 @@ void AppTask::AppEventHandler(AppEvent * aEvent)
270
270
break ;
271
271
case AppEvent::kEventType_FunctionButtonReleased : {
272
272
sFunctionButtonPressed = false ;
273
- if (sFunctionButtonSuppressed )
273
+ if (sIsButtonEventTriggered )
274
274
{
275
- sFunctionButtonSuppressed = false ;
275
+ sIsButtonEventTriggered = false ;
276
+ // Post button release event to BaseApplication
277
+ AppEvent button_event = {};
278
+ button_event.Type = AppEvent::kEventType_Button ;
279
+ button_event.ButtonEvent .Action = static_cast <uint8_t >(SilabsPlatform::ButtonAction::ButtonReleased);
280
+ button_event.Handler = BaseApplication::ButtonHandler;
281
+ AppTask::GetAppTask ().PostEvent (&button_event);
276
282
}
277
- // Post button release event to BaseApplication
278
- AppEvent button_event = {};
279
- button_event.Type = AppEvent::kEventType_Button ;
280
- button_event.ButtonEvent .Action = static_cast <uint8_t >(SilabsPlatform::ButtonAction::ButtonReleased);
281
- button_event.Handler = BaseApplication::ButtonHandler;
282
- AppTask::GetAppTask ().PostEvent (&button_event);
283
283
break ;
284
284
}
285
285
case AppEvent::kEventType_ActionButtonPressed :
@@ -289,7 +289,6 @@ void AppTask::AppEventHandler(AppEvent * aEvent)
289
289
if (sFunctionButtonPressed )
290
290
{
291
291
sActionButtonSuppressed = true ;
292
- sFunctionButtonSuppressed = true ;
293
292
LightSwitchMgr::GetInstance ().changeStepMode ();
294
293
ChipLogProgress (AppServer, " Step direction changed. Current Step Direction : %s" ,
295
294
((LightSwitchMgr::GetInstance ().getStepMode () == StepModeEnum::kUp ) ? " kUp" : " kDown" ));
0 commit comments