Repository navigation
Fix accelerometer INT1 polarity so low-power mode can go idle - #78
Merged
Merged
Conversation
INTPIN_CONF (0x20) was written as 0x02 on the belief that bit 1 is INT1_LVL. Per the QMA6100P datasheet, bit 0 is INT1_LVL and bit 1 is INT1_OD, so 0x02 made INT1 open-drain and active-low. GPIO46 has no pull-up, so the released pin floated, read HIGH as constant motion, and the idle timer never advanced: no dim, no display off, no XBee sleep. The log showed "Activity: motion" once because it only prints rising edges. - Write 0x05 (INT1 active-high push-pull; also the reset default). - Move the QMA6100P register constants into qma6100p_registers.h so a native test can pin them to the datasheet's bit layout. - Log the power tier, seconds idle and currently active sources once a second, so an input stuck active is visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On hardware, motion registered once and never again: shaking never woke the controller. Match Meshtastic's working wake-on-motion setup for the QMA6100P: - Soft reset at startup (S_RESET 0x36 = 0xB6, then 0x00): the chip stays powered across an ESP32 reset and can hold stale state. - Latched interrupt, cleared on status read (INT_CFG |= 0x81). motionDetected() reads INT_ST0 whenever INT1 is high, so every new movement reports again, and a short one can't be missed between loop passes or during light sleep. - Any-motion threshold 0x30 -> 0x08 (~31mg per sample step) over 2 samples instead of 4. The datasheet gives no sample rate, and the stricter setting never fired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Hardware test of the first commit: INT1 polarity was fixed and the controller went idle, but motion registered once and never again, so shaking didn't wake it. Second commit adopts Meshtastic's working wake-on-motion setup for this chip (QMA6100PSensor.cpp):
337 tests pass, including new register tests for the latch and soft reset. |
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
Low-power mode still never dimmed, turned the display off, or slept the XBee, with the mode set. The serial log showed
Activity: motiononce at boot and never again.The accelerometer setup wrote
0x02to INTPIN_CONF (0x20), assuming bit 1 is INT1_LVL. The QMA6100P datasheet (Rev A1, register 0x20, p. 32) puts INT1_LVL at bit 0 and INT1_OD at bit 1, so0x02made INT1 open-drain and active-low. GPIO46 is a plain input with no pull-up, so the released pin floated. Reading HIGH, it counted as motion on every loop, and the idle timer never advanced. The log printed motion only once because it reports rising edges only.Fix
0x05: INT1 active-high, push-pull. This is also the register's reset default, and INT1 idling low is safe for GPIO46's boot strapping.include/qma6100p_registers.h, so a native test can check every written value against the datasheet's bit layout. I re-checked the other values (RANGE, INT_EN2, INT_MAP1, MOT_CONF0, PM) against the datasheet; all were correct.Power <tier>, idle <n>s, active: <sources>, so an input stuck active is visible rather than hidden by the rising-edge-onlyActivity:lines.Testing
test_qma6100p_registers(7 tests), including a regression test that INT1 is active-high push-pull. It fails with the old0x02.PowerManager::idleMs()covered by a new test;power_management.cppat 100%.pio test -e native: 335 tests pass. gcovr total 98%.pio runbuilds.Not yet tried on hardware. Expect
active: noneon the new line while the controller sits still, with the idle count climbing and the tiers following.🤖 Generated with Claude Code