1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Add blackbox support for RSSI logging

This commit is contained in:
Nicholas Sherlock 2015-06-26 16:20:53 +12:00
parent 73d7bc6187
commit 583ff39bbf
3 changed files with 20 additions and 1 deletions

View file

@ -200,6 +200,7 @@ static const blackboxMainFieldDefinition_t blackboxMainFields[] = {
#ifdef SONAR #ifdef SONAR
{"sonarRaw", -1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(TAG8_8SVB), FLIGHT_LOG_FIELD_CONDITION_SONAR}, {"sonarRaw", -1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(TAG8_8SVB), FLIGHT_LOG_FIELD_CONDITION_SONAR},
#endif #endif
{"rssi", -1, UNSIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(UNSIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(TAG8_8SVB), FLIGHT_LOG_FIELD_CONDITION_RSSI},
/* Gyros and accelerometers base their P-predictions on the average of the previous 2 frames to reduce noise impact */ /* Gyros and accelerometers base their P-predictions on the average of the previous 2 frames to reduce noise impact */
{"gyroADC", 0, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)}, {"gyroADC", 0, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)},
@ -265,6 +266,9 @@ extern uint8_t motorCount;
//From mw.c: //From mw.c:
extern uint32_t currentTime; extern uint32_t currentTime;
//From rx.c:
extern uint16_t rssi;
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED; static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
static uint32_t blackboxLastArmingBeep = 0; static uint32_t blackboxLastArmingBeep = 0;
@ -360,6 +364,9 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
return false; return false;
#endif #endif
case FLIGHT_LOG_FIELD_CONDITION_RSSI:
return masterConfig.rxConfig.rssi_channel > 0 || feature(FEATURE_RSSI_ADC);
case FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME: case FLIGHT_LOG_FIELD_CONDITION_NOT_LOGGING_EVERY_FRAME:
return masterConfig.blackbox_rate_num < masterConfig.blackbox_rate_denom; return masterConfig.blackbox_rate_num < masterConfig.blackbox_rate_denom;
@ -485,6 +492,10 @@ static void writeIntraframe(void)
} }
#endif #endif
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_RSSI)) {
blackboxWriteUnsignedVB(blackboxCurrent->rssi);
}
for (x = 0; x < XYZ_AXIS_COUNT; x++) { for (x = 0; x < XYZ_AXIS_COUNT; x++) {
blackboxWriteSignedVB(blackboxCurrent->gyroADC[x]); blackboxWriteSignedVB(blackboxCurrent->gyroADC[x]);
} }
@ -518,7 +529,7 @@ static void writeIntraframe(void)
static void writeInterframe(void) static void writeInterframe(void)
{ {
int x; int x;
int32_t deltas[7]; int32_t deltas[8];
blackboxValues_t *blackboxCurrent = blackboxHistory[0]; blackboxValues_t *blackboxCurrent = blackboxHistory[0];
blackboxValues_t *blackboxLast = blackboxHistory[1]; blackboxValues_t *blackboxLast = blackboxHistory[1];
@ -598,6 +609,10 @@ static void writeInterframe(void)
} }
#endif #endif
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_RSSI)) {
deltas[optionalFieldCount++] = (int32_t) blackboxCurrent->rssi - blackboxLast->rssi;
}
blackboxWriteTag8_8SVB(deltas, optionalFieldCount); blackboxWriteTag8_8SVB(deltas, optionalFieldCount);
//Since gyros, accs and motors are noisy, base the prediction on the average of the history: //Since gyros, accs and motors are noisy, base the prediction on the average of the history:
@ -810,6 +825,8 @@ static void loadBlackboxState(void)
blackboxCurrent->sonarRaw = sonarRead(); blackboxCurrent->sonarRaw = sonarRead();
#endif #endif
blackboxCurrent->rssi = rssi;
#ifdef USE_SERVOS #ifdef USE_SERVOS
//Tail servo for tricopters //Tail servo for tricopters
blackboxCurrent->servo[5] = servo[5]; blackboxCurrent->servo[5] = servo[5];

View file

@ -46,6 +46,7 @@ typedef struct blackboxValues_t {
#ifdef SONAR #ifdef SONAR
int32_t sonarRaw; int32_t sonarRaw;
#endif #endif
uint16_t rssi;
} blackboxValues_t; } blackboxValues_t;
void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data); void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data);

View file

@ -34,6 +34,7 @@ typedef enum FlightLogFieldCondition {
FLIGHT_LOG_FIELD_CONDITION_VBAT, FLIGHT_LOG_FIELD_CONDITION_VBAT,
FLIGHT_LOG_FIELD_CONDITION_AMPERAGE_ADC, FLIGHT_LOG_FIELD_CONDITION_AMPERAGE_ADC,
FLIGHT_LOG_FIELD_CONDITION_SONAR, FLIGHT_LOG_FIELD_CONDITION_SONAR,
FLIGHT_LOG_FIELD_CONDITION_RSSI,
FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0, FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0,
FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1, FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1,