Skip to content

Commit f3e8a10

Browse files
committed
Squashed commit of #2085
commit e898e85 Author: Peter Feerick <peter.feerick@gmail.com> Date: Wed Dec 7 19:43:16 2022 +1000 chore: Cleanup commit e0b2b3e Author: Peter Feerick <peter.feerick@gmail.com> Date: Wed Dec 7 16:30:28 2022 +1000 fix: Updated translation files commit 68594e6 Author: Peter Feerick <peter.feerick@gmail.com> Date: Wed Dec 7 16:22:03 2022 +1000 fix: Add missing LR3 and TX12MKII, rebase cleanup commit 55d0fa5 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Mon Oct 10 20:14:57 2022 +1100 Companion: model edit Mixes view shows Mix name in a column for easy reference commit ce36ca6 Author: elecpower <neilh713@tpg.com.au> Date: Mon Oct 10 08:38:21 2022 +1100 cpn: refresh all model refs to LS when name changed. UI tweaks. commit a58c3a4 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Oct 9 15:27:34 2022 +1100 display friendly LS name on viewlayout commit 785c6b6 Author: Peter Feerick <peter.feerick@gmail.com> Date: Mon Sep 26 16:40:38 2022 +1000 chore: Set codename commit 6533374 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 8 19:13:51 2022 +1100 TODO: put LS friendly name on radio output window. commit 29b35fd Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 8 16:47:57 2022 +1100 companion: dynamily populate list with LS name commit 2fe540b Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 8 14:36:42 2022 +1100 Companion: bug: display correct name commit a54b5e4 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 8 14:15:27 2022 +1100 companion: display LS friendly name in Comboxes commit 3e8b1ab Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Thu Oct 6 20:02:19 2022 +1100 special funcns: stop data loss in selectin new ch commit 776ead9 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Oct 2 13:00:58 2022 +1100 logic sw & custom fn: friendly name copy & paste commit 207650e Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 1 22:40:40 2022 +1000 Companion: custom function Friendly Name Label commit 45b0b7b Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 1 15:29:57 2022 +1000 Companion: new Logic Switch & Friendly Name Label commit f380a35 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 1 15:25:50 2022 +1000 storage conversions for Logic switch Safe commit 52601fd Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 1 15:22:15 2022 +1000 bug: re enabled logic switch sticky. commit 7c19f89 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Oct 1 05:16:05 2022 +0000 print logic switch safe commit 42331d9 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Mon Jun 20 14:30:37 2022 +1000 translations non English Texts (cherry picked from commit 8ee9c82) commit 19cdbfd Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 14 07:56:37 2022 +0000 update gui for new logic switch type (cherry picked from commit 6fd47d7) commit 5a631cd Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 14 01:14:20 2022 +0000 removed AndSw for Logic Switch mode Safe (cherry picked from commit 0d95f2f) commit c7c7512 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 14 01:04:56 2022 +0000 evaluation logic for LogicSwitchFunctionSafe: disassociates the AndSwitch from affecting the new Logic Switch Type (cherry picked from commit 62a3fd1) commit 3da59ea Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Mon Jun 13 02:26:14 2022 +0000 new logic switch type Safe graphical display (cherry picked from commit c3f1a32) commit 90d27e7 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 12 23:09:38 2022 +0000 English translations commit 767b765 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 12 22:49:41 2022 +0000 new logical switch function in dropdown (cherry picked from commit 5b165c0) commit d1ae63d Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 12 22:47:00 2022 +0000 new logic switch family (cherry picked from commit 514a60e) commit 195c325 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 7 15:56:55 2022 +1000 radio\src\gui\colorlcd\special_functions.cpp changed variable from translation to dynamic string (cherry picked from commit 1d4a0f42b4e642389948a7e5b582545b450c78a9) commit b372cd3 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 7 15:26:25 2022 +1000 Update en.h re enabled definition inorder to compile simu (cherry picked from commit 2ca101cef51a132fd4d5c662792b2b508e99263d) commit 41782df Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 7 15:19:45 2022 +1000 radio\src\translations\en.h moved translations to txt file as requested by @eshifri (cherry picked from commit d10f5d634f10ca8eecf79f1ceef6c9b43554cee4) commit ba8a0f7 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Tue Jun 7 15:04:23 2022 +1000 Update special_functions.cpp changed variable from string to translation (cherry picked from commit 65df17bf1f03ab53fef98f1309b743234babd517) commit 39661a0 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 5 09:34:03 2022 +1000 Update special_functions.cpp fixed string changed to translation (cherry picked from commit 52366eed73004b1dea153dff35bd45a0f993a35e) commit 114c69d Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 5 09:01:28 2022 +1000 Update translations.cpp variable for model special function custom name (cherry picked from commit a8c494285d774c0d2268dd96ed615a957e3767c9) commit 843ae4d Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 5 08:51:21 2022 +1000 Update en.h in special functions edit screen, variable data for English translation (cherry picked from commit 82490e34094ea0ed740e58bcffe95ad66d084ca7) commit 9d588e6 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sun Jun 5 07:56:55 2022 +1000 Update special_functions.cpp removed code comment (cherry picked from commit 391ad2f44d538c594e278e6be4bfc49714a5ff40) commit 00030de Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Jun 4 21:11:28 2022 +1000 Update special_functions.cpp paint special function custom name (cherry picked from commit 59fc7c1938cd9cea8618d7b80af9c70a96cf0921) commit 5c16aef Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Sat Jun 4 20:52:24 2022 +1000 Update yaml_datastructs_funcs.cpp increase data size (cherry picked from commit 98276f4d3f1aab8ad4f699349ec7659df5f5225a) commit 13581d1 Author: shane-droid <61736830+shane-droid@users.noreply.github.com> Date: Thu Jun 2 21:34:58 2022 +1000 special functions gui
1 parent 06db4c7 commit f3e8a10

