Make TX volatge for simu more flexible (#7124)
[opentx.git] / companion / src / firmwares / sensordata.h
bloba5cdb4957112307078852e71a9bd0a9d93f6bde8
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 SENSORDATA_H
22 #define SENSORDATA_H
24 #include <QtCore>
26 constexpr int CPN_MAX_SENSORS = 60;
28 class ModelData;
30 class SensorData {
31 Q_DECLARE_TR_FUNCTIONS(SensorData)
33 public:
35 enum
37 TELEM_TYPE_CUSTOM,
38 TELEM_TYPE_CALCULATED
41 enum
43 TELEM_FORMULA_ADD,
44 TELEM_FORMULA_AVERAGE,
45 TELEM_FORMULA_MIN,
46 TELEM_FORMULA_MAX,
47 TELEM_FORMULA_MULTIPLY,
48 TELEM_FORMULA_TOTALIZE,
49 TELEM_FORMULA_CELL,
50 TELEM_FORMULA_CONSUMPTION,
51 TELEM_FORMULA_DIST,
52 TELEM_FORMULA_LAST = TELEM_FORMULA_DIST
55 enum {
56 TELEM_CELL_INDEX_LOWEST,
57 TELEM_CELL_INDEX_1,
58 TELEM_CELL_INDEX_2,
59 TELEM_CELL_INDEX_3,
60 TELEM_CELL_INDEX_4,
61 TELEM_CELL_INDEX_5,
62 TELEM_CELL_INDEX_6,
63 TELEM_CELL_INDEX_HIGHEST,
64 TELEM_CELL_INDEX_DELTA,
67 enum
69 UNIT_RAW,
70 UNIT_VOLTS,
71 UNIT_AMPS,
72 UNIT_MILLIAMPS,
73 UNIT_KTS,
74 UNIT_METERS_PER_SECOND,
75 UNIT_FEET_PER_SECOND,
76 UNIT_KMH,
77 UNIT_MPH,
78 UNIT_METERS,
79 UNIT_FEET,
80 UNIT_CELSIUS,
81 UNIT_FAHRENHEIT,
82 UNIT_PERCENT,
83 UNIT_MAH,
84 UNIT_WATTS,
85 UNIT_MILLIWATTS,
86 UNIT_DB,
87 UNIT_RPMS,
88 UNIT_G,
89 UNIT_DEGREE,
90 UNIT_RADIANS,
91 UNIT_MILLILITERS,
92 UNIT_FLOZ,
93 UNIT_HOURS,
94 UNIT_MINUTES,
95 UNIT_SECONDS,
96 // FrSky format used for these fields, could be another format in the future
97 UNIT_FIRST_VIRTUAL,
98 UNIT_CELLS = UNIT_FIRST_VIRTUAL,
99 UNIT_DATETIME,
100 UNIT_GPS,
101 UNIT_GPS_LONGITUDE,
102 UNIT_GPS_LATITUDE,
103 UNIT_GPS_LONGITUDE_EW,
104 UNIT_GPS_LATITUDE_NS,
105 UNIT_DATETIME_YEAR,
106 UNIT_DATETIME_DAY_MONTH,
107 UNIT_DATETIME_HOUR_MIN,
108 UNIT_DATETIME_SEC
111 SensorData() { clear(); }
112 unsigned int type; // custom / formula
113 unsigned int id;
114 unsigned int subid;
115 unsigned int instance;
116 unsigned int rxIdx;
117 unsigned int moduleIdx;
118 unsigned int persistentValue;
119 unsigned int formula;
120 char label[4+1];
121 unsigned int unit;
122 unsigned int prec;
123 bool autoOffset;
124 bool filter;
125 bool logs;
126 bool persistent;
127 bool onlyPositive;
129 // for custom sensors
130 unsigned int ratio;
131 int offset;
133 // for consumption
134 unsigned int amps;
136 // for cell
137 unsigned int source;
138 unsigned int index;
140 // for calculations
141 int sources[4];
143 // for GPS dist
144 unsigned int gps;
145 unsigned int alt;
147 bool isAvailable() const { return strlen(label) > 0; }
148 void updateUnit();
149 QString unitString() const;
150 QString nameToString(int index) const;
151 QString getOrigin(const ModelData* model) const;
152 void clear() { memset(this, 0, sizeof(SensorData)); }
155 #endif // SENSORDATA_H