Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3522 from giacomo892/wind_speed_BB_slow
Log estimated wind speed to BB slow frames
  • Loading branch information
fiam committed Jul 7, 2018
2 parents b0ccae5 + 950f96f commit d7c8a6e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/blackbox/blackbox.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1022,6 +1027,8 @@ static void writeSlowFrame(void)

blackboxWriteUnsignedVB(slowHistory.powerSupplyImpedance);
blackboxWriteUnsignedVB(slowHistory.sagCompensatedVBat);

blackboxWriteSigned16VBArray(slowHistory.wind, XYZ_AXIS_COUNT);

blackboxSlowFrameIterationTimer = 0;
}
Expand All @@ -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);
}

}

/**
Expand Down

0 comments on commit d7c8a6e

Please sign in to comment.