refactor: Move to new sys_poweroff API.
* Move to new `sys_poweroff` API for our deep sleep functionality.
This commit is contained in:
parent
b6d9f3c911
commit
98e3b8b435
2 changed files with 4 additions and 5 deletions
|
@ -387,13 +387,12 @@ config ZMK_IDLE_TIMEOUT
|
||||||
|
|
||||||
config ZMK_SLEEP
|
config ZMK_SLEEP
|
||||||
bool "Enable deep sleep support"
|
bool "Enable deep sleep support"
|
||||||
|
depends on HAS_POWEROFF
|
||||||
|
select POWEROFF
|
||||||
imply USB
|
imply USB
|
||||||
|
|
||||||
if ZMK_SLEEP
|
if ZMK_SLEEP
|
||||||
|
|
||||||
config PM_DEVICE
|
|
||||||
default y
|
|
||||||
|
|
||||||
config ZMK_IDLE_SLEEP_TIMEOUT
|
config ZMK_IDLE_SLEEP_TIMEOUT
|
||||||
int "Milliseconds of inactivity before entering deep sleep"
|
int "Milliseconds of inactivity before entering deep sleep"
|
||||||
default 900000
|
default 900000
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
#include <zephyr/init.h>
|
#include <zephyr/init.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/pm/pm.h>
|
#include <zephyr/sys/poweroff.h>
|
||||||
|
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void activity_work_handler(struct k_work *work) {
|
||||||
if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()) {
|
if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()) {
|
||||||
// Put devices in suspend power mode before sleeping
|
// Put devices in suspend power mode before sleeping
|
||||||
set_state(ZMK_ACTIVITY_SLEEP);
|
set_state(ZMK_ACTIVITY_SLEEP);
|
||||||
pm_state_force(0U, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
|
sys_poweroff();
|
||||||
} else
|
} else
|
||||||
#endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */
|
#endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */
|
||||||
if (inactive_time > MAX_IDLE_MS) {
|
if (inactive_time > MAX_IDLE_MS) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue