Repository navigation
Make low-power activity detection ignore idle analog inputs, and log it - #76
Merged
Merged
Conversation
Low-power mode never reached idle on the new boards. Any non-zero stick
or trigger reading counted as activity, and an uncalibrated trigger (no
mechanism installed: the hall sensor rests mid-scale, ~50% on the
default 0-4095 calibration) read as pulled on every tick.
ActivityDetector now decides what counts:
- an uncalibrated trigger never counts; a calibrated one counts while
pulled at least 5%
- an uncalibrated stick counts only when it moves 200+ raw counts; a
calibrated one counts while held at least 5% off center
- buttons held and accelerometer motion count as before
Each source's rising edge is logged ("Activity: stick"), as are power
tier changes and an idle-timeout power-off, so it's visible what keeps
the controller awake.
The accelerometer's any-motion now needs 4 consecutive samples
(ANY_MOT_DUR=3) over a higher threshold (0x30, ~190mg slope at +/-2g,
up from 0x20), per the QMA6100P datasheet's MOT_CONF0/MOT_CONF2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
On the new boards, low-power mode never dimmed, slept, or powered off. Any non-zero stick or trigger reading counted as activity:
The accelerometer's any-motion detection also fired after a single sample over an untuned threshold.
Changes
ActivityDetector(new, pure, unit-tested) decides what counts:Logging to find what keeps the controller awake:
Activity: <sources>on each source's rising edge, not every tickPower tier: <tier>on every tier changeIdle timeout reached: powering off.Accelerometer (QMA6100P datasheet Rev A1, MOT_CONF0/MOT_CONF2):
ANY_MOT_DUR=3)0x20(~125 mg) to0x30(~190 mg slope at ±2 g)Still a best guess; tune it using the
Activity: motionlog lines.Testing
pio test -e native: 324 tests pass, including regression tests for the uncalibrated trigger and the off-center uncalibrated stick.activity.cppandpower_management.cppat 100%, total 98%.pio runbuilds.Not yet tried on hardware. Over USB, light sleep stays off by design, but dim/off/XBee-sleep tiers and the log lines can all be checked on a serial monitor.
🤖 Generated with Claude Code