53 files changed

Lines changed: 488 additions & 201 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

companion/src/firmwares/customfunctiondata.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <QtCore>
2929
#include <QComboBox>
3030

31+
#define CF_CUSTNAME_LEN 10
32+
3133
class Firmware;
3234
class ModelData;
3335
class GeneralSettings;
@@ -107,6 +109,7 @@ class CustomFunctionData {
107109
unsigned int enabled; // TODO perhaps not any more the right name
108110
unsigned int adjustMode;
109111
int repeatParam;
112+
char custName[CF_CUSTNAME_LEN + 1];
110113

111114
void convert(RadioDataConversionState & cstate);
112115

companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
246246
node["def"] = def;
247247
}
248248

249+
node["custName"] = rhs.custName;
250+
249251
return node;
250252
}
251253

@@ -254,6 +256,8 @@ bool convert<CustomFunctionData>::decode(const Node& node,
254256
{
255257
node["swtch"] >> rhs.swtch;
256258

259+
node["custName"] >> rhs.custName;
260+
257261
int func = 0;
258262
node["func"] >> customFnLut >> func;
259263
rhs.func = (AssignFunc)func;

companion/src/firmwares/edgetx/yaml_logicalswitchdata.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const YamlLookupTable funcLut = {
4242
{LS_FN_DAPOS, "FUNC_ADIFFEGREATER"},
4343
{LS_FN_TIMER, "FUNC_TIMER"},
4444
{LS_FN_STICKY, "FUNC_STICKY"},
45+
{LS_FN_SAFE, "FUNC_SAFE"},
4546
};
4647

4748
static int timerValue2lsw(uint32_t t)
@@ -80,6 +81,12 @@ Node convert<LogicalSwitchData>::encode(const LogicalSwitchData& rhs)
8081
def += YamlRawSwitchEncode(RawSwitch(rhs.val2));
8182
} break;
8283

84+
case LS_FAMILY_SAFE: {
85+
def += YamlRawSwitchEncode(RawSwitch(rhs.val1));
86+
def += ",";
87+
def += YamlRawSwitchEncode(RawSwitch(rhs.val2));
88+
} break;
89+
8390
case LS_FAMILY_EDGE: {
8491
def += YamlRawSwitchEncode(RawSwitch(rhs.val1));
8592
def += ",";
@@ -119,14 +126,15 @@ Node convert<LogicalSwitchData>::encode(const LogicalSwitchData& rhs)
119126
node["andsw"] = YamlRawSwitchEncode(RawSwitch(rhs.andsw));
120127
node["lsPersist"] = (int)rhs.lsPersist;
121128
node["lsState"] = (int)rhs.lsState;
122-
129+
node["custName"] = rhs.custName;
123130
return node;
124131
}
125132

126133
bool convert<LogicalSwitchData>::decode(const Node& node,
127134
LogicalSwitchData& rhs)
128135
{
129136
node["func"] >> funcLut >> rhs.func;
137+
node["custName"] >> rhs.custName;
130138

131139
std::string def_str;
132140
node["def"] >> def_str;
@@ -142,6 +150,14 @@ bool convert<LogicalSwitchData>::decode(const Node& node,
142150
rhs.val2 = YamlRawSwitchDecode(sw_str).toValue();
143151
} break;
144152

153+
case LS_FAMILY_SAFE: {
154+
std::string sw_str;
155+
getline(def, sw_str, ',');
156+
rhs.val1 = YamlRawSwitchDecode(sw_str).toValue();
157+
getline(def, sw_str);
158+
rhs.val2 = YamlRawSwitchDecode(sw_str).toValue();
159+
} break;
160+
145161
case LS_FAMILY_EDGE: {
146162
std::string sw_str;
147163
getline(def, sw_str, ',');

companion/src/firmwares/logicalswitchdata.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
bool LogicalSwitchData::isEmpty() const
3030
{
31-
return (func == 0);
31+
return (func == LS_FN_OFF);
3232
}
3333

3434
CSFunctionFamily LogicalSwitchData::getFunctionFamily() const
@@ -39,6 +39,8 @@ CSFunctionFamily LogicalSwitchData::getFunctionFamily() const
3939
return LS_FAMILY_TIMER;
4040
else if (func == LS_FN_STICKY)
4141
return LS_FAMILY_STICKY;
42+
else if (func == LS_FN_SAFE)
43+
return LS_FAMILY_SAFE;
4244
else if (func < LS_FN_AND || func > LS_FN_ELESS)
4345
return LS_FAMILY_VOFS;
4446
else if (func < LS_FN_EQUAL)
@@ -103,6 +105,8 @@ QString LogicalSwitchData::funcToString() const
103105
return tr("Timer");
104106
case LS_FN_STICKY:
105107
return tr("Sticky");
108+
case LS_FN_SAFE:
109+
return tr("Safe");
106110
case LS_FN_EDGE:
107111
return tr("Edge");
108112
default:
@@ -112,7 +116,7 @@ QString LogicalSwitchData::funcToString() const
112116

113117
QString LogicalSwitchData::nameToString(int index) const
114118
{
115-
return RadioData::getElementName(tr("L"), index + 1, NULL, true);
119+
return RadioData::getElementName(tr("L"), index + 1, custName, true);
116120
}
117121

118122
void LogicalSwitchData::convert(RadioDataConversionState & cstate)
@@ -125,6 +129,10 @@ void LogicalSwitchData::convert(RadioDataConversionState & cstate)
125129
val1 = RawSource(val1).convert(cstate.withComponentField("V1")).toValue();
126130
break;
127131
case LS_FAMILY_STICKY:
132+
case LS_FAMILY_SAFE:
133+
val1 = RawSwitch(val1).convert(cstate.withComponentField("V1")).toValue();
134+
val2 = RawSwitch(val2).convert(cstate.withComponentField("V2")).toValue();
135+
break;
128136
case LS_FAMILY_VBOOL:
129137
val1 = RawSwitch(val1).convert(cstate.withComponentField("V1")).toValue();
130138
val2 = RawSwitch(val2).convert(cstate.withComponentField("V2")).toValue();

companion/src/firmwares/logicalswitchdata.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
* GNU General Public License for more details.
2020
*/
2121

22-
#ifndef LOGICALSWITCHDATA_H
23-
#define LOGICALSWITCHDATA_H
22+
#pragma once
2423

2524
#include <QtCore>
2625

26+
#define LS_CUSTNAME_LEN 10
27+
2728
class RadioDataConversionState;
2829

2930
enum CSFunction {
@@ -48,8 +49,10 @@ enum CSFunction {
4849
LS_FN_TIMER,
4950
LS_FN_STICKY,
5051
LS_FN_EDGE,
52+
LS_FN_SAFE,
5153
// later ... LS_FN_RANGE,
52-
LS_FN_MAX
54+
LS_FN_MAX,
55+
5356
};
5457

5558
enum CSFunctionFamily {
@@ -59,6 +62,7 @@ enum CSFunctionFamily {
5962
LS_FAMILY_TIMER,
6063
LS_FAMILY_STICKY,
6164
LS_FAMILY_EDGE,
65+
LS_FAMILY_SAFE,
6266
};
6367

6468
class LogicalSwitchData {
@@ -79,6 +83,7 @@ class LogicalSwitchData {
7983
int andsw;
8084
bool lsState;
8185
bool lsPersist;
86+
char custName[LS_CUSTNAME_LEN + 1];
8287

8388
void clear() { memset(this, 0, sizeof(LogicalSwitchData)); }
8489
bool isEmpty() const;
@@ -88,5 +93,3 @@ class LogicalSwitchData {
8893
QString nameToString(int index) const;
8994
void convert(RadioDataConversionState & cstate);
9095
};
91-
92-
#endif // LOGICALSWITCHDATA_H

companion/src/firmwares/modeldata.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,12 @@ int ModelData::updateReference()
719719
}
720720
break;
721721
case LS_FAMILY_STICKY:
722+
case LS_FAMILY_SAFE:
723+
if (lsd->val1 != 0)
724+
updateSwitchIntRef(lsd->val1);
725+
if (lsd->val2 != 0)
726+
updateSwitchIntRef(lsd->val2);
727+
break;
722728
case LS_FAMILY_VBOOL:
723729
oldval1 = lsd->val1;
724730
oldval2 = lsd->val2;

companion/src/firmwares/opentx/opentxeeprom.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ class LogicalSwitchesFunctionsTable: public ConversionTable {
15151515
addConversion(LS_FN_DAPOS, val++);
15161516
addConversion(LS_FN_TIMER, val++);
15171517
addConversion(LS_FN_STICKY, val++);
1518+
addConversion(LS_FN_SAFE, val++);
15181519
}
15191520
};
15201521

@@ -1570,7 +1571,7 @@ class LogicalSwitchField: public TransformedField {
15701571
v2 = csw.val2;
15711572
v3 = csw.val3;
15721573
}
1573-
else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) {
1574+
else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY || csw.func == LS_FN_SAFE) {
15741575
switchesConversionTable->exportValue(csw.val1, v1);
15751576
switchesConversionTable->exportValue(csw.val2, v2);
15761577
}
@@ -1595,7 +1596,7 @@ class LogicalSwitchField: public TransformedField {
15951596
csw.val2 = v2;
15961597
csw.val3 = v3;
15971598
}
1598-
else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) {
1599+
else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY || csw.func == LS_FN_SAFE) {
15991600
switchesConversionTable->importValue(v1, csw.val1);
16001601
switchesConversionTable->importValue(v2, csw.val2);
16011602
}

companion/src/firmwares/rawsource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
208208
return DataHelpers::getCompositeName(dfltName, custName, prefixCustomName);
209209

210210
case SOURCE_TYPE_CUSTOM_SWITCH:
211-
return RawSwitch(SWITCH_TYPE_VIRTUAL, index).toString(); // RawSwitch uses 1 based index
211+
return RawSwitch(SWITCH_TYPE_VIRTUAL, index + 1) .toString(board, generalSettings, model); // RawSwitch uses 1 based index
212212

213213
case SOURCE_TYPE_CYC:
214214
return tr("CYC%1").arg(index);

companion/src/firmwares/rawswitch.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,20 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
9999

100100
case SWITCH_TYPE_VIRTUAL:
101101
if (modelData)
102-
return modelData->logicalSw[index].nameToString(index - 1);
102+
return modelData->logicalSw[index - 1].nameToString(index - 1);
103103
else
104104
return LogicalSwitchData().nameToString(index - 1);
105105

106+
case SWITCH_TYPE_FUNCTIONSWITCH:
107+
if (!Boards::getCapability(board, Board::FunctionSwitches))
108+
return CPN_STR_UNKNOWN_ITEM;
109+
qr = div(index - 1, 3);
110+
if (modelData)
111+
swName = QString(modelData->functionSwitchNames[qr.quot]).trimmed();
112+
if (swName.isEmpty())
113+
swName = tr("SW%1").arg(qr.quot + 1);
114+
return swName + directionIndicators.at(qr.rem > -1 && qr.rem < directionIndicators.size() ? qr.rem : 1);
115+
106116
case SWITCH_TYPE_MULTIPOS_POT:
107117
if (!Boards::getCapability(board, Board::MultiposPotsPositions))
108118
return CPN_STR_UNKNOWN_ITEM;

0 commit comments

Comments
 (0)