mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2026-04-28 09:43:08 +00:00
Add IMU data logger to SD card with remote start/stop
Streams BHI260AP accelerometer (50Hz), gyroscope (50Hz), and magnetometer (25Hz) as timestamped CSV to SD card. Ring buffer in PSRAM (512 samples) flushed to SD from the main loop. Remote debug command 'L' toggles logging. Python tool: ./scripts/screenshot.py log CSV format: ms,ax,ay,az,gx,gy,gz,mx,my,mz (raw int16 units) Measured throughput: ~43Hz actual sample rate. Also fixed: BHI260AP init no longer gated on hw_ready (radio provisioning) — IMU sensors should work regardless of radio state. Foundation for compass calibration (PCA on magnetometer data), gesture recognition training, and activity classification.
This commit is contained in:
parent
cb367eff5c
commit
b594284060
4 changed files with 234 additions and 1 deletions
|
|
@ -158,6 +158,24 @@ def cmd_invalidate(s):
|
|||
print("Invalidated — full redraw requested")
|
||||
|
||||
|
||||
def cmd_log(s):
|
||||
send_cmd(s, ord('L'))
|
||||
buf = b""
|
||||
deadline = time.time() + 5
|
||||
while time.time() < deadline:
|
||||
chunk = s.read(max(1, s.in_waiting or 1))
|
||||
if chunk:
|
||||
buf += chunk
|
||||
magic = PREFIX + b"L"
|
||||
idx = buf.find(magic)
|
||||
if idx >= 0:
|
||||
nl = buf.find(b"\n", idx + 4)
|
||||
if nl >= 0:
|
||||
print(buf[idx + 4:nl].decode())
|
||||
return
|
||||
print(f"Timeout ({len(buf)} bytes)")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="R-Watch remote debug")
|
||||
parser.add_argument("-p", "--port", default=DEFAULT_PORT)
|
||||
|
|
@ -181,6 +199,9 @@ def main():
|
|||
|
||||
sub.add_parser("invalidate", aliases=["inv"])
|
||||
|
||||
sub.add_parser("log", aliases=["l"],
|
||||
help="Toggle IMU logging to SD card")
|
||||
|
||||
args = parser.parse_args()
|
||||
if not args.command:
|
||||
parser.print_help()
|
||||
|
|
@ -200,6 +221,8 @@ def main():
|
|||
cmd_navigate(s, args.screen)
|
||||
elif args.command in ("invalidate", "inv"):
|
||||
cmd_invalidate(s)
|
||||
elif args.command in ("log", "l"):
|
||||
cmd_log(s)
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue