Skip to content

Commit

Permalink
Fix AXIS definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Jan 2, 2023
1 parent 1a10d6c commit cc3bdfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion radio/src/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,17 @@ 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;
return 0;
}
return calibratedAnalogs[i + adcGetInputOffset(ADC_INPUT_AXIS)];
}
#endif

#if defined(IMU)
else if (i == MIXSRC_TILT_X) {
Expand Down

0 comments on commit cc3bdfa

Please sign in to comment.