diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-12-01 00:52:32 -0500 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-12-14 15:31:10 -0500 |
commit | f7c16dfe69eb551fa0eb50b8ebcf6f00e23c2bad (patch) | |
tree | 4deae4fc19973e64cc7d3bb0322e384d42608432 /app/include | |
parent | 8a529163fcabf7e63aa79e2116b96763039cfdca (diff) |
refactor(power): Extract activity/idle detection.
* Refactor power to extract more general purpose
activity detection/events.
* Use activity state to implement PM callback.
Diffstat (limited to 'app/include')
-rw-r--r-- | app/include/zmk/activity.h | 11 | ||||
-rw-r--r-- | app/include/zmk/events/activity-state-changed.h | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/app/include/zmk/activity.h b/app/include/zmk/activity.h new file mode 100644 index 0000000..9c858b1 --- /dev/null +++ b/app/include/zmk/activity.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +enum zmk_activity_state { ZMK_ACTIVITY_ACTIVE, ZMK_ACTIVITY_IDLE, ZMK_ACTIVITY_SLEEP }; + +enum zmk_activity_state zmk_activity_get_state();
\ No newline at end of file diff --git a/app/include/zmk/events/activity-state-changed.h b/app/include/zmk/events/activity-state-changed.h new file mode 100644 index 0000000..cd4c618 --- /dev/null +++ b/app/include/zmk/events/activity-state-changed.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include <zephyr.h> +#include <zmk/event-manager.h> +#include <zmk/activity.h> + +struct activity_state_changed { + struct zmk_event_header header; + enum zmk_activity_state state; +}; + +ZMK_EVENT_DECLARE(activity_state_changed); + +static inline struct activity_state_changed * +create_activity_state_changed(enum zmk_activity_state state) { + struct activity_state_changed *ev = new_activity_state_changed(); + ev->state = state; + + return ev; +}
\ No newline at end of file |