Companion global variables refactor (#5328)

* Companion Global Variables refactor to support changes to radio in 2.2

* Update model print for global variables refactor

* Check and if necessary update all flight modes gvar after updating min or max

* Fix loop limit

* Add clear single gvar context menu
Add gvar popup values to model print
Minor fixes
This commit is contained in:
Neil Horne
2017-11-11 08:56:30 +01:00
committed by Bertrand Songis
parent 69afa9d0f8
commit 8e9d370770
8 changed files with 452 additions and 66 deletions
+40 -3
View File
@@ -1024,6 +1024,44 @@ typedef char CustomScreenData[610+1];
typedef char TopbarData[216+1];
#endif
#define GVAR_NAME_LEN 3
#define GVAR_MAX_VALUE 1024
#define GVAR_MIN_VALUE -GVAR_MAX_VALUE
class GVarData {
public:
GVarData() { clear(); }
enum {
GVAR_UNIT_NUMBER,
GVAR_UNIT_PERCENT
};
enum {
GVAR_PREC_MUL10,
GVAR_PREC_MUL1
};
char name[GVAR_NAME_LEN+1];
int min;
int max;
bool popup;
unsigned int prec; // 0 0._ 1 0.0
unsigned int unit; // 0 _ 1 %
void clear() {memset(this, 0, sizeof(GVarData)); }
QString unitToString() const;
QString precToString() const;
int multiplierSet();
float multiplierGet() const;
void setMin(float val);
void setMax(float val);
int getMin() const;
int getMax() const;
float getMinPrec() const;
float getMaxPrec() const;
};
class ModelData {
public:
ModelData();
@@ -1078,9 +1116,7 @@ class ModelData {
bool potsWarningEnabled[CPN_MAX_POTS];
int potPosition[CPN_MAX_POTS];
bool displayChecklist;
// TODO structure
char gvars_names[CPN_MAX_GVARS][6+1];
bool gvars_popups[CPN_MAX_GVARS];
GVarData gvarData[CPN_MAX_GVARS];
MavlinkData mavlink;
unsigned int telemetryProtocol;
FrSkyData frsky;
@@ -1113,6 +1149,7 @@ class ModelData {
bool isGVarLinked(int phaseIdx, int gvarIdx);
int getGVarFieldValue(int phaseIdx, int gvarIdx);
float getGVarFieldValuePrec(int phaseIdx, int gvarIdx);
ModelData removeGlobalVars();