1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 16:55:36 +03:00

Avoid logging an S frame at the same time as an I frame unless req'd

This reduces our instantaneous data rate
This commit is contained in:
Nicholas Sherlock 2015-05-18 11:53:13 +12:00
parent 0811367f24
commit 505b75ce2d

View file

@ -703,10 +703,16 @@ static void loadSlowState(blackboxSlowState_t *slow)
slow->failsafePhase = failsafePhase(); slow->failsafePhase = failsafePhase();
} }
static void writeSlowFrameIfNeeded(void) /**
* If the data in the slow frame has changed, log a slow frame.
*
* If allowPeriodicWrite is true, the frame is also logged if it has been more than SLOW_FRAME_INTERVAL logging iterations
* since the field was last logged.
*/
static void writeSlowFrameIfNeeded(bool allowPeriodicWrite)
{ {
// Write the slow frame peridocially so it can be recovered if we ever lose sync // Write the slow frame peridocially so it can be recovered if we ever lose sync
bool shouldWrite = blackboxSlowFrameIterationTimer >= SLOW_FRAME_INTERVAL; bool shouldWrite = allowPeriodicWrite && blackboxSlowFrameIterationTimer >= SLOW_FRAME_INTERVAL;
if (shouldWrite) { if (shouldWrite) {
loadSlowState(&slowHistory); loadSlowState(&slowHistory);
@ -1166,10 +1172,10 @@ static void blackboxLogIteration()
// Write a keyframe every BLACKBOX_I_INTERVAL frames so we can resynchronise upon missing frames // Write a keyframe every BLACKBOX_I_INTERVAL frames so we can resynchronise upon missing frames
if (blackboxPFrameIndex == 0) { if (blackboxPFrameIndex == 0) {
/* /*
* We assume that slow frames are only interesting in that they aid the interpretation of the main data stream. * Don't log a slow frame if the slow data didn't change ("I" frames are already large enough without adding
* So only log slow frames during loop iterations where we log a main frame. * an additional item to write at the same time)
*/ */
writeSlowFrameIfNeeded(); writeSlowFrameIfNeeded(false);
loadMainState(); loadMainState();
writeIntraframe(); writeIntraframe();
@ -1177,7 +1183,11 @@ static void blackboxLogIteration()
blackboxCheckAndLogArmingBeep(); blackboxCheckAndLogArmingBeep();
if (blackboxShouldLogPFrame(blackboxPFrameIndex)) { if (blackboxShouldLogPFrame(blackboxPFrameIndex)) {
writeSlowFrameIfNeeded(); /*
* We assume that slow frames are only interesting in that they aid the interpretation of the main data stream.
* So only log slow frames during loop iterations where we log a main frame.
*/
writeSlowFrameIfNeeded(true);
loadMainState(); loadMainState();
writeInterframe(); writeInterframe();