Skip to content

Commit

Permalink
[Silabs] WiFi factory reset support for window-app 917SoC (#26066)
Browse files Browse the repository at this point in the history
* adds factory reset support for 917SoC window-app

* applied restyle
  • Loading branch information
silabs-srishylam authored and pull[bot] committed Oct 25, 2023
1 parent 562a960 commit 1766754
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
button_event.Handler = SwitchActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == SIWx917_BTN0)
else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
button_event.Handler = LightActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == SIWx917_BTN0)
else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
button_event.Handler = LockActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == SIWx917_BTN0)
else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ void IRQ021_Handler(void)
btn1 = 0;
sl_button_on_change(1, 1);
}
if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_0))
if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_0) && (!btn0))
{
btn0 = 1;
sl_button_on_change(0, 0);
}
if (!RSI_NPSSGPIO_GetPin(NPSS_GPIO_0) && btn0)
{
Expand Down
1 change: 1 addition & 0 deletions examples/window-app/silabs/SiWx917/include/WindowAppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class WindowAppImpl : public WindowApp
{
public:
static WindowAppImpl sInstance;
bool mWindowAppInit = false;

WindowAppImpl();
CHIP_ERROR Init() override;
Expand Down
26 changes: 22 additions & 4 deletions examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ CHIP_ERROR WindowAppImpl::Init()
}
#endif // QR_CODE_ENABLED

mWindowAppInit = true;

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -531,14 +533,30 @@ WindowAppImpl::Button::Button(WindowApp::Button::Id id, const char * name) : Win
void WindowAppImpl::OnButtonChange(uint8_t Btn, uint8_t btnAction)
{
WindowApp::Button * btn = static_cast<Button *>((Btn == SIWx917_BTN0) ? sInstance.mButtonUp : sInstance.mButtonDown);
btn->Press();
// since sl_button_on_change is being called only with button press, calling Release() without condition
btn->Release();
if (Btn == SIWx917_BTN1)
{
btn->Press();
btn->Release();
}
else
{
if (btnAction)
{
btn->Press();
}
else
{
btn->Release();
}
}
}

// Silabs button callback from button event ISR
void sl_button_on_change(uint8_t btn, uint8_t btnAction)
{
WindowAppImpl * app = static_cast<WindowAppImpl *>(&WindowAppImpl::sInstance);
app->OnButtonChange(btn, btnAction);
if (app->mWindowAppInit)
{
app->OnButtonChange(btn, btnAction);
}
}

0 comments on commit 1766754

Please sign in to comment.