46
46
#define LIGHT_LED 0
47
47
#endif
48
48
49
- #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
50
-
51
49
#define APP_FUNCTION_BUTTON 0
52
50
#define APP_LIGHT_SWITCH 1
53
- #endif
54
51
55
52
using namespace chip ;
56
53
using namespace ::chip::DeviceLayer;
54
+ using namespace ::chip::DeviceLayer::Silabs;
57
55
58
56
namespace {
59
57
@@ -132,9 +130,7 @@ AppTask AppTask::sAppTask;
132
130
CHIP_ERROR AppTask::Init ()
133
131
{
134
132
CHIP_ERROR err = CHIP_NO_ERROR;
135
- #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
136
133
chip::DeviceLayer::Silabs::GetPlatform ().SetButtonsCb (AppTask::ButtonEventHandler);
137
- #endif
138
134
139
135
#ifdef DISPLAY_ENABLED
140
136
GetLCD ().Init ((uint8_t *) " Lighting-App" );
@@ -241,13 +237,11 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)
241
237
action = static_cast <LightingManager::Action_t>(aEvent->LightEvent .Action );
242
238
actor = aEvent->LightEvent .Actor ;
243
239
}
244
- #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
245
240
else if (aEvent->Type == AppEvent::kEventType_Button )
246
241
{
247
242
action = (LightMgr ().IsLightOn ()) ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION;
248
243
actor = AppEvent::kEventType_Button ;
249
244
}
250
- #endif
251
245
else
252
246
{
253
247
err = APP_ERROR_UNHANDLED_EVENT;
@@ -263,14 +257,14 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)
263
257
}
264
258
}
265
259
}
266
- # ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
260
+
267
261
void AppTask::ButtonEventHandler (uint8_t button, uint8_t btnAction)
268
262
{
269
263
AppEvent button_event = {};
270
264
button_event.Type = AppEvent::kEventType_Button ;
271
265
button_event.ButtonEvent .Action = btnAction;
272
266
273
- if (button == APP_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED )
267
+ if (button == APP_LIGHT_SWITCH && btnAction == static_cast < uint8_t >(SilabsPlatform::ButtonAction::ButtonPressed) )
274
268
{
275
269
button_event.Handler = LightActionEventHandler;
276
270
AppTask::GetAppTask ().PostEvent (&button_event);
@@ -281,7 +275,6 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
281
275
AppTask::GetAppTask ().PostEvent (&button_event);
282
276
}
283
277
}
284
- #endif
285
278
286
279
void AppTask::ActionInitiated (LightingManager::Action_t aAction, int32_t aActor)
287
280
{
@@ -294,12 +287,11 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
294
287
#ifdef DISPLAY_ENABLED
295
288
sAppTask .GetLCD ().WriteDemoUI (lightOn);
296
289
#endif
297
- # ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
290
+
298
291
if (aActor == AppEvent::kEventType_Button )
299
292
{
300
293
sAppTask .mSyncClusterToButtonAction = true ;
301
294
}
302
- #endif
303
295
}
304
296
305
297
void AppTask::ActionCompleted (LightingManager::Action_t aAction)
@@ -313,13 +305,12 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction)
313
305
{
314
306
SILABS_LOG (" Light OFF" )
315
307
}
316
- # ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
308
+
317
309
if (sAppTask .mSyncClusterToButtonAction )
318
310
{
319
311
chip::DeviceLayer::PlatformMgr ().ScheduleWork (UpdateClusterState, reinterpret_cast <intptr_t >(nullptr ));
320
312
sAppTask .mSyncClusterToButtonAction = false ;
321
313
}
322
- #endif
323
314
}
324
315
325
316
void AppTask::PostLightActionRequest (int32_t aActor, LightingManager::Action_t aAction)
0 commit comments