1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

blackbox - support arrays greater that 10 elements / use printf to print numbers

This commit is contained in:
Petr Ledvina 2015-03-14 17:54:07 +01:00
parent 8d2dc82f4b
commit 35ef95cec7

View file

@ -839,22 +839,11 @@ static bool sendFieldDefinition(const char * const *headerNames, unsigned int he
// Do we need to print an index in brackets after the name? // Do we need to print an index in brackets after the name?
if (def->fieldNameIndex != -1) { if (def->fieldNameIndex != -1) {
blackboxWrite('['); charsWritten += blackboxPrintf("[%d]", def->fieldNameIndex);
// Assume the field index is a single digit:
blackboxWrite(def->fieldNameIndex + '0');
blackboxWrite(']');
charsWritten += 3;
} }
} else { } else {
//The other headers are integers //The other headers are integers
if (def->arr[xmitState.headerIndex - 1] >= 10) { charsWritten += blackboxPrintf("%d", def->arr[xmitState.headerIndex - 1]);
blackboxWrite(def->arr[xmitState.headerIndex - 1] / 10 + '0');
blackboxWrite(def->arr[xmitState.headerIndex - 1] % 10 + '0');
charsWritten += 2;
} else {
blackboxWrite(def->arr[xmitState.headerIndex - 1] + '0');
charsWritten++;
}
} }
} }
} }