Merge remote-tracking branch 'origin/next' into mhotar/layout_alignments_Issue #584

Conflicts:
	radio/src/translations/es.h.txt
	radio/src/translations/fr.h.txt
	radio/src/translations/pl.h.txt
Manually resolved.
This commit is contained in:
mhotar
2014-02-04 13:41:39 +01:00
242 changed files with 41099 additions and 31496 deletions
+102 -14
View File
@@ -1166,6 +1166,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
};
@@ -1179,12 +1181,29 @@ 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_UART3_MODE:
g_eeGeneral.hw_uartMode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.hw_uartMode, 0, 2, attr, event);
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) >> idx, 0, 1, attr, event);
if (potType)
g_eeGeneral.potsType |= mask;
else
g_eeGeneral.potsType &= ~mask;
break;
}
case ITEM_SETUP_HW_UART3_MODE:
g_eeGeneral.uart3Mode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.uart3Mode, 0, UART_MODE_MAX, attr, event);
if (checkIncDec_Ret) {
uart3Init(g_eeGeneral.uart3Mode);
}
break;
}
}
@@ -1263,19 +1282,45 @@ void menuGeneralHardware(uint8_t event)
}
#endif
#define XPOT_DELTA 5
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
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);
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
#if defined(PCBTARANIS)
if(i >= NUM_STICKS && i < NUM_STICKS+NUM_POTS-2) {
#else
if (i >= NUM_STICKS) {
#endif
if (i >= POT1 && i <= POT_LAST) {
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.xpotsCalib[idx].stepsCount;
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;
}
else {
if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255) reusableBuffer.calib.xpotsCalib[idx].lastCount++;
}
if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 10/*100ms*/) {
int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition;
bool found = false;
for (int j=0; j<count; j++) {
if (position >= 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;
}
}
}
#endif
}
}
@@ -1309,6 +1354,12 @@ void menuCommonCalib(uint8_t event)
reusableBuffer.calib.loVals[i] = 15000;
reusableBuffer.calib.hiVals[i] = -15000;
reusableBuffer.calib.midVals[i] = anaIn(i);
#if defined(PCBTARANIS)
if (i<NUM_XPOTS) {
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
}
#endif
}
break;
@@ -1319,17 +1370,40 @@ void menuCommonCalib(uint8_t event)
lcd_putsLeft(3*FH, STR_MENUWHENDONE);
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
if (abs(reusableBuffer.calib.loVals[i]-reusableBuffer.calib.hiVals[i])>50) {
g_eeGeneral.calibMid[i] = reusableBuffer.calib.midVals[i];
if (abs(reusableBuffer.calib.loVals[i]-reusableBuffer.calib.hiVals[i]) > 50) {
g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i];
int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i];
g_eeGeneral.calibSpanNeg[i] = v - v/STICK_TOLERANCE;
g_eeGeneral.calib[i].spanNeg = v - v/STICK_TOLERANCE;
v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i];
g_eeGeneral.calibSpanPos[i] = v - v/STICK_TOLERANCE;
g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE;
}
}
break;
case 3:
#if defined(PCBTARANIS)
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) {
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]) {
swap(reusableBuffer.calib.xpotsCalib[idx].steps[j], reusableBuffer.calib.xpotsCalib[idx].steps[k]);
}
}
}
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
calib->count = count - 1;
for (int j=0; j<calib->count; j++) {
calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5;
}
}
else {
g_eeGeneral.potsType &= ~(1<<idx);
}
}
#endif
g_eeGeneral.chkSum = evalChkSum();
eeDirty(EE_GENERAL);
reusableBuffer.calib.state = 4;
@@ -1341,8 +1415,22 @@ void menuCommonCalib(uint8_t event)
}
doMainScreenGraphics();
#if defined(PCBTARANIS)
drawPotsBars();
for (int i=POT1; i<=POT_LAST; i++) {
uint8_t steps = 0;
if (reusableBuffer.calib.state == 2) {
steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount;
}
else if (IS_MULTIPOS_POT(i)) {
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
steps = calib->count + 1;
}
if (steps > 0 && steps <= POTS_POS_COUNT) {
lcd_outdezAtt(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE);
}
}
#endif
}
+7 -11
View File
@@ -1060,7 +1060,7 @@ void menuModelSetup(uint8_t event)
div_t qr = div(timer->start, 60);
switch (m_posHorz) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(MAX_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(MAX_PSWITCH+NUM_CSW));
CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(NUM_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(NUM_PSWITCH+NUM_CSW));
break;
case 1:
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
@@ -1840,7 +1840,7 @@ void menuModelFlightModesAll(uint8_t event)
}
else {
putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -MAX_SWITCH, MAX_SWITCH);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -NUM_SWITCH, NUM_SWITCH);
}
break;
@@ -4298,7 +4298,7 @@ void menuModelCustomSwitchOne(uint8_t event)
case CSW_FIELD_ANDSW:
lcd_putsLeft(y, STR_AND_SWITCH);
putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr);
if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_SWITCH, MAX_SWITCH);
if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -NUM_SWITCH, NUM_SWITCH);
break;
case CSW_FIELD_DURATION:
lcd_putsLeft(y, STR_DURATION);
@@ -5593,18 +5593,14 @@ void menuModelTelemetry(uint8_t event)
lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE5;
}
#if 0
putsStrIdx(0, y, PSTR(INDENT"Line"), lineIndex+1, m_posHorz<0 ? attr : 0);
#endif
#if defined(GAUGES)
if (IS_BARS_SCREEN(screenIndex)) {
FrSkyBarData & bar = g_model.frsky.screens[screenIndex].bars[lineIndex];
uint8_t barSource = bar.source;
lcd_putsiAtt(TELEM_COL1, y, STR_VTELEMCHNS, barSource, m_posHorz==0 ? attr : 0);
if (barSource) {
putsTelemetryChannel(TELEM_BARS_COLMIN, y, barSource-1, convertTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT);
putsTelemetryChannel(TELEM_BARS_COLMAX, y, barSource-1, convertTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT);
putsTelemetryChannel(TELEM_BARS_COLMIN, y, barSource-1, convertBarTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT);
putsTelemetryChannel(TELEM_BARS_COLMAX, y, barSource-1, convertBarTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT);
}
else if (attr) {
MOVE_CURSOR_FROM_HERE();
@@ -5615,14 +5611,14 @@ void menuModelTelemetry(uint8_t event)
bar.source = checkIncDecModel(event, barSource, 0, TELEM_DISPLAY_MAX);
if (checkIncDec_Ret) {
bar.barMin = 0;
bar.barMax = 255-maxTelemValue(bar.source);
bar.barMax = 255 - maxBarTelemValue(bar.source);
}
break;
case 1:
bar.barMin = checkIncDec(event, bar.barMin, 0, 254-bar.barMax, EE_MODEL|NO_INCDEC_MARKS);
break;
case 2:
bar.barMax = 255 - checkIncDec(event, 255-bar.barMax, bar.barMin+1, maxTelemValue(barSource), EE_MODEL|NO_INCDEC_MARKS);
bar.barMax = 255 - checkIncDec(event, 255-bar.barMax, bar.barMin+1, maxBarTelemValue(barSource), EE_MODEL|NO_INCDEC_MARKS);
break;
}
}
+19 -6
View File
@@ -232,13 +232,13 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
if (event == EVT_KEY_LONG(KEY_ENTER) && i_max > SWSRC_ON) {
s_editMode = !s_editMode;
if (newval > SWSRC_ON)
newval -= (MAX_SWITCH+1);
newval -= (NUM_SWITCH+1);
else if (newval > 0)
newval += (MAX_SWITCH+1);
newval += (NUM_SWITCH+1);
else if (newval < SWSRC_OFF)
newval += (MAX_SWITCH+1);
newval += (NUM_SWITCH+1);
else if (newval < 0)
newval -= (MAX_SWITCH+1);
newval -= (NUM_SWITCH+1);
}
}
#endif
@@ -976,7 +976,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
{
lcd_putsColumnLeft(x, y, STR_SWITCH);
putsSwitches(x, y, value, attr);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, -MAX_SWITCH, MAX_SWITCH);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, -NUM_SWITCH, NUM_SWITCH);
return value;
}
@@ -1263,7 +1263,20 @@ bool isSwitchAvailable(int16_t swtch)
swtch = -swtch;
}
if (swtch>=SWSRC_FIRST_CSW && swtch<=SWSRC_LAST_CSW) {
#if defined(PCBTARANIS)
if (swtch >= SWSRC_P11 && swtch <= SWSRC_P26) {
int index = (swtch - SWSRC_P11) / POTS_POS_COUNT;
if (g_eeGeneral.potsType & (1<<index)) {
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+index];
return (calib->count >= ((swtch - SWSRC_P11) % POTS_POS_COUNT));
}
else {
return false;
}
}
#endif
if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) {
CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW);
return (cs->func != CS_OFF);
}
+3 -3
View File
@@ -120,9 +120,9 @@
void drawPotsBars()
{
// Optimization by Mike Blandford
uint8_t x, y, len ; // declare temporary variables
for (x=LCD_W/2-5, y=NUM_STICKS; y<NUM_STICKS+NUM_POTS; x+=5, y++) {
len = ((calibratedStick[y]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
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)
}
}
+3 -3
View File
@@ -214,8 +214,8 @@ void menuTelemetryFrsky(uint8_t event)
for (int8_t i=3; i>=0; i--) {
FrSkyBarData & bar = screen.bars[i];
uint8_t source = bar.source;
getvalue_t barMin = convertTelemValue(source, bar.barMin);
getvalue_t barMax = convertTelemValue(source, 255-bar.barMax);
getvalue_t barMin = convertBarTelemValue(source, bar.barMin);
getvalue_t barMax = convertBarTelemValue(source, 255-bar.barMax);
if (source && barMax > barMin) {
uint8_t y = barHeight+6+i*(barHeight+6);
lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0);
@@ -234,7 +234,7 @@ void menuTelemetryFrsky(uint8_t event)
threshold = g_model.frsky.channels[source-TELEM_A1].alarms_value[0];
#if defined(FRSKY_HUB)
else
threshold = convertTelemValue(source, barsThresholds[source-TELEM_ALT]);
threshold = convertBarTelemValue(source, barsThresholds[source-TELEM_ALT]);
#endif
if (threshold) {