graph TD START[MPU reads @50ms = 20 Hz] --> A{IMU_CHANNEL
try_send} A -->|Full| DROP1[❌ DROP: Channel full
16 slots @ 50ms = 800ms buffer] A -->|OK| B[Main Loop receive] B --> C[Drain loop:
Get freshest reading] C --> D{Time check:
≥3s since last?} D -->|No| E[Skip MQTT] D -->|Yes| F{mqtt_set_imu
try_lock IMU_LATEST} F -->|Locked| DROP2[❌ SKIP: Mutex busy] F -->|OK| G[Store payload] E --> H[show_imu] G --> H H --> I{DISPLAY_CHANNEL
try_send} I -->|Full| DROP3[❌ DROP: Display slow
8 slots @ 100ms = 800ms buffer] I -->|OK| J[Display renders] G --> K[MQTT Task loop] K --> L{IMU_LATEST
try_lock} L -->|Empty/Locked| M[Skip this iteration] L -->|Has data| N[Send to broker
QoS0 no retain] N --> O{TCP send result} O -->|Fail| RECONNECT[❌ Session dies
Reconnect in 5s] O -->|OK| P[✅ Data sent] style DROP1 fill:#ffcccc style DROP2 fill:#ffcccc style DROP3 fill:#ffcccc style RECONNECT fill:#ffcccc style P fill:#ccffcc