2026 remote: wiring as found on the real remote, IMU reset fix

- Nextion is on Serial2 (pins 7/8) - already in the last commit; docs updated.
- MPU6050 on Wire (18/19) so everything is on the edge headers (owner's
  choice); the two stick wires from 18/19 move to A7/A8 (21/22).
- Stick mapping checked on the real remote: left stick X/Y/twist on
  A3/A7/A8, right on A0/A1/A2, all inverted but the right twist.
- RemoteIMU: full device reset before waking. The remote's MPU6050 (likely
  a clone) answers and wakes without it but every data register reads 0.
  Axis defaults confirmed (+pitch nose down, +roll right side down).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-17 22:03:08 +01:00
1 parent 0b836af8de
commit aeccba3be7
4 files changed
+41 -39

No files matched your search

+14 -15
View File
@@ -31,16 +31,18 @@ constexpr uint32_t LINK_LOST_MS = 300;
// Logical axis order used everywhere in the remote code.
enum StickAxis : uint8_t { L_X = 0, L_Y, L_TWIST, R_X, R_Y, R_TWIST, NUM_AXES };
// A0-A5 in a row, as wired for the old remote (2019-teensy-nrf24/remote/Joysticks.h).
// A4/A5 are also Wire's SDA/SCL - that's why the MPU6050 is on Wire2 below.
// BENCH: which physical axis is on which pin wasn't recoverable from the old
// code; reorder these so each lands on the right logical axis ('p' dump).
constexpr uint8_t STICK_PINS[NUM_AXES] = { A0, A1, A2, A3, A4, A5 };
// The old remote had A0-A5 in a row (2019-teensy-nrf24/remote/Joysticks.h).
// The two wires on A4/A5 (pins 18/19) move to A7/A8 (pins 21/22), because
// 18/19 are Wire's SDA/SCL for the MPU6050 (owner's choice 2026-11-17: edge
// headers only, no pads underneath). A6 (20) stays free for the battery.
// Checked on the real remote (2026-11-17): the left stick is on A3/A7/A8, the
// right stick on A0/A1/A2.
constexpr uint8_t STICK_PINS[NUM_AXES] = { A3, A7, A8, A0, A1, A2 };
// Each logical axis must end up: X + = pushed RIGHT, Y + = pushed FORWARD
// (away from you), TWIST + = rotated COUNTERCLOCKWISE seen from above.
// BENCH: flip any axis that reads the wrong way on the serial 'p' status dump.
constexpr bool STICK_INVERT[NUM_AXES] = { false, false, false, false, false, false };
// Checked on the real remote (2026-11-17): every axis but the right twist reads inverted.
constexpr bool STICK_INVERT[NUM_AXES] = { true, true, true, true, true, false };
constexpr int ADC_BITS = 12; // 0..4095
constexpr int ADC_AVERAGING = 8; // hardware averaging per analogRead()
@@ -69,17 +71,14 @@ constexpr float STICK_EXPO[NUM_AXES] = { 0.25f, 0.25f, 0.30f, 0.20f, 0.20f,
// One-pole low-pass on raw ADC counts (1 = no filtering). Pots are noisy.
constexpr float STICK_FILTER_ALPHA = 0.5f;
// ---- Remote IMU: MPU6050 on the third I2C bus (Wire2: SDA2 = 25, SCL2 = 24) ----
// On the Teensy 4.0, 24/25 are solder pads on the underside, not edge pins.
// Not Wire (18/19): those pins are stick axes A4/A5. Not Wire1 (17/16) either:
// those are stick axes A3/A2.
#define IMU_WIRE Wire2
// ---- Remote IMU: MPU6050 on Wire (SDA = 18, SCL = 19) ----
// Edge-header pins; the stick axes that used to be there moved to A7/A8.
#define IMU_WIRE Wire
constexpr uint8_t IMU_ADDR = 0x68; // 0x69 if AD0 is pulled high
// Mounting remap: which chip axis (0=X,1=Y,2=Z) and sign gives each handset
// axis. Handset frame: +X = away from you, +Y = your left, +Z = up.
// BENCH: with the defaults the chip is assumed flat, component side up, its
// X arrow pointing away from you. Verify with the serial 'p' dump: tipping
// the far edge down must read +pitch, dipping the right side must read +roll.
// Checked on the real remote (2026-11-17): the defaults are right - tipping
// the far edge down reads +pitch, dipping the right side reads +roll.
constexpr uint8_t IMU_AXIS_FROM_CHIP[3] = { 0, 1, 2 };
constexpr int8_t IMU_AXIS_SIGN[3] = { +1, +1, +1 };
constexpr float IMU_ALPHA = 0.98f; // complementary filter, same as the robot