|
48 | 48 |
|
49 | 49 | #include <app/clusters/identify-server/identify-server.h>
|
50 | 50 |
|
| 51 | +#include <platform/silabs/platformAbstraction/SilabsPlatform.h> |
| 52 | + |
51 | 53 | /**********************************************************
|
52 | 54 | * Defines and Constants
|
53 | 55 | *********************************************************/
|
54 | 56 |
|
55 | 57 | #define SYSTEM_STATE_LED &sl_led_led0
|
56 | 58 |
|
57 |
| -#define APP_FUNCTION_BUTTON &sl_button_btn0 |
58 |
| -#define APP_LIGHT_SWITCH &sl_button_btn1 |
| 59 | +#define APP_FUNCTION_BUTTON 0 |
| 60 | +#define APP_LIGHT_SWITCH 1 |
59 | 61 |
|
60 | 62 | namespace {
|
61 | 63 |
|
@@ -151,6 +153,10 @@ AppTask AppTask::sAppTask;
|
151 | 153 | CHIP_ERROR AppTask::Init()
|
152 | 154 | {
|
153 | 155 | CHIP_ERROR err = CHIP_NO_ERROR;
|
| 156 | +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT |
| 157 | + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); |
| 158 | +#endif |
| 159 | + |
154 | 160 | #ifdef DISPLAY_ENABLED
|
155 | 161 | GetLCD().Init((uint8_t *) "Light Switch");
|
156 | 162 | #endif
|
@@ -248,20 +254,18 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
|
248 | 254 | }
|
249 | 255 | }
|
250 | 256 |
|
251 |
| -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) |
| 257 | +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) |
252 | 258 | {
|
253 |
| - VerifyOrReturn(buttonHandle != NULL); |
254 |
| - |
255 | 259 | AppEvent button_event = {};
|
256 | 260 | button_event.Type = AppEvent::kEventType_Button;
|
257 | 261 | button_event.ButtonEvent.Action = btnAction;
|
258 | 262 |
|
259 |
| - if (buttonHandle == APP_LIGHT_SWITCH) |
| 263 | + if (button == APP_LIGHT_SWITCH) |
260 | 264 | {
|
261 | 265 | button_event.Handler = SwitchActionEventHandler;
|
262 | 266 | sAppTask.PostEvent(&button_event);
|
263 | 267 | }
|
264 |
| - else if (buttonHandle == APP_FUNCTION_BUTTON) |
| 268 | + else if (button == APP_FUNCTION_BUTTON) |
265 | 269 | {
|
266 | 270 | button_event.Handler = BaseApplication::ButtonHandler;
|
267 | 271 | sAppTask.PostEvent(&button_event);
|
|
0 commit comments