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

OSD: Add support for uploading 64 byte fonts

Although visible data is only 54 bytes, some drivers can accept
64 bytes and use the remaining 10 for metadata. MAX7456 driver
ignores the extra 10 bytes.
This commit is contained in:
Alberto García Hierro 2019-06-02 14:45:29 +01:00
parent 929bbd6314
commit 0a14bd9024
3 changed files with 24 additions and 8 deletions

View file

@ -2283,15 +2283,28 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
case MSP_OSD_CHAR_WRITE:
if (dataSize >= 55) {
osdCharacter_t chr;
size_t osdCharacterBytes;
uint16_t addr;
if (dataSize >= 56) {
// 16 bit character address
addr = sbufReadU16(src);
if (dataSize >= OSD_CHAR_VISIBLE_BYTES + 2) {
if (dataSize >= OSD_CHAR_BYTES + 2) {
// 16 bit address, full char with metadata
addr = sbufReadU16(src);
osdCharacterBytes = OSD_CHAR_BYTES;
} else if (dataSize >= OSD_CHAR_BYTES + 1) {
// 8 bit address, full char with metadata
addr = sbufReadU8(src);
osdCharacterBytes = OSD_CHAR_BYTES;
} else {
// 16 bit character address, only visible char bytes
addr = sbufReadU16(src);
osdCharacterBytes = OSD_CHAR_VISIBLE_BYTES;
}
} else {
// 8 bit character address, for backwards compatibility
// 8 bit character address, only visible char bytes
addr = sbufReadU8(src);
osdCharacterBytes = OSD_CHAR_VISIBLE_BYTES;
}
for (unsigned ii = 0; ii < sizeof(chr.data); ii++) {
for (unsigned ii = 0; ii < MIN(osdCharacterBytes, sizeof(chr.data)); ii++) {
chr.data[ii] = sbufReadU8(src);
}
displayPort_t *osdDisplayPort = osdGetDisplayPort();