feat: Use trim as a 3POS toggle switch source (#4465)

This commit is contained in:
philmoz
2024-01-05 19:16:26 +10:00
committed by GitHub
parent fa12b27438
commit 2635a4972b
12 changed files with 52 additions and 17 deletions
@@ -514,6 +514,8 @@ struct convert<YamlTrim> {
node["value"] = rhs.value;
if (rhs.mode < 0) {
node["mode"] = (1 << 5) - 1;
} else if (rhs.mode == TRIM_MODE_3POS) {
node["mode"] = TRIM_MODE_3POS;
} else {
node["mode"] = 2 * rhs.ref + rhs.mode;
}
@@ -527,6 +529,8 @@ struct convert<YamlTrim> {
node["mode"] >> trimMode;
if (trimMode == (1 << 5) - 1) {
rhs.mode = -1;
} else if (trimMode == TRIM_MODE_3POS) {
rhs.mode = TRIM_MODE_3POS;
} else {
rhs.mode = trimMode % 2;
rhs.ref = trimMode / 2;
+1
View File
@@ -51,6 +51,7 @@ extern const QColor colors[CPN_MAX_CURVES];
#define TRIM_OFFSET 2
#define TRIM_MODE_NONE 0x1F // 0b11111
#define TRIM_MODE_3POS (2 * CPN_MAX_FLIGHT_MODES)
bool displayT16ImportWarning();
+10 -1
View File
@@ -110,6 +110,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
cb->setProperty("index", i);
if (IS_HORUS_OR_TARANIS(board)) {
cb->addItem(tr("Trim disabled"), -1);
cb->addItem(tr("3POS toggle switch"), TRIM_MODE_3POS);
}
for (int m = 0; m < fmCount; m++) {
if (m == phaseIdx) {
@@ -435,10 +436,14 @@ void FlightModePanel::trimUpdate(unsigned int trim)
trimsUse[trim]->setCurrentIndex(0);
trimsValue[trim]->setEnabled(false);
trimsSlider[trim]->setEnabled(false);
} else if (phase.trimMode[chn] == TRIM_MODE_3POS) {
trimsUse[trim]->setCurrentIndex(1);
trimsValue[trim]->setEnabled(false);
trimsSlider[trim]->setEnabled(false);
}
else {
if (IS_HORUS_OR_TARANIS(board))
trimsUse[trim]->setCurrentIndex(1 + 2 * phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
trimsUse[trim]->setCurrentIndex(2 + 2 * phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
else
trimsUse[trim]->setCurrentIndex(phase.trimRef[chn]);
if (phaseIdx == 0 || phase.trimRef[chn] == phaseIdx || (IS_HORUS_OR_TARANIS(board) && phase.trimMode[chn] != 0)) {
@@ -615,6 +620,10 @@ void FlightModePanel::phaseTrimUse_currentIndexChanged(int index)
phase.trimMode[chn] = -1;
phase.trimRef[chn] = 0;
phase.trim[chn] = 0;
} else if (data == TRIM_MODE_3POS) {
phase.trimMode[chn] = TRIM_MODE_3POS;
phase.trimRef[chn] = 0;
phase.trim[chn] = 0;
}
else {
if (IS_HORUS_OR_TARANIS(board)) {
+2
View File
@@ -287,6 +287,8 @@ QString ModelPrinter::printTrim(int flightModeIndex, int stickIndex)
if (fm.trimMode[stickIndex] == -1) {
return tr("OFF");
} else if (fm.trimMode[stickIndex] == CPN_MAX_FLIGHT_MODES * 2) {
return tr("3POS");
}
else {
if (fm.trimRef[stickIndex] == flightModeIndex) {