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