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 Dec 6, 2023
1 parent cc82618 commit 3034113
Showing 8 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
@@ -106,7 +106,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
break;
}

if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
@@ -106,7 +106,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
break;
}

if (buttonevent)
if (!buttonevent)
{
GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED);
}
2 changes: 1 addition & 1 deletion examples/lighting-app/infineon/psoc6/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions examples/lighting-app/infineon/psoc6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
@@ -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
@@ -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);
@@ -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);
}
2 changes: 1 addition & 1 deletion examples/lock-app/infineon/psoc6/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
@@ -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
@@ -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);
@@ -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);
}

0 comments on commit 3034113

Please sign in to comment.