#include "printdialog.h" #include "ui_printdialog.h" #include "helpers.h" #include "eeprominterface.h" #include #include #include #include #if !defined WIN32 && defined __GNUC__ #include #endif #define ISIZE 200 // curve image size #define ISIZEW 400 // curve image size PrintDialog::PrintDialog(QWidget *parent, FirmwareInterface * firmware, GeneralSettings *gg, ModelData *gm, QString filename) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), firmware(firmware), g_eeGeneral(gg), g_model(gm), printfilename(filename), ui(new Ui::PrintDialog), gvars(gvarsEnabled()), gvarnum (0) { if (gvars) { gvarnum=firmware->getCapability(Gvars); } ui->setupUi(this); this->setWindowIcon(CompanionIcon("print.png")); te = ui->textEdit; setWindowTitle(tr("Setup for: ") + g_model->name); te->clear(); QString modelname=g_model->name; if (modelname.isEmpty()) { curvefile5=QString("%1/curve5.png").arg(qd->tempPath()); curvefile9=QString("%1/curve9.png").arg(qd->tempPath()); } else { curvefile5=QString("%1/%2-curve5.png").arg(qd->tempPath()).arg(modelname); curvefile9=QString("%1/%2-curve9.png").arg(qd->tempPath()).arg(modelname); } printSetup(); if (gvars) { te->append(printFlightModes()+"
"); } printInputs(); printMixes(); printLimits(); printCurves(); printGvars(); printSwitches(); printFSwitches(); printFrSky(); te->scrollToAnchor("1"); if (!printfilename.isEmpty()) { printToFile(); QTimer::singleShot(0, this, SLOT(autoClose())); } } void PrintDialog::closeEvent(QCloseEvent *event) { if (printfilename.isEmpty()) { QByteArray ba = curvefile5.toLatin1(); char *name = ba.data(); unlink(name); ba = curvefile9.toLatin1(); name = ba.data(); unlink(name); } } PrintDialog::~PrintDialog() { delete ui; } QString doTC(const QString s, const QString color="", bool bold=false) { QString str = s; if(bold) str = "" + str + ""; if(!color.isEmpty()) str = "" + str + ""; return "" + str + ""; } QString doTR(const QString s, const QString color="", bool bold=false) { QString str = s; if(bold) str = "" + str + ""; if(!color.isEmpty()) str = "" + str + ""; return "" + str + ""; } QString doTL(const QString s, const QString color="", bool bold=false) { QString str = s; if(bold) str = "" + str + ""; if(!color.isEmpty()) str = "" + str + ""; return "" + str + ""; } QString PrintDialog::fv(const QString name, const QString value) { return "" + name + ": " + value + "
"; } void PrintDialog::printSetup() { QString str = ""; str.append(QString(""); if (!gvars) { str.append(""); } str.append("

").arg((firmware->getCapability(FlightModes) && !gvars) ? 2 : 1)); str.append(g_model->name); str.append(" ("); str.append(firmware->getEepromInterface()->getName()); str.append(")

"+tr("printed on: %1").arg(QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate))+"
"); str.append(""); str.append("

"+tr("General Model Settings")+"

"); str.append(fv(tr("Name"), g_model->name)); str.append(fv(tr("EEprom Size"), QString("%1").arg(firmware->getEepromInterface()->getSize(*g_model)))); str.append(fv(tr("Timer1"), getTimerStr(g_model->timers[0]))); //value, mode, count up/down str.append(fv(tr("Timer2"), getTimerStr(g_model->timers[1]))); //value, mode, count up/down str.append(fv(tr("Protocol"), getProtocol(g_model))); //proto, numch, delay, str.append(fv(tr("Pulse Polarity"), g_model->moduleData[0].ppmPulsePol ? "NEG" : "POS")); str.append(fv(tr("Throttle Trim"), g_model->thrTrim ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Throttle Expo"), g_model->thrExpo ? tr("Enabled") : tr("Disabled"))); // TODO str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw))); str.append(fv(tr("Trim Increment"), getTrimInc(g_model))); str.append(fv(tr("Center Beep"), getCenterBeep(g_model))); // specify which channels beep str.append("
"); str.append(printFlightModes()); str.append("

