Files
meshtastic_firmware/src
b20d89974a Stop accelerometer thread when double-tap/wake-on-motion disabled at runtime (#11025)
* Stop accelerometer thread when double-tap/wake-on-motion disabled at runtime

double_tap_as_button_press and wake_on_tap_or_motion are applied live: the
OFF->ON edge calls accelerometerThread->start(), but there was no ON->OFF
branch, so turning either flag off left the sensor thread running (polling
I2C, drawing power) until reboot. Worse, because enabled stayed true, a later
OFF->ON edge was a no-op (the enabled==false guard blocked re-start), leaving
the feature un-restartable without a reboot.

Add the symmetric ON->OFF branch in both handlers. When a flag goes true->off
and the other consumer of the shared thread is also off, call
accelerometerThread->disable() (stops runOnce polling and clears enabled so a
later re-enable can start() again). Each branch checks the other flag first so
disabling one feature never stops the sensor while the other still needs it.

* Keep accelerometer thread running when its sensor drives the compass

* Guard accelerometer thread config toggles against a null thread pointer

* AdminModule: factor shared accelerometer start/stop into a helper

The device and display config handlers had mirror-image blocks reconciling the
shared accelerometer thread. Extract reconcileAccelerometerThread(wasOn, nowOn,
otherFeatureOn) so the null guard, edge logic, compass (providesHeading) guard,
and rationale live in one place; each call site is now a single call. Behavior
is unchanged. Also drops the redundant per-field assignment that the
whole-struct `config.device = ...` / `config.display = ...` overwrites anyway.

---------

Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2026-07-18 06:26:20 -05:00
..
2026-03-24 12:39:21 -05:00
2026-07-16 18:35:33 -05:00
2026-07-01 19:01:27 -05:00
2026-01-29 05:56:19 -06:00
2026-02-19 07:16:33 -06:00
2026-07-16 18:35:33 -05:00
2026-05-11 11:46:13 -05:00
2026-07-01 19:01:27 -05:00
2026-07-16 18:57:50 -05:00
2026-07-01 19:01:27 -05:00
2023-01-21 21:23:24 +01:00
2026-07-01 19:01:27 -05:00
2026-07-16 18:57:50 -05:00