1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 06:15:10 +03:00

[Taranis] Issue #554 - Default is now :0 (all trims linked to the

default phase)
This commit is contained in:
Bertrand Songis 2014-01-27 09:26:02 +01:00
parent 046a4d253d
commit 16c1bd01c6
4 changed files with 30 additions and 67 deletions

View file

@ -1727,64 +1727,24 @@ FlightModesType editFlightModes(uint8_t x, uint8_t y, uint8_t event, FlightModes
enum FlightModesItems { enum FlightModesItems {
ITEM_PHASES_NAME, ITEM_PHASES_NAME,
ITEM_PHASES_SWITCH, ITEM_PHASES_SWITCH,
ITEM_PHASES_TRIMS, ITEM_PHASES_TRIM_RUD,
ITEM_PHASES_TRIM_ELE,
ITEM_PHASES_TRIM_THR,
ITEM_PHASES_TRIM_AIL,
ITEM_PHASES_FADE_IN, ITEM_PHASES_FADE_IN,
ITEM_PHASES_FADE_OUT, ITEM_PHASES_FADE_OUT,
ITEM_PHASES_COUNT, ITEM_PHASES_COUNT,
ITEM_PHASES_LAST = ITEM_PHASES_COUNT-1 ITEM_PHASES_LAST = ITEM_PHASES_COUNT-1
}; };
void editPhaseTrims(uint8_t x, uint8_t y, uint8_t phase, uint8_t event, uint8_t active)
{
static uint8_t cursorPos = 0;
for (uint8_t t=0; t<NUM_STICKS; t++) {
putsTrimMode(x+t*(3*FW-2), y, phase, t, (active && (s_editMode <= 0 || cursorPos==t)) ? INVERS : 0);
}
if (active) {
uint8_t cur = cursorPos;
if (s_editMode > 0) {
if (p1valdiff || IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP)
|| event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) {
PhaseData *p = phaseAddress(phase);
trim_t & v = p->trim[cur];
v.mode = checkIncDec(event, v.mode, -1, 2*MAX_PHASES-1, EE_MODEL);
}
switch (event) {
case EVT_KEY_BREAK(KEY_ENTER):
if (s_editMode == EDIT_MODIFY_FIELD) {
s_editMode = EDIT_MODIFY_STRING;
cur = 0;
}
else if (cur<NUM_STICKS-1)
cur++;
else
s_editMode = 0;
break;
case EVT_KEY_LONG(KEY_ENTER):
s_editMode = 0;
killEvents(event);
break;
}
}
else {
cur = 0;
}
cursorPos = cur;
}
}
void menuModelFlightModesAll(uint8_t event) void menuModelFlightModesAll(uint8_t event)
{ {
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_PHASES+1, {0, NAVIGATION_LINE_BY_LINE|(ITEM_PHASES_LAST-2), NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, 0}); MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_PHASES+1, {0, NAVIGATION_LINE_BY_LINE|(ITEM_PHASES_LAST-5), NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, 0});
int8_t sub = m_posVert - 1; int8_t sub = m_posVert - 1;
horzpos_t posHorz = m_posHorz; horzpos_t posHorz = m_posHorz;
if (sub==0 && posHorz > 0) { posHorz += 2; } if (sub==0 && posHorz > 0) { posHorz += 5; }
if (sub<MAX_PHASES && posHorz>=0) { if (sub<MAX_PHASES && posHorz>=0) {
displayColumnHeader(STR_PHASES_HEADERS, posHorz); displayColumnHeader(STR_PHASES_HEADERS, posHorz);
@ -1819,20 +1779,27 @@ void menuModelFlightModesAll(uint8_t event)
case ITEM_PHASES_SWITCH: case ITEM_PHASES_SWITCH:
if (k == 0) { if (k == 0) {
lcd_puts((5+LEN_FP_NAME)*FW-FW/2, y, STR_DEFAULT); lcd_puts((5+LEN_FP_NAME)*FW, y, STR_DEFAULT);
} }
else { else {
putsSwitches((5+LEN_FP_NAME)*FW-FW/2, y, p->swtch, attr); putsSwitches((5+LEN_FP_NAME)*FW, y, p->swtch, attr);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -MAX_SWITCH, MAX_SWITCH); if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -MAX_SWITCH, MAX_SWITCH);
} }
break; break;
case ITEM_PHASES_TRIMS: case ITEM_PHASES_TRIM_RUD:
case ITEM_PHASES_TRIM_ELE:
case ITEM_PHASES_TRIM_THR:
case ITEM_PHASES_TRIM_AIL:
if (k != 0) { if (k != 0) {
editPhaseTrims((10+LEN_FP_NAME)*FW-2*FW, y, k, event, attr); uint8_t t = j-ITEM_PHASES_TRIM_RUD;
putsTrimMode((4+LEN_FP_NAME)*FW+j*(5*FW/2), y, k, t, attr);
if (active) {
trim_t & v = p->trim[t];
v.mode = checkIncDec(event, v.mode, -1, 2*MAX_PHASES-1, EE_MODEL);
}
} }
break; break;
case ITEM_PHASES_FADE_IN: case ITEM_PHASES_FADE_IN:
lcd_outdezAtt(32*FW-2, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1); lcd_outdezAtt(32*FW-2, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1);
if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS); if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);

