Merge branch 'bsongis/Issue592_sticky_switches' into next

Conflicts:
	radio/src/gui/menu_model.cpp
This commit is contained in:
Andre Bernet
2014-02-07 23:39:28 +01:00
61 changed files with 2604 additions and 2383 deletions
+61 -86
View File
@@ -72,7 +72,6 @@ const uint8_t modn12x3[4][4]= {
#define C9X_MAX_POINTS 17
#define C9X_MAX_GVARS 9
#define C9X_MAX_ENCODERS 2
#define NUM_SAFETY_CHNOUT 16
#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
@@ -147,44 +146,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_.-,]*"
@@ -357,13 +318,11 @@ enum RawSwitchType {
SWITCH_TYPE_SWITCH,
SWITCH_TYPE_VIRTUAL,
SWITCH_TYPE_MULTIPOS_POT,
SWITCH_TYPE_MOMENT_SWITCH,
SWITCH_TYPE_MOMENT_VIRTUAL,
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 {
@@ -617,30 +576,63 @@ class MixData {
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 {
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_TIMER,
CS_FN_STICKY,
CS_FN_STAY,
// later ... CS_FN_RANGE,
CS_FN_MAX
};
class SafetySwData { // Custom Switches data
public:
SafetySwData() { clear(); }
RawSwitch swtch;
int val;
enum CSFunctionFamily {
CS_FAMILY_VOFS,
CS_FAMILY_VBOOL,
CS_FAMILY_VCOMP,
CS_FAMILY_TIMER,
CS_FAMILY_STICKY,
CS_FAMILY_STAY,
};
void clear() { memset(this, 0, sizeof(SafetySwData)); }
class CustomSwData { // Custom Switches data
public:
CustomSwData(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(CustomSwData)); }
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,
@@ -666,7 +658,7 @@ enum AssignFunc {
class FuncSwData { // Function Switches data
public:
FuncSwData() { clear(); }
FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
RawSwitch swtch;
AssignFunc func;
int param;
@@ -675,6 +667,10 @@ class FuncSwData { // Function Switches data
unsigned int adjustMode;
int repeatParam;
void clear() { memset(this, 0, sizeof(FuncSwData)); }
QString funcToString();
QString paramToString();
QString repeatToString();
QStringList toStringList();
};
class PhaseData {
@@ -809,32 +805,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
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)); }
void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); }
};
enum Protocol {
@@ -897,11 +878,9 @@ class ModelData {
CurveData curves[C9X_MAX_CURVES];
CustomSwData 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 switchWarningStates;
// TODO structure
@@ -1100,10 +1079,6 @@ 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 const int getEEpromSize() = 0;
@@ -1185,7 +1160,7 @@ 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)) {
switch (model.customSw[i].getFunctionFamily()) {
case CS_FAMILY_VCOMP:
source = RawSource(model.customSw[i].val2);
if (source.type == SOURCE_TYPE_STICK)