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

Limit the size of OSD DEBUG element

This commit is contained in:
Pawel Spychalski (DzikuVx) 2021-03-02 11:55:06 +01:00
parent cb2fccb7a0
commit 3cad49d006

View file

@ -2194,12 +2194,21 @@ static bool osdDrawSingleElement(uint8_t item)
}
break;
}
case OSD_DEBUG:
{
// Longest representable string is -2147483648, hence 11 characters
/*
* Longest representable string is -2147483648 does not fit in the screen.
* Only 7 digits for negative and 8 digits for positive values allowed
*/
for (uint8_t bufferIndex = 0; bufferIndex < DEBUG32_VALUE_COUNT; ++elemPosY, bufferIndex += 2) {
tfp_sprintf(buff, "[%u]=%11ld [%u]=%11ld", bufferIndex, debug[bufferIndex], bufferIndex+1, debug[bufferIndex+1]);
tfp_sprintf(
buff,
"[%u]=%8ld [%u]=%8ld",
bufferIndex,
constrain(debug[bufferIndex], -9999999, 99999999),
bufferIndex+1,
constrain(debug[bufferIndex+1], -9999999, 99999999)
);
displayWrite(osdDisplayPort, elemPosX, elemPosY, buff);
}
break;