1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +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?
if (def->fieldNameIndex != -1) {
blackboxWrite('[');
// Assume the field index is a single digit:
blackboxWrite(def->fieldNameIndex + '0');
blackboxWrite(']');
charsWritten += 3;
charsWritten += blackboxPrintf("[%d]", def->fieldNameIndex);
}
} else {
//The other headers are integers
if (def->arr[xmitState.headerIndex - 1] >= 10) {
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++;
}
charsWritten += blackboxPrintf("%d", def->arr[xmitState.headerIndex - 1]);
}
}
}