Merge pull request #770 from opentx/bsongis/Issue767_extra_pot
Bsongis/issue767 extra pot
This commit is contained in:
@@ -1154,7 +1154,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
#if defined(PCBTARANIS)
|
||||
lcd_putsLeft(6*FH+1, STR_BATT_CALIB);
|
||||
static int32_t adcBatt;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(8)) / 8;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8;
|
||||
uint32_t batCalV = (adcBatt + (adcBatt*g_eeGeneral.vBatCalib)/128) * BATT_SCALE;
|
||||
batCalV >>= 11;
|
||||
batCalV += 2; // because of the diode
|
||||
@@ -1162,7 +1162,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
#elif defined(PCBSKY9X)
|
||||
lcd_putsLeft(5*FH+1, STR_BATT_CALIB);
|
||||
static int32_t adcBatt;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(7)) / 8;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8;
|
||||
uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191;
|
||||
batCalV /= 55296;
|
||||
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, batCalV, (m_posVert==1 ? INVERS : 0));
|
||||
@@ -1170,7 +1170,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
lcd_putsLeft(6*FH-2, STR_BATT_CALIB);
|
||||
// Gruvin wants 2 decimal places and instant update of volts calib field when button pressed
|
||||
static uint16_t adcBatt;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P)
|
||||
adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; // running average, sourced directly (to avoid unending debate :P)
|
||||
uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap;
|
||||
lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0));
|
||||
#else
|
||||
@@ -1196,6 +1196,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
enum menuGeneralHwItems {
|
||||
ITEM_SETUP_HW_POT1,
|
||||
ITEM_SETUP_HW_POT2,
|
||||
ITEM_SETUP_HW_POT3,
|
||||
ITEM_SETUP_HW_UART3_MODE,
|
||||
ITEM_SETUP_HW_MAX
|
||||
};
|
||||
@@ -1214,14 +1215,20 @@ void menuGeneralHardware(uint8_t event)
|
||||
switch(i) {
|
||||
case ITEM_SETUP_HW_POT1:
|
||||
case ITEM_SETUP_HW_POT2:
|
||||
case ITEM_SETUP_HW_POT3:
|
||||
{
|
||||
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) >> idx, 0, 1, attr, event);
|
||||
if (potType)
|
||||
g_eeGeneral.potsType |= mask;
|
||||
else
|
||||
g_eeGeneral.potsType &= ~mask;
|
||||
uint8_t shift = (2*idx);
|
||||
uint8_t mask = (0x03 << shift);
|
||||
putsMixerSource(sizeof(TR_TYPE)*FW, y, MIXSRC_FIRST_POT+idx);
|
||||
uint8_t potType = (g_eeGeneral.potsType & mask) >> shift;
|
||||
if (potType == POT_TYPE_NONE && i < 2)
|
||||
potType = 1;
|
||||
potType = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_TYPE, STR_POTTYPES, potType, 0, POT_TYPE_MAX, attr, event);
|
||||
if (potType == POT_TYPE_POT && i < 2)
|
||||
potType = 0;
|
||||
g_eeGeneral.potsType &= ~mask;
|
||||
g_eeGeneral.potsType |= (potType << shift);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1234,7 +1241,6 @@ void menuGeneralHardware(uint8_t event)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#elif defined(PCBSKY9X)
|
||||
@@ -1323,7 +1329,7 @@ void menuCommonCalib(uint8_t event)
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t idx = i - POT1;
|
||||
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
|
||||
if (IS_MULTIPOS_POT(i) && count <= POTS_POS_COUNT) {
|
||||
if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_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;
|
||||
@@ -1341,7 +1347,7 @@ void menuCommonCalib(uint8_t event)
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (count < POTS_POS_COUNT) {
|
||||
if (count < XPOTS_MULTIPOS_COUNT) {
|
||||
reusableBuffer.calib.xpotsCalib[idx].steps[count] = position;
|
||||
}
|
||||
reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1;
|
||||
@@ -1413,7 +1419,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 (IS_MULTIPOS_POT(i) && count > 1 && count <= POTS_POS_COUNT) {
|
||||
if (IS_POT_MULTIPOS(i) && count > 1 && count <= XPOTS_MULTIPOS_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]) {
|
||||
@@ -1451,11 +1457,11 @@ void menuCommonCalib(uint8_t event)
|
||||
if (reusableBuffer.calib.state == 2) {
|
||||
steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount;
|
||||
}
|
||||
else if (IS_MULTIPOS_POT(i)) {
|
||||
else if (IS_POT_MULTIPOS(i)) {
|
||||
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
|
||||
steps = calib->count + 1;
|
||||
}
|
||||
if (steps > 0 && steps <= POTS_POS_COUNT) {
|
||||
if (steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) {
|
||||
lcd_outdezAtt(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -1351,6 +1351,12 @@ bool isSourceAvailable(int source)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
||||
return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HELI)
|
||||
if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3)
|
||||
return false;
|
||||
@@ -1438,11 +1444,11 @@ bool isSwitchAvailableInLogicalSwitches(int swtch)
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (swtch >= SWSRC_P11 && swtch <= SWSRC_P26) {
|
||||
int index = (swtch - SWSRC_P11) / POTS_POS_COUNT;
|
||||
if (g_eeGeneral.potsType & (1<<index)) {
|
||||
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) {
|
||||
int index = (swtch - SWSRC_FIRST_MULTIPOS_SWITCH) / XPOTS_MULTIPOS_COUNT;
|
||||
if (IS_POT_MULTIPOS(POT1+index)) {
|
||||
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+index];
|
||||
return (calib->count >= ((swtch - SWSRC_P11) % POTS_POS_COUNT));
|
||||
return (calib->count >= ((swtch - SWSRC_FIRST_MULTIPOS_SWITCH) % XPOTS_MULTIPOS_COUNT));
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -122,8 +122,10 @@ void drawPotsBars()
|
||||
// Optimization by Mike Blandford
|
||||
uint8_t x, i, len ; // declare temporary variables
|
||||
for (x=LCD_W/2-5, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; x+=5, i++) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
V_BAR(x, LCD_H-8, len)
|
||||
if (IS_POT_AVAILABLE(i)) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
V_BAR(x, LCD_H-8, len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,8 +198,11 @@ void displayTrims(uint8_t phase)
|
||||
void displaySliders()
|
||||
{
|
||||
for (uint8_t i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; i++) {
|
||||
xcoord_t x = (i%2 ? LCD_W-5 : 3);
|
||||
int8_t y = (i>NUM_STICKS+1 ? LCD_H/2+1 : 1);
|
||||
if (i == POT3) {
|
||||
continue;
|
||||
}
|
||||
xcoord_t x = ((i==POT1 || i==SLIDER1) ? 3 : LCD_W-5);
|
||||
int8_t y = (i>=SLIDER1 ? LCD_H/2+1 : 1);
|
||||
lcd_vline(x, y, LCD_H/2-2);
|
||||
lcd_vline(x+1, y, LCD_H/2-2);
|
||||
y += LCD_H/2-4;
|
||||
|
||||
Reference in New Issue
Block a user