-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial_cmds.ino
More file actions
52 lines (45 loc) · 2.11 KB
/
Copy pathserial_cmds.ino
File metadata and controls
52 lines (45 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ═════════════════════════════════════════════════════════════
// SERIAL CMDS — serial command handler + diagnostics
// (included as tab in simplepilot_v2.12)
// ═════════════════════════════════════════════════════════════
// ─── Serial command handler ──────────────────────────────────
void handleSerialCommands() {
if (!Serial.available()) return;
char c = Serial.read();
// Compass commands
if (c == 'D' || c == 'd') {
debugMode = !debugMode;
if (debugMode) Serial.println("DMP DEBUG ON");
else Serial.println("DMP DEBUG OFF");
}
if (c == 'B' || c == 'b') {
showCurrentBiases(); // in eeprom_bias.ino
}
if (c == 'S' || c == 's') {
saveBiasesToEEPROM(); // in eeprom_bias.ino
}
if (c == 'R' || c == 'r') {
clearEEPROMBiases(); // in eeprom_bias.ino
}
}
// ─── No-data diagnostic ──────────────────────────────────────
static bool everGotData = false;
static unsigned long firstDataWaitMs = 0;
void markDataReceived() {
everGotData = true;
}
void handleNoDataDiagnostic() {
// Only warn if we've NEVER had valid data after 30s
if (!everGotData) {
if (firstDataWaitMs == 0) firstDataWaitMs = millis();
if (dmpOK && (millis() - firstDataWaitMs > 30000)) {
Serial.println("WARN: DMP OK but no heading for 30s — FIFO diagnostic:");
Serial.printf(" sensorOK=%d dmpOK=%d\n", sensorOK, dmpOK);
static icm_20948_DMP_data_t debugData;
ICM_20948_Status_e dbgStat = myICM.readDMPdataFromFIFO(&debugData);
Serial.printf(" FIFO read: stat=%d (%s) header=0x%08X\n",
dbgStat, myICM.statusString(dbgStat), debugData.header);
firstDataWaitMs = millis(); // Reset so we don't spam
}
}
}