mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 04:45:17 +03:00
Re #1063: Deduplication of code for Inputs, Mixers, Logical Switches and Special Functions
This commit is contained in:
parent
34c311a562
commit
4e4d0fe883
19 changed files with 1991 additions and 2318 deletions
|
@ -168,6 +168,7 @@ set(companion_SRCS
|
|||
flashfirmwaredialog.cpp
|
||||
flasheepromdialog.cpp
|
||||
printdialog.cpp
|
||||
modelprinter.cpp
|
||||
fusesdialog.cpp
|
||||
logsdialog.cpp
|
||||
downloaddialog.cpp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,7 @@
|
|||
#include <QtGui>
|
||||
#include <QDir>
|
||||
#include "eeprominterface.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
namespace Ui {
|
||||
class CompareDialog;
|
||||
|
@ -21,11 +22,10 @@ class CompareDialog : public QDialog
|
|||
|
||||
protected:
|
||||
GeneralSettings * settings;
|
||||
ModelData * g_model1;
|
||||
ModelData * g_model2;
|
||||
ModelData * modeltemp;
|
||||
int model1;
|
||||
int model2;
|
||||
ModelData g_model1;
|
||||
ModelData g_model2;
|
||||
bool model1Valid;
|
||||
bool model2Valid;
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
@ -55,16 +55,21 @@ class CompareDialog : public QDialog
|
|||
return "grey";
|
||||
}
|
||||
|
||||
int ModelHasExpo(ExpoData * ExpoArray, ExpoData expo, bool * expoused);
|
||||
bool ChannelHasExpo(ExpoData * expoArray, uint8_t destCh);
|
||||
int ModelHasMix(MixData * mixArray, MixData mix, bool * mixused);
|
||||
bool ChannelHasMix(MixData * mixArray, uint8_t destCh);
|
||||
bool handleDroppedModel(const QMimeData * mimeData, ModelData * model, QLabel * label);
|
||||
void applyDiffFont(QString & v1, QString & v2, const QString & font = "", bool eqGrey = false);
|
||||
void diffAndAssembleTableLines(QStringList & i1, QStringList & i2, QString & o1, QString & o2);
|
||||
|
||||
QTextEdit * te;
|
||||
QString curvefile1;
|
||||
QString curvefile2;
|
||||
QDir *qd;
|
||||
|
||||
ModelPrinter modelPrinter1;
|
||||
ModelPrinter modelPrinter2;
|
||||
GeneralSettings dummySettings;
|
||||
|
||||
private slots:
|
||||
void on_printButton_clicked();
|
||||
void on_printFileButton_clicked();
|
||||
|
@ -78,13 +83,13 @@ protected:
|
|||
void printSetup();
|
||||
void printPhases();
|
||||
void printLimits();
|
||||
void printExpos();
|
||||
void printInputs();
|
||||
void printMixers();
|
||||
void printCurves();
|
||||
void printGvars();
|
||||
void printSwitches();
|
||||
void printLogicalSwitches();
|
||||
void printSafetySwitches();
|
||||
void printFSwitches();
|
||||
void printCustomFunctions();
|
||||
void printFrSky();
|
||||
};
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ QString SwitchDn(const char sw)
|
|||
return QString::fromUtf8(result);
|
||||
}
|
||||
|
||||
QString RawSwitch::toString()
|
||||
QString RawSwitch::toString() const
|
||||
{
|
||||
static const QString switches9X[] = {
|
||||
QString("THR"), QString("RUD"), QString("ELE"),
|
||||
|
@ -659,7 +659,7 @@ QString RawSwitch::toString()
|
|||
}
|
||||
}
|
||||
|
||||
QString CurveReference::toString()
|
||||
QString CurveReference::toString() const
|
||||
{
|
||||
if (value == 0) {
|
||||
return "----";
|
||||
|
@ -678,7 +678,7 @@ QString CurveReference::toString()
|
|||
}
|
||||
}
|
||||
|
||||
CSFunctionFamily LogicalSwitchData::getFunctionFamily()
|
||||
CSFunctionFamily LogicalSwitchData::getFunctionFamily() const
|
||||
{
|
||||
if (func == LS_FN_EDGE)
|
||||
return LS_FAMILY_EDGE;
|
||||
|
@ -694,7 +694,7 @@ CSFunctionFamily LogicalSwitchData::getFunctionFamily()
|
|||
return LS_FAMILY_VCOMP;
|
||||
}
|
||||
|
||||
unsigned int LogicalSwitchData::getRangeFlags()
|
||||
unsigned int LogicalSwitchData::getRangeFlags() const
|
||||
{
|
||||
if (func == LS_FN_DPOS)
|
||||
return RANGE_DELTA_FUNCTION;
|
||||
|
@ -704,7 +704,7 @@ unsigned int LogicalSwitchData::getRangeFlags()
|
|||
return 0;
|
||||
}
|
||||
|
||||
QString LogicalSwitchData::funcToString()
|
||||
QString LogicalSwitchData::funcToString() const
|
||||
{
|
||||
switch (func) {
|
||||
case LS_FN_OFF:
|
||||
|
@ -754,127 +754,6 @@ QString LogicalSwitchData::funcToString()
|
|||
}
|
||||
}
|
||||
|
||||
QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettings & settings)
|
||||
{
|
||||
QString result = "";
|
||||
|
||||
if (!func)
|
||||
return result;
|
||||
|
||||
if (andsw!=0) {
|
||||
result +="( ";
|
||||
}
|
||||
switch (getFunctionFamily()) {
|
||||
case LS_FAMILY_EDGE:
|
||||
result += QObject::tr("Edge(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3));
|
||||
break;
|
||||
case LS_FAMILY_STICKY:
|
||||
result += QObject::tr("Sticky(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString());
|
||||
break;
|
||||
case LS_FAMILY_TIMER:
|
||||
result += QObject::tr("Timer(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2));
|
||||
break;
|
||||
case LS_FAMILY_VOFS: {
|
||||
RawSource source = RawSource(val1);
|
||||
RawSourceRange range = source.getRange(&model, settings);
|
||||
QString res;
|
||||
if (val1)
|
||||
res += source.toString(&model);
|
||||
else
|
||||
res += "0";
|
||||
res.remove(" ");
|
||||
if (func == LS_FN_APOS || func == LS_FN_ANEG)
|
||||
res = "|" + res + "|";
|
||||
else if (func == LS_FN_DAPOS)
|
||||
res = "|d(" + res + ")|";
|
||||
else if (func == LS_FN_DPOS)
|
||||
res = "d(" + res + ")";
|
||||
result += res;
|
||||
if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DPOS || func == LS_FN_DAPOS)
|
||||
result += " > ";
|
||||
else if (func == LS_FN_EQUAL || func == LS_FN_VEQUAL)
|
||||
result += " = ";
|
||||
else if (func == LS_FN_NEQUAL)
|
||||
result += " != ";
|
||||
else if (func == LS_FN_ANEG || func == LS_FN_VNEG)
|
||||
result += " < ";
|
||||
else if (func == LS_FN_VALMOSTEQUAL)
|
||||
result += " ~ ";
|
||||
else
|
||||
result += " missing";
|
||||
result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
|
||||
break;
|
||||
}
|
||||
case LS_FAMILY_VBOOL:
|
||||
result += RawSwitch(val1).toString();
|
||||
switch (func) {
|
||||
case LS_FN_AND:
|
||||
result += " AND ";
|
||||
break;
|
||||
case LS_FN_OR:
|
||||
result += " OR ";
|
||||
break;
|
||||
case LS_FN_XOR:
|
||||
result += " XOR ";
|
||||
break;
|
||||
default:
|
||||
result += " bar ";
|
||||
break;
|
||||
}
|
||||
result += RawSwitch(val2).toString();
|
||||
break;
|
||||
|
||||
case LS_FAMILY_VCOMP:
|
||||
if (val1)
|
||||
result += RawSource(val1).toString(&model);
|
||||
else
|
||||
result += "0";
|
||||
switch (func) {
|
||||
case LS_FN_EQUAL:
|
||||
case LS_FN_VEQUAL:
|
||||
result += " = ";
|
||||
break;
|
||||
case LS_FN_NEQUAL:
|
||||
result += " != ";
|
||||
break;
|
||||
case LS_FN_GREATER:
|
||||
result += " > ";
|
||||
break;
|
||||
case LS_FN_LESS:
|
||||
result += " < ";
|
||||
break;
|
||||
case LS_FN_EGREATER:
|
||||
result += " >= ";
|
||||
break;
|
||||
case LS_FN_ELESS:
|
||||
result += " <= ";
|
||||
break;
|
||||
default:
|
||||
result += " foo ";
|
||||
break;
|
||||
}
|
||||
if (val2)
|
||||
result += RawSource(val2).toString(&model);
|
||||
else
|
||||
result += "0";
|
||||
break;
|
||||
}
|
||||
|
||||
if (andsw!=0) {
|
||||
result +=" ) AND ";
|
||||
result += RawSwitch(andsw).toString();
|
||||
}
|
||||
|
||||
if (GetCurrentFirmware()->getCapability(LogicalSwitchesExt)) {
|
||||
if (duration)
|
||||
result += QObject::tr(" Duration (%1s)").arg(duration/10.0);
|
||||
if (delay)
|
||||
result += QObject::tr(" Delay (%1s)").arg(delay/10.0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CustomFunctionData::clear()
|
||||
{
|
||||
memset(this, 0, sizeof(CustomFunctionData));
|
||||
|
@ -883,7 +762,7 @@ void CustomFunctionData::clear()
|
|||
}
|
||||
}
|
||||
|
||||
QString CustomFunctionData::funcToString()
|
||||
QString CustomFunctionData::funcToString() const
|
||||
{
|
||||
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32)
|
||||
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString());
|
||||
|
@ -936,35 +815,83 @@ QString CustomFunctionData::funcToString()
|
|||
}
|
||||
}
|
||||
|
||||
QString CustomFunctionData::paramToString()
|
||||
void CustomFunctionData::populateResetParams(ModelData * model, QComboBox * b, unsigned int value = 0)
|
||||
{
|
||||
int val = 0;
|
||||
Firmware * firmware = GetCurrentFirmware();
|
||||
BoardEnum board = GetEepromInterface()->getBoard();
|
||||
|
||||
b->addItem(QObject::tr("Timer1"), val++);
|
||||
b->addItem(QObject::tr("Timer2"), val++);
|
||||
if (IS_ARM(board)) {
|
||||
b->addItem( QObject::tr("Timer3"), val++);
|
||||
}
|
||||
b->addItem(QObject::tr("Flight"), val++);
|
||||
b->addItem(QObject::tr("Telemetry"), val++);
|
||||
int reCount = firmware->getCapability(RotaryEncoders);
|
||||
if (reCount == 1) {
|
||||
b->addItem(QObject::tr("Rotary Encoder"), val++);
|
||||
}
|
||||
else if (reCount == 2) {
|
||||
b->addItem(QObject::tr("REa"), val++);
|
||||
b->addItem(QObject::tr("REb"), val++);
|
||||
}
|
||||
if ((int)value < b->count()) {
|
||||
b->setCurrentIndex(value);
|
||||
}
|
||||
if (model && IS_ARM(board)) {
|
||||
for (int i=0; i<C9X_MAX_SENSORS; ++i) {
|
||||
if (model->sensorData[i].isAvailable()) {
|
||||
RawSource item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i);
|
||||
b->addItem(item.toString(model), val+i);
|
||||
if ((int)value == val+i) {
|
||||
b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFunctionData::populatePlaySoundParams(QStringList & qs)
|
||||
{
|
||||
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
|
||||
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
|
||||
}
|
||||
|
||||
void CustomFunctionData::populateHapticParams(QStringList & qs)
|
||||
{
|
||||
qs << "0" << "1" << "2" << "3";
|
||||
}
|
||||
|
||||
QString CustomFunctionData::paramToString(ModelData * model) const
|
||||
{
|
||||
QStringList qs;
|
||||
if (func <= FuncInstantTrim) {
|
||||
return QString("%1").arg(param);
|
||||
}
|
||||
else if (func==FuncLogs) {
|
||||
return QString("%1").arg(param/10.0) + QObject::tr("s");
|
||||
}
|
||||
else if (func==FuncPlaySound) {
|
||||
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
|
||||
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
|
||||
CustomFunctionData::populatePlaySoundParams(qs);
|
||||
if (param>=0 && param<(int)qs.count())
|
||||
return qs.at(param);
|
||||
else
|
||||
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
|
||||
}
|
||||
else if (func==FuncPlayHaptic) {
|
||||
qs << "0" << "1" << "2" << "3";
|
||||
CustomFunctionData::populateHapticParams(qs);
|
||||
if (param>=0 && param<(int)qs.count())
|
||||
return qs.at(param);
|
||||
else
|
||||
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
|
||||
}
|
||||
else if (func==FuncReset) {
|
||||
qs.append( QObject::tr("Timer1"));
|
||||
qs.append( QObject::tr("Timer2"));
|
||||
qs.append( QObject::tr("Timer3"));
|
||||
qs.append( QObject::tr("All"));
|
||||
qs.append( QObject::tr("Telemetry"));
|
||||
if (param>=0 && param<(int)qs.count())
|
||||
return qs.at(param);
|
||||
QComboBox cb;
|
||||
CustomFunctionData::populateResetParams(model, &cb);
|
||||
int pos = cb.findData(param);
|
||||
if (pos >= 0)
|
||||
return cb.itemText(pos);
|
||||
else
|
||||
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
|
||||
}
|
||||
|
@ -980,43 +907,47 @@ QString CustomFunctionData::paramToString()
|
|||
return paramarm;
|
||||
}
|
||||
}
|
||||
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
|
||||
else if ((func>=FuncAdjustGV1) && (func<FuncCount)) {
|
||||
switch (adjustMode) {
|
||||
case 0:
|
||||
return QObject::tr("Value ")+QString("%1").arg(param);
|
||||
break;
|
||||
case 1:
|
||||
return RawSource(param).toString();
|
||||
break;
|
||||
case 2:
|
||||
return RawSource(param).toString();
|
||||
break;
|
||||
case 3:
|
||||
if (param==0) {
|
||||
return QObject::tr("Decr:")+QString(" -1");
|
||||
}
|
||||
else {
|
||||
return QObject::tr("Incr:")+QString(" +1");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
if (param==0) return QObject::tr("Decr:") + " -1";
|
||||
else return QObject::tr("Incr:") + " +1";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString CustomFunctionData::repeatToString()
|
||||
QString CustomFunctionData::repeatToString() const
|
||||
{
|
||||
if (repeatParam==0) {
|
||||
return QObject::tr("No repeat");
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
|
||||
return QObject::tr("%1 sec").arg(step*repeatParam);
|
||||
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
|
||||
return QObject::tr("repeat") + QString("(%1").arg(step*repeatParam) + QObject::tr("s") + ")";
|
||||
}
|
||||
}
|
||||
|
||||
QString CustomFunctionData::enabledToString() const
|
||||
{
|
||||
if ((func>=FuncOverrideCH1 && func<=FuncOverrideCH32) ||
|
||||
(func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) ||
|
||||
(func==FuncReset) ||
|
||||
(func>=FuncSetTimer1 && func<=FuncSetTimer2) ||
|
||||
(func==FuncVolume) ||
|
||||
(func <= FuncInstantTrim)) {
|
||||
if (!enabled) {
|
||||
return QObject::tr("DISABLED");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString LimitData::minToString()
|
||||
{
|
||||
return QString::number((qreal)min/10);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QtXml>
|
||||
#include <QComboBox>
|
||||
#include <iostream>
|
||||
#include "constants.h"
|
||||
#include "simulatorinterface.h"
|
||||
|
@ -390,7 +391,7 @@ class RawSwitch {
|
|||
return index >= 0 ? (type * 256 + index) : -(type * 256 - index);
|
||||
}
|
||||
|
||||
QString toString();
|
||||
QString toString() const;
|
||||
|
||||
bool operator== ( const RawSwitch& other) {
|
||||
return (this->type == other.type) && (this->index == other.index);
|
||||
|
@ -426,7 +427,7 @@ class CurveReference {
|
|||
CurveRefType type;
|
||||
int value;
|
||||
|
||||
QString toString();
|
||||
QString toString() const;
|
||||
};
|
||||
|
||||
enum InputMode {
|
||||
|
@ -575,10 +576,9 @@ class LogicalSwitchData { // Logical Switches data
|
|||
unsigned int duration;
|
||||
int andsw;
|
||||
void clear() { memset(this, 0, sizeof(LogicalSwitchData)); }
|
||||
CSFunctionFamily getFunctionFamily();
|
||||
unsigned int getRangeFlags();
|
||||
QString funcToString();
|
||||
QString toString(const ModelData & model, const GeneralSettings & settings);
|
||||
CSFunctionFamily getFunctionFamily() const;
|
||||
unsigned int getRangeFlags() const;
|
||||
QString funcToString() const;
|
||||
};
|
||||
|
||||
enum AssignFunc {
|
||||
|
@ -624,10 +624,15 @@ class CustomFunctionData { // Function Switches data
|
|||
unsigned int adjustMode;
|
||||
int repeatParam;
|
||||
void clear();
|
||||
QString funcToString();
|
||||
QString paramToString();
|
||||
QString repeatToString();
|
||||
QStringList toStringList();
|
||||
QString funcToString() const;
|
||||
QString paramToString(ModelData * model) const;
|
||||
QString repeatToString() const;
|
||||
QString enabledToString() const;
|
||||
|
||||
static void populateResetParams(ModelData * model, QComboBox * b, unsigned int value);
|
||||
static void populatePlaySoundParams(QStringList & qs);
|
||||
static void populateHapticParams(QStringList & qs);
|
||||
|
||||
};
|
||||
|
||||
class FlightModeData {
|
||||
|
|
|
@ -65,26 +65,6 @@ QString getPhaseName(int val, const char * phasename)
|
|||
}
|
||||
}
|
||||
|
||||
QString getInputStr(ModelData * model, int index)
|
||||
{
|
||||
QString result;
|
||||
|
||||
if (GetCurrentFirmware()->getCapability(VirtualInputs)) {
|
||||
if (strlen(model->inputNames[index]) > 0) {
|
||||
result = QObject::tr("[I%1]").arg(index+1);
|
||||
result += QString(model->inputNames[index]);
|
||||
}
|
||||
else {
|
||||
result = QObject::tr("Input%1").arg(index+1, 2, 10, QChar('0'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = RawSource(SOURCE_TYPE_STICK, index).toString(model);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void populateGvSourceCB(QComboBox *b, int value)
|
||||
{
|
||||
QString strings[] = { QObject::tr("---"), QObject::tr("Rud Trim"), QObject::tr("Ele Trim"), QObject::tr("Thr Trim"), QObject::tr("Ail Trim"), QObject::tr("Rot Enc"), QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail"), QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3")};
|
||||
|
@ -858,34 +838,6 @@ QString getTrainerMode(const int trainermode, ModuleData & module)
|
|||
return result;
|
||||
}
|
||||
|
||||
QString getPhasesStr(unsigned int phases, ModelData * model)
|
||||
{
|
||||
int numphases = GetCurrentFirmware()->getCapability(FlightModes);
|
||||
|
||||
if (numphases && phases) {
|
||||
QString str;
|
||||
int count = 0;
|
||||
if (phases == (unsigned int)(1<<numphases) - 1) {
|
||||
str = QObject::tr("None");
|
||||
}
|
||||
if (phases) {
|
||||
for (int i=0; i<numphases;i++) {
|
||||
if (!(phases & (1<<i))) {
|
||||
if (count++ > 0) str += QString(", ");
|
||||
str += getPhaseName(i+1, model->flightModeData[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 1)
|
||||
return QObject::tr("Flight modes(%1)").arg(str);
|
||||
else
|
||||
return QObject::tr("Flight mode(%1)").arg(str);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QString getCenterBeepStr(ModelData * g_model)
|
||||
{
|
||||
QStringList strl;
|
||||
|
|
|
@ -101,7 +101,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
void populatePhasesCB(QComboBox *b, int value);
|
||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
QString getProtocolStr(const int proto);
|
||||
QString getPhasesStr(unsigned int phases, ModelData * model);
|
||||
|
||||
#define POPULATE_NONE (1<<0)
|
||||
#define POPULATE_SOURCES (1<<1)
|
||||
|
@ -120,7 +119,6 @@ QString getPhasesStr(unsigned int phases, ModelData * model);
|
|||
void populateGVCB(QComboBox *b, int value);
|
||||
void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags);
|
||||
QString getPhaseName(int val, const char * phasename=NULL);
|
||||
QString getInputStr(ModelData * model, int index);
|
||||
QString image2qstring(QImage image);
|
||||
int findmult(float value, float base);
|
||||
|
||||
|
|
|
@ -636,47 +636,17 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi
|
|||
QStringList qs;
|
||||
b->clear();
|
||||
if (function==FuncPlaySound) {
|
||||
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
|
||||
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
|
||||
CustomFunctionData::populatePlaySoundParams(qs);
|
||||
b->addItems(qs);
|
||||
b->setCurrentIndex(value);
|
||||
}
|
||||
else if (function==FuncPlayHaptic) {
|
||||
qs << "0" << "1" << "2" << "3";
|
||||
CustomFunctionData::populateHapticParams(qs);
|
||||
b->addItems(qs);
|
||||
b->setCurrentIndex(value);
|
||||
}
|
||||
else if (function==FuncReset) {
|
||||
int val = 0;
|
||||
b->addItem(tr("Timer1"), val++);
|
||||
b->addItem(tr("Timer2"), val++);
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
b->addItem( QObject::tr("Timer3"), val++);
|
||||
}
|
||||
b->addItem(tr("Flight"), val++);
|
||||
b->addItem(tr("Telemetry"), val++);
|
||||
int reCount = firmware->getCapability(RotaryEncoders);
|
||||
if (reCount == 1) {
|
||||
b->addItem(tr("Rotary Encoder"), val++);
|
||||
}
|
||||
else if (reCount == 2) {
|
||||
b->addItem(tr("REa"), val++);
|
||||
b->addItem(tr("REb"), val++);
|
||||
}
|
||||
if ((int)value < b->count()) {
|
||||
b->setCurrentIndex(value);
|
||||
}
|
||||
if (model && IS_ARM(firmware->getBoard())) {
|
||||
for (int i=0; i<C9X_MAX_SENSORS; ++i) {
|
||||
if (model->sensorData[i].isAvailable()) {
|
||||
RawSource item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i);
|
||||
b->addItem(item.toString(model), val+i);
|
||||
if ((int)value == val+i) {
|
||||
b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomFunctionData::populateResetParams(model, b, value);
|
||||
}
|
||||
else if (function==FuncVolume) {
|
||||
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
|
||||
|
|
|
@ -10,13 +10,14 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
|||
generalSettings(generalSettings),
|
||||
firmware(firmware),
|
||||
ed(expoData),
|
||||
inputName(inputName)
|
||||
inputName(inputName),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
|
||||
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
|
||||
|
||||
setWindowTitle(tr("Edit %1").arg(getInputStr(&model, ed->chn)));
|
||||
setWindowTitle(tr("Edit %1").arg(modelPrinter.printInputName(ed->chn)));
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "eeprominterface.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class GVarGroup;
|
||||
class CurveGroup;
|
||||
|
@ -35,6 +36,7 @@ class ExpoDialog : public QDialog {
|
|||
GVarGroup * gvWeightGroup;
|
||||
GVarGroup * gvOffsetGroup;
|
||||
CurveGroup * curveGroup;
|
||||
ModelPrinter modelPrinter;
|
||||
};
|
||||
|
||||
#endif // EXPODIALOG_H
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
expoInserted(false)
|
||||
expoInserted(false),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
{
|
||||
inputsCount = firmware->getCapability(VirtualInputs);
|
||||
if (inputsCount == 0)
|
||||
|
@ -135,7 +136,7 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
|||
QString str;
|
||||
if (new_ch) *new_ch = 0;
|
||||
if (dest < 0) {
|
||||
str = getInputStr(model, -dest-1);
|
||||
str = modelPrinter.printInputName(-dest-1);
|
||||
if (new_ch) *new_ch = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -144,9 +145,9 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
|||
if ((dest == 0) || (model->expoData[dest-1].chn != md->chn)) {
|
||||
if (new_ch) *new_ch = 1;
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
str = QString("%1").arg(getInputStr(model, md->chn), -10, ' ');
|
||||
str += QString("%1").arg(modelPrinter.printInputName(md->chn), -10, ' ');
|
||||
else
|
||||
str = getInputStr(model, md->chn);
|
||||
str = modelPrinter.printInputName(md->chn);
|
||||
}
|
||||
else {
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
|
@ -154,39 +155,10 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
|||
else
|
||||
str = " ";
|
||||
}
|
||||
|
||||
switch (md->mode) {
|
||||
case (1): str += " <-"; break;
|
||||
case (2): str += " ->"; break;
|
||||
default: str += " "; break;
|
||||
str.replace(" ", " ");
|
||||
str += modelPrinter.printInputLine(md);
|
||||
}
|
||||
|
||||
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight));
|
||||
if (md->offset) str += " " + tr("Offset(%1)").arg(getGVarString(md->offset));
|
||||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
str += " " + tr("Source(%1)").arg(md->srcRaw.toString(model));
|
||||
if (md->carryTrim>0) {
|
||||
str += " " + tr("NoTrim");
|
||||
}
|
||||
else if (md->carryTrim<0) {
|
||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
|
||||
}
|
||||
}
|
||||
|
||||
if (md->curve.value) str += " " + md->curve.toString();
|
||||
|
||||
QString phasesStr = getPhasesStr(md->phases, model);
|
||||
if (!phasesStr.isEmpty()) str += " " + phasesStr;
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString());
|
||||
|
||||
if (firmware->getCapability(HasExpoNames)) {
|
||||
QString expoName = md->name;
|
||||
if (!expoName.isEmpty()) str += QString(" [%1]").arg(expoName);
|
||||
}
|
||||
}
|
||||
return Qt::escape(str).replace(" ", " ");
|
||||
return str;
|
||||
}
|
||||
|
||||
bool InputsPanel::gm_insertExpo(int idx)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class InputsPanel : public ModelPanel
|
||||
{
|
||||
|
@ -35,6 +36,7 @@ class InputsPanel : public ModelPanel
|
|||
MixersList *ExposlistWidget;
|
||||
bool firstLine;
|
||||
int inputsCount;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getExpoIndex(unsigned int dch);
|
||||
bool gm_insertExpo(int idx);
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
mixInserted(false),
|
||||
highlightedSource(0)
|
||||
highlightedSource(0),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
{
|
||||
QGridLayout * mixesLayout = new QGridLayout(this);
|
||||
|
||||
|
@ -43,23 +44,6 @@ MixesPanel::~MixesPanel()
|
|||
{
|
||||
}
|
||||
|
||||
QString MixesPanel::getChannelLabel(int curDest)
|
||||
{
|
||||
QString str;
|
||||
str = QObject::tr("CH%1").arg(curDest);
|
||||
// TODO not nice, Qt brings a function for that, I don't remember right now
|
||||
(str.length() < 4) ? str.append(" ") : str.append(" ");
|
||||
if (firmware->getCapability(HasChNames)) {
|
||||
QString name = model->limitData[curDest-1].name;
|
||||
if (!name.isEmpty()) {
|
||||
name = QString("(") + name + QString(")");
|
||||
}
|
||||
name.append(" ");
|
||||
str += name.left(8);
|
||||
}
|
||||
return Qt::escape(str);
|
||||
}
|
||||
|
||||
void MixesPanel::update()
|
||||
{
|
||||
// curDest -> destination channel
|
||||
|
@ -141,8 +125,8 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
|||
QString str;
|
||||
if (new_ch) *new_ch = 0;
|
||||
if (dest < 0) {
|
||||
str = getChannelLabel(-dest);
|
||||
//highlight channell if needed
|
||||
str = modelPrinter.printMixerName(-dest);
|
||||
//highlight channel if needed
|
||||
if (-dest == (int)highlightedSource) {
|
||||
str = "<b>" + str + "</b>";
|
||||
}
|
||||
|
@ -151,11 +135,11 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
|||
else {
|
||||
MixData *md = &model->mixData[dest];
|
||||
//md->destCh from 1 to 32
|
||||
str = getChannelLabel(md->destCh);
|
||||
str = modelPrinter.printMixerName(md->destCh);
|
||||
|
||||
if ((dest == 0) || (model->mixData[dest-1].destCh != md->destCh)) {
|
||||
if (new_ch) *new_ch = 1;
|
||||
//highlight channell if needed
|
||||
//highlight channel if needed
|
||||
if (md->destCh == highlightedSource) {
|
||||
str = "<b>" + str + "</b>";
|
||||
}
|
||||
|
@ -164,53 +148,7 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
|||
str.fill(' ');
|
||||
}
|
||||
|
||||
switch (md->mltpx) {
|
||||
case (1): str += " *"; break;
|
||||
case (2): str += " R"; break;
|
||||
default: str += " "; break;
|
||||
};
|
||||
|
||||
// highlight source if needed
|
||||
if ( (md->srcRaw.type == SOURCE_TYPE_CH) && (md->srcRaw.index+1 == (int)highlightedSource) ) {
|
||||
str += " <b>" + Qt::escape(md->srcRaw.toString(model)) + "</b>";
|
||||
}
|
||||
else {
|
||||
str += " " + Qt::escape(md->srcRaw.toString(model));
|
||||
}
|
||||
|
||||
str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true)));
|
||||
|
||||
QString phasesStr = getPhasesStr(md->phases, model);
|
||||
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) {
|
||||
str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString()));
|
||||
}
|
||||
|
||||
if (md->carryTrim > 0)
|
||||
str += " " + Qt::escape(tr("NoTrim"));
|
||||
else if (md->carryTrim<0)
|
||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
|
||||
|
||||
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
||||
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
|
||||
int scale = firmware->getCapability(SlowScale);
|
||||
if (scale == 0)
|
||||
scale = 1;
|
||||
if (md->delayDown || md->delayUp)
|
||||
str += Qt::escape(tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale));
|
||||
if (md->speedDown || md->speedUp)
|
||||
str += Qt::escape(tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale));
|
||||
if (md->mixWarn) str += Qt::escape(tr(" Warn(%1)").arg(md->mixWarn));
|
||||
if (firmware->getCapability(HasMixerNames)) {
|
||||
QString MixerName;
|
||||
MixerName.append(md->name);
|
||||
if (!MixerName.isEmpty()) {
|
||||
str += " " + Qt::escape(QString("(%1)").arg(MixerName));
|
||||
}
|
||||
}
|
||||
str += modelPrinter.printMixerLine(md, highlightedSource);
|
||||
}
|
||||
return str.replace(" ", " ");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "mixerdialog.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class MixesPanel : public ModelPanel
|
||||
{
|
||||
|
@ -44,6 +45,7 @@ class MixesPanel : public ModelPanel
|
|||
bool mixInserted;
|
||||
unsigned int highlightedSource;
|
||||
bool firstLine;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getMixerIndex(unsigned int dch);
|
||||
bool gm_insertMix(int idx);
|
||||
|
@ -53,7 +55,6 @@ class MixesPanel : public ModelPanel
|
|||
void mixersDeleteList(QList<int> list);
|
||||
QList<int> createMixListFromSelected();
|
||||
void setSelectedByMixList(QList<int> list);
|
||||
QString getChannelLabel(int curDest);
|
||||
bool AddMixerLine(int dest);
|
||||
QString getMixerText(int dest, bool * new_ch);
|
||||
};
|
||||
|
|
317
companion/src/modelprinter.cpp
Normal file
317
companion/src/modelprinter.cpp
Normal file
|
@ -0,0 +1,317 @@
|
|||
#include "helpers.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
QString changeColor(const QString & input, const QString & to, const QString & from)
|
||||
{
|
||||
QString result = input;
|
||||
return result.replace("color="+from, "color="+to);
|
||||
}
|
||||
|
||||
ModelPrinter::ModelPrinter(Firmware * firmware,
|
||||
GeneralSettings *gg, ModelData *gm) :
|
||||
firmware(firmware),
|
||||
g_eeGeneral(gg),
|
||||
g_model(gm)
|
||||
{
|
||||
}
|
||||
|
||||
void debugHtml(const QString & html)
|
||||
{
|
||||
QFile file("foo.html");
|
||||
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
|
||||
file.write(html.toUtf8());
|
||||
file.close();
|
||||
}
|
||||
|
||||
QString addFont(const QString & input, const QString & color, const QString & size, const QString & face)
|
||||
{
|
||||
QString colorStr;
|
||||
if (!color.isEmpty()) {
|
||||
colorStr = "color=" + color;
|
||||
}
|
||||
QString sizeStr;
|
||||
if (!size.isEmpty()) {
|
||||
sizeStr = "size=" + size;
|
||||
}
|
||||
QString faceStr;
|
||||
if (!face.isEmpty()) {
|
||||
faceStr = "face='" + face + "'";
|
||||
}
|
||||
return "<font " + sizeStr + " " + faceStr + " " + colorStr + ">" + input + "</font>";
|
||||
}
|
||||
|
||||
QString ModelPrinter::printInputName(int idx)
|
||||
{
|
||||
QString result;
|
||||
if (GetCurrentFirmware()->getCapability(VirtualInputs)) {
|
||||
if (strlen(g_model->inputNames[idx]) > 0) {
|
||||
result = QObject::tr("[I%1]").arg(idx+1);
|
||||
result += QString(g_model->inputNames[idx]);
|
||||
}
|
||||
else {
|
||||
result = QObject::tr("Input%1").arg(idx+1, 2, 10, QChar('0'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = RawSource(SOURCE_TYPE_STICK, idx).toString(g_model);
|
||||
}
|
||||
return Qt::escape(result);
|
||||
}
|
||||
|
||||
QString ModelPrinter::printInputLine(const ExpoData * ed)
|
||||
{
|
||||
QString str = " ";
|
||||
|
||||
switch (ed->mode) {
|
||||
case (1): str += "<- "; break;
|
||||
case (2): str += "-> "; break;
|
||||
default: str += " "; break;
|
||||
}
|
||||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
str += Qt::escape(ed->srcRaw.toString(g_model));
|
||||
}
|
||||
|
||||
str += " " + Qt::escape(QObject::tr("Weight")) + QString("(%1)").arg(getGVarString(ed->weight,true));
|
||||
if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString());
|
||||
|
||||
QString phasesStr = getPhasesStr(ed->phases);
|
||||
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
||||
|
||||
if (ed->swtch.type != SWITCH_TYPE_NONE)
|
||||
str += " " + Qt::escape(QObject::tr("Switch") + QString("(%1)").arg(ed->swtch.toString()));
|
||||
|
||||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
if (ed->carryTrim>0) str += " " + Qt::escape(QObject::tr("NoTrim"));
|
||||
else if (ed->carryTrim<0) str += " " + Qt::escape(RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(g_model));
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasExpoNames) && ed->name[0])
|
||||
str += Qt::escape(QString(" [%1]").arg(ed->name));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
QString ModelPrinter::printMixerName(int curDest)
|
||||
{
|
||||
QString str;
|
||||
str = QObject::tr("CH%1").arg(curDest);
|
||||
// TODO not nice, Qt brings a function for that, I don't remember right now
|
||||
(str.length() < 4) ? str.append(" ") : str.append(" ");
|
||||
if (firmware->getCapability(HasChNames)) {
|
||||
QString name = g_model->limitData[curDest-1].name;
|
||||
if (!name.isEmpty()) {
|
||||
name = QString("(") + name + QString(")");
|
||||
}
|
||||
name.append(" ");
|
||||
str += name.left(8);
|
||||
}
|
||||
return Qt::escape(str);
|
||||
}
|
||||
|
||||
QString ModelPrinter::printMixerLine(const MixData * md, int highlightedSource)
|
||||
{
|
||||
QString str = " ";
|
||||
|
||||
switch(md->mltpx) {
|
||||
case (1): str += "*"; break;
|
||||
case (2): str += "R"; break;
|
||||
default: str += " "; break;
|
||||
};
|
||||
|
||||
// highlight source if needed
|
||||
QString source = Qt::escape(md->srcRaw.toString(g_model));
|
||||
if ( (md->srcRaw.type == SOURCE_TYPE_CH) && (md->srcRaw.index+1 == (int)highlightedSource) ) {
|
||||
source = "<b>" + source + "</b>";
|
||||
}
|
||||
str += " " + source;
|
||||
|
||||
str += " " + Qt::escape(QObject::tr("Weight")) + QString("(%1)").arg(getGVarString(md->weight, true));
|
||||
|
||||
QString phasesStr = getPhasesStr(md->phases);
|
||||
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) {
|
||||
str += " " + Qt::escape(QObject::tr("Switch")) + QString("(%1)").arg(md->swtch.toString());
|
||||
}
|
||||
|
||||
if (md->carryTrim>0) str += " " + Qt::escape(QObject::tr("NoTrim"));
|
||||
else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(g_model);
|
||||
|
||||
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(QObject::tr("No DR/Expo"));
|
||||
if (md->sOffset) str += " " + Qt::escape(QObject::tr("Offset")) + QString("(%1)").arg(getGVarString(md->sOffset));
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
|
||||
int scale = firmware->getCapability(SlowScale);
|
||||
if (scale == 0)
|
||||
scale = 1;
|
||||
if (md->delayDown || md->delayUp)
|
||||
str += " " + Qt::escape(QObject::tr("Delay")) + QString("(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale);
|
||||
if (md->speedDown || md->speedUp)
|
||||
str += " " + Qt::escape(QObject::tr("Slow")) + QString("(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale);
|
||||
if (md->mixWarn)
|
||||
// str += Qt::escape(QObject::tr(" Warn(%1)").arg(md->mixWarn));
|
||||
str += " " + Qt::escape(QObject::tr("Warn")) + QString("(%1)").arg(md->mixWarn);
|
||||
if (firmware->getCapability(HasMixerNames) && md->name[0])
|
||||
str += Qt::escape(QString(" [%1]").arg(md->name));
|
||||
return str;
|
||||
}
|
||||
|
||||
QString ModelPrinter::getPhasesStr(unsigned int phases)
|
||||
{
|
||||
int numphases = GetCurrentFirmware()->getCapability(FlightModes);
|
||||
|
||||
if (numphases && phases) {
|
||||
QString str;
|
||||
int count = 0;
|
||||
if (phases == (unsigned int)(1<<numphases) - 1) {
|
||||
str = " ### " + QObject::tr("DISABLED") + " ### ";
|
||||
}
|
||||
// if (phases) {
|
||||
for (int i=0; i<numphases; i++) {
|
||||
if (!(phases & (1<<i))) {
|
||||
if (count++ > 0) str += QString(", ");
|
||||
str += getPhaseName(i+1, g_model->flightModeData[i].name);
|
||||
}
|
||||
}
|
||||
// }
|
||||
if (count > 1)
|
||||
return QObject::tr("Flight modes") + QString("(%1)").arg(str);
|
||||
else
|
||||
return QObject::tr("Flight mode") + QString("(%1)").arg(str);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ModelPrinter::printLogicalSwitchLine(int idx)
|
||||
{
|
||||
QString result = "";
|
||||
const LogicalSwitchData & ls = g_model->logicalSw[idx];
|
||||
|
||||
if (!ls.func)
|
||||
return result;
|
||||
|
||||
if (ls.andsw!=0) {
|
||||
result +="( ";
|
||||
}
|
||||
switch (ls.getFunctionFamily()) {
|
||||
case LS_FAMILY_EDGE:
|
||||
result += QObject::tr("Edge(%1, [%2:%3])").arg(RawSwitch(ls.val1).toString()).arg(ValToTim(ls.val2)).arg(ValToTim(ls.val2+ls.val3));
|
||||
break;
|
||||
case LS_FAMILY_STICKY:
|
||||
result += QObject::tr("Sticky(%1, %2)").arg(RawSwitch(ls.val1).toString()).arg(RawSwitch(ls.val2).toString());
|
||||
break;
|
||||
case LS_FAMILY_TIMER:
|
||||
result += QObject::tr("Timer(%1, %2)").arg(ValToTim(ls.val1)).arg(ValToTim(ls.val2));
|
||||
break;
|
||||
case LS_FAMILY_VOFS: {
|
||||
RawSource source = RawSource(ls.val1);
|
||||
RawSourceRange range = source.getRange(g_model, *g_eeGeneral);
|
||||
QString res;
|
||||
if (ls.val1)
|
||||
res += source.toString(g_model);
|
||||
else
|
||||
res += "0";
|
||||
res.remove(" ");
|
||||
if (ls.func == LS_FN_APOS || ls.func == LS_FN_ANEG)
|
||||
res = "|" + res + "|";
|
||||
else if (ls.func == LS_FN_DAPOS)
|
||||
res = "|d(" + res + ")|";
|
||||
else if (ls.func == LS_FN_DPOS) result = "d(" + res + ")";
|
||||
result += res;
|
||||
|
||||
if (ls.func == LS_FN_APOS || ls.func == LS_FN_VPOS || ls.func == LS_FN_DPOS || ls.func == LS_FN_DAPOS)
|
||||
result += " > ";
|
||||
else if (ls.func == LS_FN_ANEG || ls.func == LS_FN_VNEG)
|
||||
result += " < ";
|
||||
else if (ls.func == LS_FN_VALMOSTEQUAL)
|
||||
result += " ~ ";
|
||||
else
|
||||
result += " missing";
|
||||
result += QString::number(range.step * (ls.val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
|
||||
break;
|
||||
}
|
||||
case LS_FAMILY_VBOOL:
|
||||
result += RawSwitch(ls.val1).toString();
|
||||
switch (ls.func) {
|
||||
case LS_FN_AND:
|
||||
result += " AND ";
|
||||
break;
|
||||
case LS_FN_OR:
|
||||
result += " OR ";
|
||||
break;
|
||||
case LS_FN_XOR:
|
||||
result += " XOR ";
|
||||
break;
|
||||
default:
|
||||
result += " bar ";
|
||||
break;
|
||||
}
|
||||
result += RawSwitch(ls.val2).toString();
|
||||
break;
|
||||
|
||||
case LS_FAMILY_VCOMP:
|
||||
if (ls.val1)
|
||||
result += RawSource(ls.val1).toString(g_model);
|
||||
else
|
||||
result += "0";
|
||||
switch (ls.func) {
|
||||
case LS_FN_EQUAL:
|
||||
case LS_FN_VEQUAL:
|
||||
result += " = ";
|
||||
break;
|
||||
case LS_FN_NEQUAL:
|
||||
result += " != ";
|
||||
break;
|
||||
case LS_FN_GREATER:
|
||||
result += " > ";
|
||||
break;
|
||||
case LS_FN_LESS:
|
||||
result += " < ";
|
||||
break;
|
||||
case LS_FN_EGREATER:
|
||||
result += " >= ";
|
||||
break;
|
||||
case LS_FN_ELESS:
|
||||
result += " <= ";
|
||||
break;
|
||||
default:
|
||||
result += " foo ";
|
||||
break;
|
||||
}
|
||||
if (ls.val2)
|
||||
result += RawSource(ls.val2).toString(g_model);
|
||||
else
|
||||
result += "0";
|
||||
break;
|
||||
}
|
||||
|
||||
if (ls.andsw!=0) {
|
||||
result +=" ) AND ";
|
||||
result += RawSwitch(ls.andsw).toString();
|
||||
}
|
||||
|
||||
if (GetCurrentFirmware()->getCapability(LogicalSwitchesExt)) {
|
||||
if (ls.duration)
|
||||
result += QObject::tr(" Duration (%1s)").arg(ls.duration/10.0);
|
||||
if (ls.delay)
|
||||
result += QObject::tr(" Delay (%1s)").arg(ls.delay/10.0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString ModelPrinter::printCustomFunctionLine(int idx)
|
||||
{
|
||||
QString result;
|
||||
const CustomFunctionData & cf = g_model->customFn[idx];
|
||||
if (cf.swtch.type == SWITCH_TYPE_NONE) return result;
|
||||
|
||||
result += cf.swtch.toString() + " - ";
|
||||
result += cf.funcToString() + "(";
|
||||
result += cf.paramToString(g_model) + ")";
|
||||
if (!cf.repeatToString().isEmpty()) result += " " + cf.repeatToString();
|
||||
if (!cf.enabledToString().isEmpty()) result += " " + cf.enabledToString();
|
||||
return result;
|
||||
}
|
35
companion/src/modelprinter.h
Normal file
35
companion/src/modelprinter.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef MODELPRINTER_H
|
||||
#define MODELPRINTER_H
|
||||
|
||||
#include <QString>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
QString changeColor(const QString & input, const QString & to, const QString & from = "grey");
|
||||
|
||||
QString addFont(const QString & input, const QString & color = "", const QString & size = "", const QString & face = "");
|
||||
|
||||
void debugHtml(const QString & html);
|
||||
|
||||
|
||||
class ModelPrinter
|
||||
{
|
||||
public:
|
||||
ModelPrinter(Firmware * firmware, GeneralSettings *gg, ModelData *gm);
|
||||
~ModelPrinter() {};
|
||||
|
||||
QString printInputName(int idx);
|
||||
QString printInputLine(const ExpoData * ed);
|
||||
QString printMixerName(int curDest);
|
||||
QString printMixerLine(const MixData * md, int highlightedSource = 0);
|
||||
QString printLogicalSwitchLine(int idx);
|
||||
QString printCustomFunctionLine(int idx);
|
||||
|
||||
private:
|
||||
Firmware * firmware;
|
||||
GeneralSettings * g_eeGeneral;
|
||||
ModelData * g_model;
|
||||
|
||||
QString getPhasesStr(unsigned int phases);
|
||||
};
|
||||
|
||||
#endif //#ifndef MODELPRINTER_H
|
|
@ -3,6 +3,7 @@
|
|||
#include "helpers.h"
|
||||
#include "helpers_html.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "modelprinter.h"
|
||||
#include <QtGui>
|
||||
#include <QImage>
|
||||
#include <QColor>
|
||||
|
@ -22,7 +23,8 @@ PrintDialog::PrintDialog(QWidget *parent, Firmware * firmware, GeneralSettings *
|
|||
g_model(gm),
|
||||
printfilename(filename),
|
||||
ui(new Ui::PrintDialog),
|
||||
gvars(firmware->getCapability(Gvars))
|
||||
gvars(firmware->getCapability(Gvars)),
|
||||
modelPrinter(firmware, gg, gm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(CompanionIcon("print.png"));
|
||||
|
@ -48,8 +50,8 @@ PrintDialog::PrintDialog(QWidget *parent, Firmware * firmware, GeneralSettings *
|
|||
printLimits();
|
||||
printCurves();
|
||||
printGvars();
|
||||
printSwitches();
|
||||
printFSwitches();
|
||||
printLogicalSwitches();
|
||||
printCustomFunctions();
|
||||
printFrSky();
|
||||
|
||||
te->scrollToAnchor("1");
|
||||
|
@ -191,161 +193,55 @@ QString PrintDialog::printFlightModes()
|
|||
void PrintDialog::printInputs()
|
||||
{
|
||||
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\"><tr><td><h2>";
|
||||
str.append(tr("Inputs"));
|
||||
str.append("</h2></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=3>");
|
||||
str += tr("Inputs");
|
||||
str += "</h2></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=3>";
|
||||
int ec=0;
|
||||
unsigned int lastCHN = 255;
|
||||
for(int i=0; i<C9X_MAX_EXPOS; i++) {
|
||||
ExpoData *ed=&g_model->expoData[i];
|
||||
if(ed->mode==0)
|
||||
continue;
|
||||
if(ed->mode==0) continue;
|
||||
ec++;
|
||||
str.append("<tr><td><font size=+1 face='Courier New'>");
|
||||
|
||||
str += "<tr><td>";
|
||||
if(lastCHN!=ed->chn) {
|
||||
lastCHN=ed->chn;
|
||||
str.append("<b>"+getInputStr(g_model, ed->chn)+"</b>");
|
||||
str += addFont("<b>"+modelPrinter.printInputName(ed->chn)+"</b>", "", "+1", "Courier New");
|
||||
}
|
||||
str.append("</font></td>");
|
||||
str.append("<td><font size=+1 face='Courier New' color=green>");
|
||||
str += "</td>";
|
||||
|
||||
switch(ed->mode) {
|
||||
case (1):
|
||||
str += "<-";
|
||||
break;
|
||||
case (2):
|
||||
str += "->";
|
||||
break;
|
||||
default:
|
||||
str += " ";
|
||||
break;
|
||||
};
|
||||
|
||||
str += " " + tr("Weight") + QString("(%1)").arg(getGVarString(ed->weight,true));
|
||||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
str += " " + tr("Source") + QString("(%1)").arg(ed->srcRaw.toString(g_model));
|
||||
if (ed->carryTrim>0) str += " " + tr("NoTrim");
|
||||
else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(g_model);
|
||||
}
|
||||
if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString());
|
||||
|
||||
if (firmware->getCapability(FlightModes)) {
|
||||
if(ed->phases) {
|
||||
if (ed->phases!=(unsigned int)(1<<firmware->getCapability(FlightModes))-1) {
|
||||
unsigned int mask=1;
|
||||
bool first = true;
|
||||
bool multiple = false;
|
||||
QString strModes;
|
||||
for (int j=0; j<firmware->getCapability(FlightModes);j++) {
|
||||
if (!(ed->phases & mask)) {
|
||||
//FlightModeData *pd = &g_model->flightModeData[j];
|
||||
const char * pdName = g_model->flightModeData[j].name;
|
||||
if (first) {
|
||||
strModes += Qt::escape(QString("%1").arg(getPhaseName(j+1,pdName)));
|
||||
first = false;
|
||||
} else {
|
||||
strModes += Qt::escape(QString(", %1").arg(getPhaseName(j+1, pdName)));
|
||||
multiple = true;
|
||||
}
|
||||
}
|
||||
mask <<= 1;
|
||||
}
|
||||
if (!strModes.isEmpty()) {
|
||||
str += " " + tr(multiple?"Flight modes":"Flight mode") + "(" + strModes + ")";
|
||||
}
|
||||
} else {
|
||||
str += tr("DISABLED")+QString(" !!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ed->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
|
||||
if (firmware->getCapability(HasExpoNames) && ed->name[0]) str += Qt::escape(QString(" [%1]").arg(ed->name));
|
||||
str += "</font></td></tr>";
|
||||
str += "<td>" + addFont(modelPrinter.printInputLine(ed), "green", "+1", "Courier New") + "</td>";
|
||||
str += "</tr>";
|
||||
}
|
||||
str += "</table></td></tr></table><br>";
|
||||
if (ec>0)
|
||||
te->append(str);
|
||||
if (ec>0) te->append(str);
|
||||
// debugHtml(str);
|
||||
}
|
||||
|
||||
|
||||
void PrintDialog::printMixes()
|
||||
{
|
||||
QString str = "<table border=1 cellspacing=0 cellpadding=3 style=\"page-break-after:always;\" width=\"100%\"><tr><td><h2>";
|
||||
str.append(tr("Mixers"));
|
||||
str.append("</h2></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=3>");
|
||||
str += tr("Mixers");
|
||||
str += "</h2></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=3>";
|
||||
|
||||
unsigned int lastCHN = 255;
|
||||
for(int i=0; i<firmware->getCapability(Mixes); i++) {
|
||||
MixData *md = &g_model->mixData[i];
|
||||
if(!md->destCh || md->destCh>(unsigned int)firmware->getCapability(Outputs) ) break;
|
||||
str.append("<tr><td><font size=+1 face='Courier New'><b>");
|
||||
|
||||
str += "<tr><td><b>";
|
||||
if(lastCHN!=md->destCh) {
|
||||
lastCHN=md->destCh;
|
||||
str += addFont(modelPrinter.printMixerName(md->destCh).replace(" ", " "), "", "+1", "Courier New");
|
||||
}
|
||||
str += "</b></td>";
|
||||
|
||||
QString chname = QObject::tr("CH%1").arg(lastCHN);
|
||||
// TODO not nice, Qt brings a function for that, I don't remember right now
|
||||
(chname.length() < 4) ? chname.append(" ") : chname.append(" ");
|
||||
if (firmware->getCapability(HasChNames)) {
|
||||
QString name = g_model->limitData[lastCHN-1].name;
|
||||
if (!name.isEmpty()) {
|
||||
name = QString("(") + name + QString(")");
|
||||
str += "<td>" + addFont(modelPrinter.printMixerLine(md), "green", "+1", "Courier New") + "</td>";
|
||||
str += "</tr>";
|
||||
}
|
||||
name.append(" ");
|
||||
chname += name.left(8);
|
||||
}
|
||||
chname = Qt::escape(chname);
|
||||
str.append(chname.replace(" ", " "));
|
||||
}
|
||||
else {
|
||||
str.append(" ");
|
||||
}
|
||||
str.append("</b></font></td>");
|
||||
str.append("<td><font size=+1 face='Courier New' color=green>");
|
||||
switch(md->mltpx) {
|
||||
case (1): str += " *"; break;
|
||||
case (2): str += " R"; break;
|
||||
default: str += " "; break;
|
||||
};
|
||||
|
||||
str += " " + md->srcRaw.toString(g_model);
|
||||
str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true)));
|
||||
|
||||
QString phasesStr = getPhasesStr(md->phases, g_model);
|
||||
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) {
|
||||
str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString()));
|
||||
}
|
||||
|
||||
if (md->carryTrim>0)
|
||||
str += " " + Qt::escape(tr("NoTrim"));
|
||||
else if (md->carryTrim<0)
|
||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(g_model);
|
||||
|
||||
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
||||
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
|
||||
int scale = firmware->getCapability(SlowScale);
|
||||
if (scale == 0)
|
||||
scale = 1;
|
||||
if (md->delayDown || md->delayUp)
|
||||
str += Qt::escape(tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale));
|
||||
if (md->speedDown || md->speedUp)
|
||||
str += Qt::escape(tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale));
|
||||
if (md->mixWarn)
|
||||
str += Qt::escape(tr(" Warn(%1)").arg(md->mixWarn));
|
||||
if (firmware->getCapability(HasMixerNames)) {
|
||||
QString MixerName;
|
||||
MixerName.append(md->name);
|
||||
if (!MixerName.isEmpty()) {
|
||||
str += " " + Qt::escape(QString("(%1)").arg(MixerName));
|
||||
}
|
||||
}
|
||||
str.append("</font></td></tr>");
|
||||
}
|
||||
str.append("</table></td></tr></table><br>");
|
||||
str += "</table></td></tr></table><br>";
|
||||
te->append(str);
|
||||
// debugHtml(str);
|
||||
}
|
||||
|
||||
void PrintDialog::printLimits()
|
||||
|
@ -572,27 +468,25 @@ void PrintDialog::printCurves()
|
|||
}
|
||||
}
|
||||
|
||||
void PrintDialog::printSwitches()
|
||||
void PrintDialog::printLogicalSwitches()
|
||||
{
|
||||
int sc=0;
|
||||
bool haveOutput = false;
|
||||
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
|
||||
str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>");
|
||||
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3>");
|
||||
|
||||
str += "<tr><td><h2>" + tr("Logical Switches") + "</h2></td></tr>";
|
||||
str += "<tr><td><table border=0 cellspacing=0 cellpadding=3>";
|
||||
for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) {
|
||||
if (g_model->logicalSw[i].func) {
|
||||
str.append("<tr>");
|
||||
str.append("<td width=\"60\"><b>"+tr("L")+QString("%1</b></td>").arg(i+1));
|
||||
QString tstr = g_model->logicalSw[i].toString(*g_model, *g_eeGeneral);
|
||||
str.append(doTL(tstr,"green"));
|
||||
str.append("</tr>");
|
||||
sc++;
|
||||
QString sw = modelPrinter.printLogicalSwitchLine(i);
|
||||
if (!sw.isEmpty()) {
|
||||
str += "<tr>";
|
||||
str += "<td width=\"60\"><b>"+ tr("L") + QString("%1</b></td>").arg(i+1);
|
||||
str += "<td align=left>" + addFont(sw, "green") + "</td>";
|
||||
str += "</tr>";
|
||||
haveOutput = true;
|
||||
}
|
||||
}
|
||||
str.append("</table></td></tr></table>");
|
||||
str.append("<br>");
|
||||
if (sc!=0)
|
||||
te->append(str);
|
||||
str += "</table></td></tr></table>";
|
||||
str += "<br>";
|
||||
if (haveOutput) te->append(str);
|
||||
}
|
||||
|
||||
void PrintDialog::printGvars()
|
||||
|
@ -619,52 +513,35 @@ void PrintDialog::printGvars()
|
|||
}
|
||||
}
|
||||
|
||||
void PrintDialog::printFSwitches()
|
||||
void PrintDialog::printCustomFunctions()
|
||||
{
|
||||
int sc=0;
|
||||
bool haveOutput = false;
|
||||
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
|
||||
str.append("<tr><td><h2>"+tr("Special Functions")+"</h2></td></tr>");
|
||||
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3><tr>");
|
||||
str.append("<td width=\"60\"><b>#</b></td>");
|
||||
str.append(doTL(tr("Switch"), "", true));
|
||||
str.append(doTL(tr("Function"), "", true));
|
||||
str.append(doTL(tr("Parameter"), "", true));
|
||||
str.append(doTL(tr("Repeat"), "", true));
|
||||
str.append(doTL(tr("Enabled"), "", true));
|
||||
str.append("</tr>");
|
||||
for(int i=0; i<firmware->getCapability(CustomFunctions); i++) {
|
||||
if (g_model->customFn[i].swtch.type!=SWITCH_TYPE_NONE) {
|
||||
str.append("<tr>");
|
||||
str.append(doTL(tr("SF%1").arg(i+1),"", true));
|
||||
str.append(doTL(g_model->customFn[i].swtch.toString(),"green"));
|
||||
str.append(doTL(g_model->customFn[i].funcToString(),"green"));
|
||||
str.append(doTL(g_model->customFn[i].paramToString(),"green"));
|
||||
int index=g_model->customFn[i].func;
|
||||
if ((g_model->customFn[i].repeatParam>0) &&
|
||||
(index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic)) {
|
||||
str.append(doTL(QString("%1").arg(g_model->customFn[i].repeatParam),"green"));
|
||||
} else {
|
||||
str.append(doTL( " ","green"));
|
||||
}
|
||||
if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) {
|
||||
str.append(doTL((g_model->customFn[i].enabled ? "ON" : "OFF"),"green"));
|
||||
} else {
|
||||
str.append(doTL( "---","green"));
|
||||
}
|
||||
str.append("</tr>");
|
||||
sc++;
|
||||
str += "<tr><td><h2>" + tr("Special Functions") + "</h2></td></tr>";
|
||||
str += "<tr><td><table border=0 cellspacing=0 cellpadding=3>";
|
||||
for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
|
||||
QString cf = modelPrinter.printCustomFunctionLine(i);
|
||||
if (!cf.isEmpty()) {
|
||||
str += "<tr>";
|
||||
str += "<td width=\"60\"><b>"+ tr("SF") + QString("%1</b></td>").arg(i+1);
|
||||
str += "<td align=left>" + addFont(cf, "green") + "</td>";
|
||||
str += "</tr>";
|
||||
haveOutput = true;
|
||||
}
|
||||
}
|
||||
str.append("</table></td></tr></table>");
|
||||
str.append("<br>");
|
||||
if (sc!=0)
|
||||
te->append(str);
|
||||
str += "</table></td></tr></table>";
|
||||
str += "<br>";
|
||||
if (haveOutput) te->append(str);
|
||||
}
|
||||
|
||||
void PrintDialog::printFrSky()
|
||||
{
|
||||
int tc=0;
|
||||
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
|
||||
int analog=2;
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
analog=4;
|
||||
}
|
||||
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||
str.append("<tr><td colspan=3><h2>"+tr("Telemetry Settings")+"</h2></td></tr>");
|
||||
|
@ -675,7 +552,7 @@ void PrintDialog::printFrSky()
|
|||
str.append("</tr>");
|
||||
|
||||
FrSkyData *fd=&g_model->frsky;
|
||||
for (int i=0; i<2; i++) {
|
||||
for (int i=0; i<analog; i++) {
|
||||
if (fd->channels[i].ratio!=0) {
|
||||
tc++;
|
||||
float ratio=(fd->channels[i].ratio/(fd->channels[i].type==0 ?10.0:1));
|
||||
|
@ -725,7 +602,7 @@ void PrintDialog::printFrSky()
|
|||
str.append("<td width=\"40\" align=\"center\"><b>"+tr("Type")+"</b></td><td width=\"40\" align=\"center\"><b>"+tr("Condition")+"</b></td><td width=\"40\" align=\"center\"><b>"+tr("Value")+"</b></td>");
|
||||
str.append("<td width=\"40\" align=\"center\"><b>"+tr("Type")+"</b></td><td width=\"40\" align=\"center\"><b>"+tr("Condition")+"</b></td><td width=\"40\" align=\"center\"><b>"+tr("Value")+"</b></td></tr>");
|
||||
FrSkyData *fd=&g_model->frsky;
|
||||
for (int i=0; i<2; i++) {
|
||||
for (int i=0; i<analog; i++) {
|
||||
if (fd->channels[i].ratio!=0) {
|
||||
tc++;
|
||||
float ratio=(fd->channels[i].ratio/(fd->channels[i].type==0 ?10.0:1));
|
||||
|
@ -749,7 +626,7 @@ void PrintDialog::printFrSky()
|
|||
str.append("<td width=\"40\" align=\"center\"><b>"+getFrSkyAlarmType(fd->rssiAlarms[1].level)+"</b></td><td width=\"40\" align=\"center\"><b><</b></td><td width=\"40\" align=\"center\"><b>"+QString::number(fd->rssiAlarms[1].value,10)+"</b></td></tr>");
|
||||
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr>");
|
||||
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Frsky serial protocol")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyProtocol(fd->usrProto)+"</td></tr>");
|
||||
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Blades")+"</b></td><td colspan=8 align=\"left\">"+fd->blades+"</td></tr>");
|
||||
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Blades")+"</b></td><td colspan=8 align=\"left\">"+QString("%1").arg(fd->blades)+"</td></tr>");
|
||||
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr></table>");
|
||||
}
|
||||
#if 0
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QtGui>
|
||||
#include <QDir>
|
||||
#include "eeprominterface.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
namespace Ui {
|
||||
class PrintDialog;
|
||||
|
@ -37,9 +38,9 @@ private:
|
|||
void printLimits();
|
||||
void printCurves();
|
||||
void printGvars();
|
||||
void printSwitches();
|
||||
void printLogicalSwitches();
|
||||
void printSafetySwitches();
|
||||
void printFSwitches();
|
||||
void printCustomFunctions();
|
||||
void printFrSky();
|
||||
void printToFile();
|
||||
|
||||
|
@ -48,6 +49,8 @@ private:
|
|||
QString curvefile9;
|
||||
QDir *qd;
|
||||
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
private slots:
|
||||
void on_printButton_clicked();
|
||||
void on_printFileButton_clicked();
|
||||
|
|
|
@ -483,8 +483,7 @@ void SimulatorDialog::initUi(T * ui)
|
|||
line = (i-16) % (std::min(16,outputs-16)/2);
|
||||
}
|
||||
QLabel * label = new QLabel(tabWidget);
|
||||
ModelData model;
|
||||
label->setText(RawSource(SOURCE_TYPE_CH, i).toString(&model));
|
||||
label->setText(RawSource(SOURCE_TYPE_CH, i).toString());
|
||||
outputTab->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
|
||||
|
||||
QSlider * slider = new QSlider(tabWidget);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue