Files
blinky/src/events/key_function_event.c

44 lines
1.1 KiB
C
Raw Normal View History

#include "key_function_event.h"
static const char *action_name(uint8_t action)
{
switch (action) {
case KEY_FUNCTION_ACTION_RELEASE:
return "release";
case KEY_FUNCTION_ACTION_PRESS:
return "press";
default:
return "unknown";
}
}
static void log_key_function_event(const struct app_event_header *aeh)
{
const struct key_function_event *event = cast_key_function_event(aeh);
APP_EVENT_MANAGER_LOG(aeh, "usage:0x%04x action:%s",
event->usage, action_name(event->action));
}
static void profile_key_function_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
const struct key_function_event *event = cast_key_function_event(aeh);
nrf_profiler_log_encode_uint16(buf, event->usage);
nrf_profiler_log_encode_uint8(buf, event->action);
}
APP_EVENT_INFO_DEFINE(key_function_event,
ENCODE(NRF_PROFILER_ARG_U16, NRF_PROFILER_ARG_U8),
ENCODE("usage", "action"),
profile_key_function_event);
APP_EVENT_TYPE_DEFINE(key_function_event,
log_key_function_event,
&key_function_event_info,
APP_EVENT_FLAGS_CREATE(
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));