diff --git a/src/gui/menu_model.cpp b/src/gui/menu_model.cpp index 2e76b956f..53ef8c631 100644 --- a/src/gui/menu_model.cpp +++ b/src/gui/menu_model.cpp @@ -4460,7 +4460,7 @@ enum menuModelTelemetryItems { #define SCREEN_TYPE_ROWS (uint8_t)-1 #endif -#if defined(TOTO) +#if defined(PCBSTD) #define VARIO_RANGE_ROWS 1 #else #define VARIO_RANGE_ROWS 3 @@ -4652,7 +4652,7 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_VARIO_RANGE: lcd_putsLeft(y, STR_LIMIT); -#if defined(TOTO) +#if defined(PCBSTD) lcd_outdezAtt(TELEM_COL2, y, 5+g_model.frsky.varioCenterMax, (m_posHorz==0 ? attr : 0)|PREC1|LEFT); lcd_outdezAtt(TELEM_COL2+8*FW, y, 10+g_model.frsky.varioMax, (m_posHorz==1 ? attr : 0)); if (attr && (s_editMode>0 || p1valdiff)) { diff --git a/src/maths.cpp b/src/maths.cpp index aeeb69cda..1891b4fd7 100644 --- a/src/maths.cpp +++ b/src/maths.cpp @@ -109,6 +109,22 @@ void varioWakeup() int16_t verticalSpeed = frskyData.hub.varioSpeed; sei(); +#if defined(PCBSTD) + int16_t varioCenterMax = (int16_t)g_model.frsky.varioCenterMax * 10 + 50; + if (verticalSpeed >= varioCenterMax) { + verticalSpeed = verticalSpeed - varioCenterMax; + int16_t varioMax = (10+(int16_t)g_model.frsky.varioMax) * 100; + if (verticalSpeed > varioMax) verticalSpeed = varioMax; + verticalSpeed = (verticalSpeed * 10) / ((varioMax-varioCenterMax) / 100); + + if ((int16_t)(s_varioTmr-tmr10ms) < 0) { + uint8_t SoundVarioBeepTime = (1600 - verticalSpeed) / 100; + uint8_t SoundVarioBeepFreq = (verticalSpeed * 10 + 16000) >> 8; + s_varioTmr = tmr10ms + (SoundVarioBeepTime*2); + AUDIO_VARIO(SoundVarioBeepFreq, SoundVarioBeepTime); + } + } +#else int16_t varioCenterMax = (int16_t)g_model.frsky.varioCenterMax * 10 + 50; if (verticalSpeed >= varioCenterMax) { verticalSpeed = verticalSpeed - varioCenterMax; @@ -130,7 +146,6 @@ void varioWakeup() } if (verticalSpeed < 0 || (int16_t)(s_varioTmr-tmr10ms) < 0) { -#if defined(CPUARM) uint8_t SoundVarioBeepTime; uint8_t SoundVarioBeepFreq; if (verticalSpeed > 0) { @@ -142,13 +157,9 @@ void varioWakeup() SoundVarioBeepFreq = (verticalSpeed * 3 + 8000) >> 7; } s_varioTmr = tmr10ms + (SoundVarioBeepTime/2); -#else - uint8_t SoundVarioBeepTime = (1600 - verticalSpeed) / 100; - uint8_t SoundVarioBeepFreq = (verticalSpeed * 10 + 16000) >> 8; - s_varioTmr = tmr10ms + (SoundVarioBeepTime*2); -#endif AUDIO_VARIO(SoundVarioBeepFreq, SoundVarioBeepTime); } +#endif #else // defined(AUDIO) diff --git a/src/opentx.cpp b/src/opentx.cpp index ae9744904..3eeac014e 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -918,6 +918,7 @@ uint8_t cswStates[NUM_CSW]; #endif int16_t csLastValue[NUM_CSW]; +#define CS_LAST_VALUE_INIT -32768 bool __getSwitch(int8_t swtch) { @@ -947,6 +948,7 @@ bool __getSwitch(int8_t swtch) CustomSwData * cs = cswAddress(cs_idx); uint8_t s = cs->andsw; if (cs->func == CS_OFF || (s && !__getSwitch(s))) { + csLastValue[cs_idx] = CS_LAST_VALUE_INIT; result = false; } else if ((s=cswFamily(cs->func)) == CS_VBOOL) { @@ -1051,7 +1053,7 @@ bool __getSwitch(int8_t swtch) break; default: { - if (csLastValue[cs_idx] == -32668) + if (csLastValue[cs_idx] == CS_LAST_VALUE_INIT) csLastValue[cs_idx] = x; int16_t diff = x - csLastValue[cs_idx]; if (cs->func == CS_DIFFEGREATER) @@ -2082,7 +2084,7 @@ void resetAll() resetTelemetry(); #endif for (uint8_t i=0; i 0) *lastValue -= 1; } - if (cs->andsw) { - int8_t x; - x = cs->andsw; - if (!getSwitch(x) == 0) { - *lastValue = -1; - } - } } } }