View file

@ -1167,20 +1167,16 @@ void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags at
{ {
trim_t v = getRawTrimValue(phase, idx); trim_t v = getRawTrimValue(phase, idx);
putsChnLetter(x, y, idx+1, att);
if (v.mode < 0) { if (v.mode < 0) {
lcd_putsAtt(x+FWNUM, y, "--", att); lcd_putsAtt(x, y, "--", att);
} }
else { else {
uint8_t p = v.mode >> 1; uint8_t p = v.mode >> 1;
if (v.mode % 2 == 0) { if (v.mode % 2 == 0)
lcd_putcAtt(x+FWNUM, y, '+', att); lcd_putcAtt(x+2, y, ':', att);
} else
else { lcd_putcAtt(x, y, '+', att);
lcd_putcAtt(x+FWNUM, y, ':', att); lcd_putcAtt(x+FW, y, '0'+p, att);
}
lcd_putcAtt(x+2*FWNUM, y, '0'+p, att);
} }
} }
#else #else

View file

@ -1667,9 +1667,9 @@ int getTrimValue(uint8_t phase, uint8_t idx)
else { else {
phase = p; phase = p;
if (v.mode % 2 == 0) if (v.mode % 2 == 0)
result += v.value;
else
result = 0; result = 0;
else
result += v.value;
} }
} }
} }
@ -1692,11 +1692,11 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim)
break;; break;;
} }
else if (v.mode % 2 == 0) { else if (v.mode % 2 == 0) {
v.value = limit<int>(-500, trim - getTrimValue(p, idx), 500); phase = p;
break;
} }
else { else {
phase = p; v.value = limit<int>(-500, trim - getTrimValue(p, idx), 500);
break;
} }
} }
#elif defined(PCBSTD) #elif defined(PCBSTD)

View file

@ -707,7 +707,7 @@
#endif #endif
// Taranis column headers // Taranis column headers
#define TR_PHASES_HEADERS { " Name ", " Switch ", " Trims ", " Fade In ", " Fade Out " } #define TR_PHASES_HEADERS { " Name ", " Switch ", " Rudder Trim ", " Elevator Trim ", " Throttle Trim ", " Aileron Trim ", " Fade In ", " Fade Out " }
#define TR_LIMITS_HEADERS { " Name ", " Subtrim ", " Min ", " Max ", " Direction ", " Curve ", " PPM Center ", " Subtrim mode " } #define TR_LIMITS_HEADERS { " Name ", " Subtrim ", " Min ", " Max ", " Direction ", " Curve ", " PPM Center ", " Subtrim mode " }
#define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " AND Switch ", " Duration ", " Delay " } #define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " AND Switch ", " Duration ", " Delay " }