"); te->append(str); } QString PrintDialog::printFlightModes() { QString str=""; str.append(QString(""); str.append(""); if (gvars) { str.append(QString(""); } if (firmware->getCapability(RotaryEncoders)) { str.append(QString(""); } str.append(""); QString labels[] = { tr("Rud"), tr("Ele"), tr("Thr"), tr("Ail") }; // TODO is elsewhere for sure for (int i=0; i<4; i++) { GeneralSettings generalSettings = *g_eeGeneral; str.append(QString("").arg(labels[CONVERT_MODE(i+1)-1])); } if (gvars) { for (unsigned int i=0; iGV%1
%2").arg(i+1).arg(g_model->gvars_names[i])); } } for (int i=0; igetCapability(RotaryEncoders); i++) { str.append(QString("
").arg((i==0 ? 'A': 'B'))); } str.append(""); for (int i=0; igetCapability(FlightModes); i++) { PhaseData *pd=&g_model->phaseData[i]; str.append("").arg(i).arg(pd->name)); str.append(QString("").arg((qreal)pd->fadeIn/firmware->getCapability(SlowScale))); str.append(QString("").arg((qreal)pd->fadeOut/firmware->getCapability(SlowScale))); for (int k=0; k<4; k++) { //TODO trim values if (pd->trimRef[k]==-1) { str.append(QString("").arg(pd->trim[k])); } else { str.append("").arg(pd->trimRef[k])); } } if (gvars) { for (unsigned int k=0; kgvars[k]<=1024) { str.append(QString(""); } else { int num = pd->gvars[k] - 1025; if (num>=i) num++; str.append("").arg(num)); } } } for (int k=0; kgetCapability(RotaryEncoders); k++) { if (pd->rotaryEncoders[k]<=1024) { str.append(QString(""); } else { int num = pd->rotaryEncoders[k] - 1025; if (num>=i) num++; str.append(QString("").arg(num)); } } str.append(QString("").arg(pd->swtch.toString())); str.append(""); } str.append("

").arg(!gvars ? 8+firmware->getCapability(RotaryEncoders) : 8+gvarnum+firmware->getCapability(RotaryEncoders))); str.append(tr("Flight modes")); str.append("

 "); str.append(tr("Fades")+""+tr("Trims")+"").arg(gvarnum)+tr("Gvars")+"").arg(firmware->getCapability(RotaryEncoders))+tr("Rot.Enc.")+""+tr("Switch")+"
"+tr("Flight mode name")); str.append(""+tr("IN")+""+tr("OUT")+"%1RE%1
"+tr("FM")+QString("%1 %2%1%1%1"+tr("FM")+QString("%1%1").arg(pd->gvars[k])+""+tr("FM")+QString("%1%1").arg(pd->rotaryEncoders[k])+"")+tr("FM")+QString("%1%1
"); return(str); } void PrintDialog::printInputs() { QString str = "

"; str.append(tr("Inputs")); str.append("

"); int ec=0; unsigned int lastCHN = 255; for(int i=0; iexpoData[i]; if(ed->mode==0) continue; ec++; str.append(""); str.append(""; } str += "
"); if(lastCHN!=ed->chn) { lastCHN=ed->chn; str.append(""+getInputStr(*g_model, ed->chn)+""); } str.append(""); 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()); if (ed->carryTrim>0) str += " " + tr("NoTrim"); else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(); } if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString()); if (firmware->getCapability(FlightModes)) { if(ed->phases) { if (ed->phases!=(unsigned int)(1<getCapability(FlightModes))-1) { unsigned int mask=1; bool first = true; bool multiple = false; QString strModes; for (int j=0; jgetCapability(FlightModes);j++) { if (!(ed->phases & mask)) { //PhaseData *pd = &g_model->phaseData[j]; const char * pdName = g_model->phaseData[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 += "

"; if (ec>0) te->append(str); } void PrintDialog::printMixes() { QString str = "

"; str.append(tr("Mixers")); str.append("

"); unsigned int lastCHN = 255; for(int i=0; igetCapability(Mixes); i++) { MixData *md = &g_model->mixData[i]; if(!md->destCh || md->destCh>(unsigned int)firmware->getCapability(Outputs) ) break; str.append(""); str.append(""); } str.append("
"); if(lastCHN!=md->destCh) { lastCHN=md->destCh; 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(")"); } name.append(" "); chname += name.left(8); } chname = Qt::escape(chname); str.append(chname.replace(" ", " ")); } else { str.append(" "); } str.append(""); switch(md->mltpx) { case (1): str += " *"; break; case (2): str += " R"; break; default: str += "  "; break; }; //set mixer src model if it is unset (srcRaw needs this to generate proper toString() for input source type) if (md->srcRaw.model == 0) md->srcRaw.model = g_model; str += " " + md->srcRaw.toString(); 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) { str += " " + Qt::escape(tr("NoTrim")); } if (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("

