Skip to content

Make low-power activity detection ignore idle analog inputs, and log it - #76

Merged
thePunderWoman merged 1 commit into
mainfrom
activity-detection
Oct 24, 2026
Merged

thePunderWoman merged 1 commit into
mainfrom
activity-detection

Conversation

@thePunderWoman

Copy link
Copy Markdown
Member

Problem

On the new boards, low-power mode never dimmed, slept, or powered off. Any non-zero stick or trigger reading counted as activity:

  • Trigger: the mechanism isn't installed yet, so the DRV5055 hall sensor rests near half supply. On the uncalibrated default range (0–4095) that reads as ~50% pulled, which counted as activity on every tick.
  • Stick: also uncalibrated, so a rest position away from the default 2048 center read as deflected.

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:

    • Trigger: an uncalibrated trigger never counts (treated like hardware that isn't there). A calibrated one counts while pulled ≥5%.
    • Stick: an uncalibrated stick counts only when a raw axis moves ≥200 counts from where it last counted. A calibrated one counts while held ≥5% off center, so steady driving keeps the device awake.
    • Held buttons and accelerometer motion count as before.
  • Logging to find what keeps the controller awake:

    • Activity: <sources> on each source's rising edge, not every tick
    • Power tier: <tier> on every tier change
    • Idle timeout reached: powering off.
  • Accelerometer (QMA6100P datasheet Rev A1, MOT_CONF0/MOT_CONF2):

    • any-motion now needs 4 consecutive samples (ANY_MOT_DUR=3)
    • threshold raised from 0x20 (~125 mg) to 0x30 (~190 mg slope at ±2 g)

    Still a best guess; tune it using the Activity: motion log lines.

Testing

  • pio test -e native: 324 tests pass, including regression tests for the uncalibrated trigger and the off-center uncalibrated stick.
  • gcovr: activity.cpp and power_management.cpp at 100%, total 98%.
  • pio run builds.

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

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>
@thePunderWoman
thePunderWoman merged commit 6f88034 into main Oct 24, 2026
3 checks passed
@thePunderWoman
thePunderWoman deleted the activity-detection branch October 24, 2026 05:52
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.

1 participant