diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp
index f02168b5c..b6be51ce4 100644
--- a/companion/src/comparedialog.cpp
+++ b/companion/src/comparedialog.cpp
@@ -25,8 +25,9 @@ public:
uint8_t models[C9X_MAX_MODELS];
};
-CompareDialog::CompareDialog(QWidget * parent):
+CompareDialog::CompareDialog(QWidget * parent, Firmware * firmware):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
+ firmware(firmware),
model1(0),
model2(0),
ui(new Ui::CompareDialog)
@@ -80,6 +81,8 @@ void CompareDialog::printDiff()
if (GetCurrentFirmware()->getCapability(FlightModes)) {
printPhases();
}
+ curvefile1=generateProcessUniqueTempFileName("curve1.png");
+ curvefile2=generateProcessUniqueTempFileName("curve2.png");
printExpos();
printMixers();
printLimits();
@@ -161,8 +164,8 @@ void CompareDialog::closeEvent(QCloseEvent *event)
CompareDialog::~CompareDialog()
{
- qunlink(curvefile5);
- qunlink(curvefile9);
+ qunlink(curvefile1);
+ qunlink(curvefile2);
delete ui;
}
@@ -220,10 +223,8 @@ void CompareDialog::printSetup()
str.append(fv(tr("Timer1"), getTimerStr(g_model1->timers[0]), color)); //value, mode, count up/down
color=getColor1(getTimerStr(g_model1->timers[1]), getTimerStr(g_model2->timers[1]));
str.append(fv(tr("Timer2"), getTimerStr(g_model1->timers[1]), color)); //value, mode, count up/down
- color=getColor1(getProtocol(g_model1),getProtocol(g_model2));
- str.append(fv(tr("Protocol"), getProtocol(g_model1), color)); //proto, numch, delay,
- color=getColor1(g_model1->moduleData[0].ppmPulsePol, g_model2->moduleData[0].ppmPulsePol);
- str.append(fv(tr("Pulse Polarity"), g_model1->moduleData[0].polarityToString(), color));
+ color=getColor1(getProtocol(g_model1->moduleData[0]),getProtocol(g_model2->moduleData[0]));
+ str.append(fv(tr("Protocol"), getProtocol(g_model1->moduleData[0]), color)); //proto, numch, delay,
color=getColor1(g_model1->thrTrim,g_model2->thrTrim);
str.append(fv(tr("Throttle Trim"), g_model1->thrTrim ? tr("Enabled") : tr("Disabled"), color));
color=getColor1(getTrimInc(g_model1),getTrimInc(g_model2));
@@ -240,10 +241,8 @@ void CompareDialog::printSetup()
str.append(fv(tr("Timer1"), getTimerStr(g_model2->timers[0]),color)); //value, mode, count up/down
color=getColor2(getTimerStr(g_model1->timers[1]), getTimerStr(g_model2->timers[1]));
str.append(fv(tr("Timer2"), getTimerStr(g_model2->timers[1]),color)); //value, mode, count up/down
- color=getColor2(getProtocol(g_model1),getProtocol(g_model2));
- str.append(fv(tr("Protocol"), getProtocol(g_model2), color)); //proto, numch, delay,
- color=getColor2(g_model1->moduleData[0].ppmPulsePol, g_model2->moduleData[0].ppmPulsePol);
- str.append(fv(tr("Pulse Polarity"), g_model2->moduleData[0].polarityToString(), color));
+ color=getColor2(getProtocol(g_model1->moduleData[0]),getProtocol(g_model2->moduleData[0]));
+ str.append(fv(tr("Protocol"), getProtocol(g_model2->moduleData[0]), color)); //proto, numch, delay,
color=getColor2(g_model1->thrTrim,g_model2->thrTrim);
str.append(fv(tr("Throttle Trim"), g_model2->thrTrim ? tr("Enabled") : tr("Disabled"), color));
color=getColor2(getTrimInc(g_model1),getTrimInc(g_model2));
@@ -898,82 +897,176 @@ void CompareDialog::printMixers()
void CompareDialog::printCurves()
{
-#if 0
- int i,r,g,b,c;
+ int i,r,g,b,c,count1,count2,usedcurves=0;
+ QString cm1y,cm1x, cm2y,cm2x;
char buffer [16];
- QString color;
- QColor * qplot_color[8];
- qplot_color[0]=new QColor(0,0,127);
- qplot_color[1]=new QColor(0,127,0);
- qplot_color[2]=new QColor(127,0,0);
- qplot_color[3]=new QColor(127,127,0);
- qplot_color[4]=new QColor(0,0,255);
- qplot_color[5]=new QColor(0,255,0);
- qplot_color[6]=new QColor(255,0,0);
- qplot_color[7]=new QColor(255,255,0);
+ QPen pen(Qt::black, 2, Qt::SolidLine);
+ int numcurves=firmware->getCapability(NumCurves);
+ if (numcurves==0) {
+ numcurves=16;
+ }
+
QString str = "
";
str.append(tr("Curves"));
str.append(" |
");
- str.append("| "+tr("5 Point Curves")+" | ");
- for(i=0; i<5; i++)
- str.append(doTC(tr("pt %1").arg(i+1), "", true));
- str.append(" | ");
- for(i=0; i<5; i++)
- str.append(doTC(tr("pt %1").arg(i+1), "", true));
- str.append(" ");
+ str.append("");
+ QImage qi1(ISIZE+1,ISIZE+1,QImage::Format_RGB32);
+ QPainter painter1(&qi1);
+ QImage qi2(ISIZE+1,ISIZE+1,QImage::Format_RGB32);
+ QPainter painter2(&qi2);
+ painter1.setBrush(QBrush("#FFFFFF"));
+ painter2.setBrush(QBrush("#FFFFFF"));
+ painter1.setPen(QColor(0,0,0));
+ painter2.setPen(QColor(0,0,0));
+ painter1.drawRect(0,0,ISIZE,ISIZE);
+ painter2.drawRect(0,0,ISIZE,ISIZE);
+
+ for(i=0; icurves[i].count; j++) {
+ if (g_model1->curves[i].points[j].y!=0)
+ count1++;
+ }
+ count2=0;
+ for(int j=0; jcurves[i].count; j++) {
+ if (g_model2->curves[i].points[j].y!=0)
+ count2++;
+ }
+ if ((count1>0) || (g_model1->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)|| (g_model1->curves[i].count !=5) ||
+ (count2>0) || (g_model2->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)|| (g_model2->curves[i].count !=5)) {
+ pen.setColor(colors[usedcurves]);
+ painter1.setPen(pen);
+ painter2.setPen(pen);
- for(i=0; igetRgb(&r,&g,&b);
- c=r;
- c*=256;
- c+=g;
- c*=256;
- c+=b;
- sprintf(buffer,"%06x",c);
- str.append("");
- for(int j=0; j<5; j++) {
- color=getColor1(g_model2->curves5[i][j],g_model2->curves5[i][j]);
- str.append(doTR(QString::number(g_model1->curves5[i][j]),color));
- }
- str.append(QString("| ").arg(buffer)+tr("Curve")+QString(" %1 | ").arg(i+1));
- for(int j=0; j<5; j++) {
- color=getColor1(g_model2->curves5[i][j],g_model2->curves5[i][j]);
- str.append(doTR(QString::number(g_model2->curves5[i][j]),color));
- }
- str.append(" ");
- }
- str.append(" ");
+ colors[usedcurves].getRgb(&r,&g,&b);
+ c=r;
+ c*=256;
+ c+=g;
+ c*=256;
+ c+=b;
+ sprintf(buffer,"%06x",c);
+ // curves are different in number of points or curve type so makes little sense to compare they are just different
+ if ((g_model1->curves[i].count!=g_model2->curves[i].count) || (g_model1->curves[i].type!=g_model2->curves[i].type)) {
+ cm1y="[";
+ cm1x="[";
+ for(int j=0; jcurves[i].count; j++) {
+ cm1y.append(QString("%1").arg(g_model1->curves[i].points[j].y));
+ cm1x.append(QString("%1").arg(g_model1->curves[i].points[j].x));
+ if (j<(g_model1->curves[i].count-1)) {
+ cm1y.append(",");
+ cm1x.append(",");
+ }
+ if (g_model1->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
+ painter1.drawLine(ISIZE/2+(ISIZE*g_model1->curves[i].points[j-1].x)/200,ISIZE/2-(ISIZE*g_model1->curves[i].points[j-1].y)/200,ISIZE/2+(ISIZE*g_model1->curves[i].points[j].x)/200,ISIZE/2-(ISIZE*g_model1->curves[i].points[j].y)/200);
+ else
+ painter1.drawLine(ISIZE*(j-1)/(g_model1->curves[i].count-1),ISIZE/2-(ISIZE*g_model1->curves[i].points[j-1].y)/200,ISIZE*(j)/(g_model1->curves[i].count-1),ISIZE/2-(ISIZE*g_model1->curves[i].points[j].y)/200);
+
+ }
+ cm1y.append("]");
+ cm1x.append("]");
+ cm2y="[";
+ cm2x="[";
+ for(int j=0; jcurves[i].count; j++) {
+ cm2y.append(QString("%1").arg(g_model2->curves[i].points[j].y));
+ cm2x.append(QString("%1").arg(g_model2->curves[i].points[j].x));
+ if (j<(g_model2->curves[i].count-1)) {
+ cm2y.append(",");
+ cm2x.append(",");
+ }
+ if (g_model2->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
+ painter2.drawLine(ISIZE/2+(ISIZE*g_model2->curves[i].points[j-1].x)/200,ISIZE/2-(ISIZE*g_model2->curves[i].points[j-1].y)/200,ISIZE/2+(ISIZE*g_model2->curves[i].points[j].x)/200,ISIZE/2-(ISIZE*g_model2->curves[i].points[j].y)/200);
+ else
+ painter2.drawLine(ISIZE*(j-1)/(g_model2->curves[i].count-1),ISIZE/2-(ISIZE*g_model2->curves[i].points[j-1].y)/200,ISIZE*(j)/(g_model2->curves[i].count-1),ISIZE/2-(ISIZE*g_model2->curves[i].points[j].y)/200);
+
+ }
+ cm2y.append("]");
+ cm2x.append("]");
+ str.append("");
+ str.append(cm1y);
+ if ((g_model1->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)) {
+ str.append(QString(" ")+cm1x+QString(" | "));
+ }
+ str.append(QString("").arg(buffer)+tr("Curve")+QString(" %1 | ").arg(i+1));
+ str.append("");
+ str.append(cm2y);
+ if ((g_model2->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)) {
+ str.append(QString(" ")+cm2x+QString(" | "));
+ }
+ } else {
+ // curves have the same number of points and the same type, we can compare them point by point
+ cm1y="[";
+ cm1x="[";
+ cm2y="[";
+ cm2x="[";
+ for(int j=0; jcurves[i].count; j++) {
+ if (g_model1->curves[i].points[j].y!=g_model2->curves[i].points[j].y) {
+ cm1y.append(QString("%1").arg(g_model1->curves[i].points[j].y));
+ cm2y.append(QString("%1").arg(g_model2->curves[i].points[j].y));
+ } else {
+ cm1y.append(QString("%1").arg(g_model1->curves[i].points[j].y));
+ cm2y.append(QString("%1").arg(g_model2->curves[i].points[j].y));
+ }
+ if (g_model1->curves[i].points[j].x!=g_model2->curves[i].points[j].x) {
+ cm1x.append(QString("%1").arg(g_model1->curves[i].points[j].x));
+ cm2x.append(QString("%1").arg(g_model2->curves[i].points[j].x));
+ } else {
+ cm1x.append(QString("%1").arg(g_model1->curves[i].points[j].x));
+ cm2x.append(QString("%1").arg(g_model2->curves[i].points[j].x));
+ }
+ if (j<(g_model1->curves[i].count-1)) {
+ cm1y.append(",");
+ cm1x.append(",");
+ cm2y.append(",");
+ cm2x.append(",");
+ }
+ if (g_model1->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
+ painter1.drawLine(ISIZE/2+(ISIZE*g_model1->curves[i].points[j-1].x)/200,ISIZE/2-(ISIZE*g_model1->curves[i].points[j-1].y)/200,ISIZE/2+(ISIZE*g_model1->curves[i].points[j].x)/200,ISIZE/2-(ISIZE*g_model1->curves[i].points[j].y)/200);
+ else
+ painter1.drawLine(ISIZE*(j-1)/(g_model1->curves[i].count-1),ISIZE/2-(ISIZE*g_model1->curves[i].points[j-1].y)/200,ISIZE*(j)/(g_model1->curves[i].count-1),ISIZE/2-(ISIZE*g_model1->curves[i].points[j].y)/200);
+ if (g_model2->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
+ painter2.drawLine(ISIZE/2+(ISIZE*g_model2->curves[i].points[j-1].x)/200,ISIZE/2-(ISIZE*g_model2->curves[i].points[j-1].y)/200,ISIZE/2+(ISIZE*g_model2->curves[i].points[j].x)/200,ISIZE/2-(ISIZE*g_model2->curves[i].points[j].y)/200);
+ else
+ painter2.drawLine(ISIZE*(j-1)/(g_model2->curves[i].count-1),ISIZE/2-(ISIZE*g_model2->curves[i].points[j-1].y)/200,ISIZE*(j)/(g_model2->curves[i].count-1),ISIZE/2-(ISIZE*g_model2->curves[i].points[j].y)/200);
+ }
+ painter1.setPen(QColor(0,0,0));
+ painter2.setPen(QColor(0,0,0));
+ painter1.drawLine(0,ISIZE/2,ISIZE,ISIZE/2);
+ painter2.drawLine(0,ISIZE/2,ISIZE,ISIZE/2);
+ painter1.drawLine(ISIZE/2,0,ISIZE/2,ISIZE);
+ painter2.drawLine(ISIZE/2,0,ISIZE/2,ISIZE);
+ for(i=0; i<21; i++) {
+ painter1.drawLine(ISIZE/2-5,(ISIZE*i)/(20),ISIZE/2+5,(ISIZE*i)/(20));
+ painter2.drawLine(ISIZE/2-5,(ISIZE*i)/(20),ISIZE/2+5,(ISIZE*i)/(20));
+ painter1.drawLine((ISIZE*i)/(20),ISIZE/2-5,(ISIZE*i)/(20),ISIZE/2+5);
+ painter2.drawLine((ISIZE*i)/(20),ISIZE/2-5,(ISIZE*i)/(20),ISIZE/2+5);
+ }
- str.append("| "+tr("9 Point Curves")+" | ");
- for(i=0; i<9; i++)
- str.append(doTC(tr("pt %1").arg(i+1), "", true));
- str.append(" | ");
- for(i=0; i<9; i++)
- str.append(doTC(tr("pt %1").arg(i+1), "", true));
- str.append(" ");
- for(i=0; igetRgb(&r,&g,&b);
- c=r;
- c*=256;
- c+=g;
- c*=256;
- c+=b;
- sprintf(buffer,"%06x",c);
- str.append("");
- for(int j=0; j<9; j++) {
- color=getColor1(g_model2->curves9[i][j],g_model2->curves9[i][j]);
- str.append(doTR(QString::number(g_model1->curves5[i][j]),color));
+ cm1y.append("]");
+ cm1x.append("]");
+ cm2y.append("]");
+ cm2x.append("]");
+ str.append(" ");
+ str.append(cm1y);
+ if ((g_model1->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)) {
+ str.append(QString(" ")+cm1x+QString(" | "));
+ }
+ str.append(QString("").arg(buffer)+tr("Curve")+QString(" %1 | ").arg(i+1));
+ str.append("");
+ str.append(cm2y);
+ if ((g_model2->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)) {
+ str.append(QString(" ")+cm2x+QString(" | "));
+ }
+ }
+ usedcurves++;
}
- str.append(QString("").arg(buffer)+tr("Curve")+QString(" %1 | ").arg(i+1+MAX_CURVE5));
- for(int j=0; j<9; j++) {
- color=getColor1(g_model2->curves9[i][j],g_model2->curves9[i][j]);
- str.append(doTR(QString::number(g_model2->curves9[i][j]),color));
- }
- str.append("");
}
- str.append("
| ");
- te->append(str);
-#endif
+ if (usedcurves>0) {
+ str.append(QString(" |
 | |  | ").arg(curvefile1).arg(curvefile2));
+ str.append("
");
+ qi1.save(curvefile1, "png",100);
+ qi2.save(curvefile2, "png",100);
+ te->append(str);
+ }
}
void CompareDialog::printSwitches()
@@ -1026,7 +1119,7 @@ void CompareDialog::printFSwitches()
for(int i=0; igetCapability(CustomFunctions); i++)
{
if (g_model1->customFn[i].swtch.type || g_model2->customFn[i].swtch.type) {
- if ((g_model1->customFn[i].swtch != g_model2->customFn[i].swtch) || (g_model1->customFn[i].func!=g_model2->customFn[i].func) || (g_model1->customFn[i].adjustMode!=g_model2->customFn[i].adjustMode) || (g_model1->customFn[i].param!=g_model2->customFn[i].param)) {
+ if ((g_model1->customFn[i].swtch != g_model2->customFn[i].swtch) || (g_model1->customFn[i].func!=g_model2->customFn[i].func) || (g_model1->customFn[i].adjustMode!=g_model2->customFn[i].adjustMode) || (g_model1->customFn[i].param!=g_model2->customFn[i].param) || (g_model1->customFn[i].enabled != g_model2->customFn[i].enabled) || (g_model1->customFn[i].repeatParam != g_model2->customFn[i].repeatParam)) {
color1="green";
color2="red";
} else {
diff --git a/companion/src/comparedialog.h b/companion/src/comparedialog.h
index e0d45d898..bfc170479 100644
--- a/companion/src/comparedialog.h
+++ b/companion/src/comparedialog.h
@@ -15,9 +15,10 @@ class CompareDialog : public QDialog
Q_OBJECT
public:
- CompareDialog(QWidget *parent);
+ CompareDialog(QWidget *parent, Firmware * firmware);
~CompareDialog();
-
+ Firmware * firmware;
+
protected:
GeneralSettings * settings;
ModelData * g_model1;
@@ -60,8 +61,8 @@ class CompareDialog : public QDialog
bool ChannelHasMix(MixData * mixArray, uint8_t destCh);
QTextEdit * te;
- QString curvefile5;
- QString curvefile9;
+ QString curvefile1;
+ QString curvefile2;
QDir *qd;
private slots:
diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp
index 4640f298f..a1b4f1982 100644
--- a/companion/src/helpers.cpp
+++ b/companion/src/helpers.cpp
@@ -797,12 +797,12 @@ QString getTimerStr(TimerData & timer)
return result;
}
-QString getProtocol(ModelData * g_model)
+QString getProtocol(ModuleData & module)
{
- QString str = getProtocolStr(g_model->moduleData[0].protocol);
+ QString str = getProtocolStr(module.protocol);
- if (g_model->moduleData[0].protocol == PPM)
- str.append(QObject::tr(": %1 Channels, %2usec Delay").arg(g_model->moduleData[0].channelsCount).arg(g_model->moduleData[0].ppmDelay));
+ if (module.protocol == PPM)
+ str.append(QObject::tr(": %1 Channels, %2usec Delay, Pulse polarity %3").arg(module.channelsCount).arg(module.ppmDelay).arg(module.polarityToString()));
return str;
}
diff --git a/companion/src/helpers.h b/companion/src/helpers.h
index 035176e58..562d1650d 100644
--- a/companion/src/helpers.h
+++ b/companion/src/helpers.h
@@ -123,7 +123,7 @@ int findmult(float value, float base);
QString getTrimInc(ModelData * g_model);
QString getTimerStr(TimerData & timer);
-QString getProtocol(ModelData * g_model);
+QString getProtocol(ModuleData & module);
QString getCenterBeepStr(ModelData * g_model);
/* FrSky helpers */
diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp
index c26a81ff4..ebfb53861 100644
--- a/companion/src/mainwindow.cpp
+++ b/companion/src/mainwindow.cpp
@@ -863,7 +863,7 @@ void MainWindow::burnFuses()
void MainWindow::compare()
{
- CompareDialog *fd = new CompareDialog(this);
+ CompareDialog *fd = new CompareDialog(this,GetCurrentFirmware());
fd->setAttribute(Qt::WA_DeleteOnClose, true);
fd->show();
}