chore: Companion - port of OpenTX function switches management (#1694)
* TPro - Port of OpenTX function switches management (https://github.com/opentx/opentx/pull/8847) * cleanup * Corrections * Fix YAML generation and adjusted switches to match TPRO firmware Co-authored-by: Batam <batam@macbook-pro.home>
This commit is contained in:
@@ -277,9 +277,10 @@ QString MultiModelPrinter::print(QTextDocument * document)
|
||||
if (firmware->getCapability(Timers)) {
|
||||
str.append(printTimers());
|
||||
}
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::NumFunctionSwitches)) {
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::FunctionSwitches)) {
|
||||
str.append(printFunctionSwitches());
|
||||
}
|
||||
|
||||
str.append(printModules());
|
||||
if (firmware->getCapability(Heli))
|
||||
str.append(printHeliSetup());
|
||||
@@ -942,51 +943,59 @@ QString MultiModelPrinter::printChecklist()
|
||||
return str;
|
||||
}
|
||||
|
||||
QString MultiModelPrinter::printFunctionSwitches()
|
||||
{
|
||||
QString str;
|
||||
MultiColumns columns(modelPrinterMap.size());
|
||||
columns.appendSectionTableStart();
|
||||
|
||||
int numFS = Boards::getCapability(firmware->getBoard(), Board::NumFunctionSwitches);
|
||||
int colwidth = 80 / numFS;
|
||||
QString MultiModelPrinter::printFunctionSwitches()
|
||||
{
|
||||
QString str;
|
||||
MultiColumns columns(modelPrinterMap.size());
|
||||
columns.appendSectionTableStart();
|
||||
|
||||
QStringList headings = { tr("Function Switches") };
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
headings << tr("Switch %1").arg(i + 1);
|
||||
}
|
||||
columns.appendRowHeader(headings);
|
||||
int numFS = Boards::getCapability(firmware->getBoard(), Board::FunctionSwitches);
|
||||
int colwidth = 80 / numFS;
|
||||
|
||||
columns.appendRowStart(tr("Name"), 20);
|
||||
QStringList headings = { tr("Function Switches") };
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
headings << tr("Switch %1").arg(i + 1);
|
||||
}
|
||||
columns.appendRowHeader(headings);
|
||||
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->functionSwitchNames[i], colwidth);
|
||||
}
|
||||
columns.appendRowStart(tr("Name"), 20);
|
||||
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Type"), 20);
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->functionSwitchNames[i], colwidth);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->funcSwitchConfigToString((unsigned int)i), colwidth);
|
||||
}
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Type"), 20);
|
||||
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Start"), 20);
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->funcSwitchConfigToString(model->getFuncSwitchConfig((unsigned int)i)), colwidth);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->funcSwitchStartToString((unsigned int)i), colwidth);
|
||||
}
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Start"), 20);
|
||||
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Group"), 20);
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->funcSwitchStartToString(model->getFuncSwitchStart((unsigned int)i)), colwidth);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH((model->functionSwitchGroup >> (2 * i)) & 0x03, colwidth);
|
||||
}
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Group"), 20);
|
||||
|
||||
columns.appendRowEnd();
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH(model->getFuncSwitchGroup((unsigned int)i), colwidth);
|
||||
}
|
||||
|
||||
columns.appendTableEnd();
|
||||
str.append(columns.print());
|
||||
return str;
|
||||
}
|
||||
columns.appendRowEnd();
|
||||
columns.appendRowStart(tr("Always On"), 20);
|
||||
|
||||
for (int i = 0; i < numFS; i++) {
|
||||
COMPARECELLWIDTH((model->getFuncSwitchAlwaysOnGroup((unsigned int)i) == 0 ? "No" : "Yes"), colwidth);
|
||||
}
|
||||
|
||||
columns.appendRowEnd();
|
||||
|
||||
columns.appendTableEnd();
|
||||
str.append(columns.print());
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user