Files
hexapod-robot/2026-current/remote/SerialConsole.cpp
T
mangavalkandClaude Opus 5.5 91dac16fca Draft: shared protocol, remote firmware, project docs
Not yet verified on hardware.

- shared/HexapodProtocol: CmdPacket (now 20 bytes, adds remote_roll /
  remote_pitch), FLAG_* bits and radio settings as the single protocol
  definition; static payload size = sizeof(CmdPacket) on both radios.
- robot: use the shared protocol; vx = forward (harness w/x <-> q/e);
  InputMapper adds remote tilt on top of the right stick when
  FLAG_REMOTE_GYRO is set, and robot.ino no longer zeroes stick
  roll/pitch when it's off.
- remote (Teensy 4.1): Sticks (calibration, EEPROM), RemoteIMU,
  RemoteState (interlocks, link-loss disarm, smoothing), PacketBuilder,
  RadioLink, NextionUI, SerialConsole.
- CLAUDE.md, README.md, remote/README.md, remote/NEXTION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:14:00 +02:00

31 lines
1.3 KiB
C++

#include "SerialConsole.h"
#include <Arduino.h>
bool SerialConsole::poll(UiEvent& ui, Local& local) {
ui = UiEvent{};
local = Local::None;
while (Serial.available()) {
char c = Serial.read();
switch (c) {
case 'a': ui.cmd = UiCmd::ToggleArm; return true;
case 'k': ui.cmd = UiCmd::Disarm; return true;
case 's': ui.cmd = UiCmd::ToggleStand; return true;
case 'g': ui.cmd = UiCmd::ToggleGait; return true;
case 'm': ui.cmd = UiCmd::ToggleWalkMode; return true;
case 't': ui.cmd = UiCmd::ToggleRStickXlate; return true;
case 'r': ui.cmd = UiCmd::ToggleRemoteGyro; return true;
case 'b': ui.cmd = UiCmd::ToggleRobotGyro; return true;
case '+': case '=': ui.cmd = UiCmd::SpeedUp; return true;
case '-': case '_': ui.cmd = UiCmd::SpeedDown; return true;
case 'z': ui.cmd = UiCmd::ZeroGyro; return true;
case 'c': ui.cmd = UiCmd::CalStartSave; return true;
case 'x': ui.cmd = UiCmd::CalCancel; return true;
case 'p': local = Local::PrintStatus; return true;
case 'd': local = Local::ToggleDump; return true;
case 'R': local = Local::ResetCal; return true;
default: break; // ignore line endings and unknown keys
}
}
return false;
}