From 10964304f1ac060a5a3cf254420b9cfa07e5a2b1 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Wed, 3 May 2023 18:30:54 -0400 Subject: [PATCH] Fix 917 buttons (#26355) --- examples/lighting-app/silabs/SiWx917/include/AppTask.h | 2 +- examples/lighting-app/silabs/SiWx917/src/AppTask.cpp | 5 +++++ examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/lighting-app/silabs/SiWx917/include/AppTask.h b/examples/lighting-app/silabs/SiWx917/include/AppTask.h index 0310e9e187c80c..b77a033773b53b 100644 --- a/examples/lighting-app/silabs/SiWx917/include/AppTask.h +++ b/examples/lighting-app/silabs/SiWx917/include/AppTask.h @@ -81,7 +81,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(uint8_t button, uint8_t btnAction); + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 409890949085dd..15474dc8527065 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -36,6 +36,8 @@ #include +#include + #include "LEDWidget.h" #define APP_ACTION_LED 1 @@ -119,6 +121,9 @@ AppTask AppTask::sAppTask; CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Lighting-App"); #endif diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index f260d858412a47..a8a4d3f63dd274 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -45,6 +45,8 @@ extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction); SilabsLCD slLCD; #endif +#include + #define APP_TASK_STACK_SIZE (4096) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 @@ -186,6 +188,8 @@ void WindowAppImpl::OnIconTimeout(WindowApp::Timer & timer) CHIP_ERROR WindowAppImpl::Init() { + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(WindowAppImpl::ButtonEventHandler); + WindowApp::Init(); // Initialize App Task