arduino: TSV telemetry protocol with mock RPM/gear

- null-terminated TSV frame: V_bat, IMU (9 fields), RPM, gear
- mock RPM ramps 800-8000, gear derived from RPM bands
- voltage calibration offset
- PROTOCOL.md documents wire format

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikkeli Matlock
2026-02-01 17:00:14 +09:00
parent 4e68dcef5f
commit f1ed809c71
10 changed files with 186 additions and 51 deletions

View File

@@ -2,6 +2,7 @@
#define COMMS_H
#include <Arduino.h>
#include "imu.h"
// Initialize Pi serial communication (call in setup)
void comms_init();
@@ -10,7 +11,12 @@ void comms_init();
// Returns true if a complete command was received
bool comms_update();
// Send telemetry line to Pi
// Send complete telemetry frame (TSV format, null-terminated)
// Format: V_bat\tAx\tAy\tAz\tGx\tGy\tGz\tRoll\tPitch\tYaw\tRPM\tGear\0
// If imu_valid is false, IMU fields are empty (but tabs preserved)
void comms_send_telemetry(float voltage, const ImuData& imu, bool imu_valid, int rpm, int gear);
// Send key:value line (for debug/ACK, newline-terminated)
void comms_send(const char* key, float value, int decimals = 2);
void comms_send(const char* key, int value);
void comms_send(const char* key, const char* value);