When an "Adjust GV" special function is reusing trim buttons to increase/decrease GVs, then the trim limits are applied instead of GV limits. This patch applies the GV limits.
This commit is contained in:
committed by
Bertrand Songis
parent
2ad0db2d80
commit
d59a853f0c
+47
-22
@@ -1368,6 +1368,9 @@ uint8_t checkTrim(event_t event)
|
|||||||
int8_t trimInc = g_model.trimInc + 1;
|
int8_t trimInc = g_model.trimInc + 1;
|
||||||
int8_t v = (trimInc==-1) ? min(32, abs(before)/4+1) : (1 << trimInc); // TODO flash saving if (trimInc < 0)
|
int8_t v = (trimInc==-1) ? min(32, abs(before)/4+1) : (1 << trimInc); // TODO flash saving if (trimInc < 0)
|
||||||
if (thro) v = 4; // if throttle trim and trim trottle then step=4
|
if (thro) v = 4; // if throttle trim and trim trottle then step=4
|
||||||
|
#if defined(GVARS)
|
||||||
|
if (TRIM_REUSED(idx)) v = 1;
|
||||||
|
#endif
|
||||||
int16_t after = (k&1) ? before + v : before - v; // positive = k&1
|
int16_t after = (k&1) ? before + v : before - v; // positive = k&1
|
||||||
bool beepTrim = false;
|
bool beepTrim = false;
|
||||||
|
|
||||||
@@ -1377,35 +1380,57 @@ uint8_t checkTrim(event_t event)
|
|||||||
AUDIO_TRIM_MIDDLE();
|
AUDIO_TRIM_MIDDLE();
|
||||||
pauseEvents(event);
|
pauseEvents(event);
|
||||||
}
|
}
|
||||||
else if (before>TRIM_MIN && after<=TRIM_MIN) {
|
|
||||||
beepTrim = true;
|
|
||||||
AUDIO_TRIM_MIN();
|
|
||||||
killEvents(event);
|
|
||||||
}
|
|
||||||
else if (before<TRIM_MAX && after>=TRIM_MAX) {
|
|
||||||
beepTrim = true;
|
|
||||||
AUDIO_TRIM_MAX();
|
|
||||||
killEvents(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((before<after && after>TRIM_MAX) || (before>after && after<TRIM_MIN)) {
|
|
||||||
if (!g_model.extendedTrims || TRIM_REUSED(idx)) after = before;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (after < TRIM_EXTENDED_MIN) {
|
|
||||||
after = TRIM_EXTENDED_MIN;
|
|
||||||
}
|
|
||||||
if (after > TRIM_EXTENDED_MAX) {
|
|
||||||
after = TRIM_EXTENDED_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(GVARS)
|
#if defined(GVARS)
|
||||||
if (TRIM_REUSED(idx)) {
|
if (TRIM_REUSED(idx)) {
|
||||||
SET_GVAR_VALUE(trimGvar[idx], phase, after);
|
int8_t gvar = trimGvar[idx];
|
||||||
|
#if defined(CPUARM)
|
||||||
|
int16_t vmin = GVAR_MIN + g_model.gvars[gvar].min;
|
||||||
|
int16_t vmax = GVAR_MAX - g_model.gvars[gvar].max;
|
||||||
|
#else
|
||||||
|
int16_t vmin = TRIM_MIN;
|
||||||
|
int16_t vmax = TRIM_MAX;
|
||||||
|
#endif
|
||||||
|
if (after < vmin) {
|
||||||
|
after = vmin;
|
||||||
|
beepTrim = true;
|
||||||
|
AUDIO_TRIM_MIN();
|
||||||
|
killEvents(event);
|
||||||
|
}
|
||||||
|
else if (after > vmax) {
|
||||||
|
after = vmax;
|
||||||
|
beepTrim = true;
|
||||||
|
AUDIO_TRIM_MAX();
|
||||||
|
killEvents(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_GVAR_VALUE(gvar, phase, after);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
if (before>TRIM_MIN && after<=TRIM_MIN) {
|
||||||
|
beepTrim = true;
|
||||||
|
AUDIO_TRIM_MIN();
|
||||||
|
killEvents(event);
|
||||||
|
}
|
||||||
|
else if (before<TRIM_MAX && after>=TRIM_MAX) {
|
||||||
|
beepTrim = true;
|
||||||
|
AUDIO_TRIM_MAX();
|
||||||
|
killEvents(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((before<after && after>TRIM_MAX) || (before>after && after<TRIM_MIN)) {
|
||||||
|
if (!g_model.extendedTrims) after = before;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (after < TRIM_EXTENDED_MIN) {
|
||||||
|
after = TRIM_EXTENDED_MIN;
|
||||||
|
}
|
||||||
|
else if (after > TRIM_EXTENDED_MAX) {
|
||||||
|
after = TRIM_EXTENDED_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
if (!setTrimValue(phase, idx, after)) {
|
if (!setTrimValue(phase, idx, after)) {
|
||||||
// we don't play a beep, so we exit now the function
|
// we don't play a beep, so we exit now the function
|
||||||
|
|||||||
Reference in New Issue
Block a user