[stock] Sink tones on vario removed

[all] Bug in custom switch timers (when using the AND switch)
This commit is contained in:
bsongis@gmail.com
2013-06-04 09:25:09 +00:00
parent 6427b8a8bb
commit cf578bbaa0
3 changed files with 23 additions and 17 deletions
+2 -2
View File
@@ -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)) {
+17 -6
View File
@@ -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)
+4 -9
View File
@@ -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<NUM_CSW; i++)
csLastValue[i] = -32768;
csLastValue[i] = CS_LAST_VALUE_INIT;
#if defined(THRTRACE)
s_traceCnt = 0;
@@ -3400,13 +3402,6 @@ void doMixerCalculations()
else { // if (*lastValue > 0)
*lastValue -= 1;
}
if (cs->andsw) {
int8_t x;
x = cs->andsw;
if (!getSwitch(x) == 0) {
*lastValue = -1;
}
}
}
}
}