Bsongis/companion r9m fixes (#5914)
[opentx.git] / companion / src / modelprinter.h
blobfd1df94a23aac2e615df3bc40017c0722ac3a5ac
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _MODELPRINTER_H_
22 #define _MODELPRINTER_H_
24 #include <QString>
25 #include <QStringList>
26 #include <QPainter>
27 #include <QTextDocument>
28 #include "eeprominterface.h"
30 QString changeColor(const QString & input, const QString & to, const QString & from = "grey");
31 QString addFont(const QString & input, const QString & color = "", const QString & size = "", const QString & face = "");
32 void debugHtml(const QString & html);
33 QString formatTitle(const QString & name);
35 class CurveImage
37 public:
38 CurveImage();
39 void drawCurve(const CurveData & curve, QColor color);
40 const QImage & get() const { return image; };
42 protected:
43 int size;
44 QImage image;
45 QPainter painter;
48 class ModelPrinter: public QObject
50 Q_OBJECT
52 public:
53 ModelPrinter(Firmware * firmware, const GeneralSettings & generalSettings, const ModelData & model);
54 virtual ~ModelPrinter();
56 QString printBoolean(const bool val, const int typ);
57 QString printEEpromSize();
58 QString printTrimIncrementMode();
59 QString printThrottle();
60 static QString printModuleProtocol(unsigned int protocol);
61 static QString printMultiRfProtocol(int rfProtocol, bool custom);
62 QString printR9MPowerValue(unsigned subType, unsigned val, bool telem);
63 static QString printMultiSubType(unsigned rfProtocol, bool custom, unsigned int subType);
64 static QString printModuleSubType(unsigned protocol, unsigned subType, unsigned rfProtocol = 0, bool custom = false);
65 QString printFlightModeSwitch(const RawSwitch & swtch);
66 QString printFlightModeName(int index);
67 QString printFlightModes(unsigned int flightModes);
68 QString printInputFlightModes(unsigned int flightModes);
69 QString printModule(int idx);
70 QString printTrainerMode();
71 QString printCenterBeep();
72 QString printHeliSwashType();
73 QString printTrim(int flightModeIndex, int stickIndex);
74 QString printGlobalVar(int flightModeIndex, int gvarIndex);
75 QString printRotaryEncoder(int flightModeIndex, int reIndex);
76 QString printTimer(int idx);
77 QString printTimer(const TimerData & timer);
78 QString printInputName(int idx);
79 QString printInputLine(int idx);
80 QString printInputLine(const ExpoData & ed);
81 QString printMixerLine(const MixData & md, bool showMultiplex, int highlightedSource = 0);
82 QString printLogicalSwitchLine(int idx);
83 QString printCustomFunctionLine(int idx);
84 QString printChannelName(int idx);
85 QString printCurveName(int idx);
86 QString printCurve(int idx);
87 QString createCurveImage(int idx, QTextDocument * document);
88 QString printGlobalVarUnit(int idx);
89 QString printGlobalVarPrec(int idx);
90 QString printGlobalVarMin(int idx);
91 QString printGlobalVarMax(int idx);
92 QString printGlobalVarPopup(int idx);
93 QString printOutputValueGVar(int val);
94 QString printOutputOffset(int idx);
95 QString printOutputMin(int idx);
96 QString printOutputMax(int idx);
97 QString printOutputRevert(int idx);
98 QString printOutputCurve(int idx);
99 QString printOutputPpmCenter(int idx);
100 QString printOutputSymetrical(int idx);
101 QString printSettingsOther();
102 QString printModuleType(int idx);
103 QString printThrottleSource(int idx);
104 QString printTrimsDisplayMode();
105 QString printSettingsTrim();
106 QString printSwitchWarnings();
107 QString printPotWarnings();
108 QString printPotsWarningMode();
109 QString printPxxPower(int power);
110 QString printFailsafe(int idx);
111 QString printFailsafeMode(unsigned int fsmode);
112 QString printFailsafeValue(int val);
113 QString printTimerCountdownBeep(unsigned int countdownBeep);
114 QString printTimerPersistent(unsigned int persistent);
115 QString printPPMFrameLength(int ppmFL);
116 QString printTimerName(int idx);
117 QString printTimeValue(const int value, const unsigned int mask);
118 QString printTimerMinuteBeep(bool mb);
119 QString printTimerTimeValue(unsigned int val);
120 QString printTelemetryProtocol(unsigned int val);
121 QString printLabelValue(const QString & lbl, const QString & val, const bool sep = false);
122 QString printLabelValues(const QString & lbl, const QStringList & vals, const bool sep = false);
123 QString printRssiAlarmsDisabled(bool mb);
124 QString printTelemetrySource(int val);
125 QString printVarioSource(unsigned int val);
126 QString printVarioCenterSilent(bool mb);
127 QString printVoltsSource(unsigned int val);
128 QString printCurrentSource(unsigned int val);
129 QString printMahPersistent(bool mb);
130 QString printIgnoreSensorIds(bool mb);
131 QString printSensorType(unsigned int val);
132 QString printSensorFormula(unsigned int val);
133 QString printSensorCells(unsigned int val);
134 QString printSensorTypeCond(unsigned int idx);
135 QString printSensorParams(unsigned int idx);
136 QString printSensorDetails(unsigned int idx);
137 QString printTelemetryScreenType(unsigned int val);
138 QString printTelemetryScreen(unsigned int idx, unsigned int line, unsigned int width);
140 private:
141 Firmware * firmware;
142 const GeneralSettings & generalSettings;
143 const ModelData & model;
147 #endif // _MODELPRINTER_H_