mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Add blackbox support for RSSI logging
This commit is contained in:
parent
73d7bc6187
commit
583ff39bbf
3 changed files with 20 additions and 1 deletions
|
@ -200,6 +200,7 @@ static const blackboxMainFieldDefinition_t blackboxMainFields[] = {
|
|||
#ifdef SONAR
|
||||
{"sonarRaw", -1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(TAG8_8SVB), FLIGHT_LOG_FIELD_CONDITION_SONAR},
|
||||
#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 */
|
||||
{"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:
|
||||
extern uint32_t currentTime;
|
||||
|
||||
//From rx.c:
|
||||
extern uint16_t rssi;
|
||||
|
||||
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
|
||||
|
||||
static uint32_t blackboxLastArmingBeep = 0;
|
||||
|
@ -360,6 +364,9 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
|
|||
return false;
|
||||
#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:
|
||||
return masterConfig.blackbox_rate_num < masterConfig.blackbox_rate_denom;
|
||||
|
||||
|
@ -485,6 +492,10 @@ static void writeIntraframe(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_RSSI)) {
|
||||
blackboxWriteUnsignedVB(blackboxCurrent->rssi);
|
||||
}
|
||||
|
||||
for (x = 0; x < XYZ_AXIS_COUNT; x++) {
|
||||
blackboxWriteSignedVB(blackboxCurrent->gyroADC[x]);
|
||||
}
|
||||
|
@ -518,7 +529,7 @@ static void writeIntraframe(void)
|
|||
static void writeInterframe(void)
|
||||
{
|
||||
int x;
|
||||
int32_t deltas[7];
|
||||
int32_t deltas[8];
|
||||
|
||||
blackboxValues_t *blackboxCurrent = blackboxHistory[0];
|
||||
blackboxValues_t *blackboxLast = blackboxHistory[1];
|
||||
|
@ -598,6 +609,10 @@ static void writeInterframe(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_RSSI)) {
|
||||
deltas[optionalFieldCount++] = (int32_t) blackboxCurrent->rssi - blackboxLast->rssi;
|
||||
}
|
||||
|
||||
blackboxWriteTag8_8SVB(deltas, optionalFieldCount);
|
||||
|
||||
//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();
|
||||
#endif
|
||||
|
||||
blackboxCurrent->rssi = rssi;
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
//Tail servo for tricopters
|
||||
blackboxCurrent->servo[5] = servo[5];
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct blackboxValues_t {
|
|||
#ifdef SONAR
|
||||
int32_t sonarRaw;
|
||||
#endif
|
||||
uint16_t rssi;
|
||||
} blackboxValues_t;
|
||||
|
||||
void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data);
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef enum FlightLogFieldCondition {
|
|||
FLIGHT_LOG_FIELD_CONDITION_VBAT,
|
||||
FLIGHT_LOG_FIELD_CONDITION_AMPERAGE_ADC,
|
||||
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_1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue