2026 remote: tabbed Nextion UI, robot telemetry, servo centre calibration
Protocol v4: CmdPacket grows to 26 bytes (cal_cmd, cal_servo, cal_value); new 30-byte Telemetry rides back on the nRF24 ack payload (robot state, IMU, battery, 18 joint angles, packets/s, servo-cal echo). Each end drops wrong-length packets, so version mismatches still fail closed. Robot (owner-approved): SERVO_CAL state while disarmed, per-servo centre trims (+-200 us) in EEPROM, telemetry, battery reading; the IMU estimate now always runs (leveling still gated by ROBOT GYRO). Remote: generated HMI (scripts/make_remote_hmi.py) with pages splash, drive, status, servos, cal, setup, upload; page-aware NextionUI that only writes the showing page and only what changed; servo calibration and UPDATE DISPLAY on the touchscreen and serial console; battery module. The display is on Serial2 (pins 7/8), found on the real remote; the old sketch's Serial1 was never connected to it. Sim: RF24 shim supports ack payloads, API version 8 (hxsim_get_ack_payload); sim_smoke checks telemetry and every CAL command. Unity CmdPacket mirror updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
481610c9fd
commit
0b836af8de
40 files changed
+1463
-281
No files matched your search
@@ -213,6 +213,9 @@ struct AirPacket {
|
||||
static bool g_radio_present = true;
|
||||
static std::deque<AirPacket> g_air; // packets waiting at the receiver
|
||||
static constexpr size_t RX_FIFO_DEPTH = 3;
|
||||
static std::vector<uint8_t> g_ack_queued; // robot's writeAckPayload(), not sent yet
|
||||
static bool g_ack_has_queued = false;
|
||||
static std::vector<uint8_t> g_ack_delivered; // came back with the last packet received
|
||||
|
||||
namespace simhw {
|
||||
void radioSetPresent(bool present) { g_radio_present = present; }
|
||||
@@ -225,6 +228,16 @@ void radioSend(const uint8_t* bytes, int len) {
|
||||
memcpy(p.address, HXP_RADIO_ADDRESS, 5);
|
||||
p.payload.assign(bytes, bytes + len);
|
||||
g_air.push_back(p);
|
||||
// The chip acks on reception, carrying whatever ack payload is queued.
|
||||
if (g_ack_has_queued) {
|
||||
g_ack_delivered = g_ack_queued;
|
||||
g_ack_has_queued = false;
|
||||
}
|
||||
}
|
||||
int radioLastAckPayload(uint8_t* out, int cap) {
|
||||
int n = (int)g_ack_delivered.size() < cap ? (int)g_ack_delivered.size() : cap;
|
||||
if (n > 0) memcpy(out, g_ack_delivered.data(), n);
|
||||
return n;
|
||||
}
|
||||
} // namespace simhw
|
||||
|
||||
@@ -240,7 +253,7 @@ bool RF24::available() {
|
||||
while (!g_air.empty()) {
|
||||
const AirPacket& p = g_air.front();
|
||||
bool match = p.channel == channel_ && p.rate == data_rate_ &&
|
||||
memcmp(p.address, address_, 5) == 0 && p.payload.size() == payload_size_;
|
||||
memcmp(p.address, address_, 5) == 0 && (dynamic_ || p.payload.size() == payload_size_);
|
||||
if (match) return true;
|
||||
g_air.pop_front();
|
||||
}
|
||||
@@ -252,3 +265,15 @@ void RF24::read(void* buf, uint8_t len) {
|
||||
memcpy(buf, p.payload.data(), len < p.payload.size() ? len : p.payload.size());
|
||||
g_air.pop_front();
|
||||
}
|
||||
uint8_t RF24::getDynamicPayloadSize() { return g_air.empty() ? 0 : (uint8_t)g_air.front().payload.size(); }
|
||||
bool RF24::writeAckPayload(uint8_t, const void* buf, uint8_t len) {
|
||||
if (!dynamic_ || len > 32) return false;
|
||||
const uint8_t* b = static_cast<const uint8_t*>(buf);
|
||||
g_ack_queued.assign(b, b + len);
|
||||
g_ack_has_queued = true;
|
||||
return true;
|
||||
}
|
||||
uint8_t RF24::flush_tx() {
|
||||
g_ack_has_queued = false;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user