mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-21 07:15:16 +03:00
Merge pull request #9942 from iNavFlight/mmosca-osd-2bit-page
Use 2 bits for msp displayport font page
This commit is contained in:
commit
b7cae2e608
3 changed files with 48 additions and 22 deletions
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
uint8_t getBfCharacter(uint8_t ch, uint8_t page)
|
uint8_t getBfCharacter(uint8_t ch, uint8_t page)
|
||||||
{
|
{
|
||||||
uint16_t ech = ch | (page << 8);
|
uint16_t ech = ch | ((page & 0x3)<< 8) ;
|
||||||
|
|
||||||
if (ech >= 0x20 && ech <= 0x5F) { // ASCII range
|
if (ech >= 0x20 && ech <= 0x5F) { // ASCII range
|
||||||
return ch;
|
return ch;
|
||||||
|
|
|
@ -100,9 +100,8 @@ static timeMs_t sendSubFrameMs = 0;
|
||||||
static uint8_t currentOsdMode; // HDZero screen mode can change across layouts
|
static uint8_t currentOsdMode; // HDZero screen mode can change across layouts
|
||||||
|
|
||||||
static uint8_t screen[SCREENSIZE];
|
static uint8_t screen[SCREENSIZE];
|
||||||
static BITARRAY_DECLARE(fontPage, SCREENSIZE); // font page for each character on the screen
|
static uint8_t attrs[SCREENSIZE]; // font page, blink and other attributes
|
||||||
static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen
|
static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen
|
||||||
static BITARRAY_DECLARE(blinkChar, SCREENSIZE); // Does the character blink?
|
|
||||||
static bool screenCleared;
|
static bool screenCleared;
|
||||||
static uint8_t screenRows, screenCols;
|
static uint8_t screenRows, screenCols;
|
||||||
static videoSystem_e osdVideoSystem;
|
static videoSystem_e osdVideoSystem;
|
||||||
|
@ -158,6 +157,22 @@ static uint8_t determineHDZeroOsdMode(void)
|
||||||
return HD_3016;
|
return HD_3016;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t setAttrPage(uint8_t origAttr, uint8_t page)
|
||||||
|
{
|
||||||
|
return (origAttr & ~DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK) | (page & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t setAttrBlink(uint8_t origAttr, uint8_t blink)
|
||||||
|
{
|
||||||
|
return (origAttr & ~DISPLAYPORT_MSP_ATTR_BLINK_MASK) | ((blink << DISPLAYPORT_MSP_ATTR_BLINK) & DISPLAYPORT_MSP_ATTR_BLINK_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t setAttrVersion(uint8_t origAttr, uint8_t version)
|
||||||
|
{
|
||||||
|
return (origAttr & ~DISPLAYPORT_MSP_ATTR_VERSION_MASK) | ((version << DISPLAYPORT_MSP_ATTR_VERSION) & DISPLAYPORT_MSP_ATTR_VERSION_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
static int setDisplayMode(displayPort_t *displayPort)
|
static int setDisplayMode(displayPort_t *displayPort)
|
||||||
{
|
{
|
||||||
if (osdVideoSystem == VIDEO_SYSTEM_HDZERO) {
|
if (osdVideoSystem == VIDEO_SYSTEM_HDZERO) {
|
||||||
|
@ -171,9 +186,8 @@ static int setDisplayMode(displayPort_t *displayPort)
|
||||||
static void init(void)
|
static void init(void)
|
||||||
{
|
{
|
||||||
memset(screen, SYM_BLANK, sizeof(screen));
|
memset(screen, SYM_BLANK, sizeof(screen));
|
||||||
BITARRAY_CLR_ALL(fontPage);
|
memset(attrs, 0, sizeof(attrs));
|
||||||
BITARRAY_CLR_ALL(dirty);
|
BITARRAY_CLR_ALL(dirty);
|
||||||
BITARRAY_CLR_ALL(blinkChar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clearScreen(displayPort_t *displayPort)
|
static int clearScreen(displayPort_t *displayPort)
|
||||||
|
@ -204,9 +218,8 @@ static bool readChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint1
|
||||||
}
|
}
|
||||||
|
|
||||||
*c = screen[pos];
|
*c = screen[pos];
|
||||||
if (bitArrayGet(fontPage, pos)) {
|
uint8_t page = getAttrPage(attrs[pos]);
|
||||||
*c |= 0x100;
|
*c |= page << 8;
|
||||||
}
|
|
||||||
|
|
||||||
if (attr) {
|
if (attr) {
|
||||||
*attr = TEXT_ATTRIBUTES_NONE;
|
*attr = TEXT_ATTRIBUTES_NONE;
|
||||||
|
@ -219,11 +232,12 @@ static int setChar(const uint16_t pos, const uint16_t c, textAttributes_t attr)
|
||||||
{
|
{
|
||||||
if (pos < SCREENSIZE) {
|
if (pos < SCREENSIZE) {
|
||||||
uint8_t ch = c & 0xFF;
|
uint8_t ch = c & 0xFF;
|
||||||
bool page = (c >> 8);
|
uint8_t page = (c >> 8) & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK;
|
||||||
if (screen[pos] != ch || bitArrayGet(fontPage, pos) != page) {
|
if (screen[pos] != ch || getAttrPage(attrs[pos]) != page) {
|
||||||
screen[pos] = ch;
|
screen[pos] = ch;
|
||||||
(page) ? bitArraySet(fontPage, pos) : bitArrayClr(fontPage, pos);
|
attrs[pos] = setAttrPage(attrs[pos], page);
|
||||||
(TEXT_ATTRIBUTES_HAVE_BLINK(attr)) ? bitArraySet(blinkChar, pos) : bitArrayClr(blinkChar, pos);
|
uint8_t blink = (TEXT_ATTRIBUTES_HAVE_BLINK(attr)) ? 1 : 0;
|
||||||
|
attrs[pos] = setAttrBlink(attrs[pos], blink);
|
||||||
bitArraySet(dirty, pos);
|
bitArraySet(dirty, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,8 +301,8 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz
|
||||||
uint8_t col = pos % COLS;
|
uint8_t col = pos % COLS;
|
||||||
uint8_t attributes = 0;
|
uint8_t attributes = 0;
|
||||||
int endOfLine = row * COLS + screenCols;
|
int endOfLine = row * COLS + screenCols;
|
||||||
bool page = bitArrayGet(fontPage, pos);
|
uint8_t page = getAttrPage(attrs[pos]);
|
||||||
bool blink = bitArrayGet(blinkChar, pos);
|
uint8_t blink = getAttrBlink(attrs[pos]);
|
||||||
|
|
||||||
uint8_t len = 4;
|
uint8_t len = 4;
|
||||||
do {
|
do {
|
||||||
|
@ -299,7 +313,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz
|
||||||
if (bitArrayGet(dirty, pos)) {
|
if (bitArrayGet(dirty, pos)) {
|
||||||
next = pos;
|
next = pos;
|
||||||
}
|
}
|
||||||
} while (next == pos && next < endOfLine && bitArrayGet(fontPage, next) == page && bitArrayGet(blinkChar, next) == blink);
|
} while (next == pos && next < endOfLine && getAttrPage(attrs[next]) == page && getAttrBlink(attrs[next]) == blink);
|
||||||
|
|
||||||
if (!isBfCompatibleVideoSystem(osdConfig())) {
|
if (!isBfCompatibleVideoSystem(osdConfig())) {
|
||||||
attributes |= (page << DISPLAYPORT_MSP_ATTR_FONTPAGE);
|
attributes |= (page << DISPLAYPORT_MSP_ATTR_FONTPAGE);
|
||||||
|
|
|
@ -27,13 +27,25 @@
|
||||||
#include "drivers/osd.h"
|
#include "drivers/osd.h"
|
||||||
#include "msp/msp_serial.h"
|
#include "msp/msp_serial.h"
|
||||||
|
|
||||||
|
// MSP displayport V2 attribute byte bit functions
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_FONTPAGE 0 // Select bank of 256 characters as per displayPortSeverity_e
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_BLINK 6 // Device local blink
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_VERSION 7 // Format indicator; must be zero for V2 (and V1)
|
||||||
|
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK 0x3
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_BLINK_MASK (1 << DISPLAYPORT_MSP_ATTR_BLINK)
|
||||||
|
#define DISPLAYPORT_MSP_ATTR_VERSION_MASK (1 << DISPLAYPORT_MSP_ATTR_VERSION)
|
||||||
|
|
||||||
typedef struct displayPort_s displayPort_t;
|
typedef struct displayPort_s displayPort_t;
|
||||||
|
|
||||||
displayPort_t *mspOsdDisplayPortInit(const videoSystem_e videoSystem);
|
displayPort_t *mspOsdDisplayPortInit(const videoSystem_e videoSystem);
|
||||||
void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn);
|
void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn);
|
||||||
mspPort_t *getMspOsdPort(void);
|
mspPort_t *getMspOsdPort(void);
|
||||||
|
|
||||||
// MSP displayport V2 attribute byte bit functions
|
#define getAttrPage(attr) (attr & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK)
|
||||||
#define DISPLAYPORT_MSP_ATTR_FONTPAGE 0 // Select bank of 256 characters as per displayPortSeverity_e
|
#define getAttrBlink(attr) ((attr & DISPLAYPORT_MSP_ATTR_BLINK_MASK) >> DISPLAYPORT_MSP_ATTR_BLINK)
|
||||||
#define DISPLAYPORT_MSP_ATTR_BLINK 6 // Device local blink
|
#define getAttrVersion(attr) ((attr & DISPLAYPORT_MSP_ATTR_VERSION_MASK) >> DISPLAYPORT_MSP_ATTR_VERSION)
|
||||||
#define DISPLAYPORT_MSP_ATTR_VERSION 7 // Format indicator; must be zero for V2 (and V1)
|
|
||||||
|
uint8_t setAttrPage(uint8_t origAttr, uint8_t page);
|
||||||
|
uint8_t setAttrBlink(uint8_t origAttr, uint8_t page);
|
||||||
|
uint8_t setAttrVersion(uint8_t origAttr, uint8_t page);
|
Loading…
Add table
Add a link
Reference in a new issue