added zmk_idle_usb

This commit is contained in:
Nicolas Munnich 2024-08-02 10:55:56 +02:00
parent dd6d610df0
commit fdd82d27d3
3 changed files with 15 additions and 8 deletions

View file

@ -406,6 +406,10 @@ config ZMK_IDLE_TIMEOUT
int "Milliseconds of inactivity before entering idle state (OLED shutoff, etc)"
default 30000
config ZMK_IDLE_USB
bool "Allow idling while connected to USB"
default y
config ZMK_SLEEP
bool "Enable deep sleep support"
depends on HAS_POWEROFF

View file

@ -62,7 +62,6 @@ enum zmk_activity_state zmk_activity_get_state(void) { return activity_state; }
int activity_event_listener(const zmk_event_t *eh) {
#if IS_ENABLED(CONFIG_ZMK_EXT_POWER_IDLE_OFF)
activity_last_uptime = k_uptime_get();
if (activity_state == ZMK_ACTIVITY_IDLE) {
const struct device *ext_power = device_get_binding("EXT_POWER");
if (ext_power == NULL) {
@ -71,9 +70,8 @@ int activity_event_listener(const zmk_event_t *eh) {
ext_power_enable(ext_power);
}
}
#else
activity_last_uptime = k_uptime_get();
#endif /* IS_ENABLED(CONFIG_ZMK_EXT_POWER_IDLE_OFF) */
activity_last_uptime = k_uptime_get();
return set_state(ZMK_ACTIVITY_ACTIVE);
}
@ -94,7 +92,11 @@ void activity_work_handler(struct k_work *work) {
sys_poweroff();
} else
#endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */
if (inactive_time > MAX_IDLE_MS) {
if (inactive_time > MAX_IDLE_MS
#if !IS_ENABLED(CONFIG_ZMK_IDLE_USB)
&& !is_usb_power_present()
#endif /* IS_ENABLED(CONFIG_ZMK_IDLE_USB) */
) {
#if IS_ENABLED(CONFIG_ZMK_EXT_POWER_IDLE_OFF)
const struct device *ext_power = device_get_binding("EXT_POWER");
if (ext_power == NULL) {

View file

@ -21,7 +21,7 @@ Definition file: [zmk/app/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/
| Config | Type | Description | Default |
| ------------------------------- | ---- | ----------------------------------------------------- | ------- |
| `CONFIG_ZMK_IDLE_TIMEOUT` | int | Milliseconds of inactivity before entering idle state | 30000 |
| `CONFIG_ZMK_EXT_POWER_IDLE_OFF` | bool | Turn off external power while idle | n |
| `CONFIG_ZMK_IDLE_USB` | bool | Enable idling while connected to USB power | y |
| `CONFIG_ZMK_SLEEP` | bool | Enable deep sleep support | n |
| `CONFIG_ZMK_IDLE_SLEEP_TIMEOUT` | int | Milliseconds of inactivity before entering deep sleep | 900000 |
@ -45,9 +45,10 @@ Driver for enabling or disabling power to peripherals such as displays and light
Definition file: [zmk/app/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/Kconfig)
| Config | Type | Description | Default |
| ---------------------- | ---- | ----------------------------------------------- | ------- |
| `CONFIG_ZMK_EXT_POWER` | bool | Enable support to control external power output | y |
| Config | Type | Description | Default |
| ------------------------------- | ---- | ----------------------------------------------- | ------- |
| `CONFIG_ZMK_EXT_POWER` | bool | Enable support to control external power output | y |
| `CONFIG_ZMK_EXT_POWER_IDLE_OFF` | bool | Turn off external power while idle | n |
### Devicetree