thinknode_m9: pick GPS enable polarity from the board revision

The GPS enable pin (GPIO11) is active-LOW on the original ThinkNode-M9 but
active-HIGH on the newer revision (keyboard controller at 0x6D, e.g. Elecrow's
Meshtastic SKU LMM15409D2). Driven LOW on those units the GPS never gets a
fix: on one unit, same spot, 0 satellites with EN active-LOW vs 15 with
active-HIGH, and 34 after 20 minutes outdoors with the GPS toggled off and on
again from the UI. Meshtastic's ELECROW-ThinkNode-M9 variant makes the same
split, keyed on the same keyboard address (m9Version > 1 ? HIGH : LOW), and
Elecrow engineers have confirmed the split.

WadaNmeaLocationProvider: keep the enable level in a member that defaults to
the compile-time GPS_EN_ACTIVE, add setEnActive() to override it at runtime
(re-driving the pin so a running GPS stays on), and an optional
setPostEnableHook() run at the end of begin(). Every other board is unaffected.

thinknode_m9: m9KeyboardAddr() and a one-shot found-callback on the keyboard
driver; target.cpp uses it, when the controller is at 0x6D, to call
gps.setEnActive(true) and to register a GPIO10 wake pulse (50 ms, HIGH 5 ms,
LOW, 50 ms) after enabling, as Elecrow engineers confirmed. Any other address
keeps the existing default (LOW, no pulse), so the 0x6C path is unchanged; it
is not tested here, no 0x6C unit was available.

Depends on the keyboard 0x6D probe change.

Signed-off-by: Pratik Patel <Pratik@MakerNova.io>
This commit is contained in:
Pratik Patel authored and Kaj Schittecat committed 2026-10-13 08:22:55 +02:00
1 parent 9cd10dfe30
commit 8dbb349fc6
5 files changed
+74 -5

No files matched your search

+30
View File
@@ -56,6 +56,35 @@ DISPLAY_CLASS display(&board.periph_power);
#define LORA_CR 5
#endif
#if defined(HAS_M9_KEYBOARD)
// The keyboard controller's I2C address identifies the board hardware revision:
// units whose keyboard answers at 0x6D carry the newer GPS wiring, whose enable pin
// is active HIGH (same split Meshtastic and Elecrow's firmware make), followed by a
// short wake pulse on GPIO10. 0x6C boards keep the compile-time default
// (PIN_GPS_EN_ACTIVE, LOW) and no pulse.
// Elecrow's own firmware pulses GPIO10 (the module's ON_OFF/wake line) after
// driving EN active on these units: 50 ms, HIGH for 5 ms, then 50 ms settle.
static void m9GpsWakePulse() {
pinMode(10, OUTPUT);
delay(50);
digitalWrite(10, HIGH);
delay(5);
digitalWrite(10, LOW);
delay(50);
}
static void m9OnKeyboardFound(uint8_t addr) {
if (addr == 0x6D) {
gps.setEnActive(true);
gps.setPostEnableHook(m9GpsWakePulse);
if (gps.isEnabled()) m9GpsWakePulse(); // GPS was already powered before the keyboard was found
Serial.println("M9 GPS: enable pin active HIGH (keyboard at 0x6D)");
} else {
Serial.printf("M9 GPS: enable pin active level unchanged (keyboard at 0x%02X)\n", addr);
}
}
#endif
bool radio_init() {
fallback_clock.begin();
// peripheral I2C bus (7/6) — RTC PCF8563 @ 0x51, brought up by
@@ -65,6 +94,7 @@ bool radio_init() {
if (hw_rtc.adopted()) rtc_clock.noteHardwareTime();
#if defined(HAS_M9_KEYBOARD)
m9KeyboardSetFoundCallback(m9OnKeyboardFound);
m9KeyboardBegin(); // own bus, Wire1 (20/21) — no contention with Wire
#endif
#if defined(HAS_M9_COMPASS)