forked from kofal.net/zmk
refactor(power): Extract activity/idle detection.
* Refactor power to extract more general purpose activity detection/events. * Use activity state to implement PM callback.
This commit is contained in:
11
app/include/zmk/activity.h
Normal file
11
app/include/zmk/activity.h
Normal file
@@ -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();
|
||||
26
app/include/zmk/events/activity-state-changed.h
Normal file
26
app/include/zmk/events/activity-state-changed.h
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user