"); te->append(str); } void PrintDialog::printLimits() { QString str = ""; int numcol; numcol=(firmware->getCapability(Outputs)+1)>17 ? 17:firmware->getCapability(Outputs)+1; str.append(QString(""); str.append(""); if (firmware->getCapability(Outputs)<17) { for(int i=0; igetCapability(Outputs); i++) { str.append(doTC(tr("CH")+QString(" %1").arg(i+1,2,10,QChar('0')),"",true)); } str.append(""); if (firmware->getCapability(HasChNames)) { str.append(""); for(int i=0; igetCapability(Outputs); i++) { str.append(doTR(g_model->limitData[i].name,"green")); } } str.append(""); for(int i=0; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].offset/10, 'f', 1),"green")); } str.append(""); str.append(""); for(int i=0; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].min/10),"green")); } str.append(""); str.append(""); for(int i=0; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].max/10),"green")); } str.append(""); str.append(""); for(int i=0; igetCapability(Outputs); i++) { str.append(doTR(QString(g_model->limitData[i].revert ? tr("INV") : tr("NOR")),"green")); } } else { for(int i=0; i<16; i++) { str.append(doTC(tr("CH")+QString(" %1").arg(i+1,2,10,QChar('0')),"",true)); } str.append(""); if (firmware->getCapability(HasChNames)) { str.append(""); for(int i=0; i<16; i++) { str.append(doTR(g_model->limitData[i].name,"green")); } } str.append(""); for(int i=0; i<16; i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].offset/10, 'f', 1),"green")); } str.append(""); str.append(""); for(int i=0; i<16; i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].min/10),"green")); } str.append(""); str.append(""); for(int i=0; i<16; i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].max/10),"green")); } str.append(""); str.append(""); for(int i=0; i<16; i++) { str.append(doTR(QString(g_model->limitData[i].revert ? tr("INV") : tr("NOR")),"green")); } str.append(""); str.append(QString(""); str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTC(tr("CH")+QString(" %1").arg(i+1,2,10,QChar('0')),"",true)); } str.append(""); if (firmware->getCapability(HasChNames)) { str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTR(g_model->limitData[i].name,"green")); } } str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].offset/10, 'f', 1),"green")); } str.append(""); str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].min/10),"green")); } str.append(""); str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTR(QString::number((qreal)g_model->limitData[i].max/10),"green")); } str.append(""); str.append(""); for(int i=16; igetCapability(Outputs); i++) { str.append(doTR(QString(g_model->limitData[i].revert ? tr("INV") : tr("NOR")),"green")); } } str.append(""); str.append("

").arg(numcol)+tr("Limits")+"

 
"+tr("Name")+"
"+tr("Offset")+"
"+tr("Min")+"
"+tr("Max")+"
"+tr("Invert")+"
"+tr("Name")+"
"+tr("Offset")+"
"+tr("Min")+"
"+tr("Max")+"
"+tr("Invert")+"
 ").arg(numcol)+"
 
"+tr("Name")+"
"+tr("Offset")+"
"+tr("Min")+"
"+tr("Max")+"
"+tr("Invert")+"
"); str.append("
"); te->append(str); } void PrintDialog::printCurves() { int i,r,g,b,c,count; char buffer[16]; QPen pen(Qt::black, 2, Qt::SolidLine); QString str = "

"; str.append(tr("Curves")); str.append("

