Fix doc path
[opentx.git] / companion / src / firmwares / gvardata.cpp
blob23c90cd2a7118bd615c101c7c28ec907cee8e82d
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 "gvardata.h"
23 #include "radiodata.h"
25 QString GVarData::unitToString() const
27 switch (unit) {
28 case GVAR_UNIT_NUMBER:
29 return tr("");
30 case GVAR_UNIT_PERCENT:
31 return tr("%");
32 default:
33 return tr("?"); // highlight unknown value
37 QString GVarData::precToString() const
39 switch (prec) {
40 case GVAR_PREC_MUL10:
41 return tr("0._");
42 case GVAR_PREC_MUL1:
43 return tr("0.0");
44 default:
45 return tr("?.?"); // highlight unknown value
49 QString GVarData::nameToString(int index) const
51 return RadioData::getElementName(tr("GV"), index + 1, name);
54 int GVarData::multiplierSet()
56 return (prec == 0 ? 1 : 10);
59 float GVarData::multiplierGet() const
61 return (prec == 0 ? 1 : 0.1);
64 void GVarData::setMin(float val)
66 min = (val * multiplierSet()) - GVAR_MIN_VALUE;
69 void GVarData::setMax(float val)
71 max = GVAR_MAX_VALUE - (val * multiplierSet());
74 int GVarData::getMin() const
76 return GVAR_MIN_VALUE + min;
79 int GVarData::getMax() const
81 return GVAR_MAX_VALUE - max;
84 float GVarData::getMinPrec() const
86 return getMin() * multiplierGet();
89 float GVarData::getMaxPrec() const
91 return getMax() * multiplierGet();