Skip to content

Add configurable display auto-sleep with wake on keypress#16

Open
not-in-stock wants to merge 2 commits intocarrefinho:mainfrom
not-in-stock:add-display-sleep
Open

Add configurable display auto-sleep with wake on keypress#16
not-in-stock wants to merge 2 commits intocarrefinho:mainfrom
not-in-stock:add-display-sleep

Conversation

@not-in-stock
Copy link

@not-in-stock not-in-stock commented Nov 14, 2025

Description

This PR adds an optional feature to automatically turn off the dongle’s display after inactivity and wake it on any keypress from peripherals. The feature is disabled by default to avoid changing behavior for existing builds.

Summary

  • Auto-off (blank) the display and backlight after a configurable idle timeout.
  • Wake the display on a key press event.
  • Optional PM-based display controller suspend/resume for additional power savings.
  • Respects ambient light sensor mode by keeping backlight off during sleep and letting ALS restore brightness after wake.
  • Disabled by default.

Changes

  • Kconfig:
    • CONFIG_PROSPECTOR_DISPLAY_SLEEP_ENABLE (default n)
    • CONFIG_PROSPECTOR_DISPLAY_IDLE_TIMEOUT_MS (default 30000)
    • CONFIG_PROSPECTOR_DISPLAY_SLEEP_USE_PM (depends on PM_DEVICE, default n)
  • New files:
    • include/prospector/display_power.h
    • boards/shields/prospector_adapter/src/display_idle.c
  • Updated:
    • boards/shields/prospector_adapter/CMakeLists.txt (added display_idle.c)
    • boards/shields/prospector_adapter/src/brightness.c (ALS loop guards backlight while sleeping)
    • README.md (configuration examples and defaults)

Configuration

Enable and configure in your shield/board config:

CONFIG_PROSPECTOR_DISPLAY_SLEEP_ENABLE=y
CONFIG_PROSPECTOR_DISPLAY_IDLE_TIMEOUT_MS=30000
# Optional: sleep for the display controller
# CONFIG_PM_DEVICE=y
# CONFIG_PROSPECTOR_DISPLAY_SLEEP_USE_PM=y

Implementation notes

  • Idle handling in boards/shields/prospector_adapter/src/display_idle.c uses:
    • k_work_delayable to track inactivity.
    • ZMK event subscriptions: zmk_keycode_state_changed, zmk_position_state_changed.
    • Zephyr Display API display_blanking_on/off or pm_device_action_run() when PM is enabled.
  • Ambient light sensor integration: boards/shields/prospector_adapter/src/brightness.c checks prospector_display_is_sleeping() to keep backlight off while sleeping.

Testing

  • Build with default config to ensure no behavior change.
  • Build with:
    • CONFIG_PROSPECTOR_DISPLAY_SLEEP_ENABLE=y
    • Confirm display turns off after timeout and wakes on any keypress.
  • Optional: enable PM_DEVICE and CONFIG_PROSPECTOR_DISPLAY_SLEEP_USE_PM=y and verify sleep/resume works as expected.

@not-in-stock not-in-stock force-pushed the main branch 3 times, most recently from 65db4b6 to a90120d Compare November 14, 2025 03:18
@not-in-stock not-in-stock force-pushed the main branch 7 times, most recently from e735be1 to abe3491 Compare December 26, 2025 05:06
- Set PWM_MIN to 15% instead of 1% to ensure display is always visible
- Force 20% brightness on wake in ALS mode before ALS thread adjusts
- Set sleeping=false before blank_off() to prevent race condition with ALS thread
- Remove LED debug code

Fixes issue where display would wake but appear off in dark rooms due to
1% backlight being invisible. Display now wakes with visible brightness
that ALS adjusts within 150ms.
@kaihchang
Copy link

kaihchang commented Feb 19, 2026

Can we add this to the new feat/new-status-screens branch (Zephyr 4.1)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants