Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log estimated wind speed to BB slow frames #3522

Merged
merged 3 commits into from Jul 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -339,6 +340,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)},
{"horizontalWindSpeed", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"verticalWindSpeed", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"windDirection", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
};

typedef enum BlackboxState {
Expand Down Expand Up @@ -436,6 +440,9 @@ typedef struct blackboxSlowState_s {
int32_t hwHealthStatus;
uint16_t powerSupplyImpedance;
uint16_t sagCompensatedVBat;
int16_t horizontalWindSpeed;
int16_t verticalWindSpeed;
uint16_t windDirection;
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()

//From rc_controls.c
Expand Down Expand Up @@ -1021,6 +1028,10 @@ static void writeSlowFrame(void)
blackboxWriteUnsignedVB(slowHistory.powerSupplyImpedance);
blackboxWriteUnsignedVB(slowHistory.sagCompensatedVBat);

blackboxWriteUnsignedVB(slowHistory.horizontalWindSpeed);
blackboxWriteUnsignedVB(slowHistory.verticalWindSpeed);
blackboxWriteUnsignedVB(slowHistory.windDirection);

blackboxSlowFrameIterationTimer = 0;
}

Expand All @@ -1043,6 +1054,8 @@ static void loadSlowState(blackboxSlowState_t *slow)
(getHwPitotmeterStatus() << 2 * 6);
slow->powerSupplyImpedance = getPowerSupplyImpedance();
slow->sagCompensatedVBat = getBatterySagCompensatedVoltage();
slow->horizontalWindSpeed = getEstimatedHorizontalWindSpeed(&slow->windDirection);
slow->verticalWindSpeed = getEstimatedWindSpeed(Z);
}

/**
Expand Down