Merge remote-tracking branch 'origin/next' into bsongis/9XR-PRO_port
Conflicts: companion/src/avroutputdialog.cpp companion/src/burnconfigdialog.cpp companion/src/eeprominterface.cpp companion/src/eeprominterface.h companion/src/firmwares/opentx/opentxinterface.cpp companion/src/helpers.cpp radio/src/gui/menu_general.cpp radio/src/opentx.cpp
This commit is contained in:
+317
-206
@@ -45,16 +45,20 @@ template<class t> t LIMIT(t mi, t x, t ma) { return std::min(std::max(mi, x), ma
|
||||
enum BoardEnum {
|
||||
BOARD_STOCK,
|
||||
BOARD_M128,
|
||||
BOARD_MEGA2560,
|
||||
BOARD_GRUVIN9X,
|
||||
BOARD_SKY9X,
|
||||
BOARD_9XRPRO,
|
||||
BOARD_TARANIS,
|
||||
BOARD_TARANIS_REV4a
|
||||
};
|
||||
#define IS_STOCK(board) (board==BOARD_STOCK || board==BOARD_M128)
|
||||
#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_9XRPRO || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
|
||||
|
||||
#define IS_9X(board) (board==BOARD_STOCK || board==BOARD_M128)
|
||||
#define IS_STOCK(board) (board==BOARD_STOCK)
|
||||
#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560)
|
||||
#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_9XRPRO || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
|
||||
#define IS_SKY9X(board) (board==BOARD_SKY9X || board==BOARD_9XRPRO)
|
||||
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
|
||||
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
|
||||
|
||||
const uint8_t modn12x3[4][4]= {
|
||||
{1, 2, 3, 4},
|
||||
@@ -62,17 +66,18 @@ const uint8_t modn12x3[4][4]= {
|
||||
{4, 2, 3, 1},
|
||||
{4, 3, 2, 1} };
|
||||
|
||||
#define C9XMAX_MODELS 60
|
||||
#define C9X_MAX_MODELS 60
|
||||
#define C9X_MAX_PHASES 9
|
||||
#define C9X_MAX_MIXERS 64
|
||||
#define C9X_MAX_EXPOS 32
|
||||
#define C9X_MAX_CURVES 16
|
||||
#define MAX_POINTS 17
|
||||
#define C9X_MAX_GVARS 9
|
||||
#define NUM_SAFETY_CHNOUT 16
|
||||
#define C9X_MAX_INPUTS 32
|
||||
#define C9X_MAX_EXPOS 64
|
||||
#define C9X_MAX_CURVES 32
|
||||
#define C9X_MAX_POINTS 17
|
||||
#define C9X_MAX_GVARS 9
|
||||
#define C9X_MAX_ENCODERS 2
|
||||
#define C9X_NUM_CHNOUT 32 // number of real output channels
|
||||
#define C9X_NUM_CSW 32 // number of custom switches
|
||||
#define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches
|
||||
#define C9X_MAX_CUSTOM_FUNCTIONS 64 // number of functions assigned to switches
|
||||
#define C9X_NUM_MODULES 2
|
||||
|
||||
#define STK_RUD 1
|
||||
@@ -105,10 +110,23 @@ const uint8_t modn12x3[4][4]= {
|
||||
#define DSW_SG2 20
|
||||
|
||||
const uint8_t chout_ar[] = { //First number is 0..23 -> template setup, Second is relevant channel out
|
||||
1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2,
|
||||
2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1,
|
||||
3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1,
|
||||
4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1 }; // TODO delete it?
|
||||
1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2,
|
||||
2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1,
|
||||
3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1,
|
||||
4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1
|
||||
}; // TODO delete it?
|
||||
|
||||
// Beep center bits
|
||||
#define BC_BIT_RUD (0x01)
|
||||
#define BC_BIT_ELE (0x02)
|
||||
#define BC_BIT_THR (0x04)
|
||||
#define BC_BIT_AIL (0x08)
|
||||
#define BC_BIT_P1 (0x10)
|
||||
#define BC_BIT_P2 (0x20)
|
||||
#define BC_BIT_P3 (0x40)
|
||||
#define BC_BIT_P4 (0x80)
|
||||
#define BC_BIT_REA (0x80)
|
||||
#define BC_BIT_REB (0x100)
|
||||
|
||||
// TODO remove this enum!
|
||||
enum EnumKeys {
|
||||
@@ -132,44 +150,6 @@ enum EnumKeys {
|
||||
#endif
|
||||
};
|
||||
|
||||
enum CSFunction {
|
||||
CS_FN_OFF,
|
||||
CS_FN_VPOS,
|
||||
CS_FN_VNEG,
|
||||
CS_FN_APOS,
|
||||
CS_FN_ANEG,
|
||||
CS_FN_AND,
|
||||
CS_FN_OR,
|
||||
CS_FN_XOR,
|
||||
CS_FN_EQUAL,
|
||||
CS_FN_NEQUAL,
|
||||
CS_FN_GREATER,
|
||||
CS_FN_LESS,
|
||||
CS_FN_EGREATER,
|
||||
CS_FN_ELESS,
|
||||
CS_FN_DPOS,
|
||||
CS_FN_DAPOS,
|
||||
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
|
||||
CS_FN_TIM,
|
||||
CS_FN_MAXF
|
||||
};
|
||||
|
||||
enum CSFunctionFamily {
|
||||
CS_FAMILY_VOFS,
|
||||
CS_FAMILY_VBOOL,
|
||||
CS_FAMILY_VCOMP,
|
||||
CS_FAMILY_TIMERS
|
||||
};
|
||||
|
||||
inline CSFunctionFamily getCSFunctionFamily(int fn)
|
||||
{
|
||||
if (fn==CS_FN_TIM) {
|
||||
return (CS_FAMILY_TIMERS);
|
||||
} else {
|
||||
return ((fn<CS_FN_AND || fn>CS_FN_ELESS) ? CS_FAMILY_VOFS : (fn<CS_FN_EQUAL ? CS_FAMILY_VBOOL : CS_FAMILY_VCOMP));
|
||||
}
|
||||
}
|
||||
|
||||
#define CHAR_FOR_NAMES " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-."
|
||||
#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*"
|
||||
|
||||
@@ -183,23 +163,28 @@ enum HeliSwashTypes {
|
||||
|
||||
#define NUM_STICKS 4
|
||||
#define BOARD_9X_NUM_POTS 3
|
||||
#define BOARD_X9D_NUM_POTS 4
|
||||
#define C9X_NUM_POTS 4
|
||||
#define C9X_NUM_POTS 5
|
||||
#define NUM_CAL_PPM 4
|
||||
#define NUM_PPM 8
|
||||
#define NUM_CYC 3
|
||||
#define C9X_NUM_SWITCHES 10
|
||||
#define C9X_NUM_KEYS 6
|
||||
#define C9X_NUM_SWITCHES 10
|
||||
#define C9X_NUM_KEYS 6
|
||||
#define C9X_MAX_TIMERS 2
|
||||
|
||||
extern const char * switches9X[];
|
||||
extern const char * switchesX9D[];
|
||||
|
||||
enum TelemetrySource {
|
||||
TELEMETRY_SOURCE_TX_BATT,
|
||||
TELEMETRY_SOURCE_TIMER1,
|
||||
TELEMETRY_SOURCE_TIMER2,
|
||||
TELEMETRY_SOURCE_SWR,
|
||||
TELEMETRY_SOURCE_RSSI_TX,
|
||||
TELEMETRY_SOURCE_RSSI_RX,
|
||||
TELEMETRY_SOURCE_RX_BATT,
|
||||
TELEMETRY_SOURCE_A1,
|
||||
TELEMETRY_SOURCE_A2,
|
||||
TELEMETRY_SOURCE_A3,
|
||||
TELEMETRY_SOURCE_A4,
|
||||
TELEMETRY_SOURCE_ALT,
|
||||
TELEMETRY_SOURCE_RPM,
|
||||
TELEMETRY_SOURCE_FUEL,
|
||||
@@ -219,8 +204,12 @@ enum TelemetrySource {
|
||||
TELEMETRY_SOURCE_ACCZ,
|
||||
TELEMETRY_SOURCE_HDG,
|
||||
TELEMETRY_SOURCE_VERTICAL_SPEED,
|
||||
TELEMETRY_SOURCE_ASPD,
|
||||
TELEMETRY_SOURCE_DTE,
|
||||
TELEMETRY_SOURCE_A1_MIN,
|
||||
TELEMETRY_SOURCE_A2_MIN,
|
||||
TELEMETRY_SOURCE_A3_MIN,
|
||||
TELEMETRY_SOURCE_A4_MIN,
|
||||
TELEMETRY_SOURCE_ALT_MIN,
|
||||
TELEMETRY_SOURCE_ALT_MAX,
|
||||
TELEMETRY_SOURCE_RPM_MAX,
|
||||
@@ -228,14 +217,16 @@ enum TelemetrySource {
|
||||
TELEMETRY_SOURCE_T2_MAX,
|
||||
TELEMETRY_SOURCE_SPEED_MAX,
|
||||
TELEMETRY_SOURCE_DIST_MAX,
|
||||
TELEMETRY_SOURCE_CURRENT_MAX,
|
||||
TELEMETRY_SOURCE_CELL_MIN,
|
||||
TELEMETRY_SOURCE_CELLS_MIN,
|
||||
TELEMETRY_SOURCE_VFAS_MIN,
|
||||
TELEMETRY_SOURCE_POWER_MAX,
|
||||
TELEMETRY_SOURCE_ACC,
|
||||
TELEMETRY_SOURCE_GPS_TIME,
|
||||
TELEMETRY_SOURCES_STATUS_COUNT,
|
||||
TELEMETRY_SOURCES_DISPLAY_COUNT = TELEMETRY_SOURCES_STATUS_COUNT-2,
|
||||
|
||||
TELEMETRY_SOURCES_COUNT = TELEMETRY_SOURCE_VERTICAL_SPEED,
|
||||
TELEMETRY_SOURCES_STATUS_COUNT = TELEMETRY_SOURCE_GPS_TIME+1,
|
||||
TELEMETRY_SOURCES_DISPLAY_COUNT = TELEMETRY_SOURCE_POWER_MAX+1,
|
||||
TELEMETRY_SOURCES_COUNT = TELEMETRY_SOURCE_DTE+1,
|
||||
TELEMETRY_SOURCE_RESERVE = -1
|
||||
};
|
||||
|
||||
#define TM_HASTELEMETRY 0x01
|
||||
@@ -244,6 +235,8 @@ enum TelemetrySource {
|
||||
|
||||
enum RawSourceType {
|
||||
SOURCE_TYPE_NONE,
|
||||
SOURCE_TYPE_VIRTUAL_INPUT,
|
||||
SOURCE_TYPE_LUA_INPUT,
|
||||
SOURCE_TYPE_STICK, // and POTS
|
||||
SOURCE_TYPE_ROTARY_ENCODER,
|
||||
SOURCE_TYPE_TRIM,
|
||||
@@ -257,25 +250,56 @@ enum RawSourceType {
|
||||
SOURCE_TYPE_TELEMETRY,
|
||||
MAX_SOURCE_TYPE
|
||||
};
|
||||
|
||||
class ModelData;
|
||||
|
||||
QString AnalogString(int index);
|
||||
QString RotaryEncoderString(int index);
|
||||
|
||||
class RawSourceRange
|
||||
{
|
||||
public:
|
||||
RawSourceRange():
|
||||
decimals(0),
|
||||
min(0.0),
|
||||
max(0.0),
|
||||
step(1.0),
|
||||
offset(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
float getValue(int value) {
|
||||
return min + float(value) * step;
|
||||
}
|
||||
|
||||
int decimals;
|
||||
double min;
|
||||
double max;
|
||||
double step;
|
||||
double offset;
|
||||
|
||||
};
|
||||
|
||||
class RawSource {
|
||||
public:
|
||||
RawSource():
|
||||
type(SOURCE_TYPE_NONE),
|
||||
index(0)
|
||||
index(0),
|
||||
model(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
RawSource(int value):
|
||||
RawSource(int value, const ModelData * model=NULL):
|
||||
type(RawSourceType(abs(value)/65536)),
|
||||
index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536))
|
||||
index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)),
|
||||
model(model)
|
||||
{
|
||||
}
|
||||
|
||||
RawSource(RawSourceType type, int index=0):
|
||||
RawSource(RawSourceType type, int index=0, const ModelData * model=NULL):
|
||||
type(type),
|
||||
index(index)
|
||||
index(index),
|
||||
model(model)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -286,32 +310,31 @@ class RawSource {
|
||||
|
||||
QString toString();
|
||||
|
||||
int getDecimals(const ModelData & Model);
|
||||
double getMin(const ModelData & Model);
|
||||
double getMax(const ModelData & Model);
|
||||
double getStep(const ModelData & Model);
|
||||
double getOffset(const ModelData & Model);
|
||||
int getRawOffset(const ModelData & Model);
|
||||
RawSourceRange getRange(bool singleprec=false);
|
||||
|
||||
bool operator== ( const RawSource& other) {
|
||||
bool operator == ( const RawSource & other) {
|
||||
return (this->type == other.type) && (this->index == other.index);
|
||||
}
|
||||
|
||||
bool operator != ( const RawSource & other) {
|
||||
return (this->type != other.type) || (this->index != other.index);
|
||||
}
|
||||
|
||||
RawSourceType type;
|
||||
int index;
|
||||
const ModelData * model;
|
||||
};
|
||||
|
||||
enum RawSwitchType {
|
||||
SWITCH_TYPE_NONE,
|
||||
SWITCH_TYPE_SWITCH,
|
||||
SWITCH_TYPE_VIRTUAL,
|
||||
SWITCH_TYPE_MOMENT_SWITCH,
|
||||
SWITCH_TYPE_MOMENT_VIRTUAL,
|
||||
SWITCH_TYPE_MULTIPOS_POT,
|
||||
SWITCH_TYPE_TRIM,
|
||||
SWITCH_TYPE_ROTARY_ENCODER,
|
||||
SWITCH_TYPE_ON,
|
||||
SWITCH_TYPE_OFF,
|
||||
SWITCH_TYPE_ONM,
|
||||
SWITCH_TYPE_TRN,
|
||||
SWITCH_TYPE_REA,
|
||||
SWITCH_TYPE_TIMER_MODE
|
||||
};
|
||||
|
||||
class RawSwitch {
|
||||
@@ -381,6 +404,9 @@ enum BeeperMode {
|
||||
class GeneralSettings {
|
||||
public:
|
||||
GeneralSettings();
|
||||
|
||||
RawSource getDefaultSource(unsigned int channel);
|
||||
|
||||
unsigned int version;
|
||||
unsigned int variant;
|
||||
int calibMid[NUM_STICKS+C9X_NUM_POTS];
|
||||
@@ -407,7 +433,6 @@ class GeneralSettings {
|
||||
int timezone;
|
||||
bool optrexDisplay;
|
||||
unsigned int inactivityTimer;
|
||||
bool throttleReversed;
|
||||
bool minuteBeep;
|
||||
bool preBeep;
|
||||
bool flashBeep;
|
||||
@@ -419,7 +444,7 @@ class GeneralSettings {
|
||||
unsigned int backlightDelay;
|
||||
bool blightinv;
|
||||
bool stickScroll;
|
||||
unsigned int templateSetup; //RETA order according to chout_ar array // TODO enum
|
||||
unsigned int templateSetup; //RETA order according to chout_ar array
|
||||
int PPM_Multiplier;
|
||||
int hapticLength;
|
||||
unsigned int reNavigation;
|
||||
@@ -449,22 +474,61 @@ class GeneralSettings {
|
||||
int beepVolume;
|
||||
int wavVolume;
|
||||
int varioVolume;
|
||||
int varioPitch;
|
||||
int varioRange;
|
||||
int varioRepeat;
|
||||
int backgroundVolume;
|
||||
unsigned int mavbaud;
|
||||
unsigned int switchUnlockStates;
|
||||
unsigned int hw_uartMode;
|
||||
unsigned int potsType[8];
|
||||
};
|
||||
|
||||
class CurveReference {
|
||||
public:
|
||||
enum CurveRefType {
|
||||
CURVE_REF_DIFF,
|
||||
CURVE_REF_EXPO,
|
||||
CURVE_REF_FUNC,
|
||||
CURVE_REF_CUSTOM
|
||||
};
|
||||
|
||||
CurveReference() { clear(); }
|
||||
|
||||
CurveReference(CurveRefType type, int value):
|
||||
type(type),
|
||||
value(value)
|
||||
{
|
||||
}
|
||||
|
||||
void clear() { memset(this, 0, sizeof(CurveReference)); }
|
||||
|
||||
CurveRefType type;
|
||||
int value;
|
||||
|
||||
QString toString();
|
||||
};
|
||||
|
||||
enum InputMode {
|
||||
INPUT_MODE_NONE,
|
||||
INPUT_MODE_POS,
|
||||
INPUT_MODE_NEG,
|
||||
INPUT_MODE_BOTH
|
||||
};
|
||||
|
||||
class ExpoData {
|
||||
public:
|
||||
ExpoData() { clear(); }
|
||||
unsigned int mode; // 0=end, 1=pos, 2=neg, 3=both
|
||||
RawSource srcRaw;
|
||||
unsigned int scale;
|
||||
unsigned int mode;
|
||||
unsigned int chn;
|
||||
RawSwitch swtch;
|
||||
unsigned int phases; // -5=!FP4, 0=normal, 5=FP4
|
||||
int weight;
|
||||
int expo;
|
||||
unsigned int curveMode;
|
||||
int curveParam;
|
||||
int offset;
|
||||
CurveReference curve;
|
||||
int carryTrim;
|
||||
char name[10+1];
|
||||
void clear() { memset(this, 0, sizeof(ExpoData)); }
|
||||
};
|
||||
@@ -477,11 +541,19 @@ class CurvePoint {
|
||||
|
||||
class CurveData {
|
||||
public:
|
||||
enum CurveType {
|
||||
CURVE_TYPE_STANDARD,
|
||||
CURVE_TYPE_CUSTOM,
|
||||
CURVE_TYPE_LAST = CURVE_TYPE_CUSTOM
|
||||
};
|
||||
|
||||
CurveData() { clear(5); }
|
||||
bool custom; // 0=end, 1=pos, 2=neg, 3=both
|
||||
uint8_t count;
|
||||
CurvePoint points[MAX_POINTS];
|
||||
char name[6+1];
|
||||
|
||||
CurveType type;
|
||||
bool smooth;
|
||||
int count;
|
||||
CurvePoint points[C9X_MAX_POINTS];
|
||||
char name[6+1];
|
||||
void clear(int count) { memset(this, 0, sizeof(CurveData)); this->count = count; }
|
||||
};
|
||||
|
||||
@@ -495,7 +567,8 @@ class LimitData {
|
||||
int ppmCenter;
|
||||
bool symetrical;
|
||||
char name[6+1];
|
||||
void clear() { memset(this, 0, sizeof(LimitData)); min = -100; max = +100; }
|
||||
CurveReference curve;
|
||||
void clear() { memset(this, 0, sizeof(LimitData)); min = -1000; max = +1000; }
|
||||
};
|
||||
|
||||
enum MltpxValue {
|
||||
@@ -504,7 +577,6 @@ enum MltpxValue {
|
||||
MLTPX_REP=2
|
||||
};
|
||||
|
||||
|
||||
class MixData {
|
||||
public:
|
||||
MixData() { clear(); }
|
||||
@@ -512,9 +584,8 @@ class MixData {
|
||||
RawSource srcRaw;
|
||||
unsigned int srcVariant;
|
||||
int weight;
|
||||
int differential;
|
||||
RawSwitch swtch;
|
||||
int curve; //0=symmetrisch
|
||||
CurveReference curve; //0=symmetrisch
|
||||
unsigned int delayUp;
|
||||
unsigned int delayDown;
|
||||
unsigned int speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
|
||||
@@ -523,39 +594,71 @@ class MixData {
|
||||
bool noExpo;
|
||||
MltpxValue mltpx; // multiplex method 0=+ 1=* 2=replace
|
||||
unsigned int mixWarn; // mixer warning
|
||||
unsigned int enableFmTrim;
|
||||
unsigned int phases; // -5=!FP4, 0=normal, 5=FP4
|
||||
unsigned int lateOffset;
|
||||
int sOffset;
|
||||
char name[10+1];
|
||||
|
||||
void clear() { memset(this, 0, sizeof(MixData)); }
|
||||
};
|
||||
|
||||
class CustomSwData { // Custom Switches data
|
||||
public:
|
||||
CustomSwData() { clear(); }
|
||||
int val1; //input
|
||||
int val2; //offset
|
||||
unsigned int func;
|
||||
unsigned int delay;
|
||||
unsigned int duration;
|
||||
unsigned int andsw;
|
||||
void clear() { memset(this, 0, sizeof(CustomSwData)); }
|
||||
enum CSFunction {
|
||||
LS_FN_OFF,
|
||||
LS_FN_VPOS,
|
||||
LS_FN_VNEG,
|
||||
LS_FN_APOS,
|
||||
LS_FN_ANEG,
|
||||
LS_FN_AND,
|
||||
LS_FN_OR,
|
||||
LS_FN_XOR,
|
||||
LS_FN_EQUAL,
|
||||
LS_FN_NEQUAL,
|
||||
LS_FN_GREATER,
|
||||
LS_FN_LESS,
|
||||
LS_FN_EGREATER,
|
||||
LS_FN_ELESS,
|
||||
LS_FN_DPOS,
|
||||
LS_FN_DAPOS,
|
||||
LS_FN_VEQUAL, // added at the end to avoid everything renumbered
|
||||
LS_FN_VALMOSTEQUAL,
|
||||
LS_FN_TIMER,
|
||||
LS_FN_STICKY,
|
||||
LS_FN_STAY,
|
||||
// later ... LS_FN_RANGE,
|
||||
LS_FN_MAX
|
||||
};
|
||||
|
||||
class SafetySwData { // Custom Switches data
|
||||
public:
|
||||
SafetySwData() { clear(); }
|
||||
RawSwitch swtch;
|
||||
int val;
|
||||
enum CSFunctionFamily {
|
||||
LS_FAMILY_VOFS,
|
||||
LS_FAMILY_VBOOL,
|
||||
LS_FAMILY_VCOMP,
|
||||
LS_FAMILY_TIMER,
|
||||
LS_FAMILY_STICKY,
|
||||
LS_FAMILY_STAY,
|
||||
};
|
||||
|
||||
void clear() { memset(this, 0, sizeof(SafetySwData)); }
|
||||
class LogicalSwitchData { // Custom Switches data
|
||||
public:
|
||||
LogicalSwitchData(unsigned int func=0)
|
||||
{
|
||||
clear();
|
||||
this->func = func;
|
||||
}
|
||||
unsigned int func;
|
||||
int val1;
|
||||
int val2;
|
||||
int val3;
|
||||
unsigned int delay;
|
||||
unsigned int duration;
|
||||
int andsw;
|
||||
void clear() { memset(this, 0, sizeof(LogicalSwitchData)); }
|
||||
CSFunctionFamily getFunctionFamily();
|
||||
QString funcToString();
|
||||
QString toString(const ModelData & model);
|
||||
};
|
||||
|
||||
enum AssignFunc {
|
||||
FuncSafetyCh1 = 0,
|
||||
FuncSafetyCh16 = FuncSafetyCh1+15,
|
||||
FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
|
||||
FuncTrainer,
|
||||
FuncTrainerRUD,
|
||||
FuncTrainerELE,
|
||||
@@ -565,6 +668,8 @@ enum AssignFunc {
|
||||
FuncPlaySound,
|
||||
FuncPlayHaptic,
|
||||
FuncReset,
|
||||
FuncSetTimer1,
|
||||
FuncSetTimer2,
|
||||
FuncVario,
|
||||
FuncPlayPrompt,
|
||||
FuncPlayBoth,
|
||||
@@ -575,38 +680,41 @@ enum AssignFunc {
|
||||
FuncBackgroundMusic,
|
||||
FuncBackgroundMusicPause,
|
||||
FuncAdjustGV1,
|
||||
FuncAdjustGV2,
|
||||
FuncAdjustGV3,
|
||||
FuncAdjustGV4,
|
||||
FuncAdjustGV5,
|
||||
FuncCount
|
||||
FuncAdjustGVLast = FuncAdjustGV1+C9X_MAX_GVARS-1,
|
||||
FuncCount,
|
||||
FuncReserve = -1
|
||||
};
|
||||
|
||||
class FuncSwData { // Function Switches data
|
||||
public:
|
||||
FuncSwData() { clear(); }
|
||||
FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
|
||||
RawSwitch swtch;
|
||||
AssignFunc func;
|
||||
int param;
|
||||
char paramarm[10];
|
||||
unsigned int enabled; // TODO perhaps not any more the right name
|
||||
unsigned int adjustMode;
|
||||
unsigned int repeatParam;
|
||||
int repeatParam;
|
||||
void clear() { memset(this, 0, sizeof(FuncSwData)); }
|
||||
QString funcToString();
|
||||
QString paramToString();
|
||||
QString repeatToString();
|
||||
QStringList toStringList();
|
||||
};
|
||||
|
||||
class PhaseData {
|
||||
public:
|
||||
PhaseData() { clear(); }
|
||||
int trimRef[NUM_STICKS]; //
|
||||
int trimMode[NUM_STICKS];
|
||||
int trimRef[NUM_STICKS];
|
||||
int trim[NUM_STICKS];
|
||||
RawSwitch swtch;
|
||||
char name[10+1];
|
||||
unsigned int fadeIn;
|
||||
unsigned int fadeOut;
|
||||
int rotaryEncoders[2];
|
||||
int gvars[5];
|
||||
void clear() { memset(this, 0, sizeof(PhaseData)); for (int i=0; i<NUM_STICKS; i++) trimRef[i] = -1; }
|
||||
int gvars[C9X_MAX_GVARS];
|
||||
void clear() { memset(this, 0, sizeof(PhaseData)); }
|
||||
};
|
||||
|
||||
class SwashRingData { // Swash Ring data
|
||||
@@ -657,6 +765,14 @@ class FrSkyChannelData {
|
||||
unsigned int multiplier;
|
||||
FrSkyAlarmData alarms[2];
|
||||
|
||||
float getRatio() const
|
||||
{
|
||||
if (type==0 || type==1 || type==2)
|
||||
return float(ratio << multiplier) / 10.0;
|
||||
else
|
||||
return ratio << multiplier;
|
||||
}
|
||||
|
||||
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
|
||||
};
|
||||
|
||||
@@ -703,6 +819,9 @@ class FrSkyData {
|
||||
int varioCenterMin; // if increment in 0.2m/s = 3.0m/s max
|
||||
int varioCenterMax;
|
||||
int varioMax;
|
||||
bool mAhPersistent;
|
||||
unsigned int storedMah;
|
||||
int fasOffset;
|
||||
|
||||
void clear() { memset(this, 0, sizeof(FrSkyData)); rssiAlarms[0].clear(2, 45); rssiAlarms[1].clear(3, 42); varioSource = 2/*VARIO*/; }
|
||||
};
|
||||
@@ -715,33 +834,17 @@ class MavlinkData {
|
||||
void clear() { memset(this, 0, sizeof(MavlinkData)); }
|
||||
};
|
||||
|
||||
enum TimerMode {
|
||||
TMRMODE_OFF=0,
|
||||
TMRMODE_ABS,
|
||||
TMRMODE_THs,
|
||||
TMRMODE_THp,
|
||||
TMRMODE_THt,
|
||||
TMRMODE_FIRST_SWITCH,
|
||||
TMRMODE_FIRST_MOMENT_SWITCH = TMRMODE_FIRST_SWITCH+64,
|
||||
TMRMODE_FIRST_CHPERC = TMRMODE_FIRST_MOMENT_SWITCH+64,
|
||||
|
||||
TMRMODE_FIRST_NEG_SWITCH=-TMRMODE_FIRST_SWITCH,
|
||||
TMRMODE_FIRST_NEG_MOMENT_SWITCH=-TMRMODE_FIRST_MOMENT_SWITCH,
|
||||
/* sw/!sw, !m_sw/!m_sw */
|
||||
};
|
||||
|
||||
class TimerData {
|
||||
public:
|
||||
TimerData() { clear(); }
|
||||
TimerMode mode; // timer trigger source -> off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw
|
||||
int8_t modeB;
|
||||
bool minuteBeep;
|
||||
bool countdownBeep;
|
||||
bool dir; // 0=>Count Down, 1=>Count Up
|
||||
RawSwitch mode;
|
||||
bool minuteBeep;
|
||||
unsigned int countdownBeep;
|
||||
bool dir; // 0=>Count Down, 1=>Count Up
|
||||
unsigned int val;
|
||||
bool persistent;
|
||||
int pvalue;
|
||||
void clear() { memset(this, 0, sizeof(TimerData)); }
|
||||
bool persistent;
|
||||
int pvalue;
|
||||
void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); }
|
||||
};
|
||||
|
||||
enum Protocol {
|
||||
@@ -777,16 +880,31 @@ class ModuleData {
|
||||
void clear() { memset(this, 0, sizeof(ModuleData)); }
|
||||
};
|
||||
|
||||
#define C9X_MAX_SCRIPTS 7
|
||||
#define C9X_MAX_SCRIPT_INPUTS 10
|
||||
class ScriptData {
|
||||
public:
|
||||
ScriptData() { clear(); }
|
||||
char filename[10+1];
|
||||
char name[10+1];
|
||||
int inputs[C9X_MAX_SCRIPT_INPUTS];
|
||||
void clear() { memset(this, 0, sizeof(ScriptData)); }
|
||||
};
|
||||
|
||||
class ModelData {
|
||||
public:
|
||||
ModelData();
|
||||
|
||||
ExpoData * insertInput(const int idx);
|
||||
void removeInput(const int idx);
|
||||
|
||||
bool used;
|
||||
char name[12+1];
|
||||
uint8_t modelVoice;
|
||||
TimerData timers[2];
|
||||
bool thrTrim; // Enable Throttle Trim
|
||||
bool thrExpo; // Enable Throttle Expo
|
||||
unsigned int trimInc; // Trim Increments
|
||||
int trimInc; // Trim Increments
|
||||
bool disableThrottleWarning;
|
||||
|
||||
unsigned int beepANACenter; // 1<<0->A1.. 1<<6->A7
|
||||
@@ -797,18 +915,25 @@ class ModelData {
|
||||
PhaseData phaseData[C9X_MAX_PHASES];
|
||||
MixData mixData[C9X_MAX_MIXERS];
|
||||
LimitData limitData[C9X_NUM_CHNOUT];
|
||||
|
||||
char inputNames[C9X_MAX_INPUTS][4+1];
|
||||
ExpoData expoData[C9X_MAX_EXPOS];
|
||||
|
||||
CurveData curves[C9X_MAX_CURVES];
|
||||
CustomSwData customSw[C9X_NUM_CSW];
|
||||
LogicalSwitchData customSw[C9X_NUM_CSW];
|
||||
FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||
SafetySwData safetySw[C9X_NUM_CHNOUT];
|
||||
SwashRingData swashRingData;
|
||||
unsigned int thrTraceSrc;
|
||||
int8_t traineron; // 0 disable trainer, 1 allow trainer
|
||||
int8_t t2throttle; // Start timer2 using throttle
|
||||
unsigned int modelId;
|
||||
unsigned int modelId;
|
||||
unsigned int switchWarningStates;
|
||||
unsigned int nSwToWarn;
|
||||
unsigned int nPotsToWarn;
|
||||
int potPosition[C9X_NUM_POTS];
|
||||
bool displayText;
|
||||
// TODO structure
|
||||
char gvars_names[C9X_MAX_GVARS][6+1];
|
||||
bool gvars_popups[C9X_MAX_GVARS];
|
||||
uint8_t gvsource[5];
|
||||
uint8_t bt_telemetry;
|
||||
uint8_t numVoice;
|
||||
@@ -824,13 +949,20 @@ class ModelData {
|
||||
|
||||
ModuleData moduleData[C9X_NUM_MODULES+1/*trainer*/];
|
||||
|
||||
ScriptData scriptData[C9X_MAX_SCRIPTS];
|
||||
|
||||
void clear();
|
||||
bool isempty();
|
||||
void setDefault(uint8_t id);
|
||||
unsigned int getTrimFlightPhase(uint8_t idx, int8_t phase);
|
||||
void setDefaultMixes(GeneralSettings & settings);
|
||||
void setDefaultValues(unsigned int id, GeneralSettings & settings);
|
||||
|
||||
int getTrimValue(int phaseIdx, int trimIdx);
|
||||
void setTrimValue(int phaseIdx, int trimIdx, int value);
|
||||
ModelData removeGlobalVars();
|
||||
|
||||
void clearMixes();
|
||||
void clearInputs();
|
||||
|
||||
protected:
|
||||
void removeGlobalVar(int & var);
|
||||
};
|
||||
@@ -838,52 +970,39 @@ class ModelData {
|
||||
class RadioData {
|
||||
public:
|
||||
GeneralSettings generalSettings;
|
||||
ModelData models[C9XMAX_MODELS];
|
||||
ModelData models[C9X_MAX_MODELS];
|
||||
};
|
||||
|
||||
// TODO rename FlightPhase to FlightMode
|
||||
enum Capability {
|
||||
OwnerName,
|
||||
FlightPhases,
|
||||
FlightPhasesAreNamed,
|
||||
FlightModesName,
|
||||
FlightPhasesHaveFades,
|
||||
SimulatorType,
|
||||
Mixes,
|
||||
MixesWithoutExpo,
|
||||
Timers,
|
||||
TimerTriggerB,
|
||||
TimeDivisions,
|
||||
minuteBeep,
|
||||
countdownBeep,
|
||||
CustomFunctions,
|
||||
VoicesAsNumbers,
|
||||
VoicesMaxLength,
|
||||
ModelVoice,
|
||||
MultiLangVoice,
|
||||
ModelImage,
|
||||
InstantTrimSW,
|
||||
Pots,
|
||||
Switches,
|
||||
SwitchesPositions,
|
||||
CustomSwitches,
|
||||
LogicalSwitches,
|
||||
CustomAndSwitches,
|
||||
HasNegAndSwitches,
|
||||
CustomSwitchesExt,
|
||||
LogicalSwitchesExt,
|
||||
RotaryEncoders,
|
||||
Outputs,
|
||||
ChannelsName,
|
||||
ExtraChannels,
|
||||
ExtraInputs,
|
||||
ExtraTrims,
|
||||
ExtendedTrims,
|
||||
HasNegCurves,
|
||||
HasInputFilter,
|
||||
HasExpoCurves,
|
||||
ExpoIsCurve,
|
||||
ExpoCurve5,
|
||||
ExpoCurve9,
|
||||
CustomCurves,
|
||||
NumCurves3,
|
||||
NumCurves5,
|
||||
NumCurves9,
|
||||
NumCurves,
|
||||
NumCurvePoints,
|
||||
OffsetWeight,
|
||||
@@ -903,7 +1022,6 @@ enum Capability {
|
||||
TrainerSwitch,
|
||||
ModelTrainerEnable,
|
||||
Timer2ThrTrig,
|
||||
HasTTrace,
|
||||
HasExpoNames,
|
||||
HasMixerNames,
|
||||
HasChNames,
|
||||
@@ -913,14 +1031,10 @@ enum Capability {
|
||||
HasPPMStart,
|
||||
HasGeneralUnits,
|
||||
HasFAIMode,
|
||||
NoTimerDirs,
|
||||
NoThrExpo,
|
||||
OptrexDisplay,
|
||||
PPMExtCtrl,
|
||||
PPMFrameLength,
|
||||
MixFmTrim,
|
||||
gsSwitchMask,
|
||||
pmSwitchMask,
|
||||
BLonStickMove,
|
||||
DSM2Indexes,
|
||||
Telemetry,
|
||||
@@ -931,14 +1045,10 @@ enum Capability {
|
||||
GvarsInCS,
|
||||
GvarsAreNamed,
|
||||
GvarsFlightPhases,
|
||||
GvarsHaveSources,
|
||||
GvarsAsSources,
|
||||
GvarsAsWeight,
|
||||
GvarsNum,
|
||||
GvarsOfsNum,
|
||||
GvarsName,
|
||||
NoTelemetryProtocol,
|
||||
TelemetryCSFields,
|
||||
TelemetryColsCSFields,
|
||||
TelemetryCustomScreens,
|
||||
TelemetryCustomScreensFieldsPerLine,
|
||||
TelemetryRSSIModel,
|
||||
TelemetryAlarm,
|
||||
TelemetryInternalAlarm,
|
||||
@@ -952,11 +1062,8 @@ enum Capability {
|
||||
HasPPMSim,
|
||||
HasCrossTrims,
|
||||
HasStickScroll,
|
||||
HasFixOffset,
|
||||
HasSoundMixer,
|
||||
NumModules,
|
||||
FSSwitch,
|
||||
DiffMixers,
|
||||
PPMCenter,
|
||||
SYMLimits,
|
||||
HasCurrentCalibration,
|
||||
@@ -964,8 +1071,6 @@ enum Capability {
|
||||
HasBrightness,
|
||||
HasContrast,
|
||||
PerModelTimers,
|
||||
PerModelThrottleWarning,
|
||||
PerModelThrottleInvert,
|
||||
SlowScale,
|
||||
SlowRange,
|
||||
PermTimers,
|
||||
@@ -973,14 +1078,18 @@ enum Capability {
|
||||
CSFunc,
|
||||
LCDWidth,
|
||||
GetThrSwitch,
|
||||
};
|
||||
|
||||
enum UseContext {
|
||||
DefaultContext,
|
||||
TimerContext,
|
||||
FlightPhaseContext,
|
||||
MixerContext,
|
||||
ExpoContext,
|
||||
HasDisplayText,
|
||||
VirtualInputs,
|
||||
TrainerInputs,
|
||||
LuaInputs,
|
||||
LimitsPer1000,
|
||||
EnhancedCurves,
|
||||
TelemetryInternalAlarms,
|
||||
HasFasOffset,
|
||||
HasMahPersistent,
|
||||
MultiposPots,
|
||||
MultiposPotsPositions,
|
||||
SimulatorVariant,
|
||||
};
|
||||
|
||||
class SimulatorInterface;
|
||||
@@ -999,7 +1108,7 @@ class EEPROMInterface
|
||||
|
||||
inline BoardEnum getBoard() { return board; }
|
||||
|
||||
virtual bool load(RadioData &radioData, uint8_t *eeprom, int size) = 0;
|
||||
virtual bool load(RadioData &radioData, const uint8_t *eeprom, int size) = 0;
|
||||
|
||||
virtual bool loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index) = 0;
|
||||
|
||||
@@ -1015,11 +1124,7 @@ class EEPROMInterface
|
||||
|
||||
virtual int isAvailable(Protocol proto, int port=0) = 0;
|
||||
|
||||
virtual bool isAvailable(const RawSwitch & swtch, UseContext context) { return true; }
|
||||
|
||||
virtual bool isAvailable(const RawSource & source, UseContext context) { return true; }
|
||||
|
||||
virtual SimulatorInterface * getSimulator() = 0;
|
||||
virtual SimulatorInterface * getSimulator() { return NULL; }
|
||||
|
||||
virtual const int getEEpromSize() = 0;
|
||||
|
||||
@@ -1041,6 +1146,12 @@ extern QString EEPROMWarnings;
|
||||
void setEEPROMString(char *dst, const char *src, int size);
|
||||
void getEEPROMString(char *dst, const char *src, int size);
|
||||
|
||||
float ValToTim(int value);
|
||||
int TimToVal(float value);
|
||||
|
||||
QString getSignedStr(int value);
|
||||
QString getGVarString(int16_t val, bool sign=false);
|
||||
|
||||
inline int applyStickMode(int stick, unsigned int mode)
|
||||
{
|
||||
if (mode == 0 || mode > 4) {
|
||||
@@ -1100,14 +1211,14 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
|
||||
// virtual switches
|
||||
for (int i=0; i<C9X_NUM_CSW; i++) {
|
||||
RawSource source;
|
||||
switch (getCSFunctionFamily(model.customSw[i].func)) {
|
||||
case CS_FAMILY_VCOMP:
|
||||
switch (model.customSw[i].getFunctionFamily()) {
|
||||
case LS_FAMILY_VCOMP:
|
||||
source = RawSource(model.customSw[i].val2);
|
||||
if (source.type == SOURCE_TYPE_STICK)
|
||||
source.index = applyStickMode(source.index + 1, mode) - 1;
|
||||
model.customSw[i].val2 = source.toValue();
|
||||
// no break
|
||||
case CS_FAMILY_VOFS:
|
||||
case LS_FAMILY_VOFS:
|
||||
source = RawSource(model.customSw[i].val1);
|
||||
if (source.type == SOURCE_TYPE_STICK)
|
||||
source.index = applyStickMode(source.index + 1, mode) - 1;
|
||||
@@ -1126,7 +1237,7 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
|
||||
void RegisterFirmwares();
|
||||
|
||||
bool LoadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index);
|
||||
bool LoadEeprom(RadioData &radioData, uint8_t *eeprom, int size);
|
||||
bool LoadEeprom(RadioData &radioData, const uint8_t *eeprom, int size);
|
||||
bool LoadEepromXml(RadioData &radioData, QDomDocument &doc);
|
||||
|
||||
struct Option {
|
||||
|
||||
Reference in New Issue
Block a user