mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +03:00
Timer modes support in Companion
This commit is contained in:
parent
01242e2b78
commit
eb80d75ee1
15 changed files with 225 additions and 292 deletions
|
@ -279,34 +279,39 @@ QString RawSwitch::toString()
|
||||||
QObject::tr("REa"), QObject::tr("REb")
|
QObject::tr("REa"), QObject::tr("REb")
|
||||||
};
|
};
|
||||||
|
|
||||||
if (index == 0) {
|
static const QString timerModes[] = {
|
||||||
return QObject::tr("----");
|
QObject::tr("OFF"), QObject::tr("ABS"),
|
||||||
}
|
QObject::tr("THs"), QObject::tr("TH%"), QObject::tr("THt")
|
||||||
else if (index < 0) {
|
};
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
return QString("!") + RawSwitch(type, -index).toString();
|
return QString("!") + RawSwitch(type, -index).toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
index = index - 1;
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SWITCH_TYPE_SWITCH:
|
case SWITCH_TYPE_SWITCH:
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
||||||
return CHECK_IN_ARRAY(switchesX9D, index);
|
return CHECK_IN_ARRAY(switchesX9D, index-1);
|
||||||
else
|
else
|
||||||
return CHECK_IN_ARRAY(switches9X, index);
|
return CHECK_IN_ARRAY(switches9X, index-1);
|
||||||
case SWITCH_TYPE_VIRTUAL:
|
case SWITCH_TYPE_VIRTUAL:
|
||||||
return CHECK_IN_ARRAY(virtualSwitches, index);
|
return CHECK_IN_ARRAY(virtualSwitches, index-1);
|
||||||
case SWITCH_TYPE_MULTIPOS_POT:
|
case SWITCH_TYPE_MULTIPOS_POT:
|
||||||
return CHECK_IN_ARRAY(multiposPots, index);
|
return CHECK_IN_ARRAY(multiposPots, index-1);
|
||||||
case SWITCH_TYPE_TRIM:
|
case SWITCH_TYPE_TRIM:
|
||||||
return CHECK_IN_ARRAY(trimsSwitches, index);
|
return CHECK_IN_ARRAY(trimsSwitches, index-1);
|
||||||
case SWITCH_TYPE_ROTARY_ENCODER:
|
case SWITCH_TYPE_ROTARY_ENCODER:
|
||||||
return CHECK_IN_ARRAY(rotaryEncoders, index);
|
return CHECK_IN_ARRAY(rotaryEncoders, index-1);
|
||||||
case SWITCH_TYPE_ON:
|
case SWITCH_TYPE_ON:
|
||||||
return QObject::tr("ON");
|
return QObject::tr("ON");
|
||||||
case SWITCH_TYPE_OFF:
|
case SWITCH_TYPE_OFF:
|
||||||
return QObject::tr("OFF");
|
return QObject::tr("OFF");
|
||||||
|
case SWITCH_TYPE_NONE:
|
||||||
|
return QObject::tr("----");
|
||||||
|
case SWITCH_TYPE_TIMER_MODE:
|
||||||
|
return CHECK_IN_ARRAY(timerModes, index);
|
||||||
default:
|
default:
|
||||||
break;
|
return QObject::tr("???");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,7 +864,8 @@ void ModelData::clear()
|
||||||
if (IS_TARANIS(board)) {
|
if (IS_TARANIS(board)) {
|
||||||
moduleData[0].protocol=PXX_XJT_X16;
|
moduleData[0].protocol=PXX_XJT_X16;
|
||||||
moduleData[1].protocol=OFF;
|
moduleData[1].protocol=OFF;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
moduleData[0].protocol=PPM;
|
moduleData[0].protocol=PPM;
|
||||||
moduleData[1].protocol=OFF;
|
moduleData[1].protocol=OFF;
|
||||||
}
|
}
|
||||||
|
@ -878,9 +884,10 @@ void ModelData::clear()
|
||||||
expoData[i].clear();
|
expoData[i].clear();
|
||||||
for (int i=0; i<C9X_NUM_CSW; i++)
|
for (int i=0; i<C9X_NUM_CSW; i++)
|
||||||
customSw[i].clear();
|
customSw[i].clear();
|
||||||
for (int i=0; i<C9X_MAX_CURVES; i++) {
|
for (int i=0; i<C9X_MAX_CURVES; i++)
|
||||||
curves[i].clear(5);
|
curves[i].clear(5);
|
||||||
}
|
for (int i=0; i<2; i++)
|
||||||
|
timers[i].clear();
|
||||||
|
|
||||||
swashRingData.clear();
|
swashRingData.clear();
|
||||||
frsky.clear();
|
frsky.clear();
|
||||||
|
|
|
@ -321,7 +321,8 @@ enum RawSwitchType {
|
||||||
SWITCH_TYPE_TRIM,
|
SWITCH_TYPE_TRIM,
|
||||||
SWITCH_TYPE_ROTARY_ENCODER,
|
SWITCH_TYPE_ROTARY_ENCODER,
|
||||||
SWITCH_TYPE_ON,
|
SWITCH_TYPE_ON,
|
||||||
SWITCH_TYPE_OFF
|
SWITCH_TYPE_OFF,
|
||||||
|
SWITCH_TYPE_TIMER_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
class RawSwitch {
|
class RawSwitch {
|
||||||
|
@ -618,7 +619,7 @@ class CustomSwData { // Custom Switches data
|
||||||
int val2;
|
int val2;
|
||||||
unsigned int delay;
|
unsigned int delay;
|
||||||
unsigned int duration;
|
unsigned int duration;
|
||||||
unsigned int andsw;
|
int andsw;
|
||||||
void clear() { memset(this, 0, sizeof(CustomSwData)); }
|
void clear() { memset(this, 0, sizeof(CustomSwData)); }
|
||||||
CSFunctionFamily getFunctionFamily();
|
CSFunctionFamily getFunctionFamily();
|
||||||
QString funcToString();
|
QString funcToString();
|
||||||
|
@ -799,29 +800,17 @@ class MavlinkData {
|
||||||
void clear() { memset(this, 0, sizeof(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_CHPERC = TMRMODE_FIRST_SWITCH+64,
|
|
||||||
TMRMODE_FIRST_NEG_SWITCH=-TMRMODE_FIRST_SWITCH,
|
|
||||||
/* sw/!sw, !m_sw/!m_sw */
|
|
||||||
};
|
|
||||||
|
|
||||||
class TimerData {
|
class TimerData {
|
||||||
public:
|
public:
|
||||||
TimerData() { clear(); }
|
TimerData() { clear(); }
|
||||||
TimerMode mode; // timer trigger source -> off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw
|
RawSwitch mode;
|
||||||
bool minuteBeep;
|
bool minuteBeep;
|
||||||
unsigned int countdownBeep;
|
unsigned int countdownBeep;
|
||||||
bool dir; // 0=>Count Down, 1=>Count Up
|
bool dir; // 0=>Count Down, 1=>Count Up
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
bool persistent;
|
bool persistent;
|
||||||
int pvalue;
|
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 {
|
enum Protocol {
|
||||||
|
@ -1085,10 +1074,6 @@ class EEPROMInterface
|
||||||
|
|
||||||
virtual int isAvailable(Protocol proto, int port=0) = 0;
|
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() = 0;
|
||||||
|
|
||||||
virtual const int getEEpromSize() = 0;
|
virtual const int getEEpromSize() = 0;
|
||||||
|
|
|
@ -335,8 +335,9 @@ t_Er9xFrSkyData::operator FrSkyData ()
|
||||||
return c9x;
|
return c9x;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimerMode getEr9xTimerMode(int mode)
|
RawSwitch getEr9xTimerMode(int mode)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (mode <= -33)
|
if (mode <= -33)
|
||||||
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33));
|
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33));
|
||||||
else if (mode <= -1)
|
else if (mode <= -1)
|
||||||
|
@ -347,6 +348,8 @@ TimerMode getEr9xTimerMode(int mode)
|
||||||
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
|
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
|
||||||
else
|
else
|
||||||
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21));
|
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21));
|
||||||
|
*/
|
||||||
|
return RawSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
t_Er9xModelData::operator ModelData ()
|
t_Er9xModelData::operator ModelData ()
|
||||||
|
|
|
@ -5,14 +5,12 @@
|
||||||
|
|
||||||
extern RawSwitch er9xToSwitch(int8_t sw);
|
extern RawSwitch er9xToSwitch(int8_t sw);
|
||||||
|
|
||||||
TimerMode getErSky9xTimerMode(int mode)
|
RawSwitch getErSky9xTimerMode(int mode)
|
||||||
{
|
{
|
||||||
if (mode<4)
|
if (mode<4)
|
||||||
return TimerMode(mode);
|
return RawSwitch(SWITCH_TYPE_TIMER_MODE, mode);
|
||||||
else if (mode < 20)
|
|
||||||
return TimerMode(TMRMODE_FIRST_CHPERC+(mode-4));
|
|
||||||
else
|
else
|
||||||
return TimerMode(0);
|
return RawSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
RawSwitch ersky9xToSwitch(int8_t sw)
|
RawSwitch ersky9xToSwitch(int8_t sw)
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
|
||||||
extern TimerMode getEr9xTimerMode(int mode);
|
extern RawSwitch getEr9xTimerMode(int mode);
|
||||||
extern int setEr9xTimerMode(TimerMode mode);
|
|
||||||
|
|
||||||
//eeprom data
|
//eeprom data
|
||||||
#define ERSKY9X_MAX_MIXERS_V10 32
|
#define ERSKY9X_MAX_MIXERS_V10 32
|
||||||
|
|
|
@ -373,7 +373,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
|
||||||
return c9x;
|
return c9x;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern TimerMode getEr9xTimerMode(int mode);
|
extern RawSwitch getEr9xTimerMode(int mode);
|
||||||
|
|
||||||
t_Gruvin9xTimerData::operator TimerData ()
|
t_Gruvin9xTimerData::operator TimerData ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,7 +124,7 @@ RawSource open9xArm210ToSource(int8_t value)
|
||||||
t_Open9xArmTimerData_v202::operator TimerData ()
|
t_Open9xArmTimerData_v202::operator TimerData ()
|
||||||
{
|
{
|
||||||
TimerData c9x;
|
TimerData c9x;
|
||||||
|
/*
|
||||||
if (mode <= -42)
|
if (mode <= -42)
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
|
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
|
||||||
else if (mode <= -1)
|
else if (mode <= -1)
|
||||||
|
@ -135,7 +135,7 @@ t_Open9xArmTimerData_v202::operator TimerData ()
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
|
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
|
||||||
else
|
else
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
|
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
|
||||||
|
*/
|
||||||
c9x.val = val;
|
c9x.val = val;
|
||||||
c9x.persistent = false;
|
c9x.persistent = false;
|
||||||
c9x.dir = (val == 0);
|
c9x.dir = (val == 0);
|
||||||
|
|
|
@ -701,7 +701,7 @@ t_Open9xPhaseData_v201::operator PhaseData ()
|
||||||
t_Open9xTimerData_v201::operator TimerData ()
|
t_Open9xTimerData_v201::operator TimerData ()
|
||||||
{
|
{
|
||||||
TimerData c9x;
|
TimerData c9x;
|
||||||
c9x.mode = TMRMODE_OFF;
|
// c9x.mode = TMRMODE_OFF;
|
||||||
c9x.val = val;
|
c9x.val = val;
|
||||||
c9x.persistent = persistent;
|
c9x.persistent = persistent;
|
||||||
c9x.dir = dir;
|
c9x.dir = dir;
|
||||||
|
@ -711,7 +711,7 @@ t_Open9xTimerData_v201::operator TimerData ()
|
||||||
t_Open9xTimerData_v202::operator TimerData ()
|
t_Open9xTimerData_v202::operator TimerData ()
|
||||||
{
|
{
|
||||||
TimerData c9x;
|
TimerData c9x;
|
||||||
|
/*
|
||||||
if (mode <= -22)
|
if (mode <= -22)
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
|
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
|
||||||
else if (mode <= -1)
|
else if (mode <= -1)
|
||||||
|
@ -722,7 +722,7 @@ t_Open9xTimerData_v202::operator TimerData ()
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
|
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
|
||||||
else
|
else
|
||||||
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
|
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
|
||||||
|
*/
|
||||||
c9x.val = val;
|
c9x.val = val;
|
||||||
c9x.persistent = false;
|
c9x.persistent = false;
|
||||||
c9x.dir = (val == 0);
|
c9x.dir = (val == 0);
|
||||||
|
|
|
@ -42,29 +42,50 @@ class SwitchesConversionTable: public ConversionTable {
|
||||||
SwitchesConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0)
|
SwitchesConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0)
|
||||||
{
|
{
|
||||||
int val=0;
|
int val=0;
|
||||||
|
int offset=0;
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_NONE), val++);
|
if (flags & POPULATE_TIMER_MODES) {
|
||||||
|
offset = 4;
|
||||||
|
for (int i=0; i<5; i++) {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_TIMER_MODE, i), val++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_NONE), val++);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
|
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
|
||||||
int s = switchIndex(i, board, version);
|
int s = switchIndex(i, board, version);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val);
|
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) {
|
if (version >= 216) {
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, -i), -val);
|
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i), -val+offset);
|
||||||
}
|
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i), val++);
|
||||||
|
|
||||||
if (IS_TARANIS(board) && version >= 216) {
|
|
||||||
for (int i=0; i<2; i++) {
|
|
||||||
for (int j=0; j<6; j++) {
|
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*6+j), val++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val);
|
if (version >= 216) {
|
||||||
|
for (int i=1; i<=8; i++) {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_TRIM, -i), -val+offset);
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_TRIM, i), val++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version >= 216) {
|
||||||
|
for (int i=1; i<=MAX_ROTARY_ENCODERS(board); i++) {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, -i), -val+offset);
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i), val++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, -i), -val+offset);
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++);
|
||||||
|
}
|
||||||
|
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
|
||||||
|
|
||||||
if (version < 216) {
|
if (version < 216) {
|
||||||
|
@ -261,59 +282,6 @@ class SourcesConversionTable: public ConversionTable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TimerModeConversionTable: public ConversionTable {
|
|
||||||
|
|
||||||
public:
|
|
||||||
TimerModeConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0)
|
|
||||||
{
|
|
||||||
int val=0;
|
|
||||||
|
|
||||||
addConversion(TMRMODE_OFF, val++);
|
|
||||||
addConversion(TMRMODE_ABS, val++);
|
|
||||||
addConversion(TMRMODE_THs, val++);
|
|
||||||
addConversion(TMRMODE_THp, val++);
|
|
||||||
addConversion(TMRMODE_THt, val++);
|
|
||||||
|
|
||||||
int swCount = MAX_SWITCHES_POSITION(board) + MAX_CUSTOM_SWITCHES(board, version);
|
|
||||||
|
|
||||||
for (int i=0; i<swCount; i++) {
|
|
||||||
int s = switchIndex(i+1, board, version) - 1;
|
|
||||||
addConversion(TMRMODE_FIRST_SWITCH+i, val+s);
|
|
||||||
addConversion(TMRMODE_FIRST_SWITCH+i, val+s+swCount);
|
|
||||||
addConversion(TMRMODE_FIRST_NEG_SWITCH-i, -1-s);
|
|
||||||
addConversion(TMRMODE_FIRST_NEG_SWITCH-i, -1-s-swCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class TimerModeField: public ConversionField< SignedField<8> > {
|
|
||||||
public:
|
|
||||||
TimerModeField(TimerMode & mode, BoardEnum board, unsigned int version, unsigned long flags=0):
|
|
||||||
ConversionField< SignedField<8> >(_mode, &conversionTable, "TimerMode"),
|
|
||||||
conversionTable(board, version, flags),
|
|
||||||
mode(mode),
|
|
||||||
_mode(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void beforeExport()
|
|
||||||
{
|
|
||||||
_mode = mode;
|
|
||||||
ConversionField< SignedField<8> >::beforeExport();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void afterImport()
|
|
||||||
{
|
|
||||||
ConversionField< SignedField<8> >::afterImport();
|
|
||||||
mode = (TimerMode)_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TimerModeConversionTable conversionTable;
|
|
||||||
TimerMode & mode;
|
|
||||||
int _mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
class SwitchField: public ConversionField< SignedField<N> > {
|
class SwitchField: public ConversionField< SignedField<N> > {
|
||||||
public:
|
public:
|
||||||
|
@ -1086,10 +1054,10 @@ class CustomSwitchesFunctionsTable: public ConversionTable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomSwitchesAndSwitchesConversionTable: public ConversionTable {
|
class AndSwitchesConversionTable: public ConversionTable {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CustomSwitchesAndSwitchesConversionTable(BoardEnum board, unsigned int version)
|
AndSwitchesConversionTable(BoardEnum board, unsigned int version)
|
||||||
{
|
{
|
||||||
int val=0;
|
int val=0;
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_NONE), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_NONE), val++);
|
||||||
|
@ -1127,6 +1095,29 @@ class CustomSwitchesAndSwitchesConversionTable: public ConversionTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ConversionTable * getInstance(BoardEnum board, unsigned int version)
|
||||||
|
{
|
||||||
|
if (IS_ARM(board) && version >= 216)
|
||||||
|
return new SwitchesConversionTable(board, version);
|
||||||
|
else
|
||||||
|
return new AndSwitchesConversionTable(board, version);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static std::list<Cache> internalCache;
|
||||||
|
|
||||||
|
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
||||||
|
Cache element = *it;
|
||||||
|
if (element.board == board && element.version == version && element.flags == flags)
|
||||||
|
return element.table;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache element(board, version, flags, new SwitchesConversionTable(board, version, flags));
|
||||||
|
internalCache.push_back(element);
|
||||||
|
return element.table;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void addConversion(const RawSwitch & sw, const int b)
|
void addConversion(const RawSwitch & sw, const int b)
|
||||||
|
@ -1147,7 +1138,7 @@ class CustomSwitchField: public TransformedField {
|
||||||
functionsConversionTable(board, version),
|
functionsConversionTable(board, version),
|
||||||
sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, (version >= 214 || (!IS_ARM(board) && version >= 213)) ? 0 : FLAG_NOSWITCHES)),
|
sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, (version >= 214 || (!IS_ARM(board) && version >= 213)) ? 0 : FLAG_NOSWITCHES)),
|
||||||
switchesConversionTable(SwitchesConversionTable::getInstance(board, version)),
|
switchesConversionTable(SwitchesConversionTable::getInstance(board, version)),
|
||||||
andswitchesConversionTable(board, version)
|
andswitchesConversionTable(AndSwitchesConversionTable::getInstance(board, version))
|
||||||
{
|
{
|
||||||
if (IS_ARM(board) && version >= 215) {
|
if (IS_ARM(board) && version >= 215) {
|
||||||
internalField.Append(new SignedField<16>(v1));
|
internalField.Append(new SignedField<16>(v1));
|
||||||
|
@ -1163,13 +1154,13 @@ class CustomSwitchField: public TransformedField {
|
||||||
internalField.Append(new UnsignedField<8>(csw.delay));
|
internalField.Append(new UnsignedField<8>(csw.delay));
|
||||||
internalField.Append(new UnsignedField<8>(csw.duration));
|
internalField.Append(new UnsignedField<8>(csw.duration));
|
||||||
if (version >= 214) {
|
if (version >= 214) {
|
||||||
internalField.Append(new ConversionField< SignedField<8> >((int &)csw.andsw, &andswitchesConversionTable, "AND switch"));
|
internalField.Append(new ConversionField< SignedField<8> >((int &)csw.andsw, andswitchesConversionTable, "AND switch"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (version >= 213) {
|
if (version >= 213) {
|
||||||
internalField.Append(new ConversionField< UnsignedField<4> >(csw.func, &functionsConversionTable, "Function"));
|
internalField.Append(new ConversionField< UnsignedField<4> >(csw.func, &functionsConversionTable, "Function"));
|
||||||
internalField.Append(new ConversionField< UnsignedField<4> >(csw.andsw, &andswitchesConversionTable, "AND switch"));
|
internalField.Append(new ConversionField< UnsignedField<4> >((unsigned int &)csw.andsw, andswitchesConversionTable, "AND switch"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
internalField.Append(new ConversionField< UnsignedField<8> >(csw.func, &functionsConversionTable, "Function"));
|
internalField.Append(new ConversionField< UnsignedField<8> >(csw.func, &functionsConversionTable, "Function"));
|
||||||
|
@ -1224,7 +1215,7 @@ class CustomSwitchField: public TransformedField {
|
||||||
CustomSwitchesFunctionsTable functionsConversionTable;
|
CustomSwitchesFunctionsTable functionsConversionTable;
|
||||||
SourcesConversionTable * sourcesConversionTable;
|
SourcesConversionTable * sourcesConversionTable;
|
||||||
SwitchesConversionTable * switchesConversionTable;
|
SwitchesConversionTable * switchesConversionTable;
|
||||||
CustomSwitchesAndSwitchesConversionTable andswitchesConversionTable;
|
ConversionTable * andswitchesConversionTable;
|
||||||
int v1;
|
int v1;
|
||||||
int v2;
|
int v2;
|
||||||
};
|
};
|
||||||
|
@ -1977,7 +1968,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<O9X_MAX_TIMERS; i++) {
|
for (int i=0; i<O9X_MAX_TIMERS; i++) {
|
||||||
internalField.Append(new TimerModeField(modelData.timers[i].mode, board, version));
|
internalField.Append(new SwitchField<8>(modelData.timers[i].mode, board, version, POPULATE_TIMER_MODES));
|
||||||
if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
|
if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
|
||||||
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
|
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
|
||||||
internalField.Append(new UnsignedField<2>(modelData.timers[i].countdownBeep));
|
internalField.Append(new UnsignedField<2>(modelData.timers[i].countdownBeep));
|
||||||
|
|
|
@ -2,18 +2,6 @@
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "th9xeeprom.h"
|
#include "th9xeeprom.h"
|
||||||
|
|
||||||
int8_t th9xFromSwitch(const RawSwitch & sw)
|
|
||||||
{
|
|
||||||
switch (sw.type) {
|
|
||||||
case SWITCH_TYPE_SWITCH:
|
|
||||||
return sw.index;
|
|
||||||
case SWITCH_TYPE_VIRTUAL:
|
|
||||||
return sw.index > 0 ? (9 + sw.index) : (-9 -sw.index);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RawSwitch th9xToSwitch(int8_t sw)
|
RawSwitch th9xToSwitch(int8_t sw)
|
||||||
{
|
{
|
||||||
if (sw == 0)
|
if (sw == 0)
|
||||||
|
@ -266,7 +254,7 @@ t_Th9xModelData::operator ModelData ()
|
||||||
ModelData c9x;
|
ModelData c9x;
|
||||||
c9x.used = true;
|
c9x.used = true;
|
||||||
getEEPROMString(c9x.name, name, sizeof(name));
|
getEEPROMString(c9x.name, name, sizeof(name));
|
||||||
switch(tmrMode) {
|
/*switch(tmrMode) {
|
||||||
case 1:
|
case 1:
|
||||||
c9x.timers[0].mode = TMRMODE_ABS;
|
c9x.timers[0].mode = TMRMODE_ABS;
|
||||||
break;
|
break;
|
||||||
|
@ -279,7 +267,7 @@ t_Th9xModelData::operator ModelData ()
|
||||||
default:
|
default:
|
||||||
c9x.timers[0].mode = TMRMODE_OFF;
|
c9x.timers[0].mode = TMRMODE_OFF;
|
||||||
break;
|
break;
|
||||||
}
|
}*/
|
||||||
// c9x.timers[0].dir = tmrDir;
|
// c9x.timers[0].dir = tmrDir;
|
||||||
c9x.timers[0].val = tmrVal;
|
c9x.timers[0].val = tmrVal;
|
||||||
/*c9x.protocol = (Protocol)protocol;
|
/*c9x.protocol = (Protocol)protocol;
|
||||||
|
|
|
@ -368,53 +368,6 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateTimerSwitchCB(QComboBox *b, int value)
|
|
||||||
{
|
|
||||||
b->clear();
|
|
||||||
uint8_t count=0;
|
|
||||||
for (int i=-128; i<128; i++) {
|
|
||||||
QString timerMode = getTimerMode(i);
|
|
||||||
if (!timerMode.isEmpty()) {
|
|
||||||
b->addItem(getTimerMode(i), i);
|
|
||||||
if (i==value)
|
|
||||||
b->setCurrentIndex(b->count()-1);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b->setMaxVisibleItems(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString getTimerMode(int tm) {
|
|
||||||
|
|
||||||
QString stt = "OFFABSTHsTH%THt";
|
|
||||||
|
|
||||||
QString s;
|
|
||||||
|
|
||||||
if (tm >= 0 && tm <= TMRMODE_THt) {
|
|
||||||
return stt.mid(abs(tm)*3, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tma = abs(tm);
|
|
||||||
|
|
||||||
if (tma >= TMRMODE_FIRST_SWITCH && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) {
|
|
||||||
s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_SWITCH + 1).toString();
|
|
||||||
if (tm < 0) s.prepend("!");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tma >= TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) {
|
|
||||||
s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString();
|
|
||||||
if (tm < 0) s.prepend("!");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tma >=TMRMODE_FIRST_CHPERC && tma <TMRMODE_FIRST_CHPERC+16) {
|
|
||||||
s = QString("CH%1%").arg(tma-TMRMODE_FIRST_CHPERC+1);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void populateBacklightCB(QComboBox *b, const uint8_t value)
|
void populateBacklightCB(QComboBox *b, const uint8_t value)
|
||||||
{
|
{
|
||||||
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
|
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
|
||||||
|
@ -427,48 +380,35 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
|
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value)
|
||||||
{
|
{
|
||||||
RawSwitch item;
|
if (IS_ARM(GetEepromInterface()->getBoard())) {
|
||||||
|
populateSwitchCB(b, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RawSwitch item;
|
||||||
|
|
||||||
b->clear();
|
b->clear();
|
||||||
|
|
||||||
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
|
item = RawSwitch(SWITCH_TYPE_NONE);
|
||||||
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
|
b->addItem(item.toString(), item.toValue());
|
||||||
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
|
|
||||||
|
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
||||||
|
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||||
|
b->addItem(item.toString(), item.toValue());
|
||||||
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=1; i<=6; i++) {
|
||||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||||
b->addItem(item.toString(), item.toValue());
|
b->addItem(item.toString(), item.toValue());
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) {
|
|
||||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
|
||||||
b->addItem(item.toString(), item.toValue());
|
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = RawSwitch(SWITCH_TYPE_NONE);
|
|
||||||
|
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
|
||||||
b->addItem(item.toString(), item.toValue());
|
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
|
||||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
|
||||||
b->addItem(item.toString(), item.toValue());
|
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) {
|
|
||||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
|
||||||
b->addItem(item.toString(), item.toValue());
|
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
|
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr)
|
||||||
{
|
{
|
||||||
RawSwitch item;
|
RawSwitch item;
|
||||||
|
|
||||||
|
@ -476,18 +416,14 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||||
|
|
||||||
if (attr & POPULATE_ONOFF) {
|
if (attr & POPULATE_ONOFF) {
|
||||||
item = RawSwitch(SWITCH_TYPE_OFF);
|
item = RawSwitch(SWITCH_TYPE_OFF);
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
b->addItem(item.toString(), item.toValue());
|
||||||
b->addItem(item.toString(), item.toValue());
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
|
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
|
||||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
b->addItem(item.toString(), item.toValue());
|
||||||
b->addItem(item.toString(), item.toValue());
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
|
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
|
||||||
|
@ -510,24 +446,27 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||||
|
|
||||||
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
|
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
|
||||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
b->addItem(item.toString(), item.toValue());
|
||||||
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attr & POPULATE_TIMER_MODES) {
|
||||||
|
for (int i=0; i<5; i++) {
|
||||||
|
item = RawSwitch(SWITCH_TYPE_TIMER_MODE, i);
|
||||||
b->addItem(item.toString(), item.toValue());
|
b->addItem(item.toString(), item.toValue());
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
item = RawSwitch(SWITCH_TYPE_NONE);
|
item = RawSwitch(SWITCH_TYPE_NONE);
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
|
||||||
b->addItem(item.toString(), item.toValue());
|
b->addItem(item.toString(), item.toValue());
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
|
||||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||||
if (GetEepromInterface()->isAvailable(item, context)) {
|
b->addItem(item.toString(), item.toValue());
|
||||||
b->addItem(item.toString(), item.toValue());
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
||||||
|
@ -927,7 +866,7 @@ QString getTrimInc(ModelData * g_model)
|
||||||
QString getTimerStr(TimerData & timer)
|
QString getTimerStr(TimerData & timer)
|
||||||
{
|
{
|
||||||
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down"));
|
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down"));
|
||||||
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + getTimerMode(timer.mode) + str;
|
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + timer.mode.toString() + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getProtocol(ModelData * g_model)
|
QString getProtocol(ModelData * g_model)
|
||||||
|
|
|
@ -80,13 +80,14 @@ class CurveGroup : public QObject {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define POPULATE_ONOFF 0x01
|
#define POPULATE_ONOFF 0x01
|
||||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
|
#define POPULATE_TIMER_MODES 0x02
|
||||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
|
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
|
||||||
|
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0);
|
||||||
|
|
||||||
void populatePhasesCB(QComboBox *b, int value);
|
void populatePhasesCB(QComboBox *b, int value);
|
||||||
void populateTrimUseCB(QComboBox *b, unsigned int phase);
|
void populateTrimUseCB(QComboBox *b, unsigned int phase);
|
||||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||||
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
|
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
|
||||||
void populateTimerSwitchCB(QComboBox *b, int value);
|
|
||||||
QString getProtocolStr(const int proto);
|
QString getProtocolStr(const int proto);
|
||||||
QString getPhasesStr(unsigned int phases, ModelData & model);
|
QString getPhasesStr(unsigned int phases, ModelData & model);
|
||||||
|
|
||||||
|
@ -105,7 +106,6 @@ QString getPhasesStr(unsigned int phases, ModelData & model);
|
||||||
void populateGVCB(QComboBox *b, int value);
|
void populateGVCB(QComboBox *b, int value);
|
||||||
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
|
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
|
||||||
void populateCSWCB(QComboBox *b, int value);
|
void populateCSWCB(QComboBox *b, int value);
|
||||||
QString getTimerMode(int tm);
|
|
||||||
QString getPhaseName(int val, char * phasename=NULL);
|
QString getPhaseName(int val, char * phasename=NULL);
|
||||||
QString getInputStr(ModelData & model, int index);
|
QString getInputStr(ModelData & model, int index);
|
||||||
QString getSignedStr(int value);
|
QString getSignedStr(int value);
|
||||||
|
|
|
@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
// V1
|
// V1
|
||||||
cswitchSource1[i] = new QComboBox(this);
|
cswitchSource1[i] = new QComboBox(this);
|
||||||
cswitchSource1[i]->setProperty("index",i);
|
cswitchSource1[i]->setProperty("index",i);
|
||||||
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
|
||||||
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
|
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
|
||||||
cswitchSource1[i]->setVisible(false);
|
cswitchSource1[i]->setVisible(false);
|
||||||
cswitchValue[i] = new QDoubleSpinBox(this);
|
cswitchValue[i] = new QDoubleSpinBox(this);
|
||||||
|
@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
// V2
|
// V2
|
||||||
cswitchSource2[i] = new QComboBox(this);
|
cswitchSource2[i] = new QComboBox(this);
|
||||||
cswitchSource2[i]->setProperty("index", i);
|
cswitchSource2[i]->setProperty("index", i);
|
||||||
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
|
||||||
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
|
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
|
||||||
cswitchSource2[i]->setVisible(false);
|
cswitchSource2[i]->setVisible(false);
|
||||||
cswitchOffset[i] = new QDoubleSpinBox(this);
|
cswitchOffset[i] = new QDoubleSpinBox(this);
|
||||||
|
@ -80,7 +80,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
cswitchAnd[i]->setProperty("index", i);
|
cswitchAnd[i]->setProperty("index", i);
|
||||||
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
|
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
|
||||||
gridLayout->addWidget(cswitchAnd[i], i+1, 4);
|
gridLayout->addWidget(cswitchAnd[i], i+1, 4);
|
||||||
cswitchAnd[i]->setVisible(false);
|
|
||||||
|
|
||||||
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
|
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
|
||||||
// Duration
|
// Duration
|
||||||
|
@ -93,7 +92,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
cswitchDuration[i]->setDecimals(1);
|
cswitchDuration[i]->setDecimals(1);
|
||||||
connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
|
connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
|
||||||
gridLayout->addWidget(cswitchDuration[i], i+1, 5);
|
gridLayout->addWidget(cswitchDuration[i], i+1, 5);
|
||||||
cswitchDuration[i]->setVisible(false);
|
|
||||||
|
|
||||||
// Delay
|
// Delay
|
||||||
cswitchDelay[i] = new QDoubleSpinBox(this);
|
cswitchDelay[i] = new QDoubleSpinBox(this);
|
||||||
|
@ -105,7 +103,6 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
cswitchDelay[i]->setDecimals(1);
|
cswitchDelay[i]->setDecimals(1);
|
||||||
connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
|
connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
|
||||||
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
|
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
|
||||||
cswitchDelay[i]->setVisible(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +113,54 @@ CustomSwitchesPanel::~CustomSwitchesPanel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomSwitchesPanel::v1Edited(int value)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
int i = sender()->property("index").toInt();
|
||||||
|
model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
|
||||||
|
if (model.customSw[i].getFunctionFamily() == CS_FAMILY_VOFS) {
|
||||||
|
RawSource source = RawSource(model.customSw[i].val1, &model);
|
||||||
|
if (source.type == SOURCE_TYPE_TELEMETRY) {
|
||||||
|
if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) {
|
||||||
|
model.customSw[i].val2 = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
model.customSw[i].val2 = -128;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RawSourceRange range = source.getRange();
|
||||||
|
if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) {
|
||||||
|
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSwitchWidgetVisibility(i);
|
||||||
|
}
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomSwitchesPanel::v2Edited(int value)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
int i = sender()->property("index").toInt();
|
||||||
|
model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomSwitchesPanel::andEdited(int value)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
int index = sender()->property("index").toInt();
|
||||||
|
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CustomSwitchesPanel::durationEdited(double duration)
|
void CustomSwitchesPanel::durationEdited(double duration)
|
||||||
{
|
{
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
|
@ -130,13 +175,6 @@ void CustomSwitchesPanel::delayEdited(double delay)
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomSwitchesPanel::andEdited(int value)
|
|
||||||
{
|
|
||||||
int index = sender()->property("index").toInt();
|
|
||||||
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomSwitchesPanel::edited()
|
void CustomSwitchesPanel::edited()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
|
@ -164,30 +202,7 @@ void CustomSwitchesPanel::edited()
|
||||||
switch (model.customSw[i].getFunctionFamily())
|
switch (model.customSw[i].getFunctionFamily())
|
||||||
{
|
{
|
||||||
case CS_FAMILY_VOFS:
|
case CS_FAMILY_VOFS:
|
||||||
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) {
|
{
|
||||||
source = RawSource(model.customSw[i].val1, &model);
|
|
||||||
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
|
|
||||||
RawSource newSource = RawSource(model.customSw[i].val1, &model);
|
|
||||||
if (newSource.type == SOURCE_TYPE_TELEMETRY) {
|
|
||||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
|
||||||
model.customSw[i].val2 = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
model.customSw[i].val2 = -128;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RawSourceRange range = source.getRange();
|
|
||||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
|
||||||
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setSwitchWidgetVisibility(i);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
source = RawSource(model.customSw[i].val1, &model);
|
source = RawSource(model.customSw[i].val1, &model);
|
||||||
RawSourceRange range = source.getRange();
|
RawSourceRange range = source.getRange();
|
||||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
||||||
|
@ -260,11 +275,7 @@ void CustomSwitchesPanel::edited()
|
||||||
cswitchValue[i]->setSingleStep(step);
|
cswitchValue[i]->setSingleStep(step);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CS_FAMILY_VBOOL:
|
default:
|
||||||
case CS_FAMILY_VCOMP:
|
|
||||||
case CS_FAMILY_STICKY:
|
|
||||||
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
|
|
||||||
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -274,6 +285,8 @@ void CustomSwitchesPanel::edited()
|
||||||
|
|
||||||
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
{
|
{
|
||||||
|
lock = true;
|
||||||
|
|
||||||
RawSource source = RawSource(model.customSw[i].val1, &model);
|
RawSource source = RawSource(model.customSw[i].val1, &model);
|
||||||
RawSourceRange range = source.getRange();
|
RawSourceRange range = source.getRange();
|
||||||
|
|
||||||
|
@ -345,24 +358,25 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
cswitchValue[i]->setValue(value);
|
cswitchValue[i]->setValue(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cswitchAnd[i]->setVisible(true);
|
|
||||||
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES);
|
lock = false;
|
||||||
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
|
|
||||||
cswitchDuration[i]->setVisible(true);
|
|
||||||
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
|
|
||||||
cswitchDelay[i]->setVisible(true);
|
|
||||||
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomSwitchesPanel::update()
|
void CustomSwitchesPanel::update()
|
||||||
{
|
{
|
||||||
lock = true;
|
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
|
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
|
||||||
|
lock = true;
|
||||||
populateCSWCB(csw[i], model.customSw[i].func);
|
populateCSWCB(csw[i], model.customSw[i].func);
|
||||||
|
lock = false;
|
||||||
setSwitchWidgetVisibility(i);
|
setSwitchWidgetVisibility(i);
|
||||||
|
lock = true;
|
||||||
|
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
|
||||||
|
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
|
||||||
|
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
|
||||||
|
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
|
||||||
|
}
|
||||||
|
lock = false;
|
||||||
}
|
}
|
||||||
lock = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomSwitchesPanel::cswPaste()
|
void CustomSwitchesPanel::cswPaste()
|
||||||
|
|
|
@ -17,9 +17,11 @@ class CustomSwitchesPanel : public ModelPanel
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void edited();
|
void edited();
|
||||||
|
void v1Edited(int value);
|
||||||
|
void v2Edited(int value);
|
||||||
|
void andEdited(int value);
|
||||||
void durationEdited(double duration);
|
void durationEdited(double duration);
|
||||||
void delayEdited(double delay);
|
void delayEdited(double delay);
|
||||||
void andEdited(int value);
|
|
||||||
void csw_customContextMenuRequested(QPoint pos);
|
void csw_customContextMenuRequested(QPoint pos);
|
||||||
void cswDelete();
|
void cswDelete();
|
||||||
void cswCopy();
|
void cswCopy();
|
||||||
|
@ -39,6 +41,7 @@ class CustomSwitchesPanel : public ModelPanel
|
||||||
int selectedSwitch;
|
int selectedSwitch;
|
||||||
|
|
||||||
void updateSelectedSwitch();
|
void updateSelectedSwitch();
|
||||||
|
void updateV2(int index);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
lock = true;
|
||||||
|
|
||||||
// Mode
|
// Mode
|
||||||
populateTimerSwitchCB(ui->mode, timer.mode);
|
populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES);
|
||||||
|
|
||||||
if (!GetEepromInterface()->getCapability(PermTimers)) {
|
if (!GetEepromInterface()->getCapability(PermTimers)) {
|
||||||
ui->persistent->hide();
|
ui->persistent->hide();
|
||||||
|
@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
|
||||||
ui->countdownBeep->addItem(tr("Beeps"));
|
ui->countdownBeep->addItem(tr("Beeps"));
|
||||||
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
|
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
|
||||||
ui->countdownBeep->addItem(tr("Countdown"));
|
ui->countdownBeep->addItem(tr("Countdown"));
|
||||||
|
|
||||||
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimerPanel::~TimerPanel()
|
TimerPanel::~TimerPanel()
|
||||||
|
@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished()
|
||||||
|
|
||||||
void TimerPanel::on_mode_currentIndexChanged(int index)
|
void TimerPanel::on_mode_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
timer.mode = TimerMode(ui->mode->itemData(index).toInt());
|
if (!lock) {
|
||||||
emit modified();
|
timer.mode = RawSwitch(ui->mode->itemData(index).toInt());
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerPanel::on_persistent_toggled(bool checked)
|
void TimerPanel::on_persistent_toggled(bool checked)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue