Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Allow idle and deep sleep timeouts to be set at runtime #2817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ReFil
Copy link
Contributor

@ReFil ReFil commented Feb 9, 2025

This adds functions to set the idle and deep sleep timeouts, the new timeouts are persisted in settings across reboots of the board

PR check-list

  • Branch has a clean commit history
  • Additional tests are included, if changing behaviors/core code that is testable.
  • Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
  • Pre-commit used to check formatting of files, commit messages, etc.
  • Includes any necessary documentation changes.

@ReFil ReFil requested a review from a team as a code owner February 9, 2025 19:55
static struct k_work_delayable activity_save_work;
#endif

static int activity_save_timeouts(void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler probably already puts this inline, but this feels like it should be inline to me. I don't know enough about the specifics of what it would do for certain though, feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ngl I don't know much about inlining functions, I modelled this after the endpoints code and I didn't recall it being inlined there

Comment on lines +14 to +18
void zmk_activity_set_idle_timeout(uint32_t timeout);

#if IS_ENABLED(CONFIG_ZMK_SLEEP)
uint32_t zmk_activity_get_sleep_timeout(void);
void zmk_activity_set_sleep_timeout(uint32_t timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void zmk_activity_set_idle_timeout(uint32_t timeout);
#if IS_ENABLED(CONFIG_ZMK_SLEEP)
uint32_t zmk_activity_get_sleep_timeout(void);
void zmk_activity_set_sleep_timeout(uint32_t timeout);
int zmk_activity_set_idle_timeout(uint32_t timeout);
#if IS_ENABLED(CONFIG_ZMK_SLEEP)
uint32_t zmk_activity_get_sleep_timeout(void);
int zmk_activity_set_sleep_timeout(uint32_t timeout);

These feel like they should return the value from activity_save_timeouts in case of error messages.

@zmkfirmware zmkfirmware deleted a comment from ReFil Feb 11, 2025
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