"); int numcurves=firmware->getCapability(NumCurves); if (numcurves==0) { numcurves=16; } { QImage qi(ISIZEW+1,ISIZEW+1,QImage::Format_RGB32); QPainter painter(&qi); painter.setBrush(QBrush("#FFFFFF")); painter.setPen(QColor(0,0,0)); painter.drawRect(0,0,ISIZEW,ISIZEW); str.append(""+QString("
").arg(curvefile5)); for(i=0; i"); str.append(QString("").arg(i+1)); if(i%2) str.append(""); } str.append("
").arg(buffer)+tr("Curve")+QString(" %1
"); str.append(""); str.append(doTC(" ")); str.append(doTC(" ")); int numpoint=0; for(i=0; icurves[i].count>numpoint) numpoint=g_model->curves[i].count; } for(i=0; i"); for(i=0; i"); int curvepoints=g_model->curves[i].count; if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM) str.append(QString("").arg(i+1)); else str.append(QString("").arg(i+1)); count=0; for(int j=0; jcurves[i].points[j].y!=0) count++; } for(int j=0; jcurves[i].points[j].y),"green")); if (j>0 && count!=0) { if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM) painter.drawLine(ISIZEW/2+(ISIZEW*g_model->curves[i].points[j-1].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW/2+(ISIZEW*g_model->curves[i].points[j].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200); else painter.drawLine(ISIZEW*(j-1)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW*(j)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200); } } for(int j=curvepoints; j"); if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM) { str.append(""); for(int j=0; jcurves[i].points[j].x),"green")); } for(int j=curvepoints; j"); } } str.append("
").arg(buffer)+tr("Curve")+QString(" %1Y").arg(buffer)+tr("Curve")+QString(" %1Y
X
"); str.append("
"); painter.setPen(QColor(0,0,0)); painter.drawLine(0,ISIZEW/2,ISIZEW,ISIZEW/2); painter.drawLine(ISIZEW/2,0,ISIZEW/2,ISIZEW); for(i=0; i<21; i++) { painter.drawLine(ISIZEW/2-5,(ISIZEW*i)/(20),ISIZEW/2+5,(ISIZEW*i)/(20)); painter.drawLine((ISIZEW*i)/(20),ISIZEW/2-5,(ISIZEW*i)/(20),ISIZEW/2+5); } qi.save(curvefile5, "png",100); } te->append(str); } void PrintDialog::printSwitches() { int sc=0; QString str = ""; str.append(""); str.append("

"+tr("Logical Switches")+"

"); for (int i=0; igetCapability(LogicalSwitches); i++) { if (g_model->customSw[i].func) { str.append(""); str.append("").arg(i+1)); QString tstr = g_model->customSw[i].toString(*g_model); str.append(doTL(tstr,"green")); str.append(""); sc++; } } str.append("
"+tr("L")+QString("%1
"); str.append("
"); if (sc!=0) te->append(str); } void PrintDialog::printGvars() { if (!firmware->getCapability(GvarsFlightModes) && (gvars && firmware->getCapability(Gvars))) { QString str = ""; str.append(""); str.append("

"+tr("Global Variables")+"

"); PhaseData *pd=&g_model->phaseData[0]; int width=100/gvarnum; str.append(""); for(unsigned int i=0; i").arg(width)+tr("GV")+QString("%1").arg(i+1)); } str.append(""); str.append(""); for(unsigned int i=0; i").arg(width)+QString("%1").arg(pd->gvars[i])); } str.append(""); str.append("
"); str.append("
"); te->append(str); } } void PrintDialog::printFSwitches() { int sc=0; QString str = ""; str.append(""); str.append("

"+tr("Special Functions")+"

"); str.append(""); 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(""); for(int i=0; igetCapability(CustomFunctions); i++) { if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { str.append(""); str.append(doTL(tr("SF%1").arg(i+1),"", true)); str.append(doTL(g_model->funcSw[i].swtch.toString(),"green")); str.append(doTL(g_model->funcSw[i].funcToString(),"green")); str.append(doTL(g_model->funcSw[i].paramToString(),"green")); int index=g_model->funcSw[i].func; if ((g_model->funcSw[i].repeatParam>0) && (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic)) { str.append(doTL(QString("%1").arg(g_model->funcSw[i].repeatParam),"green")); } else { str.append(doTL( " ","green")); } if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) { str.append(doTL((g_model->funcSw[i].enabled ? "ON" : "OFF"),"green")); } else { str.append(doTL( "---","green")); } str.append(""); sc++; } } str.append("
#
"); str.append("
"); if (sc!=0) te->append(str); } void PrintDialog::printFrSky() { int tc=0; QString str = ""; if (IS_TARANIS(GetEepromInterface()->getBoard())) { str.append(""); str.append(""); str.append(doTC(tr("Analog"),"", true)); str.append(doTC(tr("Range"),"", true)); str.append(doTC(tr("Offset"),"", true)); str.append(""); FrSkyData *fd=&g_model->frsky; for (int i=0; i<2; i++) { if (fd->channels[i].ratio!=0) { tc++; float ratio=(fd->channels[i].ratio/(fd->channels[i].type==0 ?10.0:1)); QString unit = " " + getFrSkyUnits(fd->channels[i].type); str.append(""); str.append(doTL(tr("A%1").arg(i+1), "", true)); str.append(doTC(QString::number(ratio,10,(fd->channels[i].type==0 ? 1:0))+unit, "green")); str.append(doTC(QString::number((fd->channels[i].offset*ratio)/255,10,(fd->channels[i].type==0 ? 1:0))+unit, "green")); str.append(""); } } str.append(""); str.append(""); str.append(doTC(tr("Alarms"),"", true)); str.append(doTC(tr("Low Alarm"),"", true)); str.append(doTC(tr("Critical Alarm"),"", true)); str.append(""); str.append(""); str.append(doTL(tr("RSSI"),"", true)); str.append(doTC(QString::number(fd->rssiAlarms[0].value,10),"green")); str.append(doTC(QString::number(fd->rssiAlarms[1].value,10),"green")); str.append(""); for (int i=0; i<2; i++) { if (fd->channels[i].ratio!=0) { float ratio=(fd->channels[i].ratio/(fd->channels[i].type==0 ?10.0:1)); QString unit = " " + getFrSkyUnits(fd->channels[i].type); str.append(""); str.append(doTL(tr("A%1").arg(i+1), "", true)); str.append(doTC(QString::number(ratio*(fd->channels[i].alarms[0].value/255.0+fd->channels[i].offset/255.0),10,(fd->channels[i].type==0 ? 1:0))+unit, "green")); str.append(doTC(QString::number(ratio*(fd->channels[i].alarms[1].value/255.0+fd->channels[i].offset/255.0),10,(fd->channels[i].type==0 ? 1:0))+unit, "green")); str.append(""); } } //TODO preferrably in new tables str.append(""); //str.append(""); //str.append(""); str.append(""); str.append("

"+tr("Telemetry Settings")+"

"+tr("Frsky serial protocol")+""+getFrSkyProtocol(fd->usrProto)+"
"+tr("Units system")+""+getFrSkyMeasure(fd->imperial)+"
"+tr("Blades")+""+QString("%1").arg(fd->blades)+"
"); } else { //other boards str.append("

"+tr("Telemetry Settings")+"

"); str.append(" "+tr("Alarm 1")+""+tr("Alarm 2")+""); str.append(""+tr("Analog")+""+tr("Unit")+""+tr("Scale")+""+tr("Offset")+""); str.append(""+tr("Type")+""+tr("Condition")+""+tr("Value")+""); str.append(""+tr("Type")+""+tr("Condition")+""+tr("Value")+""); FrSkyData *fd=&g_model->frsky; for (int i=0; i<2; i++) { if (fd->channels[i].ratio!=0) { tc++; float ratio=(fd->channels[i].ratio/(fd->channels[i].type==0 ?10.0:1)); str.append(""+tr("A%1").arg(i+1)+""+getFrSkyUnits(fd->channels[i].type)+""+QString::number(ratio,10,(fd->channels[i].type==0 ? 1:0))+""+QString::number((fd->channels[i].offset*ratio)/255,10,(fd->channels[i].type==0 ? 1:0))+""); str.append(""+getFrSkyAlarmType(fd->channels[i].alarms[0].level)+""); str.append(""); str.append((fd->channels[i].alarms[0].greater==1) ? ">" : "<"); str.append(""+QString::number(ratio*(fd->channels[i].alarms[0].value/255.0+fd->channels[i].offset/255.0),10,(fd->channels[i].type==0 ? 1:0))+""); str.append(""+getFrSkyAlarmType(fd->channels[i].alarms[1].level)+""); str.append(""); str.append((fd->channels[i].alarms[1].greater==1) ? ">" : "<"); str.append(""+QString::number(ratio*(fd->channels[i].alarms[1].value/255.0+fd->channels[i].offset/255.0),10,(fd->channels[i].type==0 ? 1:0))+""); } } str.append(""); str.append(" "+tr("Alarm 1")+""+tr("Alarm 2")+""); str.append(""+tr("Type")+""+tr("Condition")+""+tr("Value")+""); str.append(""+tr("Type")+""+tr("Condition")+""+tr("Value")+""); str.append(""+tr("RSSI Alarm")+""); str.append(""+getFrSkyAlarmType(fd->rssiAlarms[0].level)+"<"+QString::number(fd->rssiAlarms[0].value,10)+""); str.append(""+getFrSkyAlarmType(fd->rssiAlarms[1].level)+"<"+QString::number(fd->rssiAlarms[1].value,10)+""); str.append(""); str.append(""+tr("Frsky serial protocol")+""+getFrSkyProtocol(fd->usrProto)+""); str.append(""+tr("Units system")+""+getFrSkyMeasure(fd->imperial)+""); str.append(""+tr("Blades")+""+fd->blades+""); str.append(""); } #if 0 if (firmware->getCapability(TelemetryBars) || (firmware->getCapability(TelemetryCSFields))) { int cols=firmware->getCapability(TelemetryColsCSFields); if (cols==0) cols=2; for (int j=0; jgetCapability(TelemetryCSFields)/(4*cols); j++ ) { if (fd->screens[j].type==0) { if (cols==2) { str.append(""); } else { str.append("
"+tr("Custom Telemetry View")+"
"); } for (int r=0; r<4; r++) { str.append(""); for (int c=0; cscreens[j].body.lines[r].source[c]!=0) tc++; if (cols==2) { str.append(""); } else { str.append(""); } if (c<(cols-1)) { if (cols==2) { str.append(""); } else { str.append(""); } } } str.append(""); } str.append("
"+tr("Custom Telemetry View")+"
"+getFrSkySrc(fd->screens[j].body.lines[r].source[c])+""+getFrSkySrc(fd->screens[j].body.lines[r].source[c])+"  
"); } else { str.append(""); str.append(""); for (int i=0; i<4; i++) { if (fd->screens[j].body.bars[i].source!=0) tc++; // TODO str.append(""); } str.append("
"+tr("Telemetry Bars")+"
"+tr("Bar Number")+""+tr("Source")+""+tr("Min")+""+tr("Max")+"
"+QString::number(i+1,10)+""+getFrSkySrc(fd->screens[j].body.bars[i].source)+""+(fd->screens[j].body.bars[i].source>0 ? QString::number(getBarValue(fd->screens[j].body.bars[i].source, fd->screens[j].body.bars[i].barMin,fd)):"----")+""+(fd->screens[j].body.bars[i].source>0 ? QString::number(getBarValue(fd->screens[j].body.bars[i].source,(255-fd->screens[j].body.bars[i].barMax),fd)) :"----")+"
"); } } } #endif if (tc>0) te->append(str); } void PrintDialog::on_printButton_clicked() { QPrinter printer; printer.setPageMargins(10.0,10.0,10.0,10.0,printer.Millimeter); QPrintDialog *dialog = new QPrintDialog(&printer, this); dialog->setWindowTitle(tr("Print Document")); if (dialog->exec() != QDialog::Accepted) return; te->print(&printer); } void PrintDialog::on_printFileButton_clicked() { QString fn = QFileDialog::getSaveFileName(this,tr("Select PDF output file"),QString(),tr("ODF files (*.odt);;PDF Files(*.pdf);;HTML-Files (*.htm *.html);;All Files (*)")); if (fn.isEmpty()) return; if (! (fn.endsWith(".odt", Qt::CaseInsensitive) || fn.endsWith(".pdf", Qt::CaseInsensitive) || fn.endsWith(".htm", Qt::CaseInsensitive) || fn.endsWith(".html", Qt::CaseInsensitive)) ) fn += ".pdf"; // default if (fn.endsWith(".pdf", Qt::CaseInsensitive)) { QPrinter printer; printer.setPageMargins(10.0,10.0,10.0,10.0,printer.Millimeter); printer.setOutputFormat(QPrinter::PdfFormat); printer.setColorMode(QPrinter::Color); printer.setOutputFileName(fn); te->print(&printer); } else { QTextDocumentWriter writer(fn); writer.write(te->document()); } } void PrintDialog::printToFile() { if (printfilename.isEmpty()) return; if (! (printfilename.endsWith(".odt", Qt::CaseInsensitive) || printfilename.endsWith(".pdf", Qt::CaseInsensitive) || printfilename.endsWith(".htm", Qt::CaseInsensitive) || printfilename.endsWith(".html", Qt::CaseInsensitive)) ) printfilename += ".pdf"; // default if (printfilename.endsWith(".pdf", Qt::CaseInsensitive)) { QPrinter printer; printer.setPageMargins(10.0,10.0,10.0,10.0,printer.Millimeter); printer.setOutputFormat(QPrinter::PdfFormat); printer.setColorMode(QPrinter::Color); printer.setOutputFileName(printfilename); te->print(&printer); } else { QTextDocumentWriter writer(printfilename); writer.write(te->document()); } } void PrintDialog::autoClose() { this->close(); }