Commit Graph
4 Commits
Author SHA1 Message Date
JoshandClaude Sonnet 4.6 996b38778f Add AK09918 I2C presence check and fix mag read-error handling
- imuInit: verify WIA2 register == 0x09 before configuring the sensor.
  Prints exact error with GPIO hints if the chip doesn't respond.
  Fixes silent failure where initialize(AK09918_NORMAL) skipped I2C entirely.

- imuInit: initialize with POWER_DOWN before switchMode so the sensor
  always transitions through a known state.

- imuDataGet: only feed the low-pass filter with real data (AK09918_ERR_OK
  or OVERFLOW). On read failure, reuse the previous corrected values so
  zeros don't corrupt the filter state and the calibration session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 21:55:20 +02:00
JoshandClaude Sonnet 4.6 9b0a5a9926 Fix compass heading direction, add magnetic declination and heading offset
- Fix atan2 sign bug: atan2(-yHeading, xHeading) per Freescale AN4248 eq.22.
  The previous atan2(yHeading, xHeading) produced counter-clockwise angles,
  causing East/West to be swapped relative to compass convention.

- Add imuSetMagneticDeclination() (T:146, field "decl") to correct the
  offset between magnetic north and true north (iPhone shows true north).
  Value is persisted in imuConfig.json across reboots.

- Add imuSetHeadingOffset() (T:147, field "off") to compensate for sensor
  mounting orientation on the rover. Also persisted.

- Persist decl and hOff in imuConfig.json (version 2, backwards compatible).

- Fix calibration feedback for web interface: T:126 now includes calDone=1
  (success) or calDone=0 (fail) once after calibration completes, plus
  decl and hOff fields. Calibration start message explains polling procedure.

- Remove duplicate #include <nvs_flash.h> and unused Adafruit ICM20948
  includes that caused build failures when libraries were not installed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 21:46:00 +02:00
Joshua Sacherer 38b7b64ba8 Add persistent magnetometer calibration and docs 2026-04-23 19:25:22 +02:00
Joshua Sacherer bdd2b4315b Initial import of WAVE_ROVER_V1.0 2026-04-23 17:52:46 +02:00