Skip to content

Commit

Permalink
[Infineon] fix to factory reset button behavior (#22746)
Browse files Browse the repository at this point in the history
* fix to factory reset button behavior

* Restyled by whitespace

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 30, 2023
1 parent 8e014de commit a024cb8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define APP_LIGHT_BUTTON CYBSP_USER_BTN1
#define APP_FUNCTION_BUTTON CYBSP_USER_BTN2
#define APP_BUTTON_DEBOUNCE_PERIOD_MS 200
#define APP_BUTTON_MIN_ASSERT_TIME_MS 30

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ButtonHandler::Init(void)
for (uint8_t i = 0; i < kButtonCount; i++)
{
buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel
APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period
APP_BUTTON_MIN_ASSERT_TIME_MS, // timer period
false, // no timer reload (==one-shot)
(void *) (int) i, // init timer id = button index
TimerCallback // timer callback handler (all buttons use
Expand Down Expand Up @@ -90,7 +90,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
{
// Get the button index of the expired timer and call button event helper.
uint32_t timerId;
uint8_t buttonevent = 0;
uint8_t buttonevent = 1;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);

switch (timerId)
Expand All @@ -106,7 +106,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
break;
}

if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define APP_LIGHT_BUTTON CYBSP_USER_BTN1
#define APP_FUNCTION_BUTTON CYBSP_USER_BTN2
#define APP_BUTTON_DEBOUNCE_PERIOD_MS 200
#define APP_BUTTON_MIN_ASSERT_TIME_MS 30

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ButtonHandler::Init(void)
for (uint8_t i = 0; i < kButtonCount; i++)
{
buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel
APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period
APP_BUTTON_MIN_ASSERT_TIME_MS, // timer period
false, // no timer reload (==one-shot)
(void *) (int) i, // init timer id = button index
TimerCallback // timer callback handler (all buttons use
Expand Down Expand Up @@ -90,7 +90,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
{
// Get the button index of the expired timer and call button event helper.
uint32_t timerId;
uint8_t buttonevent = 0;
uint8_t buttonevent = 1;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);

switch (timerId)
Expand All @@ -106,7 +106,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
break;
}

if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/infineon/psoc6/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define APP_LIGHT_BUTTON CYBSP_USER_BTN1
#define APP_FUNCTION_BUTTON CYBSP_USER_BTN2
#define APP_BUTTON_DEBOUNCE_PERIOD_MS 200
#define APP_BUTTON_MIN_ASSERT_TIME_MS 30

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/infineon/psoc6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ButtonHandler::Init(void)
for (uint8_t i = 0; i < kButtonCount; i++)
{
buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel
APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period
APP_BUTTON_MIN_ASSERT_TIME_MS, // timer period
false, // no timer reload (==one-shot)
(void *) (int) i, // init timer id = button index
TimerCallback // timer callback handler (all buttons use
Expand Down Expand Up @@ -88,8 +88,8 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
{
// Get the button index of the expired timer and call button event helper.
uint32_t timerId;
uint8_t buttonevent = 0;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);
uint8_t buttonevent;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);
if (timerId)
{
buttonevent = cyhal_gpio_read(APP_FUNCTION_BUTTON);
Expand All @@ -98,7 +98,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
{
buttonevent = cyhal_gpio_read(APP_LIGHT_BUTTON);
}
if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/infineon/psoc6/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define APP_LOCK_BUTTON CYBSP_USER_BTN1
#define APP_FUNCTION_BUTTON CYBSP_USER_BTN2
#define APP_BUTTON_DEBOUNCE_PERIOD_MS 200
#define APP_BUTTON_MIN_ASSERT_TIME_MS 30

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1
Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ButtonHandler::Init(void)
for (uint8_t i = 0; i < kButtonCount; i++)
{
buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel
APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period
APP_BUTTON_MIN_ASSERT_TIME_MS, // timer period
false, // no timer reload (==one-shot)
(void *) (int) i, // init timer id = button index
TimerCallback // timer callback handler (all buttons use
Expand Down Expand Up @@ -87,8 +87,8 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
{
// Get the button index of the expired timer and call button event helper.
uint32_t timerId;
uint8_t buttonevent = 0;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);
uint8_t buttonevent;
timerId = (uint32_t) pvTimerGetTimerID(xTimer);
if (timerId)
{
buttonevent = cyhal_gpio_read(APP_FUNCTION_BUTTON);
Expand All @@ -98,7 +98,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
buttonevent = cyhal_gpio_read(APP_LOCK_BUTTON);
}

if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
Expand Down

0 comments on commit a024cb8

Please sign in to comment.