From 29fd90bec9d4480dc0aefb1ef3bcbb647c240c0a Mon Sep 17 00:00:00 2001 From: Anders Hoglund Date: Tue, 20 Feb 2018 15:59:02 +0100 Subject: [PATCH 1/2] Spektrum CMS over TM performance increase. --- src/main/telemetry/srxl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/telemetry/srxl.c b/src/main/telemetry/srxl.c index 7c783585c2..5970436e88 100644 --- a/src/main/telemetry/srxl.c +++ b/src/main/telemetry/srxl.c @@ -25,6 +25,8 @@ #include "build/version.h" +#include "cms/cms.h" + #include "common/crc.h" #include "common/streambuf.h" #include "common/utils.h" @@ -232,8 +234,11 @@ static bool lineSent[SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS]; int spektrumTmTextGenPutChar(uint8_t col, uint8_t row, char c) { if (row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS && col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS) { - srxlTextBuff[row][col] = c; - lineSent[row] = false; + // Only update and force a tm transmision if something has actually changed. + if (srxlTextBuff[row][col] != c) { + srxlTextBuff[row][col] = c; + lineSent[row] = false; + } } return 0; } @@ -448,6 +453,7 @@ const srxlScheduleFnPtr srxlScheduleFuncs[SRXL_TOTAL_COUNT] = { #endif }; + static void processSrxl(timeUs_t currentTimeUs) { static uint8_t srxlScheduleIndex = 0; @@ -462,6 +468,15 @@ static void processSrxl(timeUs_t currentTimeUs) } else { srxlFnPtr = srxlScheduleFuncs[srxlScheduleIndex + srxlScheduleUserIndex]; srxlScheduleUserIndex = (srxlScheduleUserIndex + 1) % SRXL_SCHEDULE_USER_COUNT; + +#if defined (USE_SPEKTRUM_CMS_TELEMETRY) && defined (USE_CMS) + // Boost CMS performance by sending nothing else but CMS Text frames when in a CMS menu. + // Sideeffect, all other reports are still not sent if user leaves CMS without a proper EXIT. + if (cmsInMenu) { + srxlFnPtr = srxlFrameText; + } +#endif + } if (srxlFnPtr) { From c8a42924f94876a456c39d980d2aa0a59388a50e Mon Sep 17 00:00:00 2001 From: Anders Hoglund Date: Tue, 20 Feb 2018 18:47:52 +0100 Subject: [PATCH 2/2] Spektrum CMS over TM performance increase. --- src/main/cms/cms.c | 2 +- src/main/cms/cms.h | 1 + src/main/io/displayport_srxl.c | 2 +- src/main/io/displayport_srxl.h | 1 + src/main/telemetry/srxl.c | 8 +++++--- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index b1208d4746..a3080cc5ec 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -71,7 +71,7 @@ #define CMS_MAX_DEVICE 4 #endif -static displayPort_t *pCurrentDisplay; +displayPort_t *pCurrentDisplay; static displayPort_t *cmsDisplayPorts[CMS_MAX_DEVICE]; static int cmsDeviceCount; diff --git a/src/main/cms/cms.h b/src/main/cms/cms.h index bf952a4cb3..6efd689912 100644 --- a/src/main/cms/cms.h +++ b/src/main/cms/cms.h @@ -8,6 +8,7 @@ extern bool cmsInMenu; // Device management bool cmsDisplayPortRegister(displayPort_t *pDisplay); +displayPort_t *pCurrentDisplay; // For main.c and scheduler void cmsInit(void); diff --git a/src/main/io/displayport_srxl.c b/src/main/io/displayport_srxl.c index acfdcda611..0299c81639 100644 --- a/src/main/io/displayport_srxl.c +++ b/src/main/io/displayport_srxl.c @@ -29,7 +29,7 @@ #include "telemetry/srxl.h" -static displayPort_t srxlDisplayPort; +displayPort_t srxlDisplayPort; static int srxlDrawScreen(displayPort_t *displayPort) { diff --git a/src/main/io/displayport_srxl.h b/src/main/io/displayport_srxl.h index 72019e0f13..638cb31a3e 100644 --- a/src/main/io/displayport_srxl.h +++ b/src/main/io/displayport_srxl.h @@ -18,3 +18,4 @@ #pragma once displayPort_t *displayPortSrxlInit(); +displayPort_t srxlDisplayPort; diff --git a/src/main/telemetry/srxl.c b/src/main/telemetry/srxl.c index 5970436e88..e230b9394d 100644 --- a/src/main/telemetry/srxl.c +++ b/src/main/telemetry/srxl.c @@ -26,6 +26,7 @@ #include "build/version.h" #include "cms/cms.h" +#include "io/displayport_srxl.h" #include "common/crc.h" #include "common/streambuf.h" @@ -234,7 +235,7 @@ static bool lineSent[SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS]; int spektrumTmTextGenPutChar(uint8_t col, uint8_t row, char c) { if (row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS && col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS) { - // Only update and force a tm transmision if something has actually changed. + // Only update and force a tm transmision if something has actually changed. if (srxlTextBuff[row][col] != c) { srxlTextBuff[row][col] = c; lineSent[row] = false; @@ -472,8 +473,9 @@ static void processSrxl(timeUs_t currentTimeUs) #if defined (USE_SPEKTRUM_CMS_TELEMETRY) && defined (USE_CMS) // Boost CMS performance by sending nothing else but CMS Text frames when in a CMS menu. // Sideeffect, all other reports are still not sent if user leaves CMS without a proper EXIT. - if (cmsInMenu) { - srxlFnPtr = srxlFrameText; + if (cmsInMenu && + (pCurrentDisplay == &srxlDisplayPort)) { + srxlFnPtr = srxlFrameText; } #endif