From 992e0f7ea475eed2315f01288abd4bee2879c37c Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 3 Feb 2013 16:25:26 +0000 Subject: [PATCH] Issue 188 fixed - Delay up / down and Slow up / down in Mixer must be re-tested before next release! --- src/model_menus.cpp | 6 ++-- src/open9x.cpp | 71 +++++++++++++++------------------------------ src/open9x.h | 32 ++++++++++---------- src/simpgmspace.h | 2 +- 4 files changed, 44 insertions(+), 67 deletions(-) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 47ea849f3..9a7626c38 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -1201,16 +1201,16 @@ void menuModelPhaseOne(uint8_t event) putsStrIdx(INDENT_WIDTH, y, STR_GV, idx+1); - editName(4*FW-2, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), event, m_posHorz==0 ? attr : 0); + editName(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), event, m_posHorz==0 ? attr : 0); int16_t v = phase->gvars[idx]; if (v > GVAR_MAX) { uint8_t p = v - GVAR_MAX - 1; if (p >= s_currIdx) p++; - putsFlightPhase(MIXES_2ND_COLUMN, y, p+1, m_posHorz==1 ? attr : 0); + putsFlightPhase(MIXES_2ND_COLUMN+2*FW, y, p+1, m_posHorz==1 ? attr : 0); } else { - lcd_putsAtt(MIXES_2ND_COLUMN, y, STR_OWN, m_posHorz==1 ? attr : 0); + lcd_putsAtt(MIXES_2ND_COLUMN+2*FW, y, STR_OWN, m_posHorz==1 ? attr : 0); } if (attr && s_currIdx>0 && m_posHorz==1 && ((editMode>0) || p1valdiff)) { if (v < GVAR_MAX) v = GVAR_MAX; diff --git a/src/open9x.cpp b/src/open9x.cpp index 9d560b83d..8ec9114bb 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -542,7 +542,7 @@ void applyExpos(int16_t *anas) continue; if (getSwitch(ed.swtch, 1)) { int16_t v = anas2[ed.chn]; - if((v<0 && ed.mode&1) || (v>=0 && ed.mode&2)) { + if((v<0 && (ed.mode&1)) || (v>=0 && (ed.mode&2))) { #ifdef BOLD_FONT activeExpos |= ((ACTIVE_EXPOS_TYPE)1 << i); #endif @@ -1072,26 +1072,18 @@ uint8_t s_gvar_last = 0; #if defined(CPUM64) int16_t getGVarValue(int8_t x, int16_t min, int16_t max) { - return (x >= 126 || x <= -126) ? limit(min, GVAR_VALUE((uint8_t)x - 126, -1), max) : x; - - - if (x >= -125 && x <= 120) + if (x >= -125 && x <= (max <= 120 ? 120 : 125)) return x; int8_t idx = (uint8_t)x - 126; int8_t mul = 1; - if (idx <= 0) { - if (max <= 120) { - idx = 1-idx; mul = -1; - } - else { - return x; - } + + if (idx < 0) { + idx = 1-idx; + mul = -1; } return limit(min, GVAR_VALUE(idx, -1), max) * mul; - - } void setGVarValue(uint8_t idx, int8_t value) @@ -1119,18 +1111,15 @@ uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx) int16_t getGVarValue(int8_t x, int16_t min, int16_t max, int8_t phase) { - if (x >= -125 && x <= 120) + if (x >= -125 && x <= (max <= 120 ? 120 : 125)) return x; int8_t idx = (uint8_t)x - 126; int8_t mul = 1; - if (idx <= 0) { - if (max <= 120) { - idx = 1-idx; mul = -1; - } - else { - return x; - } + + if (idx < 0) { + idx = 1-idx; + mul = -1; } return limit(min, GVAR_VALUE(idx, getGVarFlightPhase(phase, idx)), max) * mul; @@ -2289,7 +2278,7 @@ void perOut(uint8_t mode, uint8_t tick10ms) bpanaCenter = anaCenter; } -#ifdef HELI +#if defined(HELI) if(g_model.swashR.value) { uint32_t v = ((int32_t)anas[ELE_STICK]*anas[ELE_STICK] + (int32_t)anas[AIL_STICK]*anas[AIL_STICK]); @@ -2400,7 +2389,6 @@ void perOut(uint8_t mode, uint8_t tick10ms) #if defined(PCBX9D) || defined(PCBACT) else { v = getValue(k); - // TODO switches: if (v < 0 && !md->swtch) sw = false; if (k>=MIXSRC_CH1-1 && k<=MIXSRC_CHMAX-1 && md->destCh != k-MIXSRC_CH1+1) { if (dirtyChannels & ((bitfield_channels_t)1 << (k-MIXSRC_CH1+1)) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1))) passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh; @@ -2411,7 +2399,6 @@ void perOut(uint8_t mode, uint8_t tick10ms) #else else if (k >= MIXSRC_THR-1 && k <= MIXSRC_SWC-1) { v = getSwitch(k-MIXSRC_THR+1+1, 0) ? +1024 : -1024; - if (v < 0 && !md->swtch) sw = false; } else { v = getValue(k<=MIXSRC_3POS ? k : k-MAX_SWITCH); @@ -2425,9 +2412,10 @@ void perOut(uint8_t mode, uint8_t tick10ms) #endif } + bool apply_offset_and_curve = true; + //========== DELAYS =============== uint8_t swTog; - bool apply_offset = true; if (sw) { // switch on? (if no switch selected => on) swTog = !swOn[i]; if (mode == e_perout_mode_normal) { @@ -2441,12 +2429,7 @@ void perOut(uint8_t mode, uint8_t tick10ms) } if (sDelay[i] > 0) { // perform delay sDelay[i] = max(0, sDelay[i] - tick10ms); - if (!md->swtch) { - v = -1024; - } - else { - continue; - } + continue; } } if (md->mixWarn) lv_mixWarning |= 1 << (md->mixWarn - 1); // Mix warning @@ -2465,22 +2448,16 @@ void perOut(uint8_t mode, uint8_t tick10ms) } if (sDelay[i] > 0) { // perform delay sDelay[i] = max(0, sDelay[i] - tick10ms); - if (!md->swtch) v = +1024; has_delay = true; } - else if (!md->swtch) { - v = -1024; - } } if (!has_delay) { if (md->speedDown) { if (md->mltpx == MLTPX_REP) continue; - if (md->swtch) { - v = 0; - apply_offset = false; - } + v = 0; + apply_offset_and_curve = false; } - else if (md->swtch) { + else { continue; } } @@ -2491,7 +2468,7 @@ void perOut(uint8_t mode, uint8_t tick10ms) #endif //========== OFFSET =============== - if (apply_offset) { + if (apply_offset_and_curve) { int8_t offset = GET_GVAR(md->offset, -125, 125, s_perout_flight_phase); if (offset) v += calc100toRESX(offset); } @@ -2508,6 +2485,11 @@ void perOut(uint8_t mode, uint8_t tick10ms) if (mix_trim >= 0) v += trims[mix_trim]; } + //========== CURVES =============== + if (apply_offset_and_curve && md->curveParam && md->curveMode == MODE_CURVE) { + v = applyCurve(v, md->curveParam); + } + int16_t weight = GET_GVAR(md->weight, -500, 500, s_perout_flight_phase); //========== SPEED =============== @@ -2538,11 +2520,6 @@ void perOut(uint8_t mode, uint8_t tick10ms) } } - //========== CURVES =============== - if (md->curveParam && md->curveMode == MODE_CURVE) { - v = applyCurve(v, md->curveParam); - } - //========== WEIGHT =============== int32_t dv = (int32_t) v * weight; diff --git a/src/open9x.h b/src/open9x.h index 48ae8ca16..d96766d72 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -722,23 +722,23 @@ inline bool navigationRotaryEncoder(uint8_t event) #endif #if defined(GVARS) -#if defined(CPUM64) -int16_t getGVarValue(int8_t x, int16_t min, int16_t max); -void setGVarValue(uint8_t x, int8_t value); -#define GET_GVAR(x, min, max, p) getGVarValue(x, min, max) -#define SET_GVAR(idx, val, p) setGVarValue(idx, val) + #if defined(CPUM64) + int16_t getGVarValue(int8_t x, int16_t min, int16_t max); + void setGVarValue(uint8_t x, int8_t value); + #define GET_GVAR(x, min, max, p) getGVarValue(x, min, max) + #define SET_GVAR(idx, val, p) setGVarValue(idx, val) + #else + uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx); + int16_t getGVarValue(int8_t x, int16_t min, int16_t max, int8_t phase); + void setGVarValue(uint8_t x, int8_t value, int8_t phase); + #define GET_GVAR(x, min, max, p) getGVarValue(x, min, max, p) + #define SET_GVAR(idx, val, p) setGVarValue(idx, val, p) + #endif + #define GVAR_DISPLAY_TIME 100 /*1 second*/; + extern uint8_t s_gvar_timer; + extern uint8_t s_gvar_last; #else -uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx); -int16_t getGVarValue(int8_t x, int16_t min, int16_t max, int8_t phase); -void setGVarValue(uint8_t x, int8_t value, int8_t phase); -#define GET_GVAR(x, min, max, p) getGVarValue(x, min, max, p) -#define SET_GVAR(idx, val, p) setGVarValue(idx, val, p) -#endif -#define GVAR_DISPLAY_TIME 100 /*1 second*/; -extern uint8_t s_gvar_timer; -extern uint8_t s_gvar_last; -#else -#define GET_GVAR(x, ...) (x) + #define GET_GVAR(x, ...) (x) #endif extern uint16_t s_timeCumTot; diff --git a/src/simpgmspace.h b/src/simpgmspace.h index 76dd6a213..f3374ce34 100644 --- a/src/simpgmspace.h +++ b/src/simpgmspace.h @@ -291,7 +291,7 @@ extern void rxPdcUsart( void (*pChProcess)(uint8_t x) ); #define UPE0 0 #define FE0 0 -#define ISR(x) void x() +#define ISR(x...) void x() #if defined(CPUARM) extern volatile uint32_t Tenms;