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

Throttle trim - Fixes 5635 (#7677)

Add throttle trim switch
This commit is contained in:
DanielGeA 2020-10-04 08:46:47 +01:00 committed by GitHub
parent 5ec01f90cf
commit 78ccc22eac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 503 additions and 255 deletions

View file

@ -182,6 +182,7 @@ class ModelData {
unsigned int thrTraceSrc;
uint64_t switchWarningStates;
unsigned int switchWarningEnable;
unsigned int thrTrimSwitch;
unsigned int potsWarningMode;
bool potsWarnEnabled[CPN_MAX_POTS];
int potsWarnPosition[CPN_MAX_POTS];

View file

@ -2421,7 +2421,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig
internalField.Append(new UnsignedField<2>(this, modelData.potsWarningMode));
}
else {
internalField.Append(new SpareBitsField<6>(this));
internalField.Append(new SpareBitsField<3>(this));
internalField.Append(new UnsignedField<3>(this, modelData.thrTrimSwitch));
internalField.Append(new UnsignedField<2>(this, modelData.potsWarningMode));
}

View file

@ -1276,6 +1276,14 @@ void SetupPanel::on_throttleSource_currentIndexChanged(int index)
}
}
void SetupPanel::on_throttleTrimSwitch_currentIndexChanged(int index)
{
if (!lock) {
model->thrTrimSwitch = ui->throttleTrimSwitch->currentData().toUInt();
emit modified();
}
}
void SetupPanel::on_name_editingFinished()
{
if (QString(model->name) != ui->name->text()) {
@ -1348,11 +1356,29 @@ void SetupPanel::populateThrottleSourceCB()
lock = false;
}
void SetupPanel::populateThrottleTrimSwitchCB()
{
Board::Type board = firmware->getBoard();
lock = true;
ui->throttleTrimSwitch->clear();
int idx=0;
for (int i=0; i<getBoardCapability(board, Board::NumTrims); i++, idx++) {
QString trim = RawSource(SOURCE_TYPE_TRIM, i).toString(model, &generalSettings);
trim = (trim == "TrmR") ? "TrmT" : (trim == "TmrT") ? "TmrR" : trim;
ui->throttleTrimSwitch->addItem(trim, idx);
}
int thrTrimSwitchIdx = ui->throttleTrimSwitch->findData(model->thrTrimSwitch);
ui->throttleTrimSwitch->setCurrentIndex(thrTrimSwitchIdx);
lock = false;
}
void SetupPanel::update()
{
ui->name->setText(model->name);
ui->throttleReverse->setChecked(model->throttleReversed);
populateThrottleSourceCB();
populateThrottleTrimSwitchCB();
ui->throttleWarning->setChecked(!model->disableThrottleWarning);
ui->trimIncrement->setCurrentIndex(model->trimInc+2);
ui->throttleTrim->setChecked(model->thrTrim);

View file

@ -138,6 +138,7 @@ class SetupPanel : public ModelPanel
private slots:
void on_name_editingFinished();
void on_throttleSource_currentIndexChanged(int index);
void on_throttleTrimSwitch_currentIndexChanged(int index);
void on_throttleTrim_toggled(bool checked);
void on_extendedLimits_toggled(bool checked);
void on_extendedTrims_toggled(bool checked);
@ -176,6 +177,7 @@ class SetupPanel : public ModelPanel
void updatePotWarnings();
void updateBeepCenter();
void populateThrottleSourceCB();
void populateThrottleTrimSwitchCB();
int timersCount;
int selectedTimerIndex;
bool hasTimerClipboardData(QByteArray * data = nullptr) const;

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>893</width>
<width>1007</width>
<height>405</height>
</rect>
</property>
@ -32,22 +32,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="toplcdTimerLabel">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Top LCD Timer</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
@ -149,6 +133,106 @@
</item>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Model</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_timer3">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Timer 3</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ttrace">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Throttle Source</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Trim Step</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTrimsDisplay">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Trims Display</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="toplcdTimerLabel">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Top LCD Timer</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="QLabel" name="swwarn_label">
<property name="sizePolicy">
@ -171,6 +255,66 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="AutoComboBox" name="toplcdTimer">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QGridLayout" name="centerBeepLayout"/>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="7" column="1">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label_timer2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Timer 2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
@ -275,44 +419,8 @@
</item>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Model</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QGridLayout" name="centerBeepLayout"/>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_3">
<item row="5" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -334,86 +442,13 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="3">
<widget class="QCheckBox" name="displayText">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Display Checklist</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="AutoComboBox" name="trimsDisplay">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Never</string>
</property>
</item>
<item>
<property name="text">
<string>On change</string>
</property>
</item>
<item>
<property name="text">
<string>Always</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="throttleTrim">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Trim Idle Only</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="gfEnabled">
<property name="text">
<string>Global Functions</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="throttleWarning">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Warning</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="throttleSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0,0,0,0">
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="5">
<widget class="QComboBox" name="throttleTrimSwitch"/>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="trimIncrement">
@ -450,6 +485,81 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="AutoComboBox" name="trimsDisplay">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Never</string>
</property>
</item>
<item>
<property name="text">
<string>On change</string>
</property>
</item>
<item>
<property name="text">
<string>Always</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="throttleWarning">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Warning</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="displayText">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Display Checklist</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="gfEnabled">
<property name="text">
<string>Global Functions</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="editText">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit Checklist...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="throttleTrim">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Trim Idle Only</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="throttleReverse">
<property name="whatsThis">
@ -466,16 +576,10 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="editText">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="0" column="4">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Edit Checklist...</string>
<string>Throttle trim switch</string>
</property>
</widget>
</item>
@ -499,7 +603,17 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="1" column="5">
<item row="0" column="0">
<widget class="QComboBox" name="throttleSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -514,107 +628,6 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ttrace">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Throttle Source</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Trim Step</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTrimsDisplay">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Trims Display</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label_timer2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Timer 2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_timer3">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Timer 3</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="AutoComboBox" name="toplcdTimer">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -605,8 +605,9 @@ PACK(struct ModelData {
NOBACKUP(RssiAlarmData rssiAlarms);
NOBACKUP(uint8_t spare1:6);
NOBACKUP(uint8_t potsWarnMode:2);
uint8_t spare1:3;
uint8_t thrTrimSw:3;
uint8_t potsWarnMode:2;
ModuleData moduleData[NUM_MODULES];
int16_t failsafeChannels[MAX_OUTPUT_CHANNELS];
@ -625,6 +626,20 @@ PACK(struct ModelData {
CUSTOM_SCREENS_DATA
char modelRegistrationID[PXX2_LEN_REGISTRATION_ID];
uint8_t getThrottleStickTrimSource() const
{
// The order here is TERA, so that 0 (default) means Throttle
switch (thrTrimSw) {
case 0:
return MIXSRC_TrimThr;
case 2:
return MIXSRC_TrimRud;
default:
return thrTrimSw + MIXSRC_FIRST_TRIM;
}
}
});
/*

View file

@ -66,6 +66,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_THROTTLE_REVERSED,
ITEM_MODEL_SETUP_THROTTLE_TRACE,
ITEM_MODEL_SETUP_THROTTLE_TRIM,
ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH,
ITEM_MODEL_SETUP_PREFLIGHT_LABEL,
ITEM_MODEL_SETUP_CHECKLIST_DISPLAY,
ITEM_MODEL_SETUP_THROTTLE_WARNING,
@ -354,6 +355,7 @@ void menuModelSetup(event_t event)
0, // Throttle reverse
0, // Throttle trace source
0, // Throttle trim
0, // Throttle trim switch
LABEL(PreflightCheck),
0, // Checklist
@ -405,6 +407,7 @@ void menuModelSetup(event_t event)
0, // Throttle reverse
0, // Throttle trace source
0, // Throttle trim
0, // Throttle trim switch
LABEL(PreflightCheck),
0, // Checklist
@ -617,6 +620,13 @@ void menuModelSetup(event_t event)
ON_OFF_MENU_ITEM(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawTextAlignedLeft(y, STR_TTRIM_SW);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, NUM_TRIMS - 1);
drawSource(MODEL_SETUP_2ND_COLUMN, y, g_model.getThrottleStickTrimSource(), attr);
break;
case ITEM_MODEL_SETUP_PREFLIGHT_LABEL:
lcdDrawTextAlignedLeft(y, STR_PREFLIGHT);
break;

View file

@ -66,6 +66,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_THROTTLE_REVERSED,
ITEM_MODEL_SETUP_THROTTLE_TRACE,
ITEM_MODEL_SETUP_THROTTLE_TRIM,
ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH,
ITEM_MODEL_SETUP_PREFLIGHT_LABEL,
ITEM_MODEL_SETUP_CHECKLIST_DISPLAY,
ITEM_MODEL_SETUP_THROTTLE_WARNING,
@ -344,6 +345,7 @@ void menuModelSetup(event_t event)
0, // Thrxottle reverse
0, // Throttle trace source
0, // Throttle trim
0, // Throttle trim switch
LABEL(PreflightCheck),
0, // Checklist
@ -571,6 +573,13 @@ void menuModelSetup(event_t event)
ON_OFF_MENU_ITEM(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawTextAlignedLeft(y, STR_TTRIM_SW);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, NUM_TRIMS - 1);
drawSource(MODEL_SETUP_2ND_COLUMN, y, g_model.getThrottleStickTrimSource(), attr);
break;
case ITEM_MODEL_SETUP_PREFLIGHT_LABEL:
lcdDrawTextAlignedLeft(y, STR_PREFLIGHT);
break;

View file

@ -53,6 +53,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_THROTTLE_REVERSED,
ITEM_MODEL_SETUP_THROTTLE_TRACE,
ITEM_MODEL_SETUP_THROTTLE_TRIM,
ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH,
ITEM_MODEL_SETUP_PREFLIGHT_LABEL,
ITEM_MODEL_SETUP_CHECKLIST_DISPLAY,
ITEM_MODEL_SETUP_THROTTLE_WARNING,
@ -614,6 +615,7 @@ bool menuModelSetup(event_t event)
0, // Throttle reverse
0, // Throttle trace source
0, // Throttle trim
0, // Throttle trim switch
LABEL(PreflightCheck),
0, // Display checklist
@ -835,6 +837,13 @@ bool menuModelSetup(event_t event)
g_model.thrTrim = editCheckBox(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TTRIM_SW);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, NUM_TRIMS - 1);
drawSource(MODEL_SETUP_2ND_COLUMN, y, g_model.getThrottleStickTrimSource(), attr);
break;
case ITEM_MODEL_SETUP_PREFLIGHT_LABEL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PREFLIGHT);
break;

View file

@ -527,13 +527,13 @@ int getStickTrimValue(int stick, int stickValue)
return 0;
int trim = trims[stick];
if (stick == THR_STICK) {
if (g_model.thrTrim) {
int trimMin = g_model.extendedTrims ? 2*TRIM_EXTENDED_MIN : 2*TRIM_MIN;
trim = ((g_model.throttleReversed ? (trim+trimMin) : (trim-trimMin)) * (RESX-stickValue)) >> (RESX_SHIFT+1);
}
if (g_model.throttleReversed) {
uint8_t thrTrimSw = g_model.getThrottleStickTrimSource() - MIXSRC_FIRST_TRIM;
if (stick == thrTrimSw) {
if (g_model.throttleReversed)
trim = -trim;
if (g_model.thrTrim) {
trim = (g_model.extendedTrims) ? 2*TRIM_EXTENDED_MAX + trim : 2*TRIM_MAX + trim;
trim = trim * (1024 - stickValue) / (2*RESX);
}
}
return trim;

View file

@ -720,3 +720,152 @@ TEST_F(MixerTest, flightModeOverflow)
simuSetSwitch(0, 1);
CHECK_FLIGHT_MODE_TRANSITION(0, 1000, 1024, 1024);
}
TEST_F(TrimsTest, throttleTrimWithCrossTrims)
{
g_model.thrTrim = 1;
g_model.thrTrimSw = MIXSRC_TrimEle - MIXSRC_FIRST_TRIM;
ExpoData *expo = expoAddress(THR_STICK);
expo->carryTrim = TRIM_ELE;
expo = expoAddress(ELE_STICK);
expo->carryTrim = TRIM_THR;
// stick max + trim max
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], 1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim min
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], 1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim max
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024 + 500);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim mid
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, 0);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024 + 250);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim min
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
EXPECT_EQ(channelOutputs[1], 0);
// now the same tests with extended Trims
g_model.extendedTrims = 1;
// stick max + trim max
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], 1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim min
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], 1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim max
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+2000);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim mid
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, 0);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+1000);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim min
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
EXPECT_EQ(channelOutputs[1], 0);
}
TEST_F(TrimsTest, invertedThrottlePlusThrottleTrimWithCrossTrims)
{
g_model.throttleReversed = 1;
g_model.thrTrim = 1;
g_model.thrTrimSw = MIXSRC_TrimEle - MIXSRC_FIRST_TRIM;
ExpoData *expo = expoAddress(THR_STICK);
expo->carryTrim = TRIM_ELE;
expo = expoAddress(ELE_STICK);
expo->carryTrim = TRIM_THR;
// stick max + trim max
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim mid
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, 0);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+250);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim min
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+500);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim max
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim min
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
EXPECT_EQ(channelOutputs[1], 0);
// now the same tests with extended Trims
g_model.extendedTrims = 1;
// stick max + trim max
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim mid
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, 0);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+1000);
EXPECT_EQ(channelOutputs[1], 0);
// stick max + trim min
anaInValues[THR_STICK] = +1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024+2000);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim max
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MAX);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
EXPECT_EQ(channelOutputs[1], 0);
// stick min + trim min
anaInValues[THR_STICK] = -1024;
setTrimValue(0, MIXSRC_TrimEle - MIXSRC_FIRST_TRIM, TRIM_EXTENDED_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
EXPECT_EQ(channelOutputs[1], 0);
}

View file

@ -123,6 +123,7 @@ const char STR_TRIMINC[] = TR_TRIMINC;
const char STR_DISPLAY_TRIMS[] = TR_DISPLAY_TRIMS;
const char STR_TTRACE[] = TR_TTRACE;
const char STR_TTRIM[] = TR_TTRIM;
const char STR_TTRIM_SW[] = TR_TTRIM_SW;
const char STR_BEEPCTR[] = TR_BEEPCTR;
const char STR_USE_GLOBAL_FUNCS[] = TR_USE_GLOBAL_FUNCS;
const char STR_PPMFRAME[] = TR_PPMFRAME;

View file

@ -215,6 +215,7 @@ extern const char STR_TRIMINC[];
extern const char STR_DISPLAY_TRIMS[];
extern const char STR_TTRACE[];
extern const char STR_TTRIM[];
extern const char STR_TTRIM_SW[];
extern const char STR_BEEPCTR[];
extern const char STR_USE_GLOBAL_FUNCS[];

View file

@ -432,6 +432,7 @@
#define TR_DISPLAY_TRIMS TR3("Číslo v Trm", "Zobr.hodnotu trimu", "Číslo v liště trimu")
#define TR_TTRACE TR("StopaPlynu", INDENT "Stopa plynu")
#define TR_TTRIM TR3("TrimVolnob.", INDENT "Trim jen volnoběh", "Trim jen pro volnoběh")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR3("Středy \221\222", "Pípat středy \221\222", "Pípat středy")
#define TR_USE_GLOBAL_FUNCS TR("Glob.Funkce", "Použít Glob.Funkce")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -434,6 +434,7 @@
#define TR_DISPLAY_TRIMS TR("Trimanzeige", "Trimwerte anzeigen")
#define TR_TTRACE TR("Gasquelle", INDENT "Gas-Timerquelle")
#define TR_TTRIM TR("Gastrim", INDENT "Gas-Leerlauftrim")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("MittePieps", "Mittelstell. -Pieps")
#define TR_USE_GLOBAL_FUNCS TR("Glob. Funkt.", "Globale Funkt verw.")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -432,7 +432,8 @@
#define TR_TRIMINC "Trim Step"
#define TR_DISPLAY_TRIMS TR("Show Trims", "Display trims")
#define TR_TTRACE TR("T-Source", INDENT "Source")
#define TR_TTRIM TR("T-Trim", INDENT "Trim idle only")
#define TR_TTRIM TR("T-Trim-Idle", INDENT "Trim idle only")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Ctr Beep", "Center Beep")
#define TR_USE_GLOBAL_FUNCS TR("Glob.Funcs", "Use global funcs")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -432,6 +432,7 @@
#define TR_DISPLAY_TRIMS "Ver trims"
#define TR_TTRACE TR("Fuente-A", INDENT "Fuente acelerador")
#define TR_TTRIM TR("Trim-A", INDENT "Trim acelerador")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Beep ctr", "Beep centro")
#define TR_USE_GLOBAL_FUNCS TR("Funcs. glob.", "Usar func. globales")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -446,6 +446,7 @@
#define TR_DISPLAY_TRIMS "Display Trims"
#define TR_TTRACE TR("T-Source", INDENT "Throttle Source")
#define TR_TTRIM TR("T-Trim", INDENT "Throttle Trim")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Ctr Beep", "Center Beep")
#define TR_USE_GLOBAL_FUNCS "Use Global Funcs"
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -452,6 +452,7 @@
#define TR_DISPLAY_TRIMS TR("Aff. trims", "Affichage trims")
#define TR_TTRACE TR("Source gaz", INDENT "Source")
#define TR_TTRIM TR("Trim gaz", INDENT "Trim ralenti uniq.")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Bips centr", "Bips centrage")
#define TR_USE_GLOBAL_FUNCS TR("Fonc. glob.", "Fonctions globales")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -454,6 +454,7 @@
#define TR_DISPLAY_TRIMS TR("Mos. Trims", "Mostra Trims")
#define TR_TTRACE TR("So. motore", INDENT "Sorgente Motore")
#define TR_TTRIM TR("Trim Mot.", INDENT "Trim Motore")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Beep al c.", "Beep al centro")
#define TR_USE_GLOBAL_FUNCS "Usa Funz. Globali"
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -433,6 +433,7 @@
#define TR_DISPLAY_TRIMS "Toon Trims"
#define TR_TTRACE TR("T-Source", INDENT "Source")
#define TR_TTRIM TR("T-Trim", INDENT "Trim Idle Only")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Ctr Beep", "Center Beep")
#define TR_USE_GLOBAL_FUNCS TR("Glob.Funcs", "Globale Functies")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -453,6 +453,7 @@
#define TR_DISPLAY_TRIMS TR("Pok.Trym.","Pokaż Trymery")
#define TR_TTRACE TR("Źród gaz", INDENT "Źródło gazu ")
#define TR_TTRIM TR("TryGaz", INDENT "TrymWolnObrotó")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("ŚrodBeep", "Pikn.Środka")
#define TR_USE_GLOBAL_FUNCS TR("Funk.Glb.","Użyj Funkcji Glb")
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -439,6 +439,7 @@
#define TR_DISPLAY_TRIMS "Display Trims"
#define TR_TTRACE TR("T-Trace", INDENT "T-Trace")
#define TR_TTRIM TR("T-Trim", INDENT "T-Trim")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR "Ctr Beep"
#define TR_USE_GLOBAL_FUNCS "Use Global Funcs"
#if defined(PCBSKY9X) && defined(REVX)

View file

@ -452,6 +452,7 @@
#define TR_DISPLAY_TRIMS "Display Trims"
#define TR_TTRACE TR("Följ Gas", INDENT "Följ Gas")
#define TR_TTRIM TR("Gastrim", INDENT "Gastrim")
#define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch")
#define TR_BEEPCTR TR("Cent.pip", "Centerpip")
#define TR_USE_GLOBAL_FUNCS TR("Glob.Funkt", "Använd Global Funk.")
#if defined(PCBSKY9X) && defined(REVX)