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>
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#pragma once
|
|
#include "UiTypes.h"
|
|
#include "Config.h"
|
|
|
|
// Nextion serial HMI driver. No Nextion library - the protocol is small:
|
|
//
|
|
// Nextion -> remote: custom frames the HMI's touch events send with printh:
|
|
// '#' <len> <cmd> [value] e.g. printh 23 01 41 (ToggleArm)
|
|
// printh 23 02 56 + prints hSpeed.val,1
|
|
// Command bytes are listed in NEXTION.md and in NextionUI.cpp.
|
|
// Native Nextion return frames (terminated FF FF FF) are also parsed so a
|
|
// display reset (0x88 "ready") triggers a full redraw.
|
|
//
|
|
// remote -> Nextion: plain instructions ("bArm.txt=\"ARMED\"" + FF FF FF).
|
|
//
|
|
// The remote is authoritative: buttons are plain buttons (not dual-state),
|
|
// they only send requests, and render() repaints whatever the remote state
|
|
// actually is. A Nextion reboot or a dropped byte self-heals on the next
|
|
// periodic full refresh.
|
|
class NextionUI {
|
|
public:
|
|
void begin();
|
|
bool poll(UiEvent& out); // call every loop; returns one decoded event at a time
|
|
void render(const UiView& v, uint32_t now_ms);
|
|
|
|
private:
|
|
enum class Rx : uint8_t { Idle, CustomLen, CustomBody, Native };
|
|
Rx rx_ = Rx::Idle;
|
|
uint8_t body_[4];
|
|
uint8_t body_len_ = 0, body_got_ = 0;
|
|
uint8_t native_first_ = 0, native_len_ = 0, ff_run_ = 0;
|
|
|
|
UiView shown_;
|
|
bool force_full_ = true;
|
|
uint32_t last_full_ms_ = 0;
|
|
uint32_t last_link_ms_ = 0;
|
|
|
|
void cmd(const char* fmt, ...);
|
|
void pushState(const UiView& v, bool full);
|
|
void pushLink(const UiView& v);
|
|
bool decodeCustom(UiEvent& out);
|
|
};
|