Files
projekt1/mqtt_display/docs/mpu_data_flow.mermaid
2026-01-19 16:43:58 +01:00

55 lines
1.4 KiB
Plaintext

sequenceDiagram
participant HW as MPU6050 Hardware
participant MPU as MPU Task<br/>(Core 0)
participant CH as IMU_CHANNEL<br/>[16 slots]
participant MAIN as Main Loop<br/>(Core 0)
participant LATEST as IMU_LATEST<br/>(Mutex)
participant MQTT as MQTT Task<br/>(Core 1)
participant DISP as Display API
Note over MPU: Every 50ms
MPU->>HW: Read sensor (I2C)
HW-->>MPU: Raw data
MPU->>MPU: Convert to ImuReading
MPU->>CH: try_send(reading)
alt Channel full
CH--xMPU: Drop (log warning)
else Channel has space
CH-->>MPU: OK
end
Note over MAIN: Continuous loop
MAIN->>CH: receive() [blocking]
CH-->>MAIN: reading
Note over MAIN: Drain queue
loop While available
MAIN->>CH: try_receive()
CH-->>MAIN: newer reading
end
MAIN->>DISP: show_imu(reading)<br/>[try_send]
Note over MAIN: Every 3 seconds
alt Time >= 3s since last
MAIN->>MAIN: Format JSON payload
MAIN->>LATEST: mqtt_set_imu()<br/>[try_lock]
alt Mutex available
LATEST-->>MAIN: Stored
else Mutex locked
LATEST--xMAIN: Skip
end
end
Note over MQTT: Continuous loop
MQTT->>LATEST: try_lock()
alt Data available
LATEST-->>MQTT: payload
MQTT->>MQTT: send_message("esp32/imu")
else No data
LATEST--xMQTT: None
end