Calibration modified

This commit is contained in:
Bertrand Songis
2016-01-30 13:54:52 +01:00
parent c36acc5372
commit 643e449f52
3 changed files with 17 additions and 42 deletions
+6 -20
View File
@@ -60,7 +60,7 @@ bool menuCommonCalib(evt_t event)
drawScreenTemplate(NULL, OPTION_MENU_NO_FOOTER);
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
int16_t vt = anaIn(i);
int16_t vt = getAnalogValue(i) >> 1;
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
if (i >= POT1 && i <= POT_LAST) {
@@ -125,8 +125,8 @@ bool menuCommonCalib(evt_t event)
for (int i=0; i<NUM_STICKS+NUM_POTS; i++) {
reusableBuffer.calib.loVals[i] = 15000;
reusableBuffer.calib.hiVals[i] = -15000;
reusableBuffer.calib.midVals[i] = anaIn(i);
if (i<NUM_XPOTS) {
reusableBuffer.calib.midVals[i] = getAnalogValue(i) >> 1;
if (i < NUM_XPOTS) {
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
}
@@ -146,9 +146,6 @@ bool menuCommonCalib(evt_t event)
g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE;
}
}
break;
case 3:
for (int i=POT1; i<=POT_LAST; i++) {
int idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
@@ -172,6 +169,9 @@ bool menuCommonCalib(evt_t event)
}
}
}
break;
case 3:
g_eeGeneral.chkSum = evalChkSum();
storageDirty(EE_GENERAL);
calibrationState = 4;
@@ -186,20 +186,6 @@ bool menuCommonCalib(evt_t event)
drawSticks();
drawPots();
for (int i=POT1; i<=POT_LAST; i++) {
uint8_t steps = 0;
if (calibrationState == 2) {
steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount;
}
else if (IS_POT_MULTIPOS(i)) {
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
steps = calib->count + 1;
}
if (calibrationState != 0 && steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) {
lcdDrawNumber(LCD_W/2+3-(POT_BAR_INTERVAL*NUM_POTS/2)+(POT_BAR_INTERVAL*(i-POT1)), POT_BAR_BOTTOM+15, steps, TEXT_COLOR|TINSIZE, 0, "[", "]");
}
}
return true;
}
+2 -2
View File
@@ -41,7 +41,7 @@ void drawPotsBars()
void menuCommonCalib(uint8_t event)
{
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
int16_t vt = anaIn(i);
int16_t vt = getAnalogValue(i) >> 1;
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
if (i >= POT1 && i <= POT_LAST) {
@@ -108,7 +108,7 @@ void menuCommonCalib(uint8_t event)
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
reusableBuffer.calib.loVals[i] = 15000;
reusableBuffer.calib.hiVals[i] = -15000;
reusableBuffer.calib.midVals[i] = anaIn(i);
reusableBuffer.calib.midVals[i] = getAnalogValue(i) >> 1;
if (i<NUM_XPOTS) {
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
+9 -20
View File
@@ -1547,37 +1547,25 @@ void getADC()
for (uint32_t i=0; i<4; i++) {
adcRead();
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
#if defined(JITTER_MEASURE)
uint16_t val = getAnalogValue(x);
#if defined(JITTER_MEASURE)
if (JITTER_MEASURE_ACTIVE()) {
rawJitter[x].measure(val);
}
#endif
temp[x] += val;
#else
temp[x] += getAnalogValue(x);
#endif
}
#if defined(VIRTUALINPUTS)
if (calibrationState) break;
#endif
}
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
uint16_t v = temp[x] >> 3;
#if defined(VIRTUALINPUTS)
if (calibrationState) {
v = temp[x] >> 1;
}
#if defined(JITTER_FILTER)
else {
// jitter filter
uint16_t diff = (v > s_anaFilt[x]) ? (v - s_anaFilt[x]) : (s_anaFilt[x] - v);
if (diff < 10) {
// apply filter
v = (7 * s_anaFilt[x] + v) >> 3;
}
// jitter filter
uint16_t diff = (v > s_anaFilt[x]) ? (v - s_anaFilt[x]) : (s_anaFilt[x] - v);
if (diff < 10) {
// apply filter
v = (7 * s_anaFilt[x] + v) >> 3;
}
#endif
@@ -1587,8 +1575,9 @@ void getADC()
}
#endif
#if defined(VIRTUALINPUTS)
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[x];
if (!calibrationState && IS_POT_MULTIPOS(x) && calib->count>0 && calib->count<XPOTS_MULTIPOS_COUNT) {
if (IS_POT_MULTIPOS(x) && calib->count>0 && calib->count<XPOTS_MULTIPOS_COUNT) {
uint8_t vShifted = (v >> 4);
s_anaFilt[x] = 2*RESX;
for (int i=0; i<calib->count; i++) {