From 2df6dcd973776c0c0d1047d13178a72b5c0b6ca7 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Sat, 16 Mar 2024 14:15:52 -0700 Subject: [PATCH] feat(behaviors): More logging in soft off. --- app/src/behaviors/behavior_soft_off.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/behaviors/behavior_soft_off.c b/app/src/behaviors/behavior_soft_off.c index 878a2fc5..8b8ba4f9 100644 --- a/app/src/behaviors/behavior_soft_off.c +++ b/app/src/behaviors/behavior_soft_off.c @@ -45,8 +45,18 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct behavior_soft_off_data *data = dev->data; const struct behavior_soft_off_config *config = dev->config; - if (config->hold_time_ms == 0 || (k_uptime_get() - data->press_start) >= config->hold_time_ms) { + if (config->hold_time_ms == 0) { + LOG_DBG("No hold time set, triggering soft off"); zmk_pm_soft_off(); + } else { + uint32_t hold_time = k_uptime_get() - data->press_start; + + if (hold_time > config->hold_time_ms) { + zmk_pm_soft_off(); + } else { + LOG_INF("Not triggering soft off: held for %d and hold time is %d", hold_time, + config->hold_time_ms); + } } return ZMK_BEHAVIOR_OPAQUE;