Skip to content

Commit

Permalink
Add Button 3 event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ktaborowski committed Aug 20, 2020
1 parent edac1aa commit 09873b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/lock-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ void AppTask::ButtonEventHandler(uint32_t button_state, uint32_t has_changed)
button_event.Handler = FunctionHandler;
sAppTask.PostEvent(&button_event);
}

if (JOINER_BUTTON_MASK & button_state & has_changed)
{
button_event.ButtonEvent.PinNo = JOINER_BUTTON;
button_event.ButtonEvent.Action = BUTTON_PUSH_EVENT;
button_event.Handler = JoinerHandler;
sAppTask.PostEvent(&button_event);
}
}

void AppTask::TimerEventHandler(k_timer * timer)
Expand Down Expand Up @@ -299,6 +307,16 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
}
}

void AppTask::JoinerHandler(AppEvent * aEvent)
{
if (aEvent->ButtonEvent.PinNo != JOINER_BUTTON)
return;

CHIP_ERROR error = CHIP_ERROR_NOT_IMPLEMENTED;

LOG_INF("Thread joiner triggering result: %s", chip::ErrorStr(error));
}

void AppTask::CancelTimer()
{
k_timer_stop(&sFunctionTimer);
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/nrfconnect/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppTask

static void FunctionTimerEventHandler(AppEvent * aEvent);
static void FunctionHandler(AppEvent * aEvent);
static void JoinerHandler(AppEvent * aEvent);
static void LockActionEventHandler(AppEvent * aEvent);

static void ButtonEventHandler(uint32_t buttons_state, uint32_t has_changed);
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/nrfconnect/main/include/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define LOCK_BUTTON_MASK DK_BTN2_MSK
#define FUNCTION_BUTTON DK_BTN1
#define FUNCTION_BUTTON_MASK DK_BTN1_MSK
#define JOINER_BUTTON DK_BTN3
#define JOINER_BUTTON_MASK DK_BTN3_MSK

#define SYSTEM_STATE_LED DK_LED1
#define LOCK_STATE_LED DK_LED2
Expand Down

0 comments on commit 09873b3

Please sign in to comment.