Issue #588 - S1/S2 Type added in Hardware configuration page

This commit is contained in:
Bertrand Songis
2014-01-31 12:13:46 +01:00
parent 38145a02f4
commit 0446658f4b
10 changed files with 68 additions and 16 deletions
+19 -9
View File
@@ -1168,6 +1168,8 @@ void menuGeneralDiagAna(uint8_t event)
#if defined(PCBTARANIS)
enum menuGeneralHwItems {
ITEM_SETUP_HW_POT1,
ITEM_SETUP_HW_POT2,
ITEM_SETUP_HW_UART3_MODE,
ITEM_SETUP_HW_MAX
};
@@ -1181,9 +1183,22 @@ void menuGeneralHardware(uint8_t event)
uint8_t sub = m_posVert - 1;
for (uint8_t i=0; i<ITEM_SETUP_HW_MAX; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t attr = (sub == i ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
uint8_t y = 1 + 1*FH + i*FH;
uint8_t attr = (sub == i ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
switch(i) {
case ITEM_SETUP_HW_POT1:
case ITEM_SETUP_HW_POT2:
{
int idx = i - ITEM_SETUP_HW_POT1;
uint8_t mask = (1<<idx);
uint8_t potType = selectMenuItem(HW_SETTINGS_COLUMN, y, i==ITEM_SETUP_HW_POT1 ? STR_POT1TYPE : STR_POT2TYPE, STR_POTTYPES, g_eeGeneral.potsType & mask, 0, 1, attr, event);
if (potType)
g_eeGeneral.potsType |= mask;
else
g_eeGeneral.potsType &= ~mask;
break;
}
case ITEM_SETUP_HW_UART3_MODE:
g_eeGeneral.hw_uartMode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.hw_uartMode, 0, 2, attr, event);
break;
@@ -1278,7 +1293,7 @@ void menuCommonCalib(uint8_t event)
#if defined(PCBTARANIS)
uint8_t idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (count <= POTS_POS_COUNT) {
if (IS_MULTIPOS_POT(i) && count <= POTS_POS_COUNT) {
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;
@@ -1333,10 +1348,6 @@ void menuCommonCalib(uint8_t event)
lcd_putsAtt(0*FW, 2*FH, STR_SETMIDPOINT, s_noScroll ? INVERS : 0);
lcd_putsLeft(3*FH, STR_MENUWHENDONE);
#if defined(PCBTARANIS)
g_eeGeneral.potsType = 0;
#endif
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
reusableBuffer.calib.loVals[i] = 15000;
reusableBuffer.calib.hiVals[i] = -15000;
@@ -1372,7 +1383,7 @@ void menuCommonCalib(uint8_t event)
for (uint8_t i=POT1; i<=POT_LAST; i++) {
int idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (count > 1 && count <= POTS_POS_COUNT) {
if (IS_MULTIPOS_POT(i) && count > 1 && count <= POTS_POS_COUNT) {
for (int j=0; j<count; j++) {
for (int k=j+1; k<count; k++) {
if (reusableBuffer.calib.xpotsCalib[idx].steps[k] < reusableBuffer.calib.xpotsCalib[idx].steps[j]) {
@@ -1380,7 +1391,6 @@ void menuCommonCalib(uint8_t event)
}
}
}
g_eeGeneral.potsType |= (1 << idx);
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
calib->count = count - 1;
for (int j=0; j<calib->count; j++) {