Make TX volatge for simu more flexible (#7124)
[opentx.git] / companion / src / firmwares / sensordata.cpp
blob8d677ed505090716510c7fe80226ebc8d4bf5a8d
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 #include "sensordata.h"
23 #include "radiodata.h"
24 #include "modeldata.h"
26 void SensorData::updateUnit()
28 if (type == TELEM_TYPE_CALCULATED) {
29 if (formula == TELEM_FORMULA_CONSUMPTION)
30 unit = UNIT_MAH;
34 QString SensorData::unitString() const
36 switch (unit) {
37 case UNIT_VOLTS:
38 return tr("V");
39 case UNIT_AMPS:
40 return tr("A");
41 case UNIT_MILLIAMPS:
42 return tr("mA");
43 case UNIT_KTS:
44 return tr("kts");
45 case UNIT_METERS_PER_SECOND:
46 return tr("m/s");
47 case UNIT_KMH:
48 return tr("km/h");
49 case UNIT_MPH:
50 return tr("mph");
51 case UNIT_METERS:
52 return tr("m");
53 case UNIT_FEET:
54 return tr("f");
55 case UNIT_CELSIUS:
56 return tr("°C");
57 case UNIT_FAHRENHEIT:
58 return tr("°F");
59 case UNIT_PERCENT:
60 return tr("%");
61 case UNIT_MAH:
62 return tr("mAh");
63 case UNIT_WATTS:
64 return tr("W");
65 case UNIT_MILLIWATTS:
66 return tr("mW");
67 case UNIT_DB:
68 return tr("dB");
69 case UNIT_RPMS:
70 return tr("rpms");
71 case UNIT_G:
72 return tr("g");
73 case UNIT_DEGREE:
74 return tr("°");
75 case UNIT_RADIANS:
76 return tr("Rad");
77 case UNIT_HOURS:
78 return tr("hours");
79 case UNIT_MINUTES:
80 return tr("minutes");
81 case UNIT_SECONDS:
82 return tr("seconds");
83 case UNIT_CELLS:
84 return tr("V");
85 default:
86 return "";
90 QString SensorData::nameToString(int index) const
92 return RadioData::getElementName(tr("TELE"), index + 1, label);
95 QString SensorData::getOrigin(const ModelData * model) const
97 if (type != TELEM_TYPE_CUSTOM || !id)
98 return QString();
100 const ModuleData & module = model->moduleData[moduleIdx];
101 if (module.isPxx2Module() && rxIdx <= 2 && module.access.receivers & (1 << rxIdx)) {
102 return QString(module.access.receiverName[rxIdx]);
104 else {
105 return QString();