Add low-power event-driven timing support for battery-powered remotes - #67
Open
HelsingenMersken wants to merge 1 commit into
Open
Add low-power event-driven timing support for battery-powered remotes#67HelsingenMersken wants to merge 1 commit into
HelsingenMersken wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Battery-powered remote controls based on 2.4 GHz proprietary wireless or Bluetooth SoCs are extremely sensitive to standby power consumption.
The existing periodic polling API requires the MCU to wake up at every
TICKS_INTERVAL, even when no button activity is present. On devices that spend most of their lifetime in sleep mode, these unnecessary wakeups can reduce battery life.This PR adds an optional event-driven low-power API. It allows the MCU to sleep until either:
This can reduce unnecessary wakeups and help extend battery life without introducing platform-specific sleep or timer dependencies into MultiButton.
Changes
button_ticks_low_power(uint32_t elapsed_ms)0when no timer is required and the system may wait for a GPIO edgebutton_ticks()periodic polling APIMULTIBUTTON_ENABLE_DOUBLE_CLICKCompatibility
The existing API and default button behavior remain unchanged. Applications using
button_ticks()can continue to work without modification.The low-power API is optional and does not depend on any specific RTOS, timer, GPIO, Bluetooth, or 2.4 GHz SoC implementation.
Typical integration
button_ticks_low_power(elapsed_ms)after a GPIO edge or timer expiration.0, stop the timer and allow the MCU to sleep until the next GPIO edge.Actual power savings depend on the MCU, GPIO, timer, and sleep-mode implementation, but the API makes it possible to avoid fixed-period button polling while idle.
Testing
-std=c99 -Wall -Wextra -Werror -pedantic