From 65a96439104947c2e949889567be70ef05bb5743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Martin?= Date: Sun, 11 Oct 2026 17:01:57 +0200 Subject: [PATCH] Console: imu prints what the motion sensor reads Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk --- README.md | 1 + site/content/dev/debug/commands.md | 2 ++ src/main.cpp | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 68ed7c6..f8df7a4 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,7 @@ The Shell App (docs/milestones/S1.md) runs the commands below on the device's ow | `lora capture start` / `lora capture stop` | A LoRa Capture, as `c` in the App | | `lora sweep on [from MHz] [to MHz] [step kHz]` / `lora sweep off` / `lora sweep dump` | Sweep a band (863 870 100 by default), with a summary every 2 s (floor, strongest, peaks), or print the latest pass | | `gnss quiet on` / `gnss quiet off` | The "Pause GNSS for LoRa" setting | +| `imu` | What the motion sensor reads: g on its three axes, then degrees a second (the Compass, issue #16) | | `gnss status` / `gnss restart` | The receiver's state, and a restart of it | | `gnss track start` / `gnss track stop` | A Track, as `r` in the GNSS App (the reason is printed if it can't start) | | `gnss nmea on` / `gnss nmea off` | Prints each NMEA sentence the receiver sends, as `nmea: …` | diff --git a/site/content/dev/debug/commands.md b/site/content/dev/debug/commands.md index 55e86c6..b089854 100644 --- a/site/content/dev/debug/commands.md +++ b/site/content/dev/debug/commands.md @@ -26,6 +26,7 @@ lora capture start|stop a LoRa Capture to /captures/lora (pcap, LoRaTap) lora sweep on [from MHz] [to MHz] [step kHz] | lora sweep off | lora sweep dump RSSI across a band (863 870 100) lora custom [preamble] e.g. 868.1 125 7 5 34 8 (LoRaWAN) gnss quiet on|off pause the GNSS receiver while the LoRa radio listens (it costs the radio 8 dB) +imu what the motion sensor reads: g on its three axes, then degrees a second gnss status | gnss restart | gnss track start|stop | gnss nmea on|off | gnss send crash the last crash: firmware, reason, task, backtrace coredump erase forget the core dump in flash @@ -107,6 +108,7 @@ In **Safe Mode** (see [Crashes and Safe Mode](/dev/debug/crashes/)) only a few r | `lora capture start` / `lora capture stop` | A LoRa Capture, as `c` in the App | | `lora sweep on [from MHz] [to MHz] [step kHz]` / `lora sweep off` / `lora sweep dump` | Sweep a band (863 870 100 by default), with a summary every 2 s (floor, strongest, peaks), or print the latest pass | | `gnss quiet on` / `gnss quiet off` | The "Pause GNSS for LoRa" setting | +| `imu` | What the motion sensor reads: g on its three axes, then degrees a second (the Compass, issue #16) | | `gnss status` / `gnss restart` | The receiver's state, and a restart of it | | `gnss track start` / `gnss track stop` | A Track, as `r` in the GNSS App (the reason is printed if it can't start) | | `gnss nmea on` / `gnss nmea off` | Prints each NMEA sentence the receiver sends, as `nmea: …` | diff --git a/src/main.cpp b/src/main.cpp index 55ea01b..50d3c79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -684,6 +684,7 @@ static const char* const kHelp = "lora sweep on [from MHz] [to MHz] [step kHz] | lora sweep off | lora sweep dump RSSI across a band (863 870 100)\n" "lora custom [preamble] e.g. 868.1 125 7 5 34 8 (LoRaWAN)\n" "gnss quiet on|off pause the GNSS receiver while the LoRa radio listens (it costs the radio 8 dB)\n" + "imu what the motion sensor reads: g on its three axes, then degrees a second\n" "gnss status | gnss restart | gnss track start|stop | gnss nmea on|off | gnss send \n" "crash the last crash: firmware, reason, task, backtrace\n" "coredump erase forget the core dump in flash\n" @@ -1145,6 +1146,14 @@ static void runCommand(String line, bool fromSerial = false) { settings.setBool(Setting::GnssQuietForLora, line.endsWith("on")); console.printf("gnss quiet: %s\n", line.endsWith("on") ? "GNSS pauses while the LoRa radio listens" : "GNSS stays on"); } + if (line == "imu") { // the Compass's sensor (issue #16), as it reads now + if (!M5.Imu.update()) console.println("imu: no reading"); + else { + auto d = M5.Imu.getImuData(); + console.printf("imu: type %d, accel %.2f %.2f %.2f g, gyro %.1f %.1f %.1f deg/s\n", static_cast(M5.Imu.getType()), + d.accel.x, d.accel.y, d.accel.z, d.gyro.x, d.gyro.y, d.gyro.z); + } + } if (line == "gnss status" && gnssService) gnssService->printStatus(console, millis()); if ((line == "gnss nmea on" || line == "gnss nmea off") && gnssService) gnssService->setEcho(line.endsWith("on")); if (line == "gnss restart" && gnssService) gnssService->restart(millis());