From 609528d7452b9888d581fa4be8484c8f21a937c6 Mon Sep 17 00:00:00 2001 From: raphaelcoeffic Date: Mon, 2 Jan 2023 12:26:04 +0100 Subject: [PATCH] Fix AXIS definitions --- radio/src/dataconstants.h | 2 ++ radio/src/gui/gui_common.cpp | 4 ++++ radio/src/mixer.cpp | 5 ++++- radio/src/strhelpers.cpp | 9 ++++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 97efbf1368d..499ab6db7b4 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -486,8 +486,10 @@ enum MixSources { MIXSRC_FIRST_POT SKIP, MIXSRC_LAST_POT SKIP = MIXSRC_FIRST_POT + MAX_POTS - 1, +#if MAX_AXIS > 0 MIXSRC_FIRST_AXIS SKIP, MIXSRC_LAST_AXIS SKIP = MIXSRC_FIRST_AXIS + MAX_AXIS - 1, +#endif #if defined(IMU) MIXSRC_TILT_X, diff --git a/radio/src/gui/gui_common.cpp b/radio/src/gui/gui_common.cpp index 3eb28f8593b..48836fc42aa 100644 --- a/radio/src/gui/gui_common.cpp +++ b/radio/src/gui/gui_common.cpp @@ -186,8 +186,10 @@ bool isSourceAvailable(int source) return IS_POT_SLIDER_AVAILABLE(source - MIXSRC_FIRST_POT); } +#if MAX_AXIS > 0 if (source >= MIXSRC_FIRST_AXIS && source <= MIXSRC_LAST_AXIS) return source - MIXSRC_FIRST_AXIS < adcGetMaxInputs(ADC_INPUT_AXIS); +#endif #if defined(PCBHORUS) && !defined(SPACEMOUSE) if (source >= MIXSRC_FIRST_SPACEMOUSE && source <= MIXSRC_LAST_SPACEMOUSE) @@ -260,8 +262,10 @@ bool isSourceAvailableInInputs(int source) if (source >= MIXSRC_FIRST_POT && source <= MIXSRC_LAST_POT) return IS_POT_SLIDER_AVAILABLE(source - MIXSRC_FIRST_POT); +#if MAX_AXIS > 0 if (source >= MIXSRC_FIRST_AXIS && source <= MIXSRC_LAST_AXIS) return source - MIXSRC_FIRST_AXIS < adcGetMaxInputs(ADC_INPUT_AXIS); +#endif if (source >= MIXSRC_FIRST_STICK && source <= MIXSRC_MAX) return true; diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index efa50257413..4f2d002b1b9 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -337,7 +337,9 @@ getvalue_t getValue(mixsrc_t i, bool* valid) } return calibratedAnalogs[i + adcGetInputOffset(ADC_INPUT_POT)]; } - else if (i <= MIXSRC_FIRST_AXIS) { + +#if MAX_AXIS > 0 + else if (i <= MIXSRC_LAST_AXIS) { i -= MIXSRC_FIRST_AXIS; if (i >= adcGetMaxInputs(ADC_INPUT_AXIS)) { if (valid != nullptr) *valid = false; @@ -345,6 +347,7 @@ getvalue_t getValue(mixsrc_t i, bool* valid) } return calibratedAnalogs[i + adcGetInputOffset(ADC_INPUT_AXIS)]; } +#endif #if defined(IMU) else if (i == MIXSRC_TILT_X) { diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index 4669b56c482..4889652087c 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -625,9 +625,12 @@ char *getSourceString(char (&dest)[L], mixsrc_t idx) pos[dest_len - 1] = '\0'; } -#if defined(PCBHORUS) - else if (idx <= MIXSRC_MOUSE2) { - // TODO +#if MAX_AXIS > 0 + else if (idx <= MIXSRC_LAST_AXIS) { + idx -= MIXSRC_LAST_AXIS; + auto name = adcGetInputName(ADC_INPUT_AXIS, idx); + strncpy(dest, name, dest_len - 1); + dest[dest_len - 1] = '\0'; } #endif #if defined(IMU)