From c97e71e9956dd2bcb37769244b185c98d27bcfa2 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Wed, 9 Nov 2016 19:54:45 +0000 Subject: [PATCH] Made OSD device independent, now uses displayPort --- src/main/cms/cms.c | 10 +-- src/main/cms/cms_menu_blackbox.c | 4 +- src/main/drivers/display.c | 26 ++++++- src/main/drivers/display.h | 12 ++- src/main/io/displayport_max7456.c | 41 +++++++++- src/main/io/displayport_max7456.h | 2 +- src/main/io/displayport_msp.c | 34 ++++++++- src/main/io/displayport_oled.c | 33 +++++++- src/main/io/osd.c | 120 +++++++++++++++--------------- src/test/unit/cms_unittest.cc | 4 +- 10 files changed, 205 insertions(+), 81 deletions(-) diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index 3b9f6791f..388fd6b03 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -466,7 +466,7 @@ long cmsMenuChange(displayPort_t *pDisplay, const void *ptr) pageTop = currentMenu->entries; pageTopAlt = NULL; - displayClear(pDisplay); + displayClearScreen(pDisplay); cmsUpdateMaxRow(pDisplay); } @@ -481,7 +481,7 @@ STATIC_UNIT_TESTED long cmsMenuBack(displayPort_t *pDisplay) return -1; if (menuStackIdx) { - displayClear(pDisplay); + displayClearScreen(pDisplay); menuStackIdx--; currentMenu = menuStack[menuStackIdx]; cursorRow = menuStackHistory[menuStackIdx]; @@ -544,7 +544,7 @@ static void cmsTraverseGlobalExit(const CMS_Menu *pMenu) long cmsMenuExit(displayPort_t *pDisplay, const void *ptr) { if (ptr) { - displayClear(pDisplay); + displayClearScreen(pDisplay); displayWrite(pDisplay, 5, 3, "REBOOTING..."); displayResync(pDisplay); // Was max7456RefreshAll(); why at this timing? @@ -610,7 +610,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) cursorRow++; } else { if (pageTopAlt) { // we have another page - displayClear(pDisplay); + displayClearScreen(pDisplay); p = pageTopAlt; pageTopAlt = pageTop; pageTop = (OSD_Entry *)p; @@ -628,7 +628,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) if (cursorRow == -1 || (pageTop + cursorRow)->type == OME_Label) { if (pageTopAlt) { - displayClear(pDisplay); + displayClearScreen(pDisplay); p = pageTopAlt; pageTopAlt = pageTop; pageTop = (OSD_Entry *)p; diff --git a/src/main/cms/cms_menu_blackbox.c b/src/main/cms/cms_menu_blackbox.c index 7b65850ba..7ad339ccb 100644 --- a/src/main/cms/cms_menu_blackbox.c +++ b/src/main/cms/cms_menu_blackbox.c @@ -47,7 +47,7 @@ static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) { UNUSED(ptr); - displayClear(pDisplay); + displayClearScreen(pDisplay); displayWrite(pDisplay, 5, 3, "ERASING FLASH..."); displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing? @@ -56,7 +56,7 @@ static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr) delay(100); } - displayClear(pDisplay); + displayClearScreen(pDisplay); displayResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI? return 0; diff --git a/src/main/drivers/display.c b/src/main/drivers/display.c index 6589a7e93..5ac00ab91 100644 --- a/src/main/drivers/display.c +++ b/src/main/drivers/display.c @@ -24,17 +24,27 @@ #include "display.h" -void displayClear(displayPort_t *instance) +void displayClearScreen(displayPort_t *instance) { - instance->vTable->clear(instance); + instance->vTable->clearScreen(instance); instance->cleared = true; instance->cursorRow = -1; } +void displayDrawScreen(displayPort_t *instance) +{ + instance->vTable->drawScreen(instance); +} + +int displayScreenSize(const displayPort_t *instance) +{ + return instance->vTable->screenSize(instance); +} + void displayGrab(displayPort_t *instance) { instance->vTable->grab(instance); - instance->vTable->clear(instance); + instance->vTable->clearScreen(instance); instance->isGrabbed = true; } @@ -55,6 +65,16 @@ int displayWrite(displayPort_t *instance, uint8_t x, uint8_t y, const char *s) return instance->vTable->write(instance, x, y, s); } +int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t c) +{ + return instance->vTable->writeChar(instance, x, y, c); +} + +bool displayIsTransferInProgress(const displayPort_t *instance) +{ + return instance->vTable->isTransferInProgress(instance); +} + void displayHeartbeat(displayPort_t *instance) { instance->vTable->heartbeat(instance); diff --git a/src/main/drivers/display.h b/src/main/drivers/display.h index 160523773..5550273b4 100644 --- a/src/main/drivers/display.h +++ b/src/main/drivers/display.h @@ -32,8 +32,12 @@ typedef struct displayPort_s { typedef struct displayPortVTable_s { int (*grab)(displayPort_t *displayPort); int (*release)(displayPort_t *displayPort); - int (*clear)(displayPort_t *displayPort); + int (*clearScreen)(displayPort_t *displayPort); + int (*drawScreen)(displayPort_t *displayPort); + int (*screenSize)(const displayPort_t *displayPort); int (*write)(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *text); + int (*writeChar)(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c); + bool (*isTransferInProgress)(const displayPort_t *displayPort); int (*heartbeat)(displayPort_t *displayPort); void (*resync)(displayPort_t *displayPort); uint32_t (*txBytesFree)(const displayPort_t *displayPort); @@ -42,8 +46,12 @@ typedef struct displayPortVTable_s { void displayGrab(displayPort_t *instance); void displayRelease(displayPort_t *instance); bool displayIsGrabbed(const displayPort_t *instance); -void displayClear(displayPort_t *instance); +void displayClearScreen(displayPort_t *instance); +void displayDrawScreen(displayPort_t *instance); +int displayScreenSize(const displayPort_t *instance); int displayWrite(displayPort_t *instance, uint8_t x, uint8_t y, const char *s); +int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t c); +bool displayIsTransferInProgress(const displayPort_t *instance); void displayHeartbeat(displayPort_t *instance); void displayResync(displayPort_t *instance); uint16_t displayTxBytesFree(const displayPort_t *instance); diff --git a/src/main/io/displayport_max7456.c b/src/main/io/displayport_max7456.c index 0bfbb4231..d05dcb9ec 100644 --- a/src/main/io/displayport_max7456.c +++ b/src/main/io/displayport_max7456.c @@ -59,6 +59,20 @@ static int clearScreen(displayPort_t *displayPort) return 0; } +static int drawScreen(displayPort_t *displayPort) +{ + UNUSED(displayPort); + max7456DrawScreen(); + + return 0; +} + +static int screenSize(const displayPort_t *displayPort) +{ + UNUSED(displayPort); + return maxScreenSize; +} + static int write(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s) { UNUSED(displayPort); @@ -67,6 +81,24 @@ static int write(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s return 0; } +static int writeChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c) +{ + UNUSED(displayPort); + max7456WriteChar(x, y, c); + + return 0; +} + +static bool isTransferInProgress(const displayPort_t *displayPort) +{ + UNUSED(displayPort); +#ifdef MAX7456_DMA_CHANNEL_TX + return max7456DmaInProgres(); +#else + return false; +#endif +} + static void resync(displayPort_t *displayPort) { UNUSED(displayPort); @@ -90,16 +122,21 @@ static uint32_t txBytesFree(const displayPort_t *displayPort) static displayPortVTable_t max7456VTable = { .grab = grab, .release = release, - .clear = clearScreen, + .clearScreen = clearScreen, + .drawScreen = drawScreen, + .screenSize = screenSize, .write = write, + .writeChar = writeChar, + .isTransferInProgress = isTransferInProgress, .heartbeat = heartbeat, .resync = resync, .txBytesFree = txBytesFree, }; -displayPort_t *max7456DisplayPortInit(void) +displayPort_t *max7456DisplayPortInit(uint8_t system) { max7456DisplayPort.vTable = &max7456VTable; + max7456Init(system); max7456DisplayPort.isGrabbed = false; resync(&max7456DisplayPort); return &max7456DisplayPort; diff --git a/src/main/io/displayport_max7456.h b/src/main/io/displayport_max7456.h index bbb4aced3..e94ffd910 100644 --- a/src/main/io/displayport_max7456.h +++ b/src/main/io/displayport_max7456.h @@ -17,4 +17,4 @@ #pragma once -displayPort_t *max7456DisplayPortInit(void); +displayPort_t *max7456DisplayPortInit(uint8_t videoSystem); diff --git a/src/main/io/displayport_msp.c b/src/main/io/displayport_msp.c index ff16c04c8..2c6eee3c6 100644 --- a/src/main/io/displayport_msp.c +++ b/src/main/io/displayport_msp.c @@ -61,13 +61,24 @@ static int release(displayPort_t *displayPort) return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); } -static int clear(displayPort_t *displayPort) +static int clearScreen(displayPort_t *displayPort) { const uint8_t subcmd[] = { 2 }; return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); } +static int drawScreen(displayPort_t *displayPort) +{ + UNUSED(displayPort); + return 0; +} + +static int screenSize(const displayPort_t *displayPort) +{ + return displayPort->rows * displayPort->cols; +} + static int write(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string) { #define MSP_OSD_MAX_STRING_LENGTH 30 @@ -87,6 +98,21 @@ static int write(displayPort_t *displayPort, uint8_t col, uint8_t row, const cha return output(displayPort, MSP_DISPLAYPORT, buf, len + 4); } +static int writeChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8_t c) +{ + char buf[2]; + + buf[0] = c; + buf[1] = 0; + return write(displayPort, col, row, buf); //!!TODO - check if there is a direct MSP command to do this +} + +static bool isTransferInProgress(const displayPort_t *displayPort) +{ + UNUSED(displayPort); + return false; +} + static void resync(displayPort_t *displayPort) { displayPort->rows = 13; // XXX Will reflect NTSC/PAL in the future @@ -102,8 +128,12 @@ static uint32_t txBytesFree(const displayPort_t *displayPort) static const displayPortVTable_t mspDisplayPortVTable = { .grab = grab, .release = release, - .clear = clear, + .clearScreen = clearScreen, + .drawScreen = drawScreen, + .screenSize = screenSize, .write = write, + .writeChar = writeChar, + .isTransferInProgress = isTransferInProgress, .heartbeat = heartbeat, .resync = resync, .txBytesFree = txBytesFree diff --git a/src/main/io/displayport_oled.c b/src/main/io/displayport_oled.c index 8bb20329f..f8c630957 100644 --- a/src/main/io/displayport_oled.c +++ b/src/main/io/displayport_oled.c @@ -39,13 +39,24 @@ static int oledRelease(displayPort_t *displayPort) return 0; } -static int oledClear(displayPort_t *displayPort) +static int oledClearScreen(displayPort_t *displayPort) { UNUSED(displayPort); i2c_OLED_clear_display_quick(); return 0; } +static int oledDrawScreen(displayPort_t *displayPort) +{ + UNUSED(displayPort); + return 0; +} + +static int oledScreenSize(const displayPort_t *displayPort) +{ + return displayPort->rows * displayPort->cols; +} + static int oledWrite(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s) { UNUSED(displayPort); @@ -54,6 +65,20 @@ static int oledWrite(displayPort_t *displayPort, uint8_t x, uint8_t y, const cha return 0; } +static int oledWriteChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c) +{ + UNUSED(displayPort); + i2c_OLED_set_xy(x, y); + i2c_OLED_send_char(c); + return 0; +} + +static bool oledIsTransferInProgress(const displayPort_t *displayPort) +{ + UNUSED(displayPort); + return false; +} + static int oledHeartbeat(displayPort_t *displayPort) { UNUSED(displayPort); @@ -74,8 +99,12 @@ static uint32_t oledTxBytesFree(const displayPort_t *displayPort) static const displayPortVTable_t oledVTable = { .grab = oledGrab, .release = oledRelease, - .clear = oledClear, + .clearScreen = oledClearScreen, + .drawScreen = oledDrawScreen, + .screenSize = oledScreenSize, .write = oledWrite, + .writeChar = oledWriteChar, + .isTransferInProgress = oledIsTransferInProgress, .heartbeat = oledHeartbeat, .resync = oledResync, .txBytesFree = oledTxBytesFree diff --git a/src/main/io/osd.c b/src/main/io/osd.c index c8dd3d9b6..14f7a4db2 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -31,10 +31,13 @@ #ifdef OSD +#include "build/debug.h" #include "build/version.h" +#include "common/printf.h" #include "common/utils.h" +#include "drivers/max7456_symbols.h" #include "drivers/display.h" #include "drivers/system.h" @@ -42,8 +45,8 @@ #include "cms/cms_types.h" #include "cms/cms_menu_osd.h" -#include "io/displayport_max7456.h" #include "io/flashfs.h" +#include "io/displayport_max7456.h" #include "io/osd.h" #include "fc/config.h" @@ -58,12 +61,7 @@ #include "hardware_revision.h" #endif -#include "drivers/max7456.h" -#include "drivers/max7456_symbols.h" - -#include "common/printf.h" - -#include "build/debug.h" +#define VIDEO_BUFFER_CHARS_PAL 480 // Character coordinate and attributes @@ -99,7 +97,7 @@ uint16_t refreshTimeout = 0; static uint8_t armState; -static displayPort_t *osd7456DisplayPort; +static displayPort_t *osdDisplayPort; #define AH_MAX_PITCH 200 // Specify maximum AHI pitch value displayed. Default 200 = 20.0 degrees @@ -227,7 +225,7 @@ static void osdDrawSingleElement(uint8_t item) else if (FLIGHT_MODE(HORIZON_MODE)) p = "HOR"; - max7456Write(elemPosX, elemPosY, p); + displayWrite(osdDisplayPort, elemPosX, elemPosY, p); return; } @@ -265,8 +263,9 @@ static void osdDrawSingleElement(uint8_t item) case OSD_CROSSHAIRS: elemPosX = 14 - 1; // Offset for 1 char to the left elemPosY = 6; - if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) + if (displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL) { ++elemPosY; + } buff[0] = SYM_AH_CENTER_LINE; buff[1] = SYM_AH_CENTER; buff[2] = SYM_AH_CENTER_LINE_RIGHT; @@ -281,8 +280,9 @@ static void osdDrawSingleElement(uint8_t item) int rollAngle = attitude.values.roll; int pitchAngle = attitude.values.pitch; - if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) + if (displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL) { ++elemPosY; + } if (pitchAngle > AH_MAX_PITCH) pitchAngle = AH_MAX_PITCH; @@ -301,7 +301,7 @@ static void osdDrawSingleElement(uint8_t item) y -= pitchAngle; // y += 41; // == 4 * 9 + 5 if (y >= 0 && y <= 81) { - max7456WriteChar(elemPosX + x, elemPosY + (y / 9), (SYM_AH_BAR9_0 + (y % 9))); + displayWriteChar(osdDisplayPort, elemPosX + x, elemPosY + (y / 9), (SYM_AH_BAR9_0 + (y % 9))); } } @@ -315,20 +315,21 @@ static void osdDrawSingleElement(uint8_t item) elemPosX = 14; elemPosY = 6; - if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL) + if (displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL) { ++elemPosY; + } // Draw AH sides int8_t hudwidth = AH_SIDEBAR_WIDTH_POS; int8_t hudheight = AH_SIDEBAR_HEIGHT_POS; for (int8_t y = -hudheight; y <= hudheight; y++) { - max7456WriteChar(elemPosX - hudwidth, elemPosY + y, SYM_AH_DECORATION); - max7456WriteChar(elemPosX + hudwidth, elemPosY + y, SYM_AH_DECORATION); + displayWriteChar(osdDisplayPort, elemPosX - hudwidth, elemPosY + y, SYM_AH_DECORATION); + displayWriteChar(osdDisplayPort, elemPosX + hudwidth, elemPosY + y, SYM_AH_DECORATION); } // AH level indicators - max7456WriteChar(elemPosX - hudwidth + 1, elemPosY, SYM_AH_LEFT); - max7456WriteChar(elemPosX + hudwidth - 1, elemPosY, SYM_AH_RIGHT); + displayWriteChar(osdDisplayPort, elemPosX - hudwidth + 1, elemPosY, SYM_AH_LEFT); + displayWriteChar(osdDisplayPort, elemPosX + hudwidth - 1, elemPosY, SYM_AH_RIGHT); return; } @@ -337,12 +338,12 @@ static void osdDrawSingleElement(uint8_t item) return; } - max7456Write(elemPosX, elemPosY, buff); + displayWrite(osdDisplayPort, elemPosX, elemPosY, buff); } void osdDrawElements(void) { - max7456ClearScreen(); + displayClearScreen(osdDisplayPort); #if 0 if (currentElement) @@ -352,7 +353,7 @@ void osdDrawElements(void) ; #endif #ifdef CMS - else if (sensors(SENSOR_ACC) || displayIsGrabbed(osd7456DisplayPort)) + else if (sensors(SENSOR_ACC) || displayIsGrabbed(osdDisplayPort)) #else else if (sensors(SENSOR_ACC)) #endif @@ -375,7 +376,7 @@ void osdDrawElements(void) #ifdef GPS #ifdef CMS - if (sensors(SENSOR_GPS) || displayIsGrabbed(osd7456DisplayPort)) + if (sensors(SENSOR_GPS) || displayIsGrabbed(osdDisplayPort)) #else if (sensors(SENSOR_GPS)) #endif @@ -412,7 +413,10 @@ void osdResetConfig(osd_profile_t *osdProfile) void osdInit(void) { - char x, string_buffer[30]; + osdDisplayPort = max7456DisplayPortInit(masterConfig.osdProfile.video_system); +#ifdef CMS + cmsDisplayPortRegister(osdDisplayPort); +#endif armState = ARMING_FLAG(ARMED); @@ -421,33 +425,29 @@ void osdInit(void) max7456Init(&masterConfig.vcdProfile); - max7456ClearScreen(); + displayClearScreen(osdDisplayPort); // display logo and help - x = 160; + char x = 160; for (int i = 1; i < 5; i++) { for (int j = 3; j < 27; j++) { if (x != 255) - max7456WriteChar(j, i, x++); + displayWriteChar(osdDisplayPort, j, i, x++); } } + char string_buffer[30]; sprintf(string_buffer, "BF VERSION: %s", FC_VERSION_STRING); - max7456Write(5, 6, string_buffer); + displayWrite(osdDisplayPort, 5, 6, string_buffer); #ifdef CMS - max7456Write(7, 7, CMS_STARTUP_HELP_TEXT1); - max7456Write(11, 8, CMS_STARTUP_HELP_TEXT2); - max7456Write(11, 9, CMS_STARTUP_HELP_TEXT3); + displayWrite(osdDisplayPort, 7, 7, CMS_STARTUP_HELP_TEXT1); + displayWrite(osdDisplayPort, 11, 8, CMS_STARTUP_HELP_TEXT2); + displayWrite(osdDisplayPort, 11, 9, CMS_STARTUP_HELP_TEXT3); #endif - max7456RefreshAll(); + displayResync(osdDisplayPort); refreshTimeout = 4 * REFRESH_1S; - - osd7456DisplayPort = max7456DisplayPortInit(); -#ifdef CMS - cmsDisplayPortRegister(osd7456DisplayPort); -#endif } void osdUpdateAlarms(void) @@ -539,40 +539,40 @@ static void osdShowStats(void) uint8_t top = 2; char buff[10]; - max7456ClearScreen(); - max7456Write(2, top++, " --- STATS ---"); + displayClearScreen(osdDisplayPort); + displayWrite(osdDisplayPort, 2, top++, " --- STATS ---"); if (STATE(GPS_FIX)) { - max7456Write(2, top, "MAX SPEED :"); + displayWrite(osdDisplayPort, 2, top, "MAX SPEED :"); itoa(stats.max_speed, buff, 10); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); } - max7456Write(2, top, "MIN BATTERY :"); + displayWrite(osdDisplayPort, 2, top, "MIN BATTERY :"); sprintf(buff, "%d.%1dV", stats.min_voltage / 10, stats.min_voltage % 10); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); - max7456Write(2, top, "MIN RSSI :"); + displayWrite(osdDisplayPort, 2, top, "MIN RSSI :"); itoa(stats.min_rssi, buff, 10); strcat(buff, "%"); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); if (feature(FEATURE_CURRENT_METER)) { - max7456Write(2, top, "MAX CURRENT :"); + displayWrite(osdDisplayPort, 2, top, "MAX CURRENT :"); itoa(stats.max_current, buff, 10); strcat(buff, "A"); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); - max7456Write(2, top, "USED MAH :"); + displayWrite(osdDisplayPort, 2, top, "USED MAH :"); itoa(mAhDrawn, buff, 10); strcat(buff, "\x07"); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); } - max7456Write(2, top, "MAX ALTITUDE :"); + displayWrite(osdDisplayPort, 2, top, "MAX ALTITUDE :"); int32_t alt = osdGetAltitude(stats.max_altitude); sprintf(buff, "%c%d.%01d%c", alt < 0 ? '-' : ' ', abs(alt / 100), abs((alt % 100) / 10), osdGetAltitudeSymbol()); - max7456Write(22, top++, buff); + displayWrite(osdDisplayPort, 22, top++, buff); refreshTimeout = 60 * REFRESH_1S; } @@ -580,8 +580,8 @@ static void osdShowStats(void) // called when motors armed static void osdArmMotors(void) { - max7456ClearScreen(); - max7456Write(12, 7, "ARMED"); + displayClearScreen(osdDisplayPort); + displayWrite(osdDisplayPort, 12, 7, "ARMED"); refreshTimeout = REFRESH_1S / 2; osdResetStats(); } @@ -615,14 +615,14 @@ static void osdRefresh(uint32_t currentTime) refreshTimeout = 1; refreshTimeout--; if (!refreshTimeout) - max7456ClearScreen(); + displayClearScreen(osdDisplayPort); return; } blinkState = (currentTime / 200000) % 2; #ifdef CMS - if (!displayIsGrabbed(osd7456DisplayPort)) { + if (!displayIsGrabbed(osdDisplayPort)) { osdUpdateAlarms(); osdDrawElements(); #ifdef OSD_CALLS_CMS @@ -641,23 +641,23 @@ void osdUpdate(uint32_t currentTime) static uint32_t counter = 0; #ifdef MAX7456_DMA_CHANNEL_TX // don't touch buffers if DMA transaction is in progress - if (max7456DmaInProgres()) + if (displayIsTransferInProgress(osdDisplayPort)) { return; + } #endif // MAX7456_DMA_CHANNEL_TX // redraw values in buffer - if (counter++ % 5 == 0) + if (counter++ % 5 == 0) { osdRefresh(currentTime); - else // rest of time redraw screen 10 chars per idle to don't lock the main idle - max7456DrawScreen(); + } else { // rest of time redraw screen 10 chars per idle to don't lock the main idle + displayDrawScreen(osdDisplayPort); + } #ifdef CMS // do not allow ARM if we are in menu - if (displayIsGrabbed(osd7456DisplayPort)) { + if (displayIsGrabbed(osdDisplayPort)) { DISABLE_ARMING_FLAG(OK_TO_ARM); } #endif } - - #endif // OSD diff --git a/src/test/unit/cms_unittest.cc b/src/test/unit/cms_unittest.cc index a417e8b7e..cb52176cf 100644 --- a/src/test/unit/cms_unittest.cc +++ b/src/test/unit/cms_unittest.cc @@ -87,7 +87,7 @@ static uint32_t displayPortTestTxBytesFree(const displayPort_t *displayPort) static const displayPortVTable_t testDisplayPortVTable = { .grab = displayPortTestGrab, .release = displayPortTestRelease, - .clear = displayPortTestClear, + .clearScreen = displayPortTestClear, .write = displayPortTestWrite, .heartbeat = displayPortTestHeartbeat, .resync = displayPortTestResync, @@ -204,4 +204,4 @@ void saveConfigAndNotify(void) {} void stopMotors(void) {} void stopPwmAllMotors(void) {} void systemReset(void) {} -} \ No newline at end of file +}