1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +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

@ -658,7 +658,7 @@ void max7456ReadNvm(uint16_t char_address, osdCharacter_t *chr)
max7456WaitUntilNoBusy();
for (unsigned ii = 0; ii < sizeof(chr->data); ii++) {
for (unsigned ii = 0; ii < OSD_CHAR_VISIBLE_BYTES; ii++) {
busWrite(state.dev, MAX7456ADD_CMAL, ii);
busRead(state.dev, MAX7456ADD_CMDO, &chr->data[ii]);
}
@ -699,7 +699,7 @@ void max7456WriteNvm(uint16_t char_address, const osdCharacter_t *chr)
or_val = addr_h << 6;
}
for (unsigned x = 0; x < sizeof(chr->data); x++) {
for (unsigned x = 0; x < OSD_CHAR_VISIBLE_BYTES; x++) {
bufPtr = max7456PrepareBuffer(spiBuff, bufPtr, MAX7456ADD_CMAL, x | or_val); //set start address low
bufPtr = max7456PrepareBuffer(spiBuff, bufPtr, MAX7456ADD_CMDI, chr->data[x]);
}

View file

@ -25,7 +25,10 @@
#define OSD_CHAR_WIDTH 12
#define OSD_CHAR_HEIGHT 18
#define OSD_CHAR_BITS_PER_PIXEL 2
#define OSD_CHAR_BYTES (OSD_CHAR_WIDTH * OSD_CHAR_HEIGHT * OSD_CHAR_BITS_PER_PIXEL / 8)
#define OSD_CHAR_VISIBLE_BYTES (OSD_CHAR_WIDTH * OSD_CHAR_HEIGHT * OSD_CHAR_BITS_PER_PIXEL / 8)
// Only the first 54 bytes of a character represent visible data. However, some OSD drivers
// accept 64 bytes and use the extra 10 bytes for metadata.
#define OSD_CHAR_BYTES 64
#define OSD_CHARACTER_COLOR_BLACK 0
#define OSD_CHARACTER_COLOR_TRANSPARENT 1

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();