diff --git a/src/main/fc/init.c b/src/main/fc/init.c index 6bc923ec83..eee71bd7a6 100644 --- a/src/main/fc/init.c +++ b/src/main/fc/init.c @@ -101,11 +101,9 @@ #include "io/asyncfatfs/asyncfatfs.h" #include "io/beeper.h" #include "io/dashboard.h" -#include "io/displayport_crsf.h" #include "io/displayport_frsky_osd.h" #include "io/displayport_max7456.h" #include "io/displayport_msp.h" -#include "io/displayport_srxl.h" #include "io/flashfs.h" #include "io/gimbal.h" #include "io/gps.h" @@ -1011,15 +1009,6 @@ void init(void) } #endif -#if defined(USE_CMS) && defined(USE_SPEKTRUM_CMS_TELEMETRY) && defined(USE_TELEMETRY_SRXL) - // Register the srxl Textgen telemetry sensor as a displayport device - cmsDisplayPortRegister(displayPortSrxlInit()); -#endif - -#if defined(USE_CMS) && defined(USE_CRSF_CMS_TELEMETRY) - cmsDisplayPortRegister(displayPortCrsfInit()); -#endif - setArmingDisabled(ARMING_DISABLED_BOOT_GRACE_TIME); #ifdef USE_MOTOR diff --git a/src/main/io/displayport_crsf.c b/src/main/io/displayport_crsf.c index f7641cdcd3..9d7435968c 100644 --- a/src/main/io/displayport_crsf.c +++ b/src/main/io/displayport_crsf.c @@ -31,14 +31,10 @@ #include "common/printf.h" #include "common/time.h" -#include "config/feature.h" - #include "drivers/display.h" #include "drivers/time.h" -#include "io/displayport_crsf.h" - -#include "rx/rx.h" +#include "displayport_crsf.h" #define CRSF_DISPLAY_PORT_OPEN_DELAY_MS 400 #define CRSF_DISPLAY_PORT_CLEAR_DELAY_MS 45 @@ -203,18 +199,16 @@ bool crsfDisplayPortIsReady(void) return (bool)(delayExpired && cmsReady); } -displayPort_t *displayPortCrsfInit() +static displayPort_t *displayPortCrsfInit() { - if (featureIsEnabled(FEATURE_TELEMETRY) - && featureIsEnabled(FEATURE_RX_SERIAL) - && (rxConfig()->serialrx_provider == SERIALRX_CRSF)) { + crsfDisplayPortSetDimensions(CRSF_DISPLAY_PORT_ROWS_MAX, CRSF_DISPLAY_PORT_COLS_MAX); + displayInit(&crsfDisplayPort, &crsfDisplayPortVTable, DISPLAYPORT_DEVICE_TYPE_CRSF); - crsfDisplayPortSetDimensions(CRSF_DISPLAY_PORT_ROWS_MAX, CRSF_DISPLAY_PORT_COLS_MAX); - displayInit(&crsfDisplayPort, &crsfDisplayPortVTable, DISPLAYPORT_DEVICE_TYPE_CRSF); - return &crsfDisplayPort; - } else { - return NULL; - } + return &crsfDisplayPort; } +void crsfDisplayportRegister(void) +{ + cmsDisplayPortRegister(displayPortCrsfInit()); +} #endif diff --git a/src/main/io/displayport_crsf.h b/src/main/io/displayport_crsf.h index 78cdab50e9..e53e55d3da 100644 --- a/src/main/io/displayport_crsf.h +++ b/src/main/io/displayport_crsf.h @@ -34,7 +34,7 @@ typedef struct crsfDisplayPortScreen_s { bool reset; } crsfDisplayPortScreen_t; -displayPort_t *displayPortCrsfInit(void); +void crsfDisplayportRegister(void); crsfDisplayPortScreen_t *crsfDisplayPortScreen(void); void crsfDisplayPortMenuOpen(void); void crsfDisplayPortMenuExit(void); diff --git a/src/main/io/displayport_hott.c b/src/main/io/displayport_hott.c index 90b568962f..521b32549c 100644 --- a/src/main/io/displayport_hott.c +++ b/src/main/io/displayport_hott.c @@ -128,7 +128,7 @@ static const displayPortVTable_t hottVTable = { .layerCopy = NULL, }; -displayPort_t *displayPortHottInit() +static displayPort_t *displayPortHottInit() { hottDisplayPort.device = NULL; displayInit(&hottDisplayPort, &hottVTable, DISPLAYPORT_DEVICE_TYPE_HOTT); diff --git a/src/main/io/displayport_hott.h b/src/main/io/displayport_hott.h index f1f58d27ee..6814bc32e3 100644 --- a/src/main/io/displayport_hott.h +++ b/src/main/io/displayport_hott.h @@ -21,10 +21,6 @@ #pragma once #include "drivers/display.h" -displayPort_t *displayPortHottInit(); - -extern displayPort_t hottDisplayPort; - void hottDisplayportRegister(); void hottCmsOpen(); void hottSetCmsKey(uint8_t hottKey, bool esc); diff --git a/src/main/io/displayport_srxl.c b/src/main/io/displayport_srxl.c index 7af3d61e6b..fe04b2b1c8 100644 --- a/src/main/io/displayport_srxl.c +++ b/src/main/io/displayport_srxl.c @@ -23,20 +23,19 @@ #include #include "platform.h" -#if defined (USE_SPEKTRUM_CMS_TELEMETRY) && defined (USE_CMS) && defined(USE_TELEMETRY_SRXL) + +#if defined(USE_SPEKTRUM_CMS_TELEMETRY) #include "cms/cms.h" #include "common/utils.h" -#include "config/feature.h" - #include "drivers/display.h" -#include "rx/rx.h" - #include "telemetry/srxl.h" +#include "displayport_srxl.h" + displayPort_t srxlDisplayPort; static int srxlDrawScreen(displayPort_t *displayPort) @@ -143,20 +142,18 @@ static const displayPortVTable_t srxlVTable = { .layerCopy = NULL, }; -displayPort_t *displayPortSrxlInit() +static displayPort_t *displayPortSrxlInit() { - if (featureIsEnabled(FEATURE_TELEMETRY) - && featureIsEnabled(FEATURE_RX_SERIAL) - && ((rxConfig()->serialrx_provider == SERIALRX_SRXL) || (rxConfig()->serialrx_provider == SERIALRX_SRXL2))) { + srxlDisplayPort.device = NULL; + displayInit(&srxlDisplayPort, &srxlVTable, DISPLAYPORT_DEVICE_TYPE_SRXL); + srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; + srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; - srxlDisplayPort.device = NULL; - displayInit(&srxlDisplayPort, &srxlVTable, DISPLAYPORT_DEVICE_TYPE_SRXL); - srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; - srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; - return &srxlDisplayPort; - } else { - return NULL; - } + return &srxlDisplayPort; } +void srxlDisplayportRegister(void) +{ + cmsDisplayPortRegister(displayPortSrxlInit()); +} #endif diff --git a/src/main/io/displayport_srxl.h b/src/main/io/displayport_srxl.h index 8702cc1b2f..01c976c25e 100644 --- a/src/main/io/displayport_srxl.h +++ b/src/main/io/displayport_srxl.h @@ -20,6 +20,6 @@ #pragma once -displayPort_t *displayPortSrxlInit(); - extern displayPort_t srxlDisplayPort; + +void srxlDisplayportRegister(void); diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index 99ca620ae2..65a4f9074a 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -90,7 +90,6 @@ #endif #if !defined(USE_TELEMETRY) -#undef USE_CRSF_CMS_TELEMETRY #undef USE_TELEMETRY_CRSF #undef USE_TELEMETRY_GHST #undef USE_TELEMETRY_FRSKY_HUB @@ -136,10 +135,13 @@ #undef USE_SPEKTRUM_RSSI_PERCENT_CONVERSION #undef USE_SPEKTRUM_VTX_CONTROL #undef USE_SPEKTRUM_VTX_TELEMETRY -#undef USE_SPEKTRUM_CMS_TELEMETRY #undef USE_TELEMETRY_SRXL #endif +#if !defined(USE_CMS) || !defined(USE_TELEMETRY_SRXL) +#undef USE_SPEKTRUM_CMS_TELEMETRY +#endif + #if defined(USE_SERIALRX_SBUS) || defined(USE_SERIALRX_FPORT) #define USE_SBUS_CHANNELS #endif diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index 0fe3f7ebe9..3f722ea477 100644 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -30,21 +30,19 @@ #include "build/build_config.h" #include "build/version.h" -#include "config/feature.h" -#include "pg/pg.h" -#include "pg/pg_ids.h" +#include "cms/cms.h" +#include "config/feature.h" + +#include "config/config.h" #include "common/crc.h" #include "common/maths.h" #include "common/printf.h" #include "common/streambuf.h" #include "common/utils.h" -#include "cms/cms.h" - #include "drivers/nvic.h" -#include "config/config.h" #include "fc/rc_modes.h" #include "fc/runtime_config.h" @@ -55,6 +53,9 @@ #include "io/gps.h" #include "io/serial.h" +#include "pg/pg.h" +#include "pg/pg_ids.h" + #include "rx/crsf.h" #include "rx/crsf_protocol.h" @@ -64,7 +65,7 @@ #include "telemetry/telemetry.h" #include "telemetry/msp_shared.h" -#include "telemetry/crsf.h" +#include "crsf.h" #define CRSF_CYCLETIME_US 100000 // 100ms, 10 Hz @@ -525,7 +526,11 @@ void initCrsfTelemetry(void) } #endif crsfScheduleCount = (uint8_t)index; - } + +#if defined(USE_CRSF_CMS_TELEMETRY) + crsfDisplayportRegister(); +#endif +} bool checkCrsfTelemetryState(void) { diff --git a/src/main/telemetry/srxl.c b/src/main/telemetry/srxl.c index 1702fdc5d7..3c49853475 100644 --- a/src/main/telemetry/srxl.c +++ b/src/main/telemetry/srxl.c @@ -29,46 +29,44 @@ #include "build/version.h" #include "cms/cms.h" -#include "io/displayport_srxl.h" #include "common/crc.h" #include "common/streambuf.h" #include "common/utils.h" +#include "config/config.h" #include "config/feature.h" -#include "io/gps.h" -#include "io/serial.h" +#include "drivers/dshot.h" +#include "drivers/vtx_common.h" -#include "config/config.h" #include "fc/rc_controls.h" #include "fc/runtime_config.h" #include "flight/imu.h" #include "flight/mixer.h" +#include "io/displayport_srxl.h" #include "io/gps.h" +#include "io/serial.h" +#include "io/vtx_smartaudio.h" +#include "io/vtx_tramp.h" #include "pg/rx.h" #include "pg/motor.h" #include "rx/rx.h" #include "rx/spektrum.h" -#include "rx/srxl2.h" #include "io/spektrum_vtx_control.h" +#include "rx/srxl2.h" -#include "sensors/battery.h" #include "sensors/adcinternal.h" +#include "sensors/battery.h" #include "sensors/esc_sensor.h" #include "telemetry/telemetry.h" -#include "telemetry/srxl.h" -#include "drivers/vtx_common.h" -#include "drivers/dshot.h" - -#include "io/vtx_tramp.h" -#include "io/vtx_smartaudio.h" +#include "srxl.h" #define SRXL_ADDRESS_FIRST 0xA5 #define SRXL_ADDRESS_SECOND 0x80 @@ -774,18 +772,24 @@ void initSrxlTelemetry(void) { // check if there is a serial port open for SRXL telemetry (ie opened by the SRXL RX) // and feature is enabled, if so, set SRXL telemetry enabled - if (srxlRxIsActive()) { - srxlTelemetryEnabled = true; - srxl2 = false; + if (srxlRxIsActive()) { + srxlTelemetryEnabled = true; + srxl2 = false; #if defined(USE_SERIALRX_SRXL2) - } else if (srxl2RxIsActive()) { - srxlTelemetryEnabled = true; - srxl2 = true; + } else if (srxl2RxIsActive()) { + srxlTelemetryEnabled = true; + srxl2 = true; +#endif + } else { + srxlTelemetryEnabled = false; + srxl2 = false; + } + +#if defined(USE_SPEKTRUM_CMS_TELEMETRY) + if (srxlTelemetryEnabled) { + srxlDisplayportRegister(); + } #endif - } else { - srxlTelemetryEnabled = false; - srxl2 = false; - } } bool checkSrxlTelemetryState(void)