From 285a0f81801fc24c6ba47e339b1c46f70a257ca3 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 1 Oct 2022 11:22:04 +0200 Subject: [PATCH] Rename HDzero to MSP displayport --- docs/Cli.md | 2 +- src/main/CMakeLists.txt | 4 +- src/main/fc/fc_init.c | 6 +- src/main/fc/fc_tasks.c | 8 +-- ...ort_hdzero_osd.c => displayport_msp_osd.c} | 62 +++++++++---------- ...ort_hdzero_osd.h => displayport_msp_osd.h} | 4 +- src/main/io/serial.h | 2 +- src/main/target/common.h | 2 +- 8 files changed, 45 insertions(+), 45 deletions(-) rename src/main/io/{displayport_hdzero_osd.c => displayport_msp_osd.c} (88%) rename src/main/io/{displayport_hdzero_osd.h => displayport_msp_osd.h} (90%) diff --git a/docs/Cli.md b/docs/Cli.md index 900d60952e..05180d3cd9 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -156,7 +156,7 @@ A shorter form is also supported to enable and disable a single function using ` | SERVO_SERIAL | 22 | 4194304 | | TELEMETRY_SMARTPORT_MASTER | 23 | 8388608 | | IMU2 | 24 | 16777216 | -| HDZERO | 25 | 33554432 | +| MSP_DISPLAYPORT | 25 | 33554432 | Thus, to enable MSP and LTM on a port, one would use the function **value** of 17 (1 << 0)+(1<<4), aka 1+16, aka 17. diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 297f0d4f7f..bb2491cc46 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -482,8 +482,8 @@ main_sources(COMMON_SRC io/displayport_msp.h io/displayport_oled.c io/displayport_oled.h - io/displayport_hdzero_osd.c - io/displayport_hdzero_osd.h + io/displayport_msp_osd.c + io/displayport_msp_osd.h io/displayport_srxl.c io/displayport_srxl.h io/displayport_hott.c diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 6b462b12f8..3d4437a16c 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -106,7 +106,7 @@ #include "io/displayport_frsky_osd.h" #include "io/displayport_msp.h" #include "io/displayport_max7456.h" -#include "io/displayport_hdzero_osd.h" +#include "io/displayport_msp_osd.h" #include "io/displayport_srxl.h" #include "io/flashfs.h" #include "io/gps.h" @@ -547,9 +547,9 @@ void init(void) osdDisplayPort = frskyOSDDisplayPortInit(osdConfig()->video_system); } #endif -#ifdef USE_HDZERO_OSD +#ifdef USE_MSP_OSD if (!osdDisplayPort) { - osdDisplayPort = hdzeroOsdDisplayPortInit(); + osdDisplayPort = mspOsdDisplayPortInit(); } #endif #if defined(USE_MAX7456) diff --git a/src/main/fc/fc_tasks.c b/src/main/fc/fc_tasks.c index 011f98e397..97e0ae53c3 100755 --- a/src/main/fc/fc_tasks.c +++ b/src/main/fc/fc_tasks.c @@ -66,7 +66,7 @@ #include "io/smartport_master.h" #include "io/vtx.h" #include "io/osd_dji_hd.h" -#include "io/displayport_hdzero_osd.h" +#include "io/displayport_msp_osd.h" #include "io/servo_sbus.h" #include "msp/msp_serial.h" @@ -107,9 +107,9 @@ void taskHandleSerial(timeUs_t currentTimeUs) djiOsdSerialProcess(); #endif -#ifdef USE_HDZERO_OSD - // Capture HDZero messages to determine if VTX is connected - hdzeroOsdSerialProcess(mspFcProcessCommand); +#ifdef USE_MSP_OSD + // Capture MSP Displayport messages to determine if VTX is connected + mspOsdSerialProcess(mspFcProcessCommand); #endif } diff --git a/src/main/io/displayport_hdzero_osd.c b/src/main/io/displayport_msp_osd.c similarity index 88% rename from src/main/io/displayport_hdzero_osd.c rename to src/main/io/displayport_msp_osd.c index ee2462e5fc..55583e9c69 100644 --- a/src/main/io/displayport_hdzero_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -30,9 +30,9 @@ FILE_COMPILE_FOR_SPEED -//#define HDZERO_STATS +//#define MSP_DISPLAYPORT_STATS -#if defined(USE_OSD) && defined(USE_HDZERO_OSD) +#if defined(USE_OSD) && defined(USE_MSP_OSD) #include "common/utils.h" #include "common/printf.h" @@ -46,7 +46,7 @@ FILE_COMPILE_FOR_SPEED #include "msp/msp_protocol.h" #include "msp/msp_serial.h" -#include "displayport_hdzero_osd.h" +#include "displayport_msp_osd.h" #define FONT_VERSION 3 @@ -59,8 +59,8 @@ FILE_COMPILE_FOR_SPEED #define VTX_TIMEOUT 1000 // 1 second timer static mspProcessCommandFnPtr mspProcessCommand; -static mspPort_t hdZeroMspPort; -static displayPort_t hdZeroOsdDisplayPort; +static mspPort_t mspPort; +static displayPort_t mspOsdDisplayPort; static bool vtxSeen, vtxActive, vtxReset; static timeMs_t vtxHeartbeat; @@ -75,7 +75,7 @@ static bool screenCleared; extern uint8_t cliMode; -#ifdef HDZERO_STATS +#ifdef MSP_DISPLAYPORT_STATS static uint32_t dataSent; static uint8_t resetCount; #endif @@ -87,10 +87,10 @@ static int output(displayPort_t *displayPort, uint8_t cmd, uint8_t *subcmd, int int sent = 0; if (!cliMode && vtxActive) { - sent = mspSerialPushPort(cmd, subcmd, len, &hdZeroMspPort, MSP_V1); + sent = mspSerialPushPort(cmd, subcmd, len, &mspPort, MSP_V1); } -#ifdef HDZERO_STATS +#ifdef MSP_DISPLAYPORT_STATS dataSent += sent; #endif @@ -111,7 +111,7 @@ static int setHdMode(displayPort_t *displayPort) return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); } -static void hdZeroInit(void) +static void init(void) { memset(screen, SYM_BLANK, sizeof(screen)); BITARRAY_CLR_ALL(fontPage); @@ -122,7 +122,7 @@ static int clearScreen(displayPort_t *displayPort) { uint8_t subcmd[] = { MSP_CLEAR_SCREEN }; - hdZeroInit(); + init(); setHdMode(displayPort); screenCleared = true; return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); @@ -183,7 +183,7 @@ static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, con return 0; } -#ifdef HDZERO_STATS +#ifdef MSP_DISPLAYPORT_STATS static void printStats(displayPort_t *displayPort, uint32_t updates) { static timeMs_t lastTime; @@ -195,7 +195,7 @@ static void printStats(displayPort_t *displayPort, uint32_t updates) maxUpdates = updates; // updates sent per displayWrite } - uint32_t bufferUsed = TX_BUFFER_SIZE - serialTxBytesFree(hdZeroMspPort.port); + uint32_t bufferUsed = TX_BUFFER_SIZE - serialTxBytesFree(mspPort.port); if (bufferUsed > maxBufferUsed) { maxBufferUsed = bufferUsed; // serial buffer used after displayWrite } @@ -212,7 +212,7 @@ static void printStats(displayPort_t *displayPort, uint32_t updates) tfp_sprintf(lineBuffer, "R:%2d %4ld %5ld(%5ld) U:%2ld(%2ld) B:%3ld(%4ld,%4ld)", resetCount, (millis()-vtxHeartbeat), - dataSent, maxDataSent, updates, maxUpdates, bufferUsed, maxBufferUsed, hdZeroMspPort.port->txBufferSize); + dataSent, maxDataSent, updates, maxUpdates, bufferUsed, maxBufferUsed, mspPort.port->txBufferSize); writeString(displayPort, 0, 17, lineBuffer, 0); } #endif @@ -264,13 +264,13 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz output(displayPort, MSP_DISPLAYPORT, subcmd, 1); } -#ifdef HDZERO_STATS +#ifdef MSP_DISPLAYPORT_STATS printStats(displayPort, updateCount); #endif checkVtxPresent(); if (vtxReset) { -#ifdef HDZERO_STATS +#ifdef MSP_DISPLAYPORT_STATS resetCount++; #endif clearScreen(displayPort); @@ -344,7 +344,7 @@ static int release(displayPort_t *displayPort) return 0; } -static const displayPortVTable_t hdzeroOsdVTable = { +static const displayPortVTable_t mspOsdVTable = { .grab = grab, .release = release, .clearScreen = clearScreen, @@ -362,14 +362,14 @@ static const displayPortVTable_t hdzeroOsdVTable = { .isReady = isReady, }; -bool hdzeroOsdSerialInit(void) +bool mspOsdSerialInit(void) { static volatile uint8_t txBuffer[TX_BUFFER_SIZE]; - memset(&hdZeroMspPort, 0, sizeof(mspPort_t)); + memset(&mspPort, 0, sizeof(mspPort_t)); - serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_HDZERO_OSD); + serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_MSP_OSD); if (portConfig) { - serialPort_t *port = openSerialPort(portConfig->identifier, FUNCTION_HDZERO_OSD, NULL, NULL, + serialPort_t *port = openSerialPort(portConfig->identifier, FUNCTION_MSP_OSD, NULL, NULL, baudRates[portConfig->peripheral_baudrateIndex], MODE_RXTX, SERIAL_NOT_INVERTED); if (port) { @@ -379,7 +379,7 @@ bool hdzeroOsdSerialInit(void) port->txBufferTail = 0; port->txBufferHead = 0; - resetMspPort(&hdZeroMspPort, port); + resetMspPort(&mspPort, port); return true; } @@ -388,12 +388,12 @@ bool hdzeroOsdSerialInit(void) return false; } -displayPort_t* hdzeroOsdDisplayPortInit(void) +displayPort_t* mspOsdDisplayPortInit(void) { - if (hdzeroOsdSerialInit()) { - hdZeroInit(); - displayInit(&hdZeroOsdDisplayPort, &hdzeroOsdVTable); - return &hdZeroOsdDisplayPort; + if (mspOsdSerialInit()) { + init(); + displayInit(&osdDisplayPort, &mspOsdVTable); + return &osdDisplayPort; } return NULL; } @@ -403,7 +403,7 @@ displayPort_t* hdzeroOsdDisplayPortInit(void) * VTX sends an MSP command every 125ms or so. * VTX will have be marked as not ready if no commands received within VTX_TIMEOUT. */ -static mspResult_e hdZeroProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, mspPostProcessFnPtr *mspPostProcessFn) +static mspResult_e processMspCommand(mspPacket_t *cmd, mspPacket_t *reply, mspPostProcessFnPtr *mspPostProcessFn) { if (vtxSeen && !vtxActive) { vtxReset = true; @@ -416,12 +416,12 @@ static mspResult_e hdZeroProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, return mspProcessCommand(cmd, reply, mspPostProcessFn); } -void hdzeroOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn) +void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn) { - if (hdZeroMspPort.port) { + if (mspPort.port) { mspProcessCommand = mspProcessCommandFn; - mspSerialProcessOnePort(&hdZeroMspPort, MSP_SKIP_NON_MSP_DATA, hdZeroProcessMspCommand); + mspSerialProcessOnePort(&mspPort, MSP_SKIP_NON_MSP_DATA, processMspCommand); } } -#endif // USE_HDZERO_OSD +#endif // USE_MSP_OSD diff --git a/src/main/io/displayport_hdzero_osd.h b/src/main/io/displayport_msp_osd.h similarity index 90% rename from src/main/io/displayport_hdzero_osd.h rename to src/main/io/displayport_msp_osd.h index 54d9f8480b..8953b3c514 100644 --- a/src/main/io/displayport_hdzero_osd.h +++ b/src/main/io/displayport_msp_osd.h @@ -29,5 +29,5 @@ typedef struct displayPort_s displayPort_t; -displayPort_t *hdzeroOsdDisplayPortInit(void); -void hdzeroOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn); +displayPort_t *mspOsdDisplayPortInit(void); +void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn); diff --git a/src/main/io/serial.h b/src/main/io/serial.h index 3b2b5d68a6..dcb8b95bbc 100644 --- a/src/main/io/serial.h +++ b/src/main/io/serial.h @@ -56,7 +56,7 @@ typedef enum { FUNCTION_SERVO_SERIAL = (1 << 22), // 4194304 FUNCTION_TELEMETRY_SMARTPORT_MASTER = (1 << 23), // 8388608 FUNCTION_IMU2 = (1 << 24), // 16777216 - FUNCTION_HDZERO_OSD = (1 << 25), // 33554432 + FUNCTION_MSP_OSD = (1 << 25), // 33554432 } serialPortFunction_e; typedef enum { diff --git a/src/main/target/common.h b/src/main/target/common.h index d73f4a4ea2..332c591500 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -114,7 +114,7 @@ #define USE_OSD #define USE_FRSKYOSD #define USE_DJI_HD_OSD -#define USE_HDZERO_OSD +#define USE_MSP_OSD #define USE_SMARTPORT_MASTER #define NAV_NON_VOLATILE_WAYPOINT_CLI