diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index e188413603..d53228afb2 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -92,7 +92,7 @@ int menuChainBack; bool cmsDisplayPortRegister(displayPort_t *pDisplay) { - if (cmsDeviceCount >= CMS_MAX_DEVICE) { + if (!pDisplay || cmsDeviceCount >= CMS_MAX_DEVICE) { return false; } diff --git a/src/main/io/displayport_crsf.c b/src/main/io/displayport_crsf.c index 376752ad83..4ac97c713a 100644 --- a/src/main/io/displayport_crsf.c +++ b/src/main/io/displayport_crsf.c @@ -26,13 +26,20 @@ #if defined(USE_CRSF_CMS_TELEMETRY) #include "cms/cms.h" + #include "common/maths.h" #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" + #define CRSF_DISPLAY_PORT_OPEN_DELAY_MS 400 #define CRSF_DISPLAY_PORT_CLEAR_DELAY_MS 45 @@ -198,9 +205,16 @@ bool crsfDisplayPortIsReady(void) displayPort_t *displayPortCrsfInit() { - crsfDisplayPortSetDimensions(CRSF_DISPLAY_PORT_ROWS_MAX, CRSF_DISPLAY_PORT_COLS_MAX); - displayInit(&crsfDisplayPort, &crsfDisplayPortVTable); - return &crsfDisplayPort; + 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); + return &crsfDisplayPort; + } else { + return NULL; + } } #endif diff --git a/src/main/io/displayport_srxl.c b/src/main/io/displayport_srxl.c index da4390d8c7..9422cd9f4d 100644 --- a/src/main/io/displayport_srxl.c +++ b/src/main/io/displayport_srxl.c @@ -25,10 +25,15 @@ #include "platform.h" #if defined (USE_SPEKTRUM_CMS_TELEMETRY) && defined (USE_CMS) && defined(USE_TELEMETRY_SRXL) +#include "cms/cms.h" + #include "common/utils.h" +#include "config/feature.h" + #include "drivers/display.h" -#include "cms/cms.h" + +#include "rx/rx.h" #include "telemetry/srxl.h" @@ -140,11 +145,18 @@ static const displayPortVTable_t srxlVTable = { displayPort_t *displayPortSrxlInit() { - srxlDisplayPort.device = NULL; - displayInit(&srxlDisplayPort, &srxlVTable); - srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; - srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; - return &srxlDisplayPort; + if (featureIsEnabled(FEATURE_TELEMETRY) + && featureIsEnabled(FEATURE_RX_SERIAL) + && ((rxConfig()->serialrx_provider == SERIALRX_SRXL) || (rxConfig()->serialrx_provider == SERIALRX_SRXL2))) { + + srxlDisplayPort.device = NULL; + displayInit(&srxlDisplayPort, &srxlVTable); + srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; + srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; + return &srxlDisplayPort; + } else { + return NULL; + } } #endif