Skip to content

Commit

Permalink
removed multiple ifdef and hardcoded values for button
Browse files Browse the repository at this point in the history
  • Loading branch information
silabs-srishylam committed Jan 31, 2023
1 parent d98abf3 commit 30dea42
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 27 deletions.
3 changes: 3 additions & 0 deletions examples/light-switch-app/silabs/SiWx917/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
/**********************************************************
* Defines
*********************************************************/
// Button specific defines for SiWx917
#define SL_SIMPLE_BUTTON_PRESSED 1U
#define SIWx917_BTN0 0
#define SIWx917_BTN1 1

// Application-defined error codes in the CHIP_ERROR space.
#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01)
Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
AppEvent button_event = {};
button_event.Type = AppEvent::kEventType_Button;
button_event.ButtonEvent.Action = btnAction;
if (button == 1)
if (button == SIWx917_BTN1)
{
button_event.Handler = SwitchActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == 0)
else if (button == SIWx917_BTN0)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/silabs/SiWx917/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
/**********************************************************
* Defines
*********************************************************/
// Button specific defines for SiWx917
#define SL_SIMPLE_BUTTON_PRESSED 1
#define SIWx917_BTN0 0
#define SIWx917_BTN1 1

// Application-defined error codes in the CHIP_ERROR space.
#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01)
Expand Down
7 changes: 2 additions & 5 deletions examples/lighting-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@

#ifdef ENABLE_WSTK_LEDS
#include "LEDWidget.h"
#endif // ENABLE_WSTK_LEDS

#ifdef ENABLE_WSTK_LEDS
#define APP_ACTION_LED 1
#endif // ENABLE_WSTK_LEDS

Expand Down Expand Up @@ -246,12 +243,12 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
AppEvent button_event = {};
button_event.Type = AppEvent::kEventType_Button;
button_event.ButtonEvent.Action = btnAction;
if (button == 1 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
if (button == SIWx917_BTN1 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = LightActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == 0)
else if (button == SIWx917_BTN0)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
3 changes: 3 additions & 0 deletions examples/lock-app/silabs/SiWx917/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
/**********************************************************
* Defines
*********************************************************/
// Button specific defines for SiWx917
#define SL_SIMPLE_BUTTON_PRESSED 1
#define SIWx917_BTN0 0
#define SIWx917_BTN1 1

// Application-defined error codes in the CHIP_ERROR space.
#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01)
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
button_event.Type = AppEvent::kEventType_Button;
button_event.ButtonEvent.Action = btnAction;

if (button == 1 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
if (button == SIWx917_BTN1 && btnAction == SL_SIMPLE_BUTTON_PRESSED)
{
button_event.Handler = LockActionEventHandler;
sAppTask.PostEvent(&button_event);
}
else if (button == 0)
else if (button == SIWx917_BTN0)
{
button_event.Handler = BaseApplication::ButtonHandler;
sAppTask.PostEvent(&button_event);
Expand Down
18 changes: 1 addition & 17 deletions examples/platform/silabs/SiWx917/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,67 +318,51 @@ void BaseApplication::LightEventHandler()
// the LEDs at an even rate of 100ms.
//
// Otherwise, blink the LED ON for a very short time.
#ifdef ENABLE_WSTK_LEDS
if (mFunction != kFunction_FactoryReset)
{
if ((gIdentifyptr != nullptr) && (gIdentifyptr->mActive))
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(250, 250);
#endif // ENABLE_WSTK_LEDS
}
else if (sIdentifyEffect != EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT)
{
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK)
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(50, 50);
#endif // ENABLE_WSTK_LEDS
}
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE)
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(1000, 1000);
#endif // ENABLE_WSTK_LEDS
}
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY)
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(300, 700);
#endif // ENABLE_WSTK_LEDS
}
}
#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED)
else if (sIsProvisioned && sIsEnabled)
{
if (sIsAttached)
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Set(true);
#endif // ENABLE_WSTK_LEDS
}
else
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(950, 50);
#endif
}
}
else if (sHaveBLEConnections)
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(100, 100);
#endif // ENABLE_WSTK_LEDS
}
else
{
#ifdef ENABLE_WSTK_LEDS
sStatusLED.Blink(50, 950);
#endif // ENABLE_WSTK_LEDS
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_SED
}

#ifdef ENABLE_WSTK_LEDS
sStatusLED.Animate();
#endif // ENABLE_WSTK_LEDS
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ void rsi_m4_ta_interrupt_init(void)
#ifdef RSI_WITH_OS
//! Set P2P Intr priority
NVIC_SetPriority(TASS_P2P_IRQn, TASS_P2P_INTR_PRI);
// NVIC_SetPriority(74, TASS_P2P_INTR_PRI);
#endif

return;
Expand Down

0 comments on commit 30dea42

Please sign in to comment.