diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index dd150a7b28..02195f9ba1 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -75,6 +75,7 @@ #include "sensors/pitotmeter.h" #include "sensors/rangefinder.h" #include "sensors/sensors.h" +#include "flight/wind_estimator.h" #if defined(ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT) @@ -341,6 +342,9 @@ static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = { {"hwHealthStatus", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, {"powerSupplyImpedance", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, {"sagCompensatedVBat", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, + {"wind", 0, SIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, + {"wind", 1, SIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, + {"wind", 2, SIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}, }; typedef enum BlackboxState { @@ -438,6 +442,7 @@ typedef struct blackboxSlowState_s { int32_t hwHealthStatus; uint16_t powerSupplyImpedance; uint16_t sagCompensatedVBat; + int16_t wind[XYZ_AXIS_COUNT]; } __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp() //From rc_controls.c @@ -1022,6 +1027,8 @@ static void writeSlowFrame(void) blackboxWriteUnsignedVB(slowHistory.powerSupplyImpedance); blackboxWriteUnsignedVB(slowHistory.sagCompensatedVBat); + + blackboxWriteSigned16VBArray(slowHistory.wind, XYZ_AXIS_COUNT); blackboxSlowFrameIterationTimer = 0; } @@ -1045,6 +1052,12 @@ static void loadSlowState(blackboxSlowState_t *slow) (getHwPitotmeterStatus() << 2 * 6); slow->powerSupplyImpedance = getPowerSupplyImpedance(); slow->sagCompensatedVBat = getBatterySagCompensatedVoltage(); + + for (int i = 0; i < XYZ_AXIS_COUNT; i++) + { + slow->wind[i] = getEstimatedWindSpeed(i); + } + } /**