diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 766d05d8b..242b7f0fa 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -1238,6 +1238,7 @@ void menuGeneralHardware(uint8_t event) } #endif +#define XPOT_DELTA 5 void menuCommonCalib(uint8_t event) { @@ -1249,26 +1250,30 @@ void menuCommonCalib(uint8_t event) reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2; #if defined(PCBTARANIS) uint8_t idx = i - POT1; - int count = reusableBuffer.calib.xpotsPositionsCount[idx]; + int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; if (count <= POTS_POS_COUNT) { - bool found = false; - for (int j=0; j reusableBuffer.calib.xpotsPositions[idx][j][0]-10 && vt < reusableBuffer.calib.xpotsPositions[idx][j][0]+10) { - reusableBuffer.calib.xpotsPositions[idx][j][0] = min(vt, reusableBuffer.calib.xpotsPositions[idx][j][0]); - reusableBuffer.calib.xpotsPositions[idx][j][1] = max(vt, reusableBuffer.calib.xpotsPositions[idx][j][1]); - if (reusableBuffer.calib.xpotsPositions[idx][j][1] - reusableBuffer.calib.xpotsPositions[idx][j][0] > 20) { - reusableBuffer.calib.xpotsPositionsCount[idx] = 255; - } - found = true; - break; - } + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) { + reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt; + reusableBuffer.calib.xpotsCalib[idx].lastCount = 1; } - if (!found) { - if (count < 6) { - reusableBuffer.calib.xpotsPositions[idx][count][0] = vt; - reusableBuffer.calib.xpotsPositions[idx][count][1] = vt; + else { + if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255) reusableBuffer.calib.xpotsCalib[idx].lastCount++; + } + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 8/*80ms*/) { + int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition; + bool found = false; + for (int j=0; j= reusableBuffer.calib.xpotsCalib[idx].steps[j]-XPOT_DELTA && position <= reusableBuffer.calib.xpotsCalib[idx].steps[j]+XPOT_DELTA) { + found = true; + break; + } + } + if (!found) { + if (count < POTS_POS_COUNT) { + reusableBuffer.calib.xpotsCalib[idx].steps[count] = position; + } + reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1; } - reusableBuffer.calib.xpotsPositionsCount[idx] += 1; } } #endif @@ -1311,7 +1316,8 @@ void menuCommonCalib(uint8_t event) reusableBuffer.calib.midVals[i] = anaIn(i); #if defined(PCBTARANIS) if (i 1 && count <= POTS_POS_COUNT) { for (int j=0; jcount = count - 1; for (int j=0; jcount; j++) { - calib->steps[j] = (reusableBuffer.calib.xpotsPositions[idx][j+1][0] + reusableBuffer.calib.xpotsPositions[idx][j][1]) >> 5; + calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5; } } } @@ -1374,7 +1379,7 @@ void menuCommonCalib(uint8_t event) for (int i=POT1; i<=POT_LAST; i++) { uint8_t steps = 0; if (reusableBuffer.calib.state == 2) { - steps = reusableBuffer.calib.xpotsPositionsCount[i-POT1]; + steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount; } else if (IS_MULTIPOS_POT(i)) { StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i]; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 2e7fb6d8f..6923ecdce 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -2497,17 +2497,11 @@ void getADC() for (uint32_t i=0; i<4; i++) { adcRead(); for (uint32_t x=0; x=POT1 && x<=POT2 && temp[x]!=Analog_values[x]) { - i = 0; - } - temp[x] = Analog_values[x]; - } - else -#endif temp[x] += Analog_values[x]; } +#if defined(PCBTARANIS) + if (s_noScroll) break; +#endif } for (uint32_t x=0; x