refactor: Move to new sys_poweroff API.

* Move to new `sys_poweroff` API for our deep sleep functionality.
This commit is contained in:
Peter Johanson 2023-11-09 23:59:15 +00:00 committed by Pete Johanson
parent b6d9f3c911
commit 98e3b8b435
2 changed files with 4 additions and 5 deletions

View File

@ -387,13 +387,12 @@ config ZMK_IDLE_TIMEOUT
config ZMK_SLEEP
bool "Enable deep sleep support"
depends on HAS_POWEROFF
select POWEROFF
imply USB
if ZMK_SLEEP
config PM_DEVICE
default y
config ZMK_IDLE_SLEEP_TIMEOUT
int "Milliseconds of inactivity before entering deep sleep"
default 900000

View File

@ -7,7 +7,7 @@
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/sys/poweroff.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()) {
// Put devices in suspend power mode before sleeping
set_state(ZMK_ACTIVITY_SLEEP);
pm_state_force(0U, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
sys_poweroff();
} else
#endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */
if (inactive_time > MAX_IDLE_MS) {