Fixes #1424
This commit is contained in:
+23
-10
@@ -551,17 +551,17 @@ int getTrimValue(uint8_t phase, uint8_t idx)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
|
||||||
{
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
|
bool setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
||||||
|
{
|
||||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||||
trim_t & v = flightModeAddress(phase)->trim[idx];
|
trim_t & v = flightModeAddress(phase)->trim[idx];
|
||||||
if (v.mode == TRIM_MODE_NONE)
|
if (v.mode == TRIM_MODE_NONE)
|
||||||
return;
|
return false;
|
||||||
unsigned int p = v.mode >> 1;
|
unsigned int p = v.mode >> 1;
|
||||||
if (p == phase || phase == 0) {
|
if (p == phase || phase == 0) {
|
||||||
v.value = trim;
|
v.value = trim;
|
||||||
break;;
|
break;
|
||||||
}
|
}
|
||||||
else if (v.mode % 2 == 0) {
|
else if (v.mode % 2 == 0) {
|
||||||
phase = p;
|
phase = p;
|
||||||
@@ -571,7 +571,13 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(PCBSTD)
|
eeDirty(EE_MODEL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
||||||
|
{
|
||||||
|
#if defined(PCBSTD)
|
||||||
FlightModeData *p = flightModeAddress(phase);
|
FlightModeData *p = flightModeAddress(phase);
|
||||||
p->trim[idx] = (int8_t)(trim >> 2);
|
p->trim[idx] = (int8_t)(trim >> 2);
|
||||||
idx <<= 1;
|
idx <<= 1;
|
||||||
@@ -582,6 +588,7 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
|||||||
#endif
|
#endif
|
||||||
eeDirty(EE_MODEL);
|
eeDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(PCBTARANIS)
|
#if !defined(PCBTARANIS)
|
||||||
uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx)
|
uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx)
|
||||||
@@ -1320,12 +1327,18 @@ uint8_t checkTrim(uint8_t event)
|
|||||||
if (TRIM_REUSED(idx)) {
|
if (TRIM_REUSED(idx)) {
|
||||||
SET_GVAR_VALUE(trimGvar[idx], phase, after);
|
SET_GVAR_VALUE(trimGvar[idx], phase, after);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
setTrimValue(phase, idx, after);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
setTrimValue(phase, idx, after);
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
if (!setTrimValue(phase, idx, after)) {
|
||||||
|
// we don't play a beep, so we exit now the function
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
setTrimValue(phase, idx, after);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(AUDIO)
|
#if defined(AUDIO)
|
||||||
// toneFreq higher/lower according to trim position
|
// toneFreq higher/lower according to trim position
|
||||||
|
|||||||
@@ -753,7 +753,12 @@ int8_t getMovedSwitch();
|
|||||||
|
|
||||||
trim_t getRawTrimValue(uint8_t phase, uint8_t idx);
|
trim_t getRawTrimValue(uint8_t phase, uint8_t idx);
|
||||||
int getTrimValue(uint8_t phase, uint8_t idx);
|
int getTrimValue(uint8_t phase, uint8_t idx);
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
bool setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
||||||
|
#else
|
||||||
void setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
void setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODERS)
|
#if defined(ROTARY_ENCODERS)
|
||||||
int16_t getRotaryEncoder(uint8_t idx);
|
int16_t getRotaryEncoder(uint8_t idx);
|
||||||
|
|||||||
Reference in New Issue
Block a user