Merge branch 'next'
This commit is contained in:
+2
-2
@@ -1078,7 +1078,7 @@ MSG_CLEANING = Cleaning project:
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
|
||||
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS)
|
||||
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) -fdata-sections -ffunction-sections $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS)
|
||||
AVRCPPFLAGS = -mmcu=$(MCU) -I. -x c++ -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS) -fwhole-program
|
||||
|
||||
ifeq ($(ARCH), AVR)
|
||||
@@ -1349,7 +1349,7 @@ OBJS = $(TMP:.s=.o)
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $@
|
||||
$(CC) $(ARMCPPFLAGS) $< -o allsrc.o
|
||||
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@
|
||||
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@
|
||||
endif
|
||||
|
||||
# Target: clean project.
|
||||
|
||||
@@ -333,7 +333,7 @@ void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
|
||||
{
|
||||
char * str = getModelPath(filename);
|
||||
int len = STR_VSWITCHES[0];
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_CSW-1)], len);
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH-1)], len);
|
||||
str += len;
|
||||
strcpy(str, suffixes[event]);
|
||||
strcat(str, SOUNDS_EXT);
|
||||
@@ -369,7 +369,7 @@ void referenceModelAudioFiles()
|
||||
if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
|
||||
|
||||
// Phases Audio Files <phasename>-[on|off].wav
|
||||
for (int i=0; i<MAX_PHASES && !found; i++) {
|
||||
for (int i=0; i<MAX_FLIGHT_MODES && !found; i++) {
|
||||
for (int event=0; event<2; event++) {
|
||||
getPhaseAudioFile(path, i, event);
|
||||
if (!strcasecmp(filename, fn)) {
|
||||
|
||||
@@ -225,7 +225,7 @@ PACK(typedef struct {
|
||||
LogicalSwitchData_v215 customSw[NUM_LOGICAL_SWITCH];
|
||||
CustomFnData_v215 funcSw[32];
|
||||
SwashRingData swashR;
|
||||
PhaseData_v215 phaseData[MAX_PHASES];
|
||||
PhaseData_v215 phaseData[MAX_FLIGHT_MODES];
|
||||
|
||||
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5ms increments
|
||||
uint8_t thrTraceSrc;
|
||||
|
||||
@@ -629,13 +629,13 @@ TEST(Mixer, SlowOnPhase)
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
s_perout_flight_phase = 0;
|
||||
s_perout_flight_mode = 0;
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 250);
|
||||
|
||||
s_perout_flight_phase = 1;
|
||||
s_perout_flight_mode = 1;
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
}
|
||||
|
||||
@@ -663,11 +663,11 @@ TEST(Mixer, SlowOnSwitchAndPhase)
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
s_perout_flight_phase = 0;
|
||||
s_perout_flight_mode = 0;
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 250);
|
||||
|
||||
simuSetSwitch(0, -1);
|
||||
s_perout_flight_phase = 1;
|
||||
s_perout_flight_mode = 1;
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1067,7 +1067,7 @@ void menuModelSetup(uint8_t event)
|
||||
div_t qr = div(timer->start, 60);
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1/*--- which is OFF*/);
|
||||
CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
||||
@@ -1108,7 +1108,7 @@ void menuModelSetup(uint8_t event)
|
||||
s_editMode = 0;
|
||||
if (event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
s_noHi = NO_HI_LEN;
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
memclear(&g_model.phaseData[i], TRIMS_ARRAY_SIZE);
|
||||
}
|
||||
eeDirty(EE_MODEL);
|
||||
@@ -1757,7 +1757,7 @@ uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, cons
|
||||
|
||||
void displayFlightModes(uint8_t x, uint8_t y, FlightModesType value)
|
||||
{
|
||||
uint8_t p = MAX_PHASES;
|
||||
uint8_t p = MAX_FLIGHT_MODES;
|
||||
do {
|
||||
--p;
|
||||
if (!(value & (1<<p)))
|
||||
@@ -1781,7 +1781,7 @@ FlightModesType editFlightModes(uint8_t x, uint8_t y, uint8_t event, FlightModes
|
||||
bool expoMenu = (x==EXPO_ONE_2ND_COLUMN-5*FW);
|
||||
#endif
|
||||
|
||||
for (uint8_t p=0; p<MAX_PHASES; p++) {
|
||||
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
|
||||
#if defined(CPUARM) && LCD_W < 212
|
||||
if (expoMenu && ((attr && p < posHorz-4) || (x > EXPO_ONE_2ND_COLUMN-FW)))
|
||||
continue;
|
||||
@@ -1835,14 +1835,14 @@ bool isTrimModeAvailable(int mode)
|
||||
|
||||
void menuModelFlightModesAll(uint8_t event)
|
||||
{
|
||||
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});
|
||||
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_FLIGHT_MODES+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;
|
||||
|
||||
horzpos_t posHorz = m_posHorz;
|
||||
if (sub==0 && posHorz > 0) { posHorz += 5; }
|
||||
|
||||
if (sub<MAX_PHASES && posHorz>=0) {
|
||||
if (sub<MAX_FLIGHT_MODES && posHorz>=0) {
|
||||
displayColumnHeader(STR_PHASES_HEADERS, posHorz);
|
||||
}
|
||||
|
||||
@@ -1850,11 +1850,11 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
uint8_t y = 1 + (i+1)*FH;
|
||||
uint8_t k = i+s_pgOfs;
|
||||
|
||||
if (k==MAX_PHASES) {
|
||||
if (k==MAX_FLIGHT_MODES) {
|
||||
// last line available - add the "check trims" line
|
||||
lcd_putsLeft((LCD_LINES-1)*FH+1, STR_CHECKTRIMS);
|
||||
putsFlightPhase(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_phase+1);
|
||||
if (sub==MAX_PHASES && !trimsCheckTimer) {
|
||||
putsFlightMode(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_mode+1);
|
||||
if (sub==MAX_FLIGHT_MODES && !trimsCheckTimer) {
|
||||
lcd_status_line();
|
||||
}
|
||||
return;
|
||||
@@ -1862,7 +1862,7 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
|
||||
PhaseData *p = phaseAddress(k);
|
||||
|
||||
putsFlightPhase(0, y, k+1, (getFlightPhase()==k ? BOLD : 0) | ((sub==k && m_posHorz<0) ? INVERS : 0));
|
||||
putsFlightMode(0, y, k+1, (getFlightPhase()==k ? BOLD : 0) | ((sub==k && m_posHorz<0) ? INVERS : 0));
|
||||
|
||||
for (uint8_t j=0; j<ITEM_PHASES_COUNT; j++) {
|
||||
uint8_t attr = ((sub==k && posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||
@@ -1878,7 +1878,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, SWSRC_FIRST, SWSRC_LAST);
|
||||
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_SHORT_LIST, SWSRC_LAST_SHORT_LIST);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1891,7 +1891,7 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
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==TRIM_MODE_NONE ? -1 : v.mode, -1, 2*MAX_PHASES-1, EE_MODEL, isTrimModeAvailable);
|
||||
v.mode = checkIncDec(event, v.mode==TRIM_MODE_NONE ? -1 : v.mode, -1, 2*MAX_FLIGHT_MODES-1, EE_MODEL, isTrimModeAvailable);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1933,7 +1933,7 @@ enum menuModelPhaseItems {
|
||||
void menuModelPhaseOne(uint8_t event)
|
||||
{
|
||||
PhaseData *phase = phaseAddress(s_currIdx);
|
||||
putsFlightPhase(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0));
|
||||
putsFlightMode(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0));
|
||||
|
||||
#if defined(GVARS) && !defined(PCBSTD)
|
||||
static const pm_uint8_t mstate_tab_phase1[] PROGMEM = {0, 0, 0, (uint8_t)-1, 1, 1, 1, 1, 1};
|
||||
@@ -1979,7 +1979,7 @@ void menuModelPhaseOne(uint8_t event)
|
||||
if (attr && m_posHorz==t && ((editMode>0) || p1valdiff)) {
|
||||
int16_t v = getRawTrimValue(s_currIdx, t);
|
||||
if (v < TRIM_EXTENDED_MAX) v = TRIM_EXTENDED_MAX;
|
||||
v = checkIncDec(event, v, TRIM_EXTENDED_MAX, TRIM_EXTENDED_MAX+MAX_PHASES-1, EE_MODEL);
|
||||
v = checkIncDec(event, v, TRIM_EXTENDED_MAX, TRIM_EXTENDED_MAX+MAX_FLIGHT_MODES-1, EE_MODEL);
|
||||
if (checkIncDec_Ret) {
|
||||
if (v == TRIM_EXTENDED_MAX) v = 0;
|
||||
setTrimValue(s_currIdx, t, v);
|
||||
@@ -2004,7 +2004,7 @@ void menuModelPhaseOne(uint8_t event)
|
||||
int16_t v = phaseAddress(s_currIdx)->rotaryEncoders[t];
|
||||
#endif
|
||||
if (v < ROTARY_ENCODER_MAX) v = ROTARY_ENCODER_MAX;
|
||||
v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_PHASES-1, EE_MODEL);
|
||||
v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_FLIGHT_MODES-1, EE_MODEL);
|
||||
if (checkIncDec_Ret) {
|
||||
if (v == ROTARY_ENCODER_MAX) v = 0;
|
||||
#if ROTARY_ENCODERS > 2
|
||||
@@ -2048,14 +2048,14 @@ void menuModelPhaseOne(uint8_t event)
|
||||
if (v > GVAR_MAX) {
|
||||
uint8_t p = v - GVAR_MAX - 1;
|
||||
if (p >= s_currIdx) p++;
|
||||
putsFlightPhase(11*FW, y, p+1, posHorz==1 ? attr : 0);
|
||||
putsFlightMode(11*FW, y, p+1, posHorz==1 ? attr : 0);
|
||||
}
|
||||
else {
|
||||
lcd_putsAtt(11*FW, y, STR_OWN, posHorz==1 ? attr : 0);
|
||||
}
|
||||
if (attr && s_currIdx>0 && posHorz==1 && (editMode>0 || p1valdiff)) {
|
||||
if (v < GVAR_MAX) v = GVAR_MAX;
|
||||
v = checkIncDec(event, v, GVAR_MAX, GVAR_MAX+MAX_PHASES-1, EE_MODEL);
|
||||
v = checkIncDec(event, v, GVAR_MAX, GVAR_MAX+MAX_FLIGHT_MODES-1, EE_MODEL);
|
||||
if (checkIncDec_Ret) {
|
||||
if (v == GVAR_MAX) v = 0;
|
||||
phase->gvars[idx] = v;
|
||||
@@ -2095,20 +2095,20 @@ void menuModelPhaseOne(uint8_t event)
|
||||
|
||||
void menuModelFlightModesAll(uint8_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_PHASES+1);
|
||||
SIMPLE_MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_FLIGHT_MODES+1);
|
||||
|
||||
int8_t sub = m_posVert - 1;
|
||||
|
||||
switch (event) {
|
||||
CASE_EVT_ROTARY_BREAK
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
if (sub == MAX_PHASES) {
|
||||
if (sub == MAX_FLIGHT_MODES) {
|
||||
s_editMode = 0;
|
||||
trimsCheckTimer = 200; // 2 seconds
|
||||
}
|
||||
// no break
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
if (sub >= 0 && sub < MAX_PHASES) {
|
||||
if (sub >= 0 && sub < MAX_FLIGHT_MODES) {
|
||||
s_currIdx = sub;
|
||||
pushMenu(menuModelPhaseOne);
|
||||
}
|
||||
@@ -2116,7 +2116,7 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
}
|
||||
|
||||
uint8_t att;
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
#if defined(CPUARM)
|
||||
int8_t y = 1 + (1+i-s_pgOfs)*FH;
|
||||
if (y<1*FH+1 || y>(LCD_LINES-1)*FH+1) continue;
|
||||
@@ -2126,9 +2126,9 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
att = (i==sub ? INVERS : 0);
|
||||
PhaseData *p = phaseAddress(i);
|
||||
#if ROTARY_ENCODERS > 2
|
||||
putsFlightPhase(0, y, i+1, att|CONDENSED|(getFlightPhase()==i ? BOLD : 0));
|
||||
putsFlightMode(0, y, i+1, att|CONDENSED|(getFlightPhase()==i ? BOLD : 0));
|
||||
#else
|
||||
putsFlightPhase(0, y, i+1, att|(getFlightPhase()==i ? BOLD : 0));
|
||||
putsFlightMode(0, y, i+1, att|(getFlightPhase()==i ? BOLD : 0));
|
||||
#endif
|
||||
|
||||
lcd_putsnAtt(4*FW+NAME_OFS, y, p->name, sizeof(p->name), ZCHAR);
|
||||
@@ -2153,12 +2153,12 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (s_pgOfs != MAX_PHASES-(LCD_LINES-2)) return;
|
||||
if (s_pgOfs != MAX_FLIGHT_MODES-(LCD_LINES-2)) return;
|
||||
#endif
|
||||
|
||||
lcd_putsLeft((LCD_LINES-1)*FH+1, STR_CHECKTRIMS);
|
||||
putsFlightPhase(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_phase+1);
|
||||
if (sub==MAX_PHASES && !trimsCheckTimer) {
|
||||
putsFlightMode(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_mode+1);
|
||||
if (sub==MAX_FLIGHT_MODES && !trimsCheckTimer) {
|
||||
lcd_status_line();
|
||||
}
|
||||
}
|
||||
@@ -2910,7 +2910,7 @@ void menuModelExpoOne(uint8_t event)
|
||||
putsMixerSource(7*FW+FW/2, 0, MIXSRC_Rud+ed->chn, 0);
|
||||
#endif
|
||||
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, {CASE_PCBTARANIS(0) IF_CPUARM(0) CASE_PCBTARANIS(0) CASE_PCBTARANIS((ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW)) 0, CASE_PCBTARANIS(0) CASE_9X(0) IF_CURVES(CURVE_ROWS) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, {CASE_PCBTARANIS(0) IF_CPUARM(0) CASE_PCBTARANIS(0) CASE_PCBTARANIS((ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW)) 0, CASE_PCBTARANIS(0) CASE_9X(0) IF_CURVES(CURVE_ROWS) IF_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
|
||||
SET_SCROLLBAR_X(EXPO_ONE_2ND_COLUMN+10*FW);
|
||||
|
||||
@@ -3111,11 +3111,11 @@ void menuModelMixOne(uint8_t event)
|
||||
#else
|
||||
if (m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS)
|
||||
#endif
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(0) IF_CURVES(0) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/})
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(0) IF_CURVES(0) IF_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/})
|
||||
else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) IF_CURVES(1) IF_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
#else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) CASE_PCBTARANIS(0) IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) CASE_PCBTARANIS(0) IF_CURVES(1) IF_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
#endif
|
||||
|
||||
#if MENU_COLUMNS > 1
|
||||
@@ -3314,7 +3314,7 @@ static uint8_t s_copySrcCh;
|
||||
#define EXPO_LINE_WEIGHT_POS 7*FW+1
|
||||
#define EXPO_LINE_EXPO_POS 11*FW
|
||||
#define EXPO_LINE_SWITCH_POS 11*FW+4
|
||||
#if MAX_PHASES == 6
|
||||
#if MAX_FLIGHT_MODES == 6
|
||||
#define EXPO_LINE_SIDE_POS 15*FW
|
||||
#else
|
||||
#define EXPO_LINE_SIDE_POS 15*FW+2
|
||||
@@ -4102,7 +4102,7 @@ void onGVARSMenu(const char *result)
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
else if (result == STR_CLEAR) {
|
||||
for (int i=0; i<MAX_PHASES; i++) {
|
||||
for (int i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
g_model.phaseData[i].gvars[sub] = 0;
|
||||
}
|
||||
eeDirty(EE_MODEL);
|
||||
@@ -4127,7 +4127,7 @@ void menuModelGVars(uint8_t event)
|
||||
menuTitle = STR_MENUGLOBALVARS;
|
||||
}
|
||||
|
||||
MENU_FLAGS(menuTitle, menuTabModel, e_GVars, first2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES});
|
||||
MENU_FLAGS(menuTitle, menuTabModel, e_GVars, first2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -4146,7 +4146,7 @@ void menuModelGVars(uint8_t event)
|
||||
if (g_model.gvars[i].popup) lcd_putc(3*FW, y, '!');
|
||||
putsStrIdx(0, y, STR_GV, i+1, (sub==i && m_posHorz<0) ? INVERS : 0);
|
||||
|
||||
for (uint8_t j=0; j<1+MAX_PHASES; j++) {
|
||||
for (uint8_t j=0; j<1+MAX_FLIGHT_MODES; j++) {
|
||||
LcdFlags attr = ((sub==i && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||
xcoord_t x = GVARS_FM_COLUMN(j-1);
|
||||
|
||||
@@ -4170,8 +4170,8 @@ void menuModelGVars(uint8_t event)
|
||||
if (v > GVAR_MAX) {
|
||||
uint8_t p = v - GVAR_MAX - 1;
|
||||
if (p >= j-1) p++;
|
||||
putsFlightPhase(x-15, y, p+1, attr|SMLSIZE);
|
||||
vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_PHASES-1;
|
||||
putsFlightMode(x-15, y, p+1, attr|SMLSIZE);
|
||||
vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_FLIGHT_MODES-1;
|
||||
}
|
||||
else {
|
||||
if (abs(v) >= 100)
|
||||
@@ -4967,10 +4967,11 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
{
|
||||
INCDEC_DECLARE_VARS();
|
||||
int16_t val_displayed = CFN_PARAM(sd);
|
||||
int8_t val_min = 0;
|
||||
#if defined(CPUARM)
|
||||
int16_t val_min = 0;
|
||||
int16_t val_max = 255;
|
||||
#else
|
||||
int8_t val_min = 0;
|
||||
uint8_t val_max = 255;
|
||||
#endif
|
||||
if (func == FUNC_SAFETY_CHANNEL) {
|
||||
@@ -5084,7 +5085,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
switch (CFN_GVAR_MODE(sd)) {
|
||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
val_displayed = (int8_t)CFN_PARAM(sd);
|
||||
val_min = -125; val_max = 125;
|
||||
val_min = -CFN_GVAR_CST_MAX; val_max = +CFN_GVAR_CST_MAX;
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_SOURCE:
|
||||
|
||||
@@ -1132,7 +1132,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, SWSRC_FIRST, SWSRC_LAST);
|
||||
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_SHORT_LIST, SWSRC_LAST_SHORT_LIST);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1152,11 +1152,11 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m
|
||||
s_editMode = !s_editMode;
|
||||
#if defined(CPUARM)
|
||||
if (attr & PREC1)
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase)*10 : delta);
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode)*10 : delta);
|
||||
else
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode) : delta);
|
||||
#else
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode) : delta);
|
||||
#endif
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
@@ -1500,8 +1500,8 @@ bool isSwitchAvailable(int swtch)
|
||||
swtch = -swtch;
|
||||
}
|
||||
|
||||
if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) {
|
||||
LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_CSW);
|
||||
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
|
||||
LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH);
|
||||
return (cs->func != LS_FUNC_NONE);
|
||||
}
|
||||
|
||||
|
||||
@@ -650,7 +650,7 @@ void menuMainView(uint8_t event)
|
||||
|
||||
{
|
||||
// Flight Phase Name
|
||||
uint8_t phase = s_perout_flight_phase;
|
||||
uint8_t phase = s_perout_flight_mode;
|
||||
lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR|PHASE_FLAGS);
|
||||
|
||||
// Model Name
|
||||
@@ -862,13 +862,13 @@ void menuMainView(uint8_t event)
|
||||
putsStrIdx(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, s_gvar_last+1);
|
||||
lcd_putsnAtt(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
|
||||
lcd_putsAtt(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("[\010]"), BOLD);
|
||||
lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
|
||||
lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, s_perout_flight_mode), BOLD);
|
||||
#else
|
||||
s_warning = STR_GLOBAL_VAR;
|
||||
displayBox();
|
||||
lcd_putsnAtt(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
|
||||
lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD);
|
||||
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
|
||||
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_mode), BOLD);
|
||||
s_warning = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
+6
-1
@@ -1020,11 +1020,16 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
lcd_putcAtt(x-2, y, '!', att);
|
||||
idx = -idx;
|
||||
}
|
||||
#if defined(CPUARM) && defined(FLIGHT_MODES)
|
||||
if (idx >= SWSRC_FIRST_FLIGHT_MODE)
|
||||
putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
|
||||
else
|
||||
#endif
|
||||
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
|
||||
}
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; }
|
||||
if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); idx = -idx; }
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ void putsStrIdx(xcoord_t x, uint8_t y, const pm_char *str, uint8_t idx, LcdFlags
|
||||
void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att);
|
||||
void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0);
|
||||
void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0);
|
||||
void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
|
||||
void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
|
||||
#if defined(PCBTARANIS) && !defined(BOOT)
|
||||
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
|
||||
#endif
|
||||
|
||||
+26
-1
@@ -741,6 +741,29 @@ static int luaModelSetOutput(lua_State *L)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaModelGetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS)
|
||||
lua_pushinteger(L, g_model.phaseData[phase].gvars[idx]);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int luaModelSetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
int value = luaL_checkinteger(L, 3);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_LIMIT && value <= GVAR_LIMIT) {
|
||||
g_model.phaseData[phase].gvars[idx] = value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaPopupInput(lua_State *L)
|
||||
{
|
||||
uint8_t event = luaL_checkinteger(L, 2);
|
||||
@@ -849,6 +872,8 @@ static const luaL_Reg modelLib[] = {
|
||||
{ "setCustomFunction", luaModelSetCustomFunction },
|
||||
{ "getOutput", luaModelGetOutput },
|
||||
{ "setOutput", luaModelSetOutput },
|
||||
{ "getGlobalVariable", luaModelGetGlobalVariable },
|
||||
{ "setGlobalVariable", luaModelSetGlobalVariable },
|
||||
{ NULL, NULL } /* sentinel */
|
||||
};
|
||||
|
||||
@@ -901,7 +926,7 @@ void luaInit()
|
||||
lua_registerint(L, "STICK_ELEVATOR", MIXSRC_Ele);
|
||||
lua_registerint(L, "STICK_THROTTLE", MIXSRC_Thr);
|
||||
lua_registerint(L, "STICK_AILERON", MIXSRC_Ail);
|
||||
lua_registerint(L, "SWITCH_LAST", SWSRC_LAST_CSW);
|
||||
lua_registerint(L, "SWITCH_LAST", SWSRC_LAST_LOGICAL_SWITCH);
|
||||
lua_registerint(L, "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU));
|
||||
lua_registerint(L, "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE));
|
||||
lua_registerint(L, "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER));
|
||||
|
||||
+29
-16
@@ -73,7 +73,7 @@
|
||||
#if defined(PCBTARANIS)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
#define MAX_PHASES 9
|
||||
#define MAX_FLIGHT_MODES 9
|
||||
#define MAX_MIXERS 64
|
||||
#define MAX_EXPOS 64
|
||||
#define NUM_LOGICAL_SWITCH 32 // number of custom switches
|
||||
@@ -86,7 +86,7 @@
|
||||
#elif defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
#define MAX_PHASES 9
|
||||
#define MAX_FLIGHT_MODES 9
|
||||
#define MAX_MIXERS 64
|
||||
#define MAX_EXPOS 32
|
||||
#define NUM_LOGICAL_SWITCH 32 // number of custom switches
|
||||
@@ -97,7 +97,7 @@
|
||||
#elif defined(CPUM2560) || defined(CPUM2561)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 6
|
||||
#define MAX_FLIGHT_MODES 6
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 16
|
||||
#define NUM_LOGICAL_SWITCH 15 // number of custom switches
|
||||
@@ -108,7 +108,7 @@
|
||||
#elif defined(CPUM128)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_FLIGHT_MODES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_LOGICAL_SWITCH 15 // number of custom switches
|
||||
@@ -119,7 +119,7 @@
|
||||
#else
|
||||
#define MAX_MODELS 16
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_FLIGHT_MODES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_LOGICAL_SWITCH 12 // number of custom switches
|
||||
@@ -522,9 +522,9 @@ PACK(typedef struct t_ExpoData {
|
||||
#define limit_min_max_t int16_t
|
||||
#define LIMIT_EXT_PERCENT 150
|
||||
#define LIMIT_EXT_MAX (LIMIT_EXT_PERCENT*10)
|
||||
#define LIMIT_MAX(lim) (GV_IS_GV_VALUE(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_phase)*10 : lim->max+1000)
|
||||
#define LIMIT_MIN(lim) (GV_IS_GV_VALUE(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_phase)*10 : lim->min-1000)
|
||||
#define LIMIT_OFS(lim) (GV_IS_GV_VALUE(lim->offset, -1000, 1000) ? GET_GVAR(lim->offset, -1000, 1000, s_perout_flight_phase)*10 : lim->offset)
|
||||
#define LIMIT_MAX(lim) (GV_IS_GV_VALUE(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_mode)*10 : lim->max+1000)
|
||||
#define LIMIT_MIN(lim) (GV_IS_GV_VALUE(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_mode)*10 : lim->min-1000)
|
||||
#define LIMIT_OFS(lim) (GV_IS_GV_VALUE(lim->offset, -1000, 1000) ? GET_GVAR(lim->offset, -1000, 1000, s_perout_flight_mode)*10 : lim->offset)
|
||||
#define LIMIT_MAX_RESX(lim) calc1000toRESX(LIMIT_MAX(lim))
|
||||
#define LIMIT_MIN_RESX(lim) calc1000toRESX(LIMIT_MIN(lim))
|
||||
#define LIMIT_OFS_RESX(lim) calc1000toRESX(LIMIT_OFS(lim))
|
||||
@@ -692,7 +692,7 @@ PACK(typedef struct t_MixData {
|
||||
PACK( union u_gvarint_t {
|
||||
struct {
|
||||
int8_t lo;
|
||||
uint8_t hi;
|
||||
uint8_t hi;
|
||||
} bytes_t;
|
||||
int16_t word;
|
||||
|
||||
@@ -916,6 +916,7 @@ PACK(typedef struct t_CustomFnData { // Function Switches data
|
||||
#define CFN_GVAR_MODE(p) ((p)->all.mode)
|
||||
#define CFN_PARAM(p) ((p)->all.val)
|
||||
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
|
||||
#define CFN_GVAR_CST_MAX GVAR_LIMIT
|
||||
#else
|
||||
PACK(typedef struct t_CustomFnData {
|
||||
PACK(union {
|
||||
@@ -948,6 +949,7 @@ PACK(typedef struct t_CustomFnData {
|
||||
#define CFN_GVAR_MODE(p) ((p)->gvar.mode)
|
||||
#define CFN_PARAM(p) ((p)->value)
|
||||
#define CFN_RESET(p) ((p)->all.active = 0, CFN_PARAM(p) = 0)
|
||||
#define CFN_GVAR_CST_MAX 125
|
||||
#endif
|
||||
|
||||
enum TelemetryUnit {
|
||||
@@ -1244,7 +1246,7 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
|
||||
#define NUM_ROTARY_ENCODERS_EXTRA 2
|
||||
#define NUM_ROTARY_ENCODERS (2+NUM_ROTARY_ENCODERS_EXTRA)
|
||||
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[2];
|
||||
#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_PHASES][NUM_ROTARY_ENCODERS_EXTRA];
|
||||
#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_FLIGHT_MODES][NUM_ROTARY_ENCODERS_EXTRA];
|
||||
#elif defined(CPUM2560) && ROTARY_ENCODERS <= 2
|
||||
#define NUM_ROTARY_ENCODERS_EXTRA 0
|
||||
#define NUM_ROTARY_ENCODERS 2
|
||||
@@ -1369,8 +1371,8 @@ enum SwitchSources {
|
||||
SWSRC_REb,
|
||||
#endif
|
||||
|
||||
SWSRC_FIRST_CSW,
|
||||
SWSRC_SW1 = SWSRC_FIRST_CSW,
|
||||
SWSRC_FIRST_LOGICAL_SWITCH,
|
||||
SWSRC_SW1 = SWSRC_FIRST_LOGICAL_SWITCH,
|
||||
SWSRC_SW2,
|
||||
SWSRC_SW3,
|
||||
SWSRC_SW4,
|
||||
@@ -1382,13 +1384,24 @@ enum SwitchSources {
|
||||
SWSRC_SWA,
|
||||
SWSRC_SWB,
|
||||
SWSRC_SWC,
|
||||
SWSRC_LAST_CSW = SWSRC_SW1+NUM_LOGICAL_SWITCH-1,
|
||||
SWSRC_LAST_LOGICAL_SWITCH = SWSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1,
|
||||
|
||||
SWSRC_ON,
|
||||
|
||||
#if defined(CPUARM)
|
||||
SWSRC_FIRST_FLIGHT_MODE,
|
||||
SWSRC_LAST_FLIGHT_MODE = SWSRC_FIRST_FLIGHT_MODE+MAX_FLIGHT_MODES-1,
|
||||
#endif
|
||||
|
||||
SWSRC_COUNT,
|
||||
|
||||
SWSRC_OFF = -SWSRC_ON,
|
||||
|
||||
SWSRC_FIRST = SWSRC_OFF,
|
||||
SWSRC_LAST = SWSRC_ON
|
||||
SWSRC_LAST = SWSRC_COUNT-1,
|
||||
SWSRC_FIRST = -SWSRC_LAST,
|
||||
|
||||
SWSRC_LAST_SHORT_LIST = SWSRC_LAST_LOGICAL_SWITCH,
|
||||
SWSRC_FIRST_SHORT_LIST = -SWSRC_LAST_SHORT_LIST,
|
||||
};
|
||||
|
||||
enum MixSources {
|
||||
@@ -1680,7 +1693,7 @@ PACK(typedef struct t_ModelData {
|
||||
LogicalSwitchData customSw[NUM_LOGICAL_SWITCH];
|
||||
CustomFnData funcSw[NUM_CFN];
|
||||
SwashRingData swashR;
|
||||
PhaseData phaseData[MAX_PHASES];
|
||||
PhaseData phaseData[MAX_FLIGHT_MODES];
|
||||
|
||||
AVR_FIELD(int8_t ppmFrameLength) // 0=22.5ms (10ms-30ms) 0.5ms increments
|
||||
uint8_t thrTraceSrc;
|
||||
|
||||
+81
-58
@@ -319,7 +319,8 @@ void per10ms()
|
||||
if (lightOffCounter) lightOffCounter--;
|
||||
if (flashCounter) flashCounter--;
|
||||
if (s_noHi) s_noHi--;
|
||||
if (trimsCheckTimer) trimsCheckTimer --;
|
||||
if (trimsCheckTimer) trimsCheckTimer--;
|
||||
if (ppmInValid) ppmInValid--;
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
/* Update global Date/Time every 100 per10ms cycles */
|
||||
@@ -768,7 +769,7 @@ int applyCurve(int x, CurveRef & curve)
|
||||
switch (curve.type) {
|
||||
case CURVE_REF_DIFF:
|
||||
{
|
||||
int curveParam = calc100to256(GET_GVAR(curve.value, -100, 100, s_perout_flight_phase));
|
||||
int curveParam = calc100to256(GET_GVAR(curve.value, -100, 100, s_perout_flight_mode));
|
||||
if (curveParam > 0 && x < 0)
|
||||
x = (x * (256 - curveParam)) >> 8;
|
||||
else if (curveParam < 0 && x > 0)
|
||||
@@ -777,7 +778,7 @@ int applyCurve(int x, CurveRef & curve)
|
||||
}
|
||||
|
||||
case CURVE_REF_EXPO:
|
||||
return expo(x, GET_GVAR(curve.value, -100, 100, s_perout_flight_phase));
|
||||
return expo(x, GET_GVAR(curve.value, -100, 100, s_perout_flight_mode));
|
||||
|
||||
case CURVE_REF_FUNC:
|
||||
switch (curve.value) {
|
||||
@@ -980,7 +981,7 @@ void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
||||
if (!EXPO_VALID(ed)) break; // end of list
|
||||
if (ed->chn == cur_chn)
|
||||
continue;
|
||||
if (ed->phases & (1<<s_perout_flight_phase))
|
||||
if (ed->phases & (1<<s_perout_flight_mode))
|
||||
continue;
|
||||
if (getSwitch(ed->swtch)) {
|
||||
#if defined(PCBTARANIS)
|
||||
@@ -1019,18 +1020,18 @@ void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
||||
if (ed->curveMode == MODE_CURVE)
|
||||
v = applyCurve(v, curveParam);
|
||||
else
|
||||
v = expo(v, GET_GVAR(curveParam, -100, 100, s_perout_flight_phase));
|
||||
v = expo(v, GET_GVAR(curveParam, -100, 100, s_perout_flight_mode));
|
||||
}
|
||||
#endif
|
||||
|
||||
//========== WEIGHT ===============
|
||||
int16_t weight = GET_GVAR(ed->weight, MIN_EXPO_WEIGHT, 100, s_perout_flight_phase);
|
||||
int16_t weight = GET_GVAR(ed->weight, MIN_EXPO_WEIGHT, 100, s_perout_flight_mode);
|
||||
weight = calc100to256(weight);
|
||||
v = ((int32_t)v * weight) >> 8;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
//========== OFFSET ===============
|
||||
int16_t offset = GET_GVAR(ed->offset, -100, 100, s_perout_flight_phase);
|
||||
int16_t offset = GET_GVAR(ed->offset, -100, 100, s_perout_flight_mode);
|
||||
if (offset) v += calc100toRESX(offset);
|
||||
|
||||
//========== TRIMS ================
|
||||
@@ -1267,7 +1268,7 @@ getvalue_t getValue(uint8_t i)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
else if (i<=MIXSRC_TrimAil) return calc1000toRESX((int16_t)8 * getTrimValue(s_perout_flight_phase, i-MIXSRC_TrimRud));
|
||||
else if (i<=MIXSRC_TrimAil) return calc1000toRESX((int16_t)8 * getTrimValue(s_perout_flight_mode, i-MIXSRC_TrimRud));
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
else if (i==MIXSRC_SA) return (switchState(SW_SA0) ? -1024 : (switchState(SW_SA1) ? 0 : 1024));
|
||||
@@ -1278,7 +1279,7 @@ getvalue_t getValue(uint8_t i)
|
||||
else if (i==MIXSRC_SF) return (switchState(SW_SF0) ? -1024 : 1024);
|
||||
else if (i==MIXSRC_SG) return (switchState(SW_SG0) ? -1024 : (switchState(SW_SG1) ? 0 : 1024));
|
||||
else if (i==MIXSRC_SH) return (switchState(SW_SH0) ? -1024 : 1024);
|
||||
else if (i<=MIXSRC_LAST_LOGICAL_SWITCH) return getSwitch(SWSRC_FIRST_CSW+i-MIXSRC_FIRST_LOGICAL_SWITCH) ? 1024 : -1024;
|
||||
else if (i<=MIXSRC_LAST_LOGICAL_SWITCH) return getSwitch(SWSRC_FIRST_LOGICAL_SWITCH+i-MIXSRC_FIRST_LOGICAL_SWITCH) ? 1024 : -1024;
|
||||
#else
|
||||
else if (i==MIXSRC_3POS) return (getSwitch(SW_ID0-SW_BASE+1) ? -1024 : (getSwitch(SW_ID1-SW_BASE+1) ? 0 : 1024));
|
||||
// don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning
|
||||
@@ -1293,7 +1294,7 @@ getvalue_t getValue(uint8_t i)
|
||||
else if (i<=MIXSRC_LAST_CH) return ex_chans[i-MIXSRC_CH1];
|
||||
|
||||
#if defined(GVARS)
|
||||
else if (i<=MIXSRC_LAST_GVAR) return GVAR_VALUE(i-MIXSRC_GVAR1, getGVarFlightPhase(s_perout_flight_phase, i-MIXSRC_GVAR1));
|
||||
else if (i<=MIXSRC_LAST_GVAR) return GVAR_VALUE(i-MIXSRC_GVAR1, getGVarFlightPhase(s_perout_flight_mode, i-MIXSRC_GVAR1));
|
||||
#endif
|
||||
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE) return g_vbat100mV;
|
||||
@@ -1512,9 +1513,15 @@ bool getSwitch(int8_t swtch)
|
||||
else if (cs_idx == SWSRC_REb) {
|
||||
result = REB_DOWN();
|
||||
}
|
||||
#endif
|
||||
#if defined(CPUARM) && defined(FLIGHT_MODES)
|
||||
else if (cs_idx >= SWSRC_FIRST_FLIGHT_MODE) {
|
||||
uint8_t idx = cs_idx - SWSRC_FIRST_FLIGHT_MODE;
|
||||
result = (idx == s_perout_flight_mode);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
cs_idx -= SWSRC_FIRST_CSW;
|
||||
cs_idx -= SWSRC_FIRST_LOGICAL_SWITCH;
|
||||
|
||||
GETSWITCH_RECURSIVE_TYPE mask = ((GETSWITCH_RECURSIVE_TYPE)1 << cs_idx);
|
||||
if (s_last_switch_used & mask) {
|
||||
@@ -1800,7 +1807,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||
#if defined(FLIGHT_MODES)
|
||||
uint8_t getFlightPhase()
|
||||
{
|
||||
for (uint8_t i=1; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=1; i<MAX_FLIGHT_MODES; i++) {
|
||||
PhaseData *phase = &g_model.phaseData[i];
|
||||
if (phase->swtch && getSwitch(phase->swtch)) {
|
||||
return i;
|
||||
@@ -1824,7 +1831,7 @@ int getTrimValue(uint8_t phase, uint8_t idx)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
int result = 0;
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
trim_t v = getRawTrimValue(phase, idx);
|
||||
if (v.mode == TRIM_MODE_NONE) {
|
||||
return result;
|
||||
@@ -1851,7 +1858,7 @@ int getTrimValue(uint8_t phase, uint8_t idx)
|
||||
void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
trim_t & v = phaseAddress(phase)->trim[idx];
|
||||
if (v.mode == TRIM_MODE_NONE)
|
||||
return;
|
||||
@@ -1883,7 +1890,7 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
||||
#if !defined(PCBTARANIS)
|
||||
uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx)
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
if (phase == 0) return 0;
|
||||
trim_t trim = getRawTrimValue(phase, idx);
|
||||
if (trim <= TRIM_EXTENDED_MAX) return phase;
|
||||
@@ -1898,8 +1905,8 @@ uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx)
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
uint8_t getRotaryEncoderFlightPhase(uint8_t idx)
|
||||
{
|
||||
uint8_t phase = s_perout_flight_phase;
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
uint8_t phase = s_perout_flight_mode;
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
if (phase == 0) return 0;
|
||||
#if ROTARY_ENCODERS > 2
|
||||
int16_t value;
|
||||
@@ -1989,7 +1996,7 @@ uint8_t s_gvar_last = 0;
|
||||
|
||||
uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx)
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
if (phase == 0) return 0;
|
||||
int16_t val = GVAR_VALUE(idx, phase); // TODO phase at the end everywhere to be consistent!
|
||||
if (val <= GVAR_MAX) return phase;
|
||||
@@ -2144,7 +2151,7 @@ getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value)
|
||||
result = value * 5;
|
||||
break;
|
||||
case TELEM_CONSUMPTION:
|
||||
result = value * 20;
|
||||
result = value * 100;
|
||||
break;
|
||||
case TELEM_VSPEED:
|
||||
result = ((getvalue_t)value - 125) * 10;
|
||||
@@ -2690,13 +2697,13 @@ uint8_t checkTrim(uint8_t event)
|
||||
#if defined(PCBSTD)
|
||||
phase = 0;
|
||||
#else
|
||||
phase = getGVarFlightPhase(s_perout_flight_phase, trimGvar[idx]);
|
||||
phase = getGVarFlightPhase(s_perout_flight_mode, trimGvar[idx]);
|
||||
#endif
|
||||
before = GVAR_VALUE(trimGvar[idx], phase);
|
||||
thro = false;
|
||||
}
|
||||
else {
|
||||
phase = getTrimFlightPhase(s_perout_flight_phase, idx);
|
||||
phase = getTrimFlightPhase(s_perout_flight_mode, idx);
|
||||
#if defined(PCBTARANIS)
|
||||
before = getTrimValue(phase, idx);
|
||||
#else
|
||||
@@ -2705,7 +2712,7 @@ uint8_t checkTrim(uint8_t event)
|
||||
thro = (idx==THR_STICK && g_model.thrTrim);
|
||||
}
|
||||
#else
|
||||
phase = getTrimFlightPhase(s_perout_flight_phase, idx);
|
||||
phase = getTrimFlightPhase(s_perout_flight_mode, idx);
|
||||
#if defined(PCBTARANIS)
|
||||
before = getTrimValue(phase, idx);
|
||||
#else
|
||||
@@ -3080,7 +3087,7 @@ uint16_t isqrt32(uint32_t n)
|
||||
|
||||
FORCEINLINE void evalTrims()
|
||||
{
|
||||
uint8_t phase = s_perout_flight_phase;
|
||||
uint8_t phase = s_perout_flight_mode;
|
||||
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
||||
// do trim -> throttle trim if applicable
|
||||
int16_t trim = getTrimValue(phase, i);
|
||||
@@ -3196,7 +3203,7 @@ void evalInputs(uint8_t mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch)) {
|
||||
if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch) && ppmInValid) {
|
||||
// trainer mode
|
||||
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
||||
if (td->mode) {
|
||||
@@ -3530,14 +3537,14 @@ void evalFunctions()
|
||||
#if defined(GVARS)
|
||||
case FUNC_ADJUST_GVAR:
|
||||
if (CFN_GVAR_MODE(sd) == 0) {
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), CFN_PARAM(sd), s_perout_flight_phase);
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), CFN_PARAM(sd), s_perout_flight_mode);
|
||||
}
|
||||
else if (CFN_GVAR_MODE(sd) == 2) {
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_phase), s_perout_flight_phase);
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_mode), s_perout_flight_mode);
|
||||
}
|
||||
else if (CFN_GVAR_MODE(sd) == 3) {
|
||||
if (!(activeFnSwitches & switch_mask)) {
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_GVAR_INDEX(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_INDEX(sd))) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_phase);
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_GVAR_INDEX(sd), getGVarFlightPhase(s_perout_flight_mode, CFN_GVAR_INDEX(sd))) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_mode);
|
||||
}
|
||||
}
|
||||
else if (CFN_PARAM(sd) >= MIXSRC_TrimRud && CFN_PARAM(sd) <= MIXSRC_TrimAil) {
|
||||
@@ -3547,12 +3554,12 @@ void evalFunctions()
|
||||
else if (CFN_PARAM(sd) >= MIXSRC_REa && CFN_PARAM(sd) < MIXSRC_TrimRud) {
|
||||
int8_t scroll = rePreviousValues[CFN_PARAM(sd)-MIXSRC_REa] - (g_rotenc[CFN_PARAM(sd)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY);
|
||||
if (scroll) {
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_GVAR_INDEX(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_INDEX(sd))) + scroll, s_perout_flight_phase);
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), GVAR_VALUE(CFN_GVAR_INDEX(sd), getGVarFlightPhase(s_perout_flight_mode, CFN_GVAR_INDEX(sd))) + scroll, s_perout_flight_mode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), limit((getvalue_t)-LIMIT_EXT_MAX, getValue(CFN_PARAM(sd)), (getvalue_t)LIMIT_EXT_MAX) / 10, s_perout_flight_phase);
|
||||
SET_GVAR(CFN_GVAR_INDEX(sd), limit((getvalue_t)-LIMIT_EXT_MAX, getValue(CFN_PARAM(sd)), (getvalue_t)LIMIT_EXT_MAX) / 10, s_perout_flight_mode);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -3635,7 +3642,7 @@ void evalFunctions()
|
||||
else {
|
||||
#if defined(GVARS)
|
||||
if (CFN_FUNC(sd) == FUNC_PLAY_TRACK && param > 250)
|
||||
param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_phase, param-251));
|
||||
param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_mode, param-251));
|
||||
#endif
|
||||
PUSH_CUSTOM_PROMPT(active ? param : param+1, i+1);
|
||||
}
|
||||
@@ -3716,7 +3723,7 @@ void evalFunctions()
|
||||
#define HELI_ANAS_ARRAY anas
|
||||
#endif
|
||||
|
||||
uint8_t s_perout_flight_phase;
|
||||
uint8_t s_perout_flight_mode;
|
||||
void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
{
|
||||
evalInputs(mode);
|
||||
@@ -3821,7 +3828,11 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
|
||||
//========== PHASE && SWITCH =====
|
||||
bool mixCondition = (md->phases != 0 || md->swtch);
|
||||
delayval_t mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(md->swtch);
|
||||
delayval_t mixEnabled = !(md->phases & (1 << s_perout_flight_mode)) && getSwitch(md->swtch);
|
||||
|
||||
if (mixEnabled && md->srcRaw >= MIXSRC_FIRST_TRAINER && md->srcRaw <= MIXSRC_LAST_TRAINER && !ppmInValid) {
|
||||
mixEnabled = 0;
|
||||
}
|
||||
|
||||
//========== VALUE ===============
|
||||
getvalue_t v = 0;
|
||||
@@ -3906,14 +3917,14 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
if (apply_offset_and_curve) {
|
||||
#if !defined(PCBTARANIS) // OFFSET is now applied AFTER weight on Taranis
|
||||
//========== OFFSET / SOURCE ===============
|
||||
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
|
||||
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_mode);
|
||||
if (offset) v += calc100toRESX_16Bits(offset);
|
||||
#endif
|
||||
|
||||
//========== TRIMS ================
|
||||
if (!(mode & e_perout_mode_notrims)) {
|
||||
#if defined(PCBTARANIS)
|
||||
if (!md->carryTrim) {
|
||||
if (md->carryTrim == 0) {
|
||||
int8_t mix_trim;
|
||||
if (stickIndex < NUM_STICKS)
|
||||
mix_trim = stickIndex;
|
||||
@@ -3921,7 +3932,13 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
mix_trim = virtualInputsTrims[md->srcRaw-1];
|
||||
else
|
||||
mix_trim = -1;
|
||||
if (mix_trim >= 0) v += trims[mix_trim];
|
||||
if (mix_trim >= 0) {
|
||||
int16_t trim = trims[mix_trim];
|
||||
if (mix_trim == THR_STICK && g_model.throttleReversed)
|
||||
v -= trim;
|
||||
else
|
||||
v += trim;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int8_t mix_trim = md->carryTrim;
|
||||
@@ -3931,13 +3948,19 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
mix_trim = stickIndex;
|
||||
else
|
||||
mix_trim = -1;
|
||||
if (mix_trim >= 0) v += trims[mix_trim];
|
||||
if (mix_trim >= 0) {
|
||||
int16_t trim = trims[mix_trim];
|
||||
if (mix_trim == THR_STICK && g_model.throttleReversed)
|
||||
v -= trim;
|
||||
else
|
||||
v += trim;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// saves 12 bytes code if done here and not together with weight; unknown reason
|
||||
int16_t weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
|
||||
int16_t weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_mode);
|
||||
weight = calc100to256_16Bits(weight);
|
||||
|
||||
//========== SPEED ===============
|
||||
@@ -3998,7 +4021,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
//========== OFFSET / AFTER ===============
|
||||
#if defined(PCBTARANIS)
|
||||
if (apply_offset_and_curve) {
|
||||
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
|
||||
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_mode);
|
||||
if (offset) dv += calc100toRESX_16Bits(offset) << 8;
|
||||
}
|
||||
#endif
|
||||
@@ -4011,7 +4034,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
#else
|
||||
if (md->curveMode == MODE_DIFFERENTIAL) {
|
||||
// @@@2 also recalculate curveParam to a 256 basis which ease the calculation later a lot
|
||||
int16_t curveParam = calc100to256(GET_GVAR(md->curveParam, -100, 100, s_perout_flight_phase));
|
||||
int16_t curveParam = calc100to256(GET_GVAR(md->curveParam, -100, 100, s_perout_flight_mode));
|
||||
if (curveParam > 0 && dv < 0)
|
||||
dv = (dv * (256 - curveParam)) >> 8;
|
||||
else if (curveParam < 0 && dv > 0)
|
||||
@@ -4140,7 +4163,7 @@ void doMixerCalculations()
|
||||
#endif
|
||||
|
||||
#define MAX_ACT 0xffff
|
||||
static uint16_t fp_act[MAX_PHASES] = {0};
|
||||
static uint16_t fp_act[MAX_FLIGHT_MODES] = {0};
|
||||
static uint16_t delta = 0;
|
||||
static ACTIVE_PHASES_TYPE s_fade_flight_phases = 0;
|
||||
static uint8_t s_last_phase = 255; // TODO reinit everything here when the model changes, no???
|
||||
@@ -4175,10 +4198,10 @@ void doMixerCalculations()
|
||||
int32_t weight = 0;
|
||||
if (s_fade_flight_phases) {
|
||||
memclear(sum_chans512, sizeof(sum_chans512));
|
||||
for (uint8_t p=0; p<MAX_PHASES; p++) {
|
||||
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
|
||||
s_last_switch_used = 0;
|
||||
if (s_fade_flight_phases & ((ACTIVE_PHASES_TYPE)1 << p)) {
|
||||
s_perout_flight_phase = p;
|
||||
s_perout_flight_mode = p;
|
||||
perOut(p==phase ? e_perout_mode_normal : e_perout_mode_inactive_phase, p==phase ? tick10ms : 0);
|
||||
for (uint8_t i=0; i<NUM_CHNOUT; i++)
|
||||
sum_chans512[i] += (chans[i] >> 4) * fp_act[p];
|
||||
@@ -4187,10 +4210,10 @@ void doMixerCalculations()
|
||||
s_last_switch_used = 0;
|
||||
}
|
||||
assert(weight);
|
||||
s_perout_flight_phase = phase;
|
||||
s_perout_flight_mode = phase;
|
||||
}
|
||||
else {
|
||||
s_perout_flight_phase = phase;
|
||||
s_perout_flight_mode = phase;
|
||||
perOut(e_perout_mode_normal, tick10ms);
|
||||
}
|
||||
|
||||
@@ -4522,7 +4545,7 @@ void doMixerCalculations()
|
||||
|
||||
if (s_fade_flight_phases) {
|
||||
uint16_t tick_delta = delta * tick10ms;
|
||||
for (uint8_t p=0; p<MAX_PHASES; p++) {
|
||||
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
|
||||
ACTIVE_PHASES_TYPE phaseMask = ((ACTIVE_PHASES_TYPE)1 << p);
|
||||
if (s_fade_flight_phases & phaseMask) {
|
||||
if (p == phase) {
|
||||
@@ -5046,6 +5069,7 @@ void perMain()
|
||||
|
||||
int16_t g_ppmIns[NUM_TRAINER];
|
||||
uint8_t ppmInState = 0; // 0=unsync 1..8= wait for value i-1
|
||||
uint8_t ppmInValid = 0;
|
||||
|
||||
#if !defined(SIMU) && !defined(CPUARM)
|
||||
|
||||
@@ -5132,19 +5156,18 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
|
||||
|
||||
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if (val>4000 && val < 16000) // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
if (val>4000 && val < 16000) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
else
|
||||
{
|
||||
if (ppmInState && ppmInState<=8)
|
||||
{
|
||||
if (val>800 && val<2200) // if valid pulse-width range
|
||||
{
|
||||
g_ppmIns[ppmInState++ - 1] =
|
||||
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else {
|
||||
if (ppmInState>0 && ppmInState<=8) {
|
||||
if (val>800 && val<2200) { // if valid pulse-width range
|
||||
ppmInValid = 100;
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500) * (uint8_t)(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else
|
||||
else {
|
||||
ppmInState = 0; // not triggered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5215,7 +5238,7 @@ void instantTrim()
|
||||
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
||||
if (i!=THR_STICK) {
|
||||
// don't instant trim the throttle stick
|
||||
uint8_t trim_phase = getTrimFlightPhase(s_perout_flight_phase, i);
|
||||
uint8_t trim_phase = getTrimFlightPhase(s_perout_flight_mode, i);
|
||||
#if defined(PCBTARANIS)
|
||||
int16_t trim = limit<int16_t>(TRIM_EXTENDED_MIN, (calibratedStick[i] + trims[i]) / 2, TRIM_EXTENDED_MAX);
|
||||
#else
|
||||
@@ -5279,8 +5302,8 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||
// reset all trims, except throttle (if throttle trim)
|
||||
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
||||
if (i!=THR_STICK || !g_model.thrTrim) {
|
||||
int16_t original_trim = getTrimValue(s_perout_flight_phase, i);
|
||||
for (uint8_t phase=0; phase<MAX_PHASES; phase++) {
|
||||
int16_t original_trim = getTrimValue(s_perout_flight_mode, i);
|
||||
for (uint8_t phase=0; phase<MAX_FLIGHT_MODES; phase++) {
|
||||
#if defined(PCBTARANIS)
|
||||
trim_t trim = getRawTrimValue(phase, i);
|
||||
if (trim.mode / 2 == phase)
|
||||
|
||||
+2
-1
@@ -647,7 +647,7 @@ enum StartupWarningStates {
|
||||
#define FORCE_INDIRECT(ptr) __asm__ __volatile__ ("" : "=e" (ptr) : "0" (ptr))
|
||||
#endif
|
||||
|
||||
extern uint8_t s_perout_flight_phase;
|
||||
extern uint8_t s_perout_flight_mode;
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define bitfield_channels_t uint32_t
|
||||
@@ -1013,6 +1013,7 @@ extern uint8_t g_beepCnt;
|
||||
extern uint8_t g_beepVal[5];
|
||||
|
||||
extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
|
||||
extern uint8_t ppmInValid;
|
||||
extern int16_t g_ppmIns[NUM_TRAINER];
|
||||
extern int32_t chans[NUM_CHNOUT];
|
||||
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
|
||||
|
||||
@@ -314,15 +314,14 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && ppmInState<=16)
|
||||
{
|
||||
if (val>800 && val<2200) // if valid pulse-width range
|
||||
{
|
||||
g_ppmIns[ppmInState++ - 1] =
|
||||
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
if (ppmInState>0 && ppmInState<=16) {
|
||||
if (val>800 && val<2200) { // if valid pulse-width range
|
||||
ppmInValid = 100;
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else
|
||||
else {
|
||||
ppmInState = 0; // not triggered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,12 +126,13 @@ extern "C" void TIM3_IRQHandler()
|
||||
|
||||
// We process g_ppmInsright here to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && (ppmInState<=16)) {
|
||||
if ((val>800) && (val<2200)) {
|
||||
if (ppmInState>0 && ppmInState<=16) {
|
||||
if (val>800 && val<2200) {
|
||||
ppmInValid = 100;
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -294,9 +294,13 @@
|
||||
#define TR_A3_A4_MIN
|
||||
#endif
|
||||
|
||||
#define TR_ASPD_MAX "ASp+"
|
||||
#define TR_ASPD_MAX TR("ASp+", "ASpd+")
|
||||
|
||||
#define TR_VTELEMCHNS "---\0""Batt""Tmr1""Tmr2" TR_SWR "Tx\0 ""Rx\0 " TR_RX_BATT "A1\0 ""A2\0 " TR_A3_A4 "Höjd""Varv""Tank""T1\0 ""T2\0 ""Fart""Avst""GHjd""Batt""Cels""Vfas""Curr""Cnsp""Powr""AccX""AccY""AccZ""Hdg\0""VFrt""ASpd""dTE\0" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "A1-\0""A2-\0" TR_A3_A4_MIN "Hjd-""Hjd+""Rpm+""T1+\0""T2+\0""Frt+""Avs+" TR_ASPD_MAX "Cel-""Cls-""Vfs-""Cur+""Pwr+" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "Acc\0""Tid\0"
|
||||
#if LCD_W >= 212
|
||||
#define TR_VTELEMCHNS "---\0 ""Batt\0""Tmr1\0""Tmr2\0" TR_SWR "Tx\0 ""Rx\0 " TR_RX_BATT "A1\0 ""A2\0 " TR_A3_A4 "Alt\0 ""Rpm\0 ""Fuel\0""T1\0 ""T2\0 ""Spd\0 ""Dist\0""GAlt\0""Cell\0""Cells""Vfas\0""Curr\0""Cnsp\0""Powr\0""AccX\0""AccY\0""AccZ\0""Hdg\0 ""VSpd\0""ASpd\0""dTE\0 " TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "A1-\0 ""A2-\0 " TR_A3_A4_MIN "Alt-\0""Alt+\0""Rpm+\0""T1+\0 ""T2+\0 ""Spd+\0""Dst+\0" TR_ASPD_MAX "Cell-""Cels-""Vfas-""Curr+""Powr+" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "Acc\0 ""Time\0"
|
||||
#else
|
||||
#define TR_VTELEMCHNS "---\0""Batt""Tmr1""Tmr2" TR_SWR "Tx\0 ""Rx\0 " TR_RX_BATT "A1\0 ""A2\0 " TR_A3_A4 "Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""GAlt""Cell""Cels""Vfas""Curr""Cnsp""Powr""AccX""AccY""AccZ""Hdg\0""VSpd""ASpd""dTE\0" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "A1-\0""A2-\0" TR_A3_A4_MIN "Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+" TR_ASPD_MAX "Cel-""Cls-""Vfs-""Cur+""Pwr+" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "Acc\0""Time"
|
||||
#endif
|
||||
|
||||
#define LENGTH_UNIT_IMP "ft\0"
|
||||
#define SPEED_UNIT_IMP "mph"
|
||||
@@ -415,7 +419,7 @@
|
||||
#define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]"
|
||||
#endif
|
||||
|
||||
#define TR_VSRCRAW "---\0""Rod\0""Hjd\0""Gas\0""Ske\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODER "MAX " TR_CYC_VSRCRAW "TrmR" "TrmH" "TrmG" "TrmS" TR_SW_VSRCRAW
|
||||
#define TR_VSRCRAW "---\0""Rod\0""Hjd\0""Gas\0""Ske\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmH" "TrmG" "TrmS" TR_SW_VSRCRAW
|
||||
|
||||
#define LEN_VTMRMODES "\003"
|
||||
#define TR_VTMRMODES "Av\0""ABS""GAs""GA%""GAt"
|
||||
@@ -440,7 +444,6 @@
|
||||
#define LEN_INDENT 1
|
||||
#define INDENT_WIDTH (FW/2)
|
||||
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define TR_ENTER "[ENTER]"
|
||||
#else
|
||||
@@ -475,7 +478,7 @@
|
||||
#define TR_TTRIM TR("Gastrim", INDENT "Gastrim")
|
||||
#define TR_BEEPCTR TR("Cent.pip", "Centerpip")
|
||||
#define TR_PROTO TR(INDENT "Proto", INDENT "Protokoll")
|
||||
#define TR_PPMFRAME "PPM-paket"
|
||||
#define TR_PPMFRAME TR(INDENT "PPM-paket", INDENT "PPM-paket")
|
||||
#define TR_MS "ms"
|
||||
#define TR_SWITCH "Brytare"
|
||||
#define TR_TRIMS "Trimmar"
|
||||
@@ -851,7 +854,6 @@
|
||||
#define TR_ABOUT_HARDWARE_3 ""
|
||||
#endif
|
||||
|
||||
|
||||
#define TR_ABOUT_PARENTS_1 "Ursprungsprojekt"
|
||||
#define TR_ABOUT_PARENTS_2 "ersky9x (Mike Blandford)"
|
||||
#define TR_ABOUT_PARENTS_3 "ER9X (Erez Raviv)"
|
||||
@@ -874,4 +876,4 @@
|
||||
#define TR_VIEW_CHANNELS "Visa Kanaler"
|
||||
#define TR_VIEW_NOTES "Visa Noteringars"
|
||||
#define TR_MODS_FORBIDDEN "Modifikationer förbjudna!"
|
||||
#define TR_UNLOCKED "Olåst"
|
||||
#define TR_UNLOCKED "Olåst"
|
||||
Reference in New Issue
Block a user