Merge branch 'bsongis/Companion_ModelEdit_split' into next

This commit is contained in:
Andre Bernet
2014-01-15 14:55:15 +01:00
112 changed files with 12768 additions and 40732 deletions
+10 -20
View File
@@ -109,6 +109,8 @@ add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp
)
add_subdirectory(modeledit)
SET( companion9x_SRCS
eeprominterface.cpp
hexinterface.cpp
@@ -124,28 +126,24 @@ SET( companion9x_SRCS
${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp
firmwares/gruvin9x/gruvin9xeeprom.cpp
firmwares/gruvin9x/gruvin9xinterface.cpp
firmwares/opentx/open9xeeprom.cpp
firmwares/opentx/opentxeeprom.cpp
firmwares/opentx/open9xStockeeprom.cpp
firmwares/opentx/open9xinterface.cpp
firmwares/opentx/open9xGruvin9xeeprom.cpp
firmwares/opentx/open9xSky9xeeprom.cpp
firmwares/opentx/opentxinterface.cpp
firmwares/opentx/opentxTaranisSimulator.cpp
firmwares/opentx/open9xSky9xsimulator.cpp
firmwares/opentx/open9xGruvin9xsimulator.cpp
firmwares/opentx/open9xM128simulator.cpp
firmwares/opentx/open9xsimulator.cpp
firmwares/opentx/opentxSky9xsimulator.cpp
firmwares/opentx/opentxGruvin9xsimulator.cpp
firmwares/opentx/opentxM128simulator.cpp
firmwares/opentx/opentxsimulator.cpp
firmwares/ersky9x/ersky9xeeprom.cpp
firmwares/ersky9x/ersky9xinterface.cpp
${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp
node.cpp
edge.cpp
helpers.cpp
mdichild.cpp
generaledit.cpp
modeledit.cpp
modelslist.cpp
mountlist.cpp
mixerslist.cpp
avroutputdialog.cpp
preferencesdialog.cpp
burnconfigdialog.cpp
@@ -155,8 +153,6 @@ SET( companion9x_SRCS
burndialog.cpp
printdialog.cpp
fusesdialog.cpp
expodialog.cpp
mixerdialog.cpp
logsdialog.cpp
downloaddialog.cpp
simulatordialog.cpp
@@ -175,9 +171,7 @@ SET( companion9x_MOC_HDRS
comparedialog.h
printdialog.h
fusesdialog.h
mixerdialog.h
logsdialog.h
expodialog.h
contributorsdialog.h
customizesplashdialog.h
splashlibrary.h
@@ -191,14 +185,13 @@ SET( companion9x_MOC_HDRS
xmenuwidget.h
xsimulatordialog.h
generaledit.h
modeledit.h
modelslist.h
mixerslist.h
mdichild.h
mainwindow.h
myslider.h
modelconfigdialog.h
qcustomplot.h
helpers.h
)
SET( companion9x_UIS
@@ -206,16 +199,13 @@ SET( companion9x_UIS
avroutputdialog.ui
comparedialog.ui
fusesdialog.ui
expodialog.ui
logsdialog.ui
mixerdialog.ui
preferencesdialog.ui
simulatordialog.ui
xsimulatordialog.ui
burnconfigdialog.ui
downloaddialog.ui
generaledit.ui
modeledit.ui
printdialog.ui
contributorsdialog.ui
customizesplashdialog.ui
@@ -314,7 +304,7 @@ ELSE( )
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion9x_SRCS} ${companion9x_QM} )
ENDIF( )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} modeledit ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} )
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
+15 -26
View File
@@ -21,7 +21,7 @@ public:
}
bool general_settings;
uint8_t models_count;
uint8_t models[C9XMAX_MODELS];
uint8_t models[C9X_MAX_MODELS];
};
compareDialog::compareDialog(QWidget *parent, GeneralSettings *gg) :
@@ -342,7 +342,7 @@ void compareDialog::printPhases()
gvars=1;
}
if (gvars==1) {
gvarnum=GetEepromInterface()->getCapability(GvarsNum);
gvarnum=GetEepromInterface()->getCapability(Gvars);
}
if ((gvars==1 && GetEepromInterface()->getCapability(GvarsFlightPhases)) || GetEepromInterface()->getCapability(RotaryEncoders)) {
str.append("<br><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
@@ -564,7 +564,7 @@ void compareDialog::printGvars()
int gvarnum=0;
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT ) || (!GetEepromInterface()->getCapability(HasVariants) && GetEepromInterface()->getCapability(Gvars))) {
gvars=1;
gvarnum=GetEepromInterface()->getCapability(GvarsNum);
gvarnum=GetEepromInterface()->getCapability(Gvars);
}
if (!GetEepromInterface()->getCapability(GvarsFlightPhases) && (gvars==1 && GetEepromInterface()->getCapability(Gvars))) {
@@ -649,7 +649,8 @@ void compareDialog::printExpos()
};
str += tr("Weight") + QString("%1").arg(getGVarString(ed->weight)).rightJustified(6, ' ');
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(ed->phases) {
if (ed->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@@ -681,16 +682,14 @@ void compareDialog::printExpos()
mask <<=1;
}
str += QString(")");
} else {
}
else {
str += tr("DISABLED")+QString(" !!!");
}
}
}
if (ed->swtch.type)
str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
if (ed->curveMode)
if (ed->curveParam)
str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(ed->curveParam).replace("<", "&lt;").replace(">", "&gt;"));
str += "</font></td></tr>";
}
}
@@ -728,7 +727,8 @@ void compareDialog::printExpos()
}
str += tr("Weight") + QString("%1").arg(getGVarString(ed->weight)).rightJustified(6, ' ');
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(ed->phases) {
if (ed->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@@ -767,9 +767,7 @@ void compareDialog::printExpos()
}
if (ed->swtch.type)
str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
if (ed->curveMode)
if (ed->curveParam)
str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(ed->curveParam).replace("<", "&lt;").replace(">", "&gt;"));
str += "</font></td></tr>";
}
}
@@ -824,13 +822,8 @@ void compareDialog::printMixers()
str += md->srcRaw.toString();
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if(GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1){
if (md->sOffset) str += " "+ tr("FMTrim") + QString(" (%1%)").arg(md->sOffset);
} else {
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
}
if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
str += md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);
@@ -907,13 +900,9 @@ void compareDialog::printMixers()
str += md->srcRaw.toString();
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if(GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1){
if (md->sOffset) str += " "+ tr("FMTrim") + QString(" (%1%)").arg(getGVarString(md->sOffset));
} else {
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
}
if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
// TODO if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
// TODO if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);
+28 -9
View File
@@ -74,7 +74,10 @@ class DataField {
QByteArray bytes = bitsToBytes(bits);
int result = (offset+bits.count()) % 8;
for (int i=0; i<level; i++) printf(" ");
printf("%s ", getName());
if (bits.count() % 8 == 0)
printf("%s (%dbytes) ", getName(), bytes.count());
else
printf("%s (%dbits) ", getName(), bits.count());
for (int i=0; i<bytes.count(); i++) {
unsigned char c = bytes[i];
if ((i==0 && offset) || (i==bytes.count()-1 && result!=0))
@@ -422,7 +425,7 @@ class StructField: public DataField {
virtual int Dump(int level=0, int offset=0)
{
for (int i=0; i<level; i++) printf(" ");
printf("%s\n", getName());
printf("%s (%d bytes)\n", getName(), size()/8);
foreach(DataField *field, fields) {
offset = field->Dump(level+1, offset);
}
@@ -547,6 +550,7 @@ class ConversionField: public TransformedField {
_field(0),
table(table),
shift(0),
scale(1),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
@@ -562,6 +566,7 @@ class ConversionField: public TransformedField {
_field(0),
table(table),
shift(0),
scale(0),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
@@ -577,6 +582,7 @@ class ConversionField: public TransformedField {
_field(0),
table(NULL),
shift(0),
scale(0),
min(INT_MIN),
max(INT_MAX),
exportFunc(exportFunc),
@@ -585,13 +591,14 @@ class ConversionField: public TransformedField {
{
}
ConversionField(int & field, int shift, int min=INT_MIN, int max=INT_MAX, const char *name = "Signed shifted"):
ConversionField(int & field, int shift, int scale=0, int min=INT_MIN, int max=INT_MAX, const char *name = "Signed shifted"):
TransformedField(internalField),
internalField(_field, name),
field(field),
_field(0),
table(NULL),
shift(shift),
scale(scale),
min(min),
max(max),
exportFunc(NULL),
@@ -600,13 +607,14 @@ class ConversionField: public TransformedField {
{
}
ConversionField(unsigned int & field, int shift):
ConversionField(unsigned int & field, int shift, int scale=0):
TransformedField(internalField),
internalField((unsigned int &)_field),
field((int &)field),
_field(0),
table(NULL),
shift(shift),
scale(scale),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
@@ -617,19 +625,25 @@ class ConversionField: public TransformedField {
virtual void beforeExport()
{
int val = field;
if (scale) {
val /= scale;
}
if (table) {
if (table->exportValue(field, _field))
if (table->exportValue(val, _field))
return;
if (!error.isEmpty())
EEPROMWarnings += error + "\n";
}
else if (shift) {
if (field < min) _field = min + shift;
else if (field > max) _field = max + shift;
else _field = field + shift;
if (val < min) _field = min + shift;
else if (val > max) _field = max + shift;
else _field = val + shift;
}
else {
_field = exportFunc(field);
_field = exportFunc(val);
}
}
@@ -645,6 +659,10 @@ class ConversionField: public TransformedField {
else {
field = importFunc(_field);
}
if (scale) {
field *= scale;
}
}
protected:
@@ -653,6 +671,7 @@ class ConversionField: public TransformedField {
int _field;
ConversionTable * table;
int shift;
int scale;
int min;
int max;
int (*exportFunc)(int);
+61 -34
View File
@@ -4,12 +4,16 @@
#include "firmwares/er9x/er9xinterface.h"
#include "firmwares/th9x/th9xinterface.h"
#include "firmwares/gruvin9x/gruvin9xinterface.h"
#include "firmwares/opentx/open9xinterface.h"
#include "firmwares/opentx/opentxinterface.h"
#include "firmwares/ersky9x/ersky9xinterface.h"
#include "qsettings.h"
#include "helpers.h"
QString EEPROMWarnings;
const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" };
const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" };
void setEEPROMString(char *dst, const char *src, int size)
{
memcpy(dst, src, size);
@@ -244,27 +248,28 @@ double RawSource::getStep(const ModelData & Model)
}
}
QString AnalogString(int index)
{
static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") };
static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") };
static const QString potsX9D[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS") };
if (index < 4)
return CHECK_IN_ARRAY(sticks, index);
else
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsX9D, index-4) : CHECK_IN_ARRAY(pots9X, index-4));
}
QString RotaryEncoderString(int index)
{
static const QString rotary[] = { QObject::tr("REa"), QObject::tr("REb") };
return CHECK_IN_ARRAY(rotary, index);
}
QString RawSource::toString()
{
static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") };
static const QString trims[] = { QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA")};
static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") };
static const QString potsX9D[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS") };
static const QString rotary[] = { QObject::tr("REa"), QObject::tr("REb") };
static const QString switches9X[] = { QObject::tr("3POS"),
QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"),
QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN"),
};
static const QString switchesX9D[] = { QObject::tr("SA"), QObject::tr("SB"), QObject::tr("SC"), QObject::tr("SD"),
QObject::tr("SE"), QObject::tr("SF"), QObject::tr("SG"), QObject::tr("SH"),
};
static const QString telemetry[] = { QObject::tr("Batt"), QObject::tr("Timer1"), QObject::tr("Timer2"),
(IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("SWR") : QObject::tr("Tx")), (IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("RSSI") : QObject::tr("Rx")), QObject::tr("A1"), QObject::tr("A2"), QObject::tr("Alt"), QObject::tr("Rpm"), QObject::tr("Fuel"), QObject::tr("T1"),
QObject::tr("T2"), QObject::tr("Speed"), QObject::tr("Dist"), QObject::tr("GPS Alt"), QObject::tr("Cell"), QObject::tr("Cels"), QObject::tr("Vfas"), QObject::tr("Curr"),
@@ -284,14 +289,11 @@ QString RawSource::toString()
}
switch(type) {
case SOURCE_TYPE_STICK:
if (index < 4)
return CHECK_IN_ARRAY(sticks, index);
else
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsX9D, index-4) : CHECK_IN_ARRAY(pots9X, index-4));
return AnalogString(index);
case SOURCE_TYPE_TRIM:
return CHECK_IN_ARRAY(trims, index);
case SOURCE_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotary, index);
return RotaryEncoderString(index);
case SOURCE_TYPE_MAX:
return QObject::tr("MAX");
case SOURCE_TYPE_SWITCH:
@@ -407,6 +409,25 @@ QString RawSwitch::toString()
return QObject::tr("----");
}
QString CurveReference::toString()
{
if (value == 0) {
return "----";
}
else {
switch(type) {
case CURVE_REF_DIFF:
return QObject::tr("Diff(%1)").arg(getGVarString(value));
case CURVE_REF_EXPO:
return QObject::tr("Expo(%1)").arg(getGVarString(value));
case CURVE_REF_FUNC:
return QObject::tr("Function(%1)").arg(QString("x>0" "x<0" "|x|" "f>0" "f<0" "|f|").mid(3*(value-1), 3));
default:
return QString(value > 0 ? QObject::tr("Curve(%1)") : QObject::tr("!Curve(%1)")).arg(abs(value));
}
}
}
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
@@ -534,6 +555,18 @@ ModelData::ModelData()
clear();
}
void ModelData::clearInputs()
{
for (int i=0; i<C9X_MAX_EXPOS; i++)
expoData[i].clear();
}
void ModelData::clearMixes()
{
for (int i=0; i<C9X_MAX_MIXERS; i++)
mixData[i].clear();
}
void ModelData::clear()
{
memset(this, 0, sizeof(ModelData));
@@ -553,10 +586,8 @@ void ModelData::clear()
}
for (int i=0; i<C9X_MAX_PHASES; i++)
phaseData[i].clear();
for (int i=0; i<C9X_MAX_EXPOS; i++)
expoData[i].clear();
for (int i=0; i<C9X_MAX_MIXERS; i++)
mixData[i].clear();
clearInputs();
clearMixes();
for(int i=0; i<4; i++){
mixData[i].destCh = i+1;
mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i);
@@ -568,12 +599,8 @@ void ModelData::clear()
expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear();
bool custom = GetEepromInterface()->getCapability(CustomCurves);
for (int i=0; i<C9X_MAX_CURVES; i++) {
if (!custom && i>=8)
curves[i].clear(9);
else
curves[i].clear(5);
curves[i].clear(5);
}
swashRingData.clear();
@@ -617,13 +644,13 @@ ModelData ModelData::removeGlobalVars()
for (int i=0; i<C9X_MAX_MIXERS; i++) {
removeGlobalVar(mixData[i].weight);
removeGlobalVar(mixData[i].differential);
removeGlobalVar(mixData[i].curve.value);
removeGlobalVar(mixData[i].sOffset);
}
for (int i=0; i<C9X_MAX_EXPOS; i++) {
removeGlobalVar(expoData[i].weight);
removeGlobalVar(expoData[i].expo);
removeGlobalVar(expoData[i].curve.value);
}
return result;
+95 -52
View File
@@ -44,14 +44,17 @@ 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_TARANIS,
BOARD_TARANIS_REV4a
};
#define IS_STOCK(board) (board==BOARD_STOCK || board==BOARD_M128)
#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560)
#define IS_ARM(board) (board==BOARD_SKY9X || 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},
@@ -59,13 +62,14 @@ 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 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 NUM_SAFETY_CHNOUT 16
#define C9X_NUM_CHNOUT 32 // number of real output channels
#define C9X_NUM_CSW 32 // number of custom switches
@@ -107,6 +111,18 @@ const uint8_t chout_ar[] = { //First number is 0..23 -> template setup, Second
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 {
KEY_MENU,
@@ -185,10 +201,13 @@ enum HeliSwashTypes {
#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,
@@ -241,6 +260,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,
@@ -254,8 +275,12 @@ enum RawSourceType {
SOURCE_TYPE_TELEMETRY,
MAX_SOURCE_TYPE
};
class ModelData;
QString AnalogString(int index);
QString RotaryEncoderString(int index);
class RawSource {
public:
RawSource():
@@ -404,7 +429,6 @@ class GeneralSettings {
int timezone;
bool optrexDisplay;
unsigned int inactivityTimer;
bool throttleReversed;
bool minuteBeep;
bool preBeep;
bool flashBeep;
@@ -451,17 +475,44 @@ class GeneralSettings {
unsigned int switchUnlockStates;
};
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();
};
class ExpoData {
public:
ExpoData() { clear(); }
RawSource srcRaw;
unsigned int scale;
unsigned int mode; // 0=end, 1=pos, 2=neg, 3=both
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)); }
};
@@ -474,11 +525,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; }
};
@@ -492,6 +551,7 @@ class LimitData {
int ppmCenter;
bool symetrical;
char name[6+1];
CurveReference curve;
void clear() { memset(this, 0, sizeof(LimitData)); min = -100; max = +100; }
};
@@ -501,7 +561,6 @@ enum MltpxValue {
MLTPX_REP=2
};
class MixData {
public:
MixData() { clear(); }
@@ -509,9 +568,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)
@@ -520,9 +578,7 @@ 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];
@@ -572,10 +628,7 @@ enum AssignFunc {
FuncBackgroundMusic,
FuncBackgroundMusicPause,
FuncAdjustGV1,
FuncAdjustGV2,
FuncAdjustGV3,
FuncAdjustGV4,
FuncAdjustGV5,
FuncAdjustGVLast = FuncAdjustGV1+C9X_MAX_GVARS-1,
FuncCount
};
@@ -602,7 +655,7 @@ class PhaseData {
unsigned int fadeIn;
unsigned int fadeOut;
int rotaryEncoders[2];
int gvars[5];
int gvars[C9X_MAX_GVARS];
void clear() { memset(this, 0, sizeof(PhaseData)); for (int i=0; i<NUM_STICKS; i++) trimRef[i] = -1; }
};
@@ -805,7 +858,9 @@ class ModelData {
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId;
unsigned int switchWarningStates;
// 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;
@@ -828,6 +883,9 @@ class ModelData {
ModelData removeGlobalVars();
void clearMixes();
void clearInputs();
protected:
void removeGlobalVar(int & var);
};
@@ -835,19 +893,19 @@ 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,
@@ -857,7 +915,6 @@ enum Capability {
ModelVoice,
MultiLangVoice,
ModelImage,
InstantTrimSW,
Pots,
Switches,
SwitchesPositions,
@@ -867,20 +924,12 @@ enum Capability {
CustomSwitchesExt,
RotaryEncoders,
Outputs,
ChannelsName,
ExtraChannels,
ExtraInputs,
ExtraTrims,
ExtendedTrims,
HasNegCurves,
HasInputFilter,
HasExpoCurves,
ExpoIsCurve,
ExpoCurve5,
ExpoCurve9,
CustomCurves,
NumCurves3,
NumCurves5,
NumCurves9,
NumCurves,
NumCurvePoints,
OffsetWeight,
@@ -900,7 +949,6 @@ enum Capability {
TrainerSwitch,
ModelTrainerEnable,
Timer2ThrTrig,
HasTTrace,
HasExpoNames,
HasMixerNames,
HasChNames,
@@ -910,14 +958,10 @@ enum Capability {
HasPPMStart,
HasGeneralUnits,
HasFAIMode,
NoTimerDirs,
NoThrExpo,
OptrexDisplay,
PPMExtCtrl,
PPMFrameLength,
MixFmTrim,
gsSwitchMask,
pmSwitchMask,
BLonStickMove,
DSM2Indexes,
Telemetry,
@@ -930,9 +974,7 @@ enum Capability {
GvarsFlightPhases,
GvarsHaveSources,
GvarsAsSources,
GvarsAsWeight,
GvarsNum,
GvarsOfsNum,
GvarsName,
NoTelemetryProtocol,
TelemetryCSFields,
TelemetryColsCSFields,
@@ -949,11 +991,9 @@ enum Capability {
HasPPMSim,
HasCrossTrims,
HasStickScroll,
HasFixOffset,
HasSoundMixer,
NumModules,
FSSwitch,
DiffMixers,
PPMCenter,
SYMLimits,
HasCurrentCalibration,
@@ -961,8 +1001,6 @@ enum Capability {
HasBrightness,
HasContrast,
PerModelTimers,
PerModelThrottleWarning,
PerModelThrottleInvert,
SlowScale,
SlowRange,
PermTimers,
@@ -970,6 +1008,11 @@ enum Capability {
CSFunc,
LCDWidth,
GetThrSwitch,
VirtualInputs,
LuaInputs,
LimitsPer1000,
EnhancedCurves,
TelemetryInternalAlarms
};
enum UseContext {
-334
View File
@@ -1,334 +0,0 @@
#include "expodialog.h"
#include "ui_expodialog.h"
#include "eeprominterface.h"
#include "helpers.h"
ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
QDialog(parent),
ui(new Ui::ExpoDialog),
ed(expoData)
{
ui->setupUi(this);
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==0) {
ui->expoGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->expoCurveGV->setDisabled(true);
if (ed->expo>100) {
ed->expo=0;
}
if (ed->weight>100 || ed->weight<-100) {
ed->weight=100;
}
if (ed->curveParam>100 || ed->curveParam<-100) {
ed->curveParam=0;
}
}
populateGVCB(ui->expoCB,ed->expo);
populateGVCB(ui->weightCB,ed->weight);
populateGVCB(ui->expoCurveCB,ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (ed->weight>100 || ed->weight<0) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(ed->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
if (ed->expo>100 || ed->expo<-100) {
ui->expoGV->setChecked(true);
ui->expoSB->hide();
ui->expoCB->show();
} else {
ui->expoGV->setChecked(false);
ui->expoSB->setValue(ed->expo);
ui->expoSB->show();
ui->expoCB->hide();
}
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
if (ed->curveParam>100 || ed->curveParam<-100) {
ui->expoCurveGV->setChecked(true);
ui->expoCurveSB->hide();
ui->expoCurveCB->show();
} else {
ui->expoCurveGV->setChecked(false);
ui->expoCurveSB->setValue(ed->curveParam);
ui->expoCurveSB->show();
ui->expoCurveCB->hide();
}
} else {
ui->expoGV->hide();
ui->weightGV->hide();
ui->expoCurveGV->hide();
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
ui->expoSB->setValue(ed->expo);
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
ui->expoCurveSB->setValue(ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
ui->weightSB->setValue(ed->weight);
}
populateSwitchCB(ui->switchesCB,ed->swtch);
if (ed->curveMode==0) {
populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x
} else {
populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x
}
ui->modeCB->setCurrentIndex(ed->mode-1);
if (!GetEepromInterface()->getCapability(HasExpoCurves)) {
ui->label_curves->hide();
ui->curvesCB->hide();
ed->curveMode=1;
}
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ui->label_curves->setText(tr("Curve"));
} else {
ui->label_expo->hide();
ui->expoCB->hide();
ui->expoGV->hide();
ui->expoSB->hide();
}
if (!GetEepromInterface()->getCapability(FlightPhases)) {
ui->label_phases->hide();
for (int i=0; i<9; i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
} else {
int mask=1;
for (int i=0; i<9 ; i++) {
if ((ed->phases & mask)==0) {
cb_fp[i]->setChecked(true);
}
mask <<= 1;
}
for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
}
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
if (!expolength) {
ui->label_name->hide();
ui->expoName->hide();
} else {
ui->expoName->setMaxLength(expolength);
}
ui->expoName->setValidator(new QRegExpValidator(rx, this));
ui->expoName->setText(ed->name);
valuesChanged();
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoCurveSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
for (int i=0; i<9; i++) {
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
ExpoDialog::~ExpoDialog()
{
delete ui;
}
void ExpoDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void ExpoDialog::widgetChanged()
{
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==1) {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
if (ui->expoGV->isChecked()) {
ui->expoCB->show();
ui->expoSB->hide();
} else {
ui->expoCB->hide();
ui->expoSB->show();
}
} else {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
void ExpoDialog::valuesChanged()
{
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
if (ui->curvesCB->currentIndex()==0) {
if (GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 0;
ui->expoCurveGV->show();
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
ed->curveParam = ui->expoCurveSB->value();
}
ed->expo = ed->curveParam;
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ed->curveMode = 0;
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
ed->curveParam = ed->expo;
}
} else {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
} else {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
ed->expo = 0;
}
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
}
if (ui->weightGV->isChecked()) {
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
} else {
ed->weight = ui->weightSB->value();
}
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
ed->mode = ui->modeCB->currentIndex() + 1;
int i=0;
for (i=0; i<ui->expoName->text().toAscii().length(); i++) {
ed->name[i]=ui->expoName->text().toAscii().at(i);
}
ed->name[i]=0;
ed->phases=0;
for (int i=8; i>=0 ; i--) {
if (!cb_fp[i]->checkState()) {
ed->phases+=1;
}
ed->phases<<=1;
}
ed->phases>>=1;
if (GetEepromInterface()->getCapability(FlightPhases)) {
int zeros=0;
int ones=0;
int phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
ones++;
}
else {
zeros++;
}
phtemp >>=1;
}
if (zeros==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if ((phtemp & 1)==0) {
break;
}
phtemp >>=1;
}
}
else if (ones==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
break;
}
phtemp >>=1;
}
}
} else {
ed->phases=0;
}
}
void ExpoDialog::shrink()
{
resize(0,0);
}
+4 -1
View File
@@ -323,7 +323,10 @@ unsigned int EFile::readRlc12(uint8_t *buf, unsigned int i_len, bool rlc2)
if (read(&m_bRlc, 1) !=1) break; //read how many bytes to read
assert(m_bRlc & 0x7f);
if (!(m_bRlc & 0x7f)) {
qDebug() << "RLC decoding error!";
return 0;
}
if (rlc2) {
if(m_bRlc&0x80){ // if contains high byte
+22 -492
View File
@@ -3,26 +3,6 @@
#include "helpers.h"
#include <QObject>
int8_t er9xFromSwitch(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);
case SWITCH_TYPE_ON:
return 22;
case SWITCH_TYPE_OFF:
return -22;
case SWITCH_TYPE_MOMENT_SWITCH:
return sw.index > 0 ? (22 + sw.index) : (-22 + sw.index);
case SWITCH_TYPE_MOMENT_VIRTUAL:
return sw.index > 0 ? (31 + sw.index) : (-31 + sw.index);
default:
return 0;
}
}
RawSwitch er9xToSwitch(int8_t sw)
{
uint8_t swa = abs(sw);
@@ -47,15 +27,6 @@ t_Er9xTrainerMix::t_Er9xTrainerMix()
memset(this, 0, sizeof(t_Er9xTrainerMix));
}
t_Er9xTrainerMix::t_Er9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerMix));
srcChn = c9x.src;
swtch = er9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Er9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
@@ -71,15 +42,6 @@ t_Er9xTrainerData::t_Er9xTrainerData()
memset(this, 0, sizeof(t_Er9xTrainerData));
}
t_Er9xTrainerData::t_Er9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Er9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
@@ -95,76 +57,6 @@ t_Er9xGeneral::t_Er9xGeneral()
memset(this, 0, sizeof(t_Er9xGeneral));
}
t_Er9xGeneral::t_Er9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Er9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = c9x.beeperLength + 4;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer - 10;
throttleReversed = c9x.throttleReversed;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
disablePotScroll=(c9x.disablePotScroll ? 1 : 0);
disableBG=(c9x.disableBG ? 1 :0);
frskyinternalalarm = c9x.frskyinternalalarm;
blightinv=(c9x.blightinv ? 1 : 0);
stickScroll=(c9x.stickScroll ? 1 : 0);
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
if (c9x.backlightMode & 2)
lightOnStickMove = c9x.backlightDelay;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
setEEPROMString(ownerName, c9x.ownerName, sizeof(ownerName));
speakerPitch = c9x.speakerPitch;
hapticStrength = c9x.hapticStrength;
hideNameOnSplash = (c9x.hideNameOnSplash ? 1 : 0);
enablePpmsim = (c9x.enablePpmsim ? 1 : 0);;
speakerMode = c9x.speakerMode;
switchWarningStates =c9x.switchWarningStates;
crosstrim=(c9x.crosstrim ? 1 : 0);
}
Er9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
@@ -207,7 +99,6 @@ Er9xGeneral::operator GeneralSettings ()
result.disableAlarmWarning = disableAlarmWarning;
result.stickMode = std::max((uint8_t)0, std::min(stickMode, (uint8_t)3));
result.inactivityTimer = inactivityTimer + 10;
result.throttleReversed = throttleReversed;
result.minuteBeep = minuteBeep;
result.preBeep = preBeep;
result.flashBeep = flashBeep;
@@ -244,15 +135,6 @@ t_Er9xLimitData::t_Er9xLimitData()
memset(this, 0, sizeof(t_Er9xLimitData));
}
t_Er9xLimitData::t_Er9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Er9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Er9xLimitData::operator LimitData ()
{
LimitData c9x;
@@ -268,107 +150,6 @@ t_Er9xMixData::t_Er9xMixData()
memset(this, 0, sizeof(t_Er9xMixData));
}
t_Er9xMixData::t_Er9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Er9xMixData));
destCh = c9x.destCh;
swtch = er9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = er9xFromSwitch(RawSwitch(c9x.srcRaw.index));
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_GVAR) {
srcRaw = 38 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
if (abs(c9x.weight)>125) {
if (c9x.weight>0) {
int index=abs(c9x.weight)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
weight = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as weight") + "\n";
weight=0;
}
} else {
weight = c9x.weight;
}
if (abs(c9x.sOffset)>125) {
if (c9x.sOffset>0) {
int index=abs(c9x.sOffset)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
sOffset = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as offset") + "\n";
sOffset=0;
}
} else {
sOffset = c9x.sOffset;
}
if (c9x.curve!=0) {
curve = c9x.curve;
differential=0;
} else {
if (c9x.differential!=0) {
curve=c9x.differential;
differential=1;
} else {
curve=0;
differential=0;
}
}
lateOffset=c9x.lateOffset;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
mixWarn = c9x.mixWarn;
enableFmTrim=c9x.enableFmTrim;
}
t_Er9xMixData::operator MixData ()
{
MixData c9x;
@@ -434,14 +215,21 @@ t_Er9xMixData::operator MixData ()
else {
c9x.srcRaw = RawSource(SOURCE_TYPE_GVAR, srcRaw-38);
}
if (differential==1) {
c9x.differential=curve;
c9x.curve=0;
} else {
c9x.differential=0;
c9x.curve=curve;
c9x.curve.type = CurveReference::CURVE_REF_DIFF;
c9x.curve.value = differential;
}
c9x.lateOffset=lateOffset;
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
// c9x.lateOffset=lateOffset;
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
@@ -449,32 +237,10 @@ t_Er9xMixData::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
c9x.enableFmTrim=enableFmTrim;
// c9x.enableFmTrim=enableFmTrim;
return c9x;
}
int8_t er9xFromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource er9xToSource(int8_t value)
{
if (value == 0) {
@@ -503,33 +269,6 @@ RawSource er9xToSource(int8_t value)
}
}
t_Er9xCustomSwData::t_Er9xCustomSwData(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = er9xFromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = er9xFromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = er9xFromSwitch(RawSwitch(c9x.val1));
v2 = er9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>ER9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("er9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Er9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@@ -559,13 +298,6 @@ t_Er9xSafetySwData::t_Er9xSafetySwData()
memset(this, 0, sizeof(t_Er9xSafetySwData));
}
t_Er9xSafetySwData::t_Er9xSafetySwData(SafetySwData &c9x)
{
memset(this, 0, sizeof(t_Er9xSafetySwData));
swtch = er9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Er9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
@@ -574,35 +306,11 @@ t_Er9xSafetySwData::operator SafetySwData ()
return c9x;
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
if (c9x.type==0) {
if (c9x.multiplier==0) {
type = 0;
} else if (c9x.multiplier==1) {
type = 2;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this range for A1/A2") + "\n";
}
} else if (c9x.type==1 || c9x.type==3) {
type=c9x.type;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this telemetry units") + "\n";
}
}
t_Er9xFrSkyChannelData::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@@ -622,19 +330,11 @@ t_Er9xFrSkyChannelData::operator FrSkyChannelData ()
return c9x;
}
t_Er9xFrSkyData::t_Er9xFrSkyData()
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
}
t_Er9xFrSkyData::t_Er9xFrSkyData(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Er9xFrSkyData::operator FrSkyData ()
{
FrSkyData c9x;
@@ -643,24 +343,6 @@ t_Er9xFrSkyData::operator FrSkyData ()
return c9x;
}
int setEr9xTimerMode(TimerMode mode)
{
if (mode == TMRMODE_OFF || mode == TMRMODE_ABS)
return mode;
else if (mode == TMRMODE_THs || mode == TMRMODE_THp)
return mode + 4;
else if (mode >= TMRMODE_FIRST_MOMENT_SWITCH)
return 37+mode-TMRMODE_FIRST_MOMENT_SWITCH;
else if (mode >= TMRMODE_FIRST_SWITCH)
return 16+mode-TMRMODE_FIRST_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_MOMENT_SWITCH)
return -37+mode-TMRMODE_FIRST_NEG_MOMENT_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_SWITCH)
return -16+mode-TMRMODE_FIRST_NEG_SWITCH;
else
return 0;
}
TimerMode getEr9xTimerMode(int mode)
{
if (mode <= -33)
@@ -675,162 +357,6 @@ TimerMode getEr9xTimerMode(int mode)
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21));
}
t_Er9xModelData::t_Er9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Er9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
modelVoice=c9x.modelVoice;
tmrMode = setEr9xTimerMode(c9x.timers[0].mode);
tmrModeB = c9x.timers[0].modeB;
tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case PPM16:
protocol = 3;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Er9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
traineron = c9x.traineron;
t2throttle = c9x.t2throttle;
ppmFrameLength = c9x.moduleData[0].ppmFrameLength;
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncInstantTrim && c9x.funcSw[i].swtch.type != SWITCH_TYPE_NONE) {
trimSw = er9xFromSwitch(c9x.funcSw[i].swtch);
break;
}
beepANACenter = (uint8_t)(c9x.beepANACenter & 0x7F);
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
swashInvertELE = c9x.swashRingData.invertELE;
swashInvertAIL = c9x.swashRingData.invertAIL;
swashInvertCOL = c9x.swashRingData.invertCOL;
swashType = c9x.swashRingData.type;
swashCollectiveSource = er9xFromSource(c9x.swashRingData.collectiveSource);
swashRingValue = c9x.swashRingData.value;
for (int i=0; i<ER9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
// expoData
for (unsigned int i=0; i<NUM_STICKS; i++) {
// first we find the switches
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i) {
if (c9x.expoData[e].swtch.type!=SWITCH_TYPE_NONE) {
if (!expoData[i].drSw1)
expoData[i].drSw1 = -er9xFromSwitch(c9x.expoData[e].swtch);
else if (er9xFromSwitch(c9x.expoData[e].swtch) != -expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw2 = -er9xFromSwitch(c9x.expoData[e].swtch);
}
}
}
}
if (expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw1 = -expoData[i].drSw1;
}
for (int pos=0; pos<3; pos++) {
int swtch1=0, swtch2=0;
if (expoData[i].drSw1 && !expoData[i].drSw2) {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
break;
default:
swtch1 = expoData[i].drSw1;
break;
}
}
else {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
swtch2 = -expoData[i].drSw2;
break;
default:
swtch1 = expoData[i].drSw1;
swtch2 = expoData[i].drSw2;
break;
}
}
for (int mode=0; mode<2; mode++) {
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i && !c9x.expoData[e].phases) {
if (c9x.expoData[e].swtch.type==SWITCH_TYPE_NONE || c9x.expoData[e].swtch == er9xToSwitch(swtch1) || c9x.expoData[e].swtch == er9xToSwitch(swtch2)) {
if (c9x.expoData[e].mode == 3 || (c9x.expoData[e].mode==2 && mode==0) || (c9x.expoData[e].mode==1 && mode==1)) {
expoData[i].expo[pos][0][mode] = c9x.expoData[e].expo;
expoData[i].expo[pos][1][mode] = c9x.expoData[e].weight - 100;
break;
}
}
}
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
trim[i] = std::max(-125, std::min(125, c9x.phaseData[0].trim[i]));
for (int i=0; i<ER9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<ER9X_MAX_CURVE9; i++)
if (c9x.curves[i+ER9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+ER9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+ER9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+ER9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+ER9X_MAX_CURVE5].count).arg(i+1+ER9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<ER9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
safetySw[i] = c9x.safetySw[i];
frsky = c9x.frsky;
FrSkyUsrProto = c9x.frsky.usrProto;
FrSkyImperial = c9x.frsky.imperial;
FrSkyGpsAlt = c9x.frsky.FrSkyGpsAlt;
}
}
t_Er9xModelData::operator ModelData ()
{
ModelData c9x;
@@ -902,7 +428,10 @@ t_Er9xModelData::operator ModelData ()
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
}
c9x.expoData[e].chn = ch;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][0];
if (expoData[ch].expo[pos][0][0]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
}
c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
c9x.expoData[e++].mode = 3;
@@ -913,7 +442,10 @@ t_Er9xModelData::operator ModelData ()
c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
c9x.expoData[++e].chn = ch;
c9x.expoData[e].mode = 1;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][1];
if (expoData[ch].expo[pos][0][1]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
}
c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
}
}
@@ -924,7 +456,6 @@ t_Er9xModelData::operator ModelData ()
c9x.phaseData[0].trim[i] = trim[i];
for (int i=0; i<ER9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@@ -932,7 +463,6 @@ t_Er9xModelData::operator ModelData ()
}
}
for (int i=0; i<ER9X_MAX_CURVE9; i++) {
c9x.curves[ER9X_MAX_CURVE5 + i].custom = false;
c9x.curves[ER9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[ER9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
-15
View File
@@ -42,8 +42,6 @@ PACK(typedef struct t_Er9xTrainerMix {
operator TrainerMix();
t_Er9xTrainerMix();
t_Er9xTrainerMix(TrainerMix&);
}) Er9xTrainerMix; //
PACK(typedef struct t_Er9xTrainerData {
@@ -52,8 +50,6 @@ PACK(typedef struct t_Er9xTrainerData {
operator TrainerData();
t_Er9xTrainerData();
t_Er9xTrainerData(TrainerData&);
}) Er9xTrainerData;
PACK(typedef struct t_Er9xGeneral {
@@ -109,8 +105,6 @@ PACK(typedef struct t_Er9xGeneral {
operator GeneralSettings();
t_Er9xGeneral();
t_Er9xGeneral(GeneralSettings&);
}) Er9xGeneral;
PACK(typedef struct t_Er9xExpoData {
@@ -130,7 +124,6 @@ PACK(typedef struct t_Er9xLimitData {
operator LimitData();
t_Er9xLimitData();
t_Er9xLimitData(LimitData&);
}) Er9xLimitData;
#define MLTPX_ADD 0
@@ -158,7 +151,6 @@ PACK(typedef struct t_Er9xMixData {
operator MixData();
t_Er9xMixData();
t_Er9xMixData(MixData&);
}) Er9xMixData;
@@ -170,7 +162,6 @@ PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data
operator CustomSwData();
t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); }
t_Er9xCustomSwData(CustomSwData&);
}) Er9xCustomSwData;
PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
@@ -179,7 +170,6 @@ PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
operator SafetySwData();
t_Er9xSafetySwData();
t_Er9xSafetySwData(SafetySwData&);
}) Er9xSafetySwData;
PACK(typedef struct t_Er9xFrSkyChannelData {
@@ -191,7 +181,6 @@ PACK(typedef struct t_Er9xFrSkyChannelData {
operator FrSkyChannelData();
t_Er9xFrSkyChannelData();
t_Er9xFrSkyChannelData(FrSkyChannelData&);
}) Er9xFrSkyChannelData;
PACK(typedef struct t_Er9xFrSkyData {
@@ -199,7 +188,6 @@ PACK(typedef struct t_Er9xFrSkyData {
operator FrSkyData();
t_Er9xFrSkyData();
t_Er9xFrSkyData(FrSkyData&);
}) Er9xFrSkyData;
PACK(typedef struct t_gvar {
@@ -268,9 +256,6 @@ PACK(typedef struct t_Er9xModelData {
operator ModelData();
t_Er9xModelData() { memset(this, 0, sizeof(t_Er9xModelData)); }
t_Er9xModelData(ModelData&);
}) Er9xModelData;
#endif
/*eof*/
+6 -59
View File
@@ -184,57 +184,20 @@ bool Er9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize,
int Er9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc1(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Er9xModelData er9xModel(radioData.models[i]);
applyStickModeToModel(er9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc1(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
return 0;
}
int Er9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xModelData er9xModel(model);
int sz = efile->writeRlc1(0, FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return -1;
}
return efile->size(0);
return 0;
}
int Er9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Er9xInterface::getCapability(const Capability capability)
@@ -244,12 +207,6 @@ int Er9xInterface::getCapability(const Capability capability)
return 4;
case Mixes:
return ER9X_MAX_MIXERS;
case NumCurves5:
return ER9X_MAX_CURVE5;
case NumCurves9:
return ER9X_MAX_CURVE5;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:
@@ -286,10 +243,6 @@ int Er9xInterface::getCapability(const Capability capability)
return 12;
case CustomAndSwitches:
return 5;
case GvarsNum:
return 7;
case GvarsOfsNum:
return 5;
case CSFunc:
return 13;
case Outputs:
@@ -306,8 +259,6 @@ int Er9xInterface::getCapability(const Capability capability)
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryUnits:
return 1;
case TimerTriggerB:
return 1;
case TelemetryMaxMultiplier:
return 2;
case MaxVolume:
@@ -325,17 +276,13 @@ int Er9xInterface::getCapability(const Capability capability)
case HasStickScroll:
case HasAltitudeSel:
case HasContrast:
case InstantTrimSW:
case HasVolume:
case HasBlInvert:
case ModelVoice:
case DiffMixers:
case HasNegCurves:
case HasFixOffset:
case Gvars:
return 7;
case GvarsHaveSources:
case GvarsAsSources:
case GvarsAsWeight:
return 1;
case GetThrSwitch:
return DSW_THR;
File diff suppressed because it is too large Load Diff
@@ -51,8 +51,6 @@ PACK(typedef struct t_Ersky9xTrainerMix {
operator TrainerMix();
t_Ersky9xTrainerMix();
t_Ersky9xTrainerMix(TrainerMix&);
}) Ersky9xTrainerMix; //
PACK(typedef struct t_Ersky9xTrainerData {
@@ -61,8 +59,6 @@ PACK(typedef struct t_Ersky9xTrainerData {
operator TrainerData();
t_Ersky9xTrainerData();
t_Ersky9xTrainerData(TrainerData&);
}) Ersky9xTrainerData;
PACK(typedef struct t_Ersky9xGeneral {
@@ -122,8 +118,6 @@ PACK(typedef struct t_Ersky9xGeneral {
uint8_t rotaryDivisor ;
operator GeneralSettings();
t_Ersky9xGeneral();
t_Ersky9xGeneral(GeneralSettings&);
}) Ersky9xGeneral;
PACK(typedef struct t_Ersky9xExpoData {
@@ -143,7 +137,6 @@ PACK(typedef struct t_Ersky9xLimitData {
operator LimitData();
t_Ersky9xLimitData() ;
t_Ersky9xLimitData(LimitData&);
}) Ersky9xLimitData;
#define MLTPX_ADD 0
@@ -170,7 +163,6 @@ PACK(typedef struct t_Ersky9xMixData_v10 {
operator MixData();
t_Ersky9xMixData_v10();
t_Ersky9xMixData_v10(MixData&);
}) Ersky9xMixData_v10;
PACK(typedef struct t_Ersky9xMixData_v11 {
@@ -192,7 +184,6 @@ PACK(typedef struct t_Ersky9xMixData_v11 {
uint8_t res[4];
operator MixData();
t_Ersky9xMixData_v11();
t_Ersky9xMixData_v11(MixData&);
}) Ersky9xMixData_v11;
PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
@@ -202,8 +193,6 @@ PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
operator CustomSwData();
t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); }
t_Ersky9xCustomSwData_v10(CustomSwData&);
}) Ersky9xCustomSwData_v10;
PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
@@ -215,8 +204,6 @@ PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
operator CustomSwData();
t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); }
t_Ersky9xCustomSwData_v11(CustomSwData&);
}) Ersky9xCustomSwData_v11;
PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
@@ -225,7 +212,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
operator SafetySwData();
t_Ersky9xSafetySwData_v10();
t_Ersky9xSafetySwData_v10(SafetySwData&);
}) Ersky9xSafetySwData_v10;
PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
@@ -246,7 +232,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
operator SafetySwData();
t_Ersky9xSafetySwData_v11();
t_Ersky9xSafetySwData_v11(SafetySwData&);
}) Ersky9xSafetySwData_v11;
PACK(typedef struct t_Ersky9xgvar {
@@ -281,7 +266,6 @@ PACK(typedef struct t_Ersky9xFrSkyChannelData_v10 {
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v10();
t_Ersky9xFrSkyChannelData_v10(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v10;
PACK(typedef struct t_Ersky9xFrSkyData_v10 {
@@ -289,7 +273,6 @@ PACK(typedef struct t_Ersky9xFrSkyData_v10 {
operator FrSkyData();
t_Ersky9xFrSkyData_v10();
t_Ersky9xFrSkyData_v10(FrSkyData&);
}) Ersky9xFrSkyData_v10;
PACK(typedef struct t_Ersky9xFrSkyChannelData_v11 {
@@ -303,7 +286,6 @@ PACK(typedef struct t_Ersky9xFrSkyChannelData_v11 {
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v11();
t_Ersky9xFrSkyChannelData_v11(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v11;
PACK(typedef struct t_Ersky9xFrSkyData_v11 {
@@ -311,7 +293,6 @@ PACK(typedef struct t_Ersky9xFrSkyData_v11 {
operator FrSkyData();
t_Ersky9xFrSkyData_v11();
t_Ersky9xFrSkyData_v11(FrSkyData&);
}) Ersky9xFrSkyData_v11;
PACK(typedef struct t_Ersky9xFrSkyalarms_v11 {
@@ -390,7 +371,6 @@ PACK(typedef struct t_Ersky9xModelData_v10 {
Ersky9xTimerMode_v10 timer[2] ;
operator ModelData();
t_Ersky9xModelData_v10() { memset(this, 0, sizeof(t_Ersky9xModelData_v10)); }
t_Ersky9xModelData_v10(ModelData&);
}) Ersky9xModelData_v10;
PACK(typedef struct t_Ersky9xModelData_v11 {
@@ -449,8 +429,6 @@ PACK(typedef struct t_Ersky9xModelData_v11 {
operator ModelData();
t_Ersky9xModelData_v11() { memset(this, 0, sizeof(t_Ersky9xModelData_v11)); }
t_Ersky9xModelData_v11(ModelData&);
}) Ersky9xModelData_v11;
#endif
/*eof*/
@@ -228,33 +228,10 @@ bool Ersky9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esi
int Ersky9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
efile->EeFsCreate(eeprom, EESIZE_SKY9X, BOARD_SKY9X);
Ersky9xGeneral ersky9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&ersky9xGeneral, sizeof(Ersky9xGeneral));
if(sz != sizeof(Ersky9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Ersky9xModelData_v11 ersky9xModel(radioData.models[i]);
applyStickModeToModel(ersky9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&ersky9xModel, sizeof(Ersky9xModelData_v11));
if(sz != sizeof(Ersky9xModelData_v11)) {
return 0;
}
}
}
if (!EEPROMWarnings.isEmpty())
QMessageBox::warning(NULL,
QObject::tr("Warning"),
QObject::tr("EEPROM saved with these warnings:") + "\n- " + EEPROMWarnings.remove(EEPROMWarnings.length()-1, 1).replace("\n", "\n- "));
return EESIZE_SKY9X;
return 0;
}
int Ersky9xInterface::getSize(ModelData &model)
@@ -272,12 +249,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
switch (capability) {
case Mixes:
return ERSKY9X_MAX_MIXERS_V11;
case NumCurves5:
return ERSKY9X_MAX_CURVE5;
case NumCurves9:
return ERSKY9X_MAX_CURVE9;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:
@@ -306,10 +277,8 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 2;
case Pots:
return 3;
case GvarsNum:
case Gvars:
return 7;
case GvarsOfsNum:
return 5;
case Switches:
return 7;
case SwitchesPositions:
@@ -338,8 +307,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 1;
case OptrexDisplay:
return 1;
case TimerTriggerB:
return 2;
case HasAltitudeSel:
case HasCurrentCalibration:
case HasVolume:
@@ -350,12 +317,8 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 125;
case MaxVolume:
return 23;
case Gvars:
case GvarsHaveSources:
case GvarsAsSources:
case GvarsAsWeight:
return 1;
case InstantTrimSW:
return 1;
case TelemetryMaxMultiplier:
return 2;
@@ -6,7 +6,6 @@
#define EEPROM_VER 106
extern void setEEPROMZString(char *dst, const char *src, int size);
extern void getEEPROMZString(char *dst, const char *src, int size);
RawSwitch gruvin9xToSwitch(int8_t sw)
@@ -19,18 +18,6 @@ RawSwitch gruvin9xToSwitch(int8_t sw)
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-9 : sw+9);
}
int8_t gruvin9xFromSwitch(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;
}
}
t_Gruvin9xTrainerMix_v103::operator TrainerMix()
{
TrainerMix c9x;
@@ -50,14 +37,6 @@ t_Gruvin9xTrainerMix_v104::operator TrainerMix()
return c9x;
}
t_Gruvin9xTrainerMix_v104::t_Gruvin9xTrainerMix_v104(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v104));
srcChn = c9x.src;
studWeight = c9x.weight;
mode = c9x.mode;
}
t_Gruvin9xTrainerData_v103::operator TrainerData ()
{
TrainerData c9x;
@@ -78,16 +57,6 @@ t_Gruvin9xTrainerData_v104::operator TrainerData ()
return c9x;
}
t_Gruvin9xTrainerData_v104::t_Gruvin9xTrainerData_v104(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xTrainerData_v104));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
Gruvin9xGeneral_v103::operator GeneralSettings ()
{
GeneralSettings result;
@@ -134,7 +103,6 @@ Gruvin9xGeneral_v103::operator GeneralSettings ()
result.disableAlarmWarning = disableAlarmWarning;
result.stickMode = stickMode;
result.inactivityTimer = inactivityTimer;
result.throttleReversed = throttleReversed;
result.minuteBeep = minuteBeep;
result.preBeep = preBeep;
result.flashBeep = flashBeep;
@@ -147,60 +115,6 @@ Gruvin9xGeneral_v103::operator GeneralSettings ()
return result;
}
t_Gruvin9xGeneral_v104::t_Gruvin9xGeneral_v104(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xGeneral_v104));
myVers = EEPROM_VER;
for (int i=0; i<NUM_STICKS+BOARD_9X_NUM_POTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = std::min(4, c9x.beeperLength + 4);
switchWarning = c9x.switchWarning;
disableMemoryWarning = c9x.disableMemoryWarning;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer;
throttleReversed = c9x.throttleReversed;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
enableTelemetryAlarm = c9x.enableTelemetryAlarm;
spare = 0;
filterInput = c9x.filterInput;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
// TODO frskyRssiAlarms[2];
}
Gruvin9xGeneral_v104::operator GeneralSettings ()
{
GeneralSettings result;
@@ -234,7 +148,6 @@ Gruvin9xGeneral_v104::operator GeneralSettings ()
result.disableAlarmWarning = disableAlarmWarning;
result.stickMode = stickMode;
result.inactivityTimer = inactivityTimer;
result.throttleReversed = throttleReversed;
result.minuteBeep = minuteBeep;
result.preBeep = preBeep;
result.flashBeep = flashBeep;
@@ -252,69 +165,11 @@ t_Gruvin9xExpoData::t_Gruvin9xExpoData()
memset(this, 0, sizeof(t_Gruvin9xExpoData));
}
t_Gruvin9xExpoData::t_Gruvin9xExpoData(ExpoData &c9x)
{
mode = c9x.mode;
chn = c9x.chn;
if (c9x.curveMode==1) {
curve = c9x.curveParam;
} else {
curve=0;
}
swtch = gruvin9xFromSwitch(c9x.swtch);
int zeros=0;
int ones=0;
int phtemp=c9x.phases;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if (phtemp & 1) {
ones++;
} else {
zeros++;
}
phtemp >>=1;
}
if (zeros==G9X_MAX_PHASES || zeros==0) {
phase=0;
negPhase=0;
} else if (zeros==1) {
int phtemp=c9x.phases;
int ph=0;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if ((phtemp & 1)==0) {
ph=i;
break;
}
phtemp >>=1;
}
phase=ph+1;
negPhase=0;
} else if (ones==1) {
int phtemp=c9x.phases;
int ph=0;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if (phtemp & 1) {
ph=i;
break;
}
phtemp >>=1;
}
phase=(ph+1);
negPhase=1;
} else {
phase=0;
EEPROMWarnings += ::QObject::tr("Flight modes settings on expos not exported") + "\n";
}
weight = c9x.weight;
expo = c9x.expo;
}
t_Gruvin9xExpoData::operator ExpoData ()
{
ExpoData c9x;
c9x.mode = mode;
c9x.chn = chn;
c9x.curveParam = curve;
c9x.curveMode=1;
c9x.swtch = gruvin9xToSwitch(swtch);
if (negPhase) {
c9x.phases= 1 << (phase -1);
@@ -325,7 +180,18 @@ t_Gruvin9xExpoData::operator ExpoData ()
c9x.phases &= ~(1 << (phase -1));
}
c9x.weight = weight;
c9x.expo = expo;
if (expo) {
c9x.curve.type = CurveReference::CURVE_REF_EXPO;
c9x.curve.value = expo;
}
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
return c9x;
}
@@ -334,14 +200,6 @@ t_Gruvin9xLimitData::t_Gruvin9xLimitData()
memset(this, 0, sizeof(t_Gruvin9xLimitData));
}
t_Gruvin9xLimitData::t_Gruvin9xLimitData(LimitData &c9x)
{
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Gruvin9xLimitData::operator LimitData ()
{
LimitData c9x;
@@ -352,67 +210,11 @@ t_Gruvin9xLimitData::operator LimitData ()
return c9x;
}
t_Gruvin9xMixData::t_Gruvin9xMixData()
{
memset(this, 0, sizeof(t_Gruvin9xMixData));
}
t_Gruvin9xMixData::t_Gruvin9xMixData(MixData &c9x)
{
destCh = c9x.destCh;
mixWarn = c9x.mixWarn;
swtch = gruvin9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("Open9x on this board doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = c9x.srcRaw.index+1;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("gruvin9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
weight = c9x.weight;
curve = c9x.curve;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("gruvin9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
// phase = c9x.phase;
sOffset = c9x.sOffset;
}
t_Gruvin9xMixData::operator MixData ()
{
MixData c9x;
@@ -450,7 +252,6 @@ t_Gruvin9xMixData::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
}
c9x.curve = curve;
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
@@ -458,34 +259,18 @@ t_Gruvin9xMixData::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
// c9x.phase = phase;
c9x.sOffset = sOffset;
return c9x;
}
int8_t gruvin9xFromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("gruvin9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
/* else if (source.type == SOURCE_TYPE_3POS)
v1 = 0; */
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
return c9x;
}
RawSource gruvin9xToSource(int8_t value)
@@ -516,33 +301,6 @@ RawSource gruvin9xToSource(int8_t value)
}
}
t_Gruvin9xCustomSwData::t_Gruvin9xCustomSwData(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = gruvin9xFromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = gruvin9xFromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = gruvin9xFromSwitch(RawSwitch(c9x.val1));
v2 = gruvin9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>GR9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("gruvin9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Gruvin9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@@ -566,12 +324,6 @@ Gruvin9xCustomSwData::operator CustomSwData ()
return c9x;
}
t_Gruvin9xFuncSwData::t_Gruvin9xFuncSwData(FuncSwData &c9x)
{
swtch = gruvin9xFromSwitch(c9x.swtch);
func = c9x.func - G9X_NUM_CHNOUT;
}
Gruvin9xFuncSwData::operator FuncSwData ()
{
FuncSwData c9x;
@@ -580,12 +332,6 @@ Gruvin9xFuncSwData::operator FuncSwData ()
return c9x;
}
t_Gruvin9xSafetySwData::t_Gruvin9xSafetySwData(SafetySwData &c9x)
{
swtch = gruvin9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Gruvin9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
@@ -599,16 +345,6 @@ t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData()
memset(this, 0, sizeof(t_Gruvin9xSwashRingData));
}
t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData(SwashRingData &c9x)
{
invertELE = c9x.invertELE;
invertAIL = c9x.invertAIL;
invertCOL = c9x.invertCOL;
type = c9x.type;
collectiveSource = gruvin9xFromSource(c9x.collectiveSource);
value = c9x.value;
}
t_Gruvin9xSwashRingData::operator SwashRingData ()
{
SwashRingData c9x;
@@ -645,21 +381,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
return c9x;
}
t_Gruvin9xPhaseData_v106::t_Gruvin9xPhaseData_v106(PhaseData &c9x)
{
trim_ext = 0;
for (int i=0; i<NUM_STICKS; i++) {
trim[i] = (int8_t)(c9x.trim[i] >> 2);
trim_ext = (trim_ext & ~(0x03 << (2*i))) + (((c9x.trim[i] & 0x03) << (2*i)));
}
swtch = gruvin9xFromSwitch(c9x.swtch);
setEEPROMZString(name, c9x.name, sizeof(name));
fadeIn = c9x.fadeIn;
fadeOut = c9x.fadeOut;
}
extern TimerMode getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
t_Gruvin9xTimerData::operator TimerData ()
{
@@ -670,29 +392,11 @@ t_Gruvin9xTimerData::operator TimerData ()
return c9x;
}
t_Gruvin9xTimerData::t_Gruvin9xTimerData(TimerData &c9x)
{
mode = setEr9xTimerMode(c9x.mode);
val = c9x.val;
dir = c9x.dir;
}
t_Gruvin9xFrSkyChannelData::t_Gruvin9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyChannelData));
}
t_Gruvin9xFrSkyChannelData::t_Gruvin9xFrSkyChannelData(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyChannelData));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
type = c9x.type;
}
t_Gruvin9xFrSkyChannelData::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@@ -707,19 +411,11 @@ t_Gruvin9xFrSkyChannelData::operator FrSkyChannelData ()
return c9x;
}
t_Gruvin9xFrSkyData::t_Gruvin9xFrSkyData()
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyData));
}
t_Gruvin9xFrSkyData::t_Gruvin9xFrSkyData(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyData));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Gruvin9xFrSkyData::operator FrSkyData ()
{
FrSkyData c9x;
@@ -728,7 +424,6 @@ t_Gruvin9xFrSkyData::operator FrSkyData ()
return c9x;
}
t_Gruvin9xModelData_v102::operator ModelData ()
{
ModelData c9x;
@@ -778,7 +473,6 @@ t_Gruvin9xModelData_v102::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@@ -786,7 +480,6 @@ t_Gruvin9xModelData_v102::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@@ -851,7 +544,6 @@ t_Gruvin9xModelData_v103::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@@ -859,7 +551,6 @@ t_Gruvin9xModelData_v103::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@@ -941,7 +632,6 @@ t_Gruvin9xModelData_v105::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@@ -949,7 +639,6 @@ t_Gruvin9xModelData_v105::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@@ -1027,7 +716,6 @@ t_Gruvin9xModelData_v106::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@@ -1035,7 +723,6 @@ t_Gruvin9xModelData_v106::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@@ -1055,99 +742,3 @@ t_Gruvin9xModelData_v106::operator ModelData ()
return c9x;
}
t_Gruvin9xModelData_v106::t_Gruvin9xModelData_v106(ModelData &c9x)
{
if (c9x.used) {
setEEPROMZString(name, c9x.name, sizeof(name));
timer1 = c9x.timers[0];
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case SILV_A:
protocol = 3;
break;
case SILV_B:
protocol = 4;
break;
case SILV_C:
protocol = 5;
break;
case CTP1009:
protocol = 6;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Er9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
extendedTrims = c9x.extendedTrims;
spare2 = 0;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
beepANACenter = c9x.beepANACenter;
timer2 = c9x.timers[1];
for (int i=0; i<G9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
for (int i=0; i<G9X_MAX_EXPOS; i++)
expoData[i] = c9x.expoData[i];
if (c9x.expoData[G9X_MAX_EXPOS].mode)
EEPROMWarnings += QObject::tr("gruvin9x only accepts %1 expos").arg(G9X_MAX_EXPOS) + "\n";
for (int i=0; i<G9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("gruvin9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("gruvin9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<G9X_MAX_CURVE9; i++)
if (c9x.curves[i+G9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+G9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("gruvin9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+G9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+G9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("gruvin9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+G9X_MAX_CURVE5].count).arg(i+1+G9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<G9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++)
funcSw[i] = c9x.funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
safetySw[i] = c9x.safetySw[i];
swashR = c9x.swashRingData;
for (int i=0; i<G9X_MAX_PHASES; i++) {
PhaseData phase = c9x.phaseData[i];
for (int j=0; j<NUM_STICKS; j++) {
if (phase.trimRef[j] >= 0) {
phase.trim[j] = 501 + phase.trimRef[j] - (phase.trimRef[j] >= i ? 1 : 0);
}
else {
phase.trim[j] = std::max(-500, std::min(500, phase.trim[j]));
}
}
phaseData[i] = phase;
}
frsky = c9x.frsky;
}
else {
memset(this, 0, sizeof(t_Gruvin9xModelData_v106));
}
}
@@ -38,8 +38,6 @@ PACK(typedef struct t_Gruvin9xTrainerMix_v104 {
operator TrainerMix();
t_Gruvin9xTrainerMix_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v104)); }
t_Gruvin9xTrainerMix_v104(TrainerMix&);
}) Gruvin9xTrainerMix_v104; //
PACK(typedef struct t_Gruvin9xTrainerData_v103 {
@@ -55,8 +53,6 @@ PACK(typedef struct t_Gruvin9xTrainerData_v104 {
operator TrainerData();
t_Gruvin9xTrainerData_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerData_v104)); }
t_Gruvin9xTrainerData_v104(TrainerData&);
}) Gruvin9xTrainerData_v104;
PACK(typedef struct t_Gruvin9xFrSkyRSSIAlarm {
@@ -136,8 +132,6 @@ PACK(typedef struct t_Gruvin9xGeneral_v104 {
operator GeneralSettings();
t_Gruvin9xGeneral_v104() { memset(this, 0, sizeof(t_Gruvin9xGeneral_v104)); }
t_Gruvin9xGeneral_v104(GeneralSettings&);
}) Gruvin9xGeneral_v104;
typedef Gruvin9xGeneral_v104 Gruvin9xGeneral;
@@ -156,8 +150,6 @@ PACK(typedef struct t_Gruvin9xExpoData {
operator ExpoData();
t_Gruvin9xExpoData();
t_Gruvin9xExpoData(ExpoData&);
}) Gruvin9xExpoData;
PACK(typedef struct t_Gruvin9xLimitData {
@@ -168,8 +160,6 @@ PACK(typedef struct t_Gruvin9xLimitData {
operator LimitData();
t_Gruvin9xLimitData();
t_Gruvin9xLimitData(LimitData&);
}) Gruvin9xLimitData;
#define MLTPX_ADD 0
@@ -194,8 +184,6 @@ PACK(typedef struct t_Gruvin9xMixData {
operator MixData();
t_Gruvin9xMixData();
t_Gruvin9xMixData(MixData&);
}) Gruvin9xMixData;
PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
@@ -205,8 +193,6 @@ PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
operator CustomSwData();
t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); }
t_Gruvin9xCustomSwData(CustomSwData&);
}) Gruvin9xCustomSwData;
PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
@@ -215,8 +201,6 @@ PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
t_Gruvin9xSafetySwData(SafetySwData&);
}) Gruvin9xSafetySwData;
PACK(typedef struct t_Gruvin9xFuncSwData { // Function Switches data
@@ -225,8 +209,6 @@ PACK(typedef struct t_Gruvin9xFuncSwData { // Function Switches data
operator FuncSwData();
t_Gruvin9xFuncSwData() { memset(this, 0, sizeof(t_Gruvin9xFuncSwData)); }
t_Gruvin9xFuncSwData(FuncSwData&);
}) Gruvin9xFuncSwData;
PACK(typedef struct t_Gruvin9xFrSkyChannelData {
@@ -242,17 +224,13 @@ PACK(typedef struct t_Gruvin9xFrSkyChannelData {
operator FrSkyChannelData();
t_Gruvin9xFrSkyChannelData();
t_Gruvin9xFrSkyChannelData(FrSkyChannelData&);
}) Gruvin9xFrSkyChannelData;
PACK(typedef struct t_Gruvin9xFrSkyData {
Gruvin9xFrSkyChannelData channels[2];
operator FrSkyData();
t_Gruvin9xFrSkyData();
t_Gruvin9xFrSkyData(FrSkyData&);
Gruvin9xFrSkyChannelData channels[2];
operator FrSkyData();
t_Gruvin9xFrSkyData();
}) Gruvin9xFrSkyData;
PACK(typedef struct t_Gruvin9xSwashRingData { // Swash Ring data
@@ -265,8 +243,6 @@ PACK(typedef struct t_Gruvin9xSwashRingData { // Swash Ring data
operator SwashRingData();
t_Gruvin9xSwashRingData();
t_Gruvin9xSwashRingData(SwashRingData&);
}) Gruvin9xSwashRingData;
PACK(typedef struct t_Gruvin9xPhaseData_v102 {
@@ -291,7 +267,6 @@ PACK(typedef struct t_Gruvin9xPhaseData_v106 {
operator PhaseData();
t_Gruvin9xPhaseData_v106() { memset(this, 0, sizeof(t_Gruvin9xPhaseData_v106)); }
t_Gruvin9xPhaseData_v106(PhaseData &eepe);
}) Gruvin9xPhaseData_v106;
PACK(typedef struct t_Gruvin9xTimerData {
@@ -301,7 +276,6 @@ PACK(typedef struct t_Gruvin9xTimerData {
operator TimerData();
t_Gruvin9xTimerData() { memset(this, 0, sizeof(t_Gruvin9xTimerData)); }
t_Gruvin9xTimerData(TimerData &eepe);
}) Gruvin9xTimerData;
#define G9X_MAX_PHASES 5
@@ -410,8 +384,6 @@ PACK(typedef struct t_Gruvin9xModelData_v105 {
operator ModelData();
t_Gruvin9xModelData_v105() { memset(this, 0, sizeof(t_Gruvin9xModelData_v105)); }
t_Gruvin9xModelData_v105(ModelData&);
}) Gruvin9xModelData_v105;
PACK(typedef struct t_Gruvin9xModelData_v106 {
@@ -443,11 +415,8 @@ PACK(typedef struct t_Gruvin9xModelData_v106 {
operator ModelData();
t_Gruvin9xModelData_v106() { memset(this, 0, sizeof(t_Gruvin9xModelData_v106)); }
t_Gruvin9xModelData_v106(ModelData&);
}) Gruvin9xModelData_v106;
typedef Gruvin9xModelData_v106 Gruvin9xModelData;
#endif
/*eof*/
@@ -200,62 +200,20 @@ bool Gruvin9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int es
int Gruvin9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
int size = getEEpromSize();
efile->EeFsCreate(eeprom, size, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(Gruvin9xGeneral));
if(sz != sizeof(Gruvin9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
ModelData model = radioData.models[i];
if (1/*version < */) {
applyStickModeToModel(model, radioData.generalSettings.stickMode+1);
}
Gruvin9xModelData gruvin9xModel(model);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return 0;
}
}
}
return size;
return 0;
}
int Gruvin9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xModelData gruvin9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return -1;
}
return efile->size(0);
return 0;
}
int Gruvin9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(gruvin9xGeneral));
if(sz != sizeof(gruvin9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Gruvin9xInterface::getCapability(const Capability capability)
@@ -263,10 +221,6 @@ int Gruvin9xInterface::getCapability(const Capability capability)
switch (capability) {
case OwnerName:
return 0;
case NumCurves5:
return G9X_MAX_CURVE5;
case NumCurves9:
return G9X_MAX_CURVE9;
case Mixes:
return G9X_MAX_MIXERS;
case FlightPhases:
@@ -297,7 +251,6 @@ int Gruvin9xInterface::getCapability(const Capability capability)
return true;
case OffsetWeight:
return 125;
case HasExpoCurves:
case HasContrast:
return true;
case Telemetry:
File diff suppressed because it is too large Load Diff
@@ -32,7 +32,6 @@ PACK(typedef struct t_Open9xGruvin9xPhaseData_v207 {
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v207)); }
t_Open9xGruvin9xPhaseData_v207(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v207;
PACK(typedef struct t_Open9xGruvin9xPhaseData_v208 {
@@ -44,7 +43,6 @@ PACK(typedef struct t_Open9xGruvin9xPhaseData_v208 {
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v208)); }
t_Open9xGruvin9xPhaseData_v208(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v208;
PACK(typedef struct t_Open9xGruvin9xMixData_v207 {
@@ -66,8 +64,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v207 {
operator MixData();
t_Open9xGruvin9xMixData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v207)); }
t_Open9xGruvin9xMixData_v207(MixData&);
}) Open9xGruvin9xMixData_v207;
PACK(typedef struct t_Open9xGruvin9xMixData_v209 {
@@ -89,8 +85,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v209 {
operator MixData();
t_Open9xGruvin9xMixData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v209)); }
t_Open9xGruvin9xMixData_v209(MixData&);
}) Open9xGruvin9xMixData_v209;
PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
@@ -114,8 +108,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
operator MixData();
t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); }
t_Open9xGruvin9xMixData_v211(MixData&);
}) Open9xGruvin9xMixData_v211;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
@@ -125,10 +117,8 @@ PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); }
t_Open9xGruvin9xCustomSwData_v207(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v207;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
@@ -138,10 +128,8 @@ PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); }
t_Open9xGruvin9xCustomSwData_v209(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v209;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
@@ -151,8 +139,6 @@ PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v203)); }
t_Open9xGruvin9xFuncSwData_v203(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v203;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v210 { // Function Switches data
@@ -163,8 +149,6 @@ PACK(typedef struct t_Open9xGruvin9xFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v210)); }
t_Open9xGruvin9xFuncSwData_v210(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v210;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v208 { // Swash Ring data
@@ -177,8 +161,6 @@ PACK(typedef struct t_Open9xGruvin9xSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v208)); }
t_Open9xGruvin9xSwashRingData_v208(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v208;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v209 { // Swash Ring data
@@ -191,8 +173,6 @@ PACK(typedef struct t_Open9xGruvin9xSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v209)); }
t_Open9xGruvin9xSwashRingData_v209(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
@@ -227,8 +207,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
operator ModelData();
t_Open9xGruvin9xModelData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v207)); }
t_Open9xGruvin9xModelData_v207(ModelData&);
}) Open9xGruvin9xModelData_v207;
PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
@@ -268,8 +246,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
operator ModelData();
t_Open9xGruvin9xModelData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v208)); }
t_Open9xGruvin9xModelData_v208(ModelData&);
}) Open9xGruvin9xModelData_v208;
PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
@@ -310,8 +286,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
operator ModelData();
t_Open9xGruvin9xModelData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v209)); }
t_Open9xGruvin9xModelData_v209(ModelData&);
}) Open9xGruvin9xModelData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
@@ -350,8 +324,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
operator ModelData();
t_Open9xGruvin9xModelData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v210)); }
t_Open9xGruvin9xModelData_v210(ModelData&);
}) Open9xGruvin9xModelData_v210;
PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
@@ -388,8 +360,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
operator ModelData();
t_Open9xGruvin9xModelData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v211)); }
t_Open9xGruvin9xModelData_v211(ModelData&);
}) Open9xGruvin9xModelData_v211;
#endif
File diff suppressed because it is too large Load Diff
@@ -36,7 +36,6 @@ PACK(typedef struct t_Open9xArmTimerData_v202 {
operator TimerData();
t_Open9xArmTimerData_v202() { memset(this, 0, sizeof(t_Open9xArmTimerData_v202)); }
t_Open9xArmTimerData_v202(TimerData &eepe);
}) Open9xArmTimerData_v202;
PACK(typedef struct t_Open9xArmExpoData_v208 {
@@ -50,8 +49,6 @@ PACK(typedef struct t_Open9xArmExpoData_v208 {
operator ExpoData();
t_Open9xArmExpoData_v208() { memset(this, 0, sizeof(t_Open9xArmExpoData_v208)); }
t_Open9xArmExpoData_v208(ExpoData&);
}) Open9xArmExpoData_v208;
PACK(typedef struct t_Open9xArmExpoData_v210 {
@@ -67,8 +64,6 @@ PACK(typedef struct t_Open9xArmExpoData_v210 {
operator ExpoData();
t_Open9xArmExpoData_v210() { memset(this, 0, sizeof(t_Open9xArmExpoData_v210)); }
t_Open9xArmExpoData_v210(ExpoData&);
}) Open9xArmExpoData_v210;
PACK(typedef struct t_Open9xArmExpoData_v212 {
@@ -83,8 +78,6 @@ PACK(typedef struct t_Open9xArmExpoData_v212 {
operator ExpoData();
t_Open9xArmExpoData_v212() { memset(this, 0, sizeof(t_Open9xArmExpoData_v212)); }
t_Open9xArmExpoData_v212(ExpoData&);
}) Open9xArmExpoData_v212;
PACK(typedef struct t_Open9xArmMixData_v208 {
@@ -106,8 +99,6 @@ PACK(typedef struct t_Open9xArmMixData_v208 {
operator MixData();
t_Open9xArmMixData_v208() { memset(this, 0, sizeof(t_Open9xArmMixData_v208)); }
t_Open9xArmMixData_v208(MixData&);
}) Open9xArmMixData_v208;
PACK(typedef struct t_Open9xArmMixData_v209 {
@@ -129,8 +120,6 @@ PACK(typedef struct t_Open9xArmMixData_v209 {
operator MixData();
t_Open9xArmMixData_v209() { memset(this, 0, sizeof(t_Open9xArmMixData_v209)); }
t_Open9xArmMixData_v209(MixData&);
}) Open9xArmMixData_v209;
PACK(typedef struct t_Open9xArmMixData_v210 {
@@ -154,8 +143,6 @@ PACK(typedef struct t_Open9xArmMixData_v210 {
operator MixData();
t_Open9xArmMixData_v210() { memset(this, 0, sizeof(t_Open9xArmMixData_v210)); }
t_Open9xArmMixData_v210(MixData&);
}) Open9xArmMixData_v210;
PACK(typedef struct t_Open9xArmMixData_v212 {
@@ -180,8 +167,6 @@ PACK(typedef struct t_Open9xArmMixData_v212 {
operator MixData();
t_Open9xArmMixData_v212() { memset(this, 0, sizeof(t_Open9xArmMixData_v212)); }
t_Open9xArmMixData_v212(MixData&);
}) Open9xArmMixData_v212;
PACK(typedef struct t_Open9xArmPhaseData_v208 {
@@ -192,7 +177,6 @@ PACK(typedef struct t_Open9xArmPhaseData_v208 {
uint8_t fadeOut:4;
operator PhaseData();
t_Open9xArmPhaseData_v208() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v208)); }
t_Open9xArmPhaseData_v208(PhaseData &eepe);
}) Open9xArmPhaseData_v208;
PACK(typedef struct t_Open9xArmPhaseData_v212 {
@@ -204,7 +188,6 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 {
int16_t rotaryEncoders[1];
operator PhaseData();
t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); }
t_Open9xArmPhaseData_v212(PhaseData &eepe);
}) Open9xArmPhaseData_v212;
PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
@@ -214,7 +197,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); }
t_Open9xArmCustomSwData_v208(CustomSwData&);
}) Open9xArmCustomSwData_v208;
PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
@@ -224,7 +206,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); }
t_Open9xArmCustomSwData_v209(CustomSwData&);
}) Open9xArmCustomSwData_v209;
PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
@@ -236,7 +217,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); }
t_Open9xArmCustomSwData_v210(CustomSwData&);
}) Open9xArmCustomSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
@@ -246,8 +226,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v208() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v208)); }
t_Open9xArmFuncSwData_v208(FuncSwData&);
}) Open9xArmFuncSwData_v208;
PACK(typedef struct t_Open9xArmFuncSwData_v210 { // Function Switches data
@@ -257,8 +235,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v210)); }
t_Open9xArmFuncSwData_v210(FuncSwData&);
}) Open9xArmFuncSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v211 { // Function Switches data
@@ -270,8 +246,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v211 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v211() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v211)); }
t_Open9xArmFuncSwData_v211(FuncSwData&);
}) Open9xArmFuncSwData_v211;
PACK(typedef struct t_Open9xArmSwashRingData_v208 { // Swash Ring data
@@ -284,8 +258,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v208)); }
t_Open9xArmSwashRingData_v208(SwashRingData&);
}) Open9xArmSwashRingData_v208;
PACK(typedef struct t_Open9xArmSwashRingData_v209 { // Swash Ring data
@@ -298,8 +270,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v209)); }
t_Open9xArmSwashRingData_v209(SwashRingData&);
}) Open9xArmSwashRingData_v209;
PACK(typedef struct t_Open9xArmSwashRingData_v210 { // Swash Ring data
@@ -312,8 +282,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v210 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v210() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v210)); }
t_Open9xArmSwashRingData_v210(SwashRingData&);
}) Open9xArmSwashRingData_v210;
@@ -336,7 +304,6 @@ PACK(typedef struct t_Open9xArmFrSkyData_v210 {
operator FrSkyData();
t_Open9xArmFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v210)); }
t_Open9xArmFrSkyData_v210(FrSkyData&);
}) Open9xArmFrSkyData_v210;
PACK(typedef struct t_Open9xArmFrSkyData_v211 {
@@ -355,7 +322,6 @@ PACK(typedef struct t_Open9xArmFrSkyData_v211 {
operator FrSkyData();
t_Open9xArmFrSkyData_v211() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v211)); }
t_Open9xArmFrSkyData_v211(FrSkyData&);
}) Open9xArmFrSkyData_v211;
PACK(typedef struct t_Open9xArmModelData_v208 {
@@ -395,8 +361,6 @@ PACK(typedef struct t_Open9xArmModelData_v208 {
operator ModelData();
t_Open9xArmModelData_v208() { memset(this, 0, sizeof(t_Open9xArmModelData_v208)); }
t_Open9xArmModelData_v208(ModelData&);
}) Open9xArmModelData_v208;
PACK(typedef struct t_Open9xArmModelData_v209 {
@@ -437,8 +401,6 @@ PACK(typedef struct t_Open9xArmModelData_v209 {
operator ModelData();
t_Open9xArmModelData_v209() { memset(this, 0, sizeof(t_Open9xArmModelData_v209)); }
t_Open9xArmModelData_v209(ModelData&);
}) Open9xArmModelData_v209;
PACK(typedef struct t_Open9xArmModelData_v210 {
@@ -477,7 +439,6 @@ PACK(typedef struct t_Open9xArmModelData_v210 {
operator ModelData();
t_Open9xArmModelData_v210() { memset(this, 0, sizeof(t_Open9xArmModelData_v210)); }
t_Open9xArmModelData_v210(ModelData&);
}) Open9xArmModelData_v210;
@@ -517,8 +478,6 @@ PACK(typedef struct t_Open9xArmModelData_v211 {
operator ModelData();
t_Open9xArmModelData_v211() { memset(this, 0, sizeof(t_Open9xArmModelData_v211)); }
t_Open9xArmModelData_v211(ModelData&);
}) Open9xArmModelData_v211;
PACK(typedef struct t_Open9xArmModelData_v212 {
@@ -555,8 +514,6 @@ PACK(typedef struct t_Open9xArmModelData_v212 {
operator ModelData();
t_Open9xArmModelData_v212() { memset(this, 0, sizeof(t_Open9xArmModelData_v212)); }
t_Open9xArmModelData_v212(ModelData&);
}) Open9xArmModelData_v212;
#endif
File diff suppressed because it is too large Load Diff
@@ -65,7 +65,6 @@ PACK(typedef struct t_Open9xFrSkyRSSIAlarm {
int8_t value:6;
FrSkyRSSIAlarm get(int index);
t_Open9xFrSkyRSSIAlarm() { memset(this, 0, sizeof(t_Open9xFrSkyRSSIAlarm)); }
t_Open9xFrSkyRSSIAlarm(int index, FrSkyRSSIAlarm&);
}) Open9xFrSkyRSSIAlarm;
PACK(typedef struct t_Open9xExpoData_v201 {
@@ -80,8 +79,6 @@ PACK(typedef struct t_Open9xExpoData_v201 {
operator ExpoData();
t_Open9xExpoData_v201() { memset(this, 0, sizeof(t_Open9xExpoData_v201)); }
t_Open9xExpoData_v201(ExpoData&);
}) Open9xExpoData_v201;
PACK(typedef struct t_Open9xExpoData_v211 {
@@ -95,8 +92,6 @@ PACK(typedef struct t_Open9xExpoData_v211 {
operator ExpoData();
t_Open9xExpoData_v211() { memset(this, 0, sizeof(t_Open9xExpoData_v211)); }
t_Open9xExpoData_v211(ExpoData&);
}) Open9xExpoData_v211;
PACK(typedef struct t_Open9xLimitData_v201 {
@@ -107,8 +102,6 @@ PACK(typedef struct t_Open9xLimitData_v201 {
operator LimitData();
t_Open9xLimitData_v201() { memset(this, 0, sizeof(t_Open9xLimitData_v201)); }
t_Open9xLimitData_v201(LimitData&);
}) Open9xLimitData_v201;
PACK(typedef struct t_Open9xLimitData_v211 {
@@ -121,8 +114,6 @@ PACK(typedef struct t_Open9xLimitData_v211 {
operator LimitData();
t_Open9xLimitData_v211() { memset(this, 0, sizeof(t_Open9xLimitData_v211)); }
t_Open9xLimitData_v211(LimitData&);
}) Open9xLimitData_v211;
PACK(typedef struct t_Open9xMixData_v201 {
@@ -143,8 +134,6 @@ PACK(typedef struct t_Open9xMixData_v201 {
operator MixData();
t_Open9xMixData_v201() { memset(this, 0, sizeof(t_Open9xMixData_v201)); }
t_Open9xMixData_v201(MixData&);
}) Open9xMixData_v201;
PACK(typedef struct t_Open9xMixData_v203 {
@@ -165,8 +154,6 @@ PACK(typedef struct t_Open9xMixData_v203 {
operator MixData();
t_Open9xMixData_v203() { memset(this, 0, sizeof(t_Open9xMixData_v203)); }
t_Open9xMixData_v203(MixData&);
}) Open9xMixData_v203;
PACK(typedef struct t_Open9xMixData_v205 {
@@ -188,8 +175,6 @@ PACK(typedef struct t_Open9xMixData_v205 {
operator MixData();
t_Open9xMixData_v205() { memset(this, 0, sizeof(t_Open9xMixData_v205)); }
t_Open9xMixData_v205(MixData&);
}) Open9xMixData_v205;
PACK(typedef struct t_Open9xMixData_v209 {
@@ -211,8 +196,6 @@ PACK(typedef struct t_Open9xMixData_v209 {
operator MixData();
t_Open9xMixData_v209() { memset(this, 0, sizeof(t_Open9xMixData_v209)); }
t_Open9xMixData_v209(MixData&);
}) Open9xMixData_v209;
PACK(typedef struct t_Open9xMixData_v211 {
@@ -236,8 +219,6 @@ PACK(typedef struct t_Open9xMixData_v211 {
operator MixData();
t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); }
t_Open9xMixData_v211(MixData&);
}) Open9xMixData_v211;
PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data
@@ -257,7 +238,6 @@ PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); }
t_Open9xCustomSwData_v209(CustomSwData&);
}) Open9xCustomSwData_v209;
PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
@@ -266,8 +246,6 @@ PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
t_Open9xSafetySwData(SafetySwData&);
}) Open9xSafetySwData;
PACK(typedef struct t_Open9xFuncSwData_v201 { // Function Switches data
@@ -276,8 +254,6 @@ PACK(typedef struct t_Open9xFuncSwData_v201 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v201() { memset(this, 0, sizeof(t_Open9xFuncSwData_v201)); }
t_Open9xFuncSwData_v201(FuncSwData&);
}) Open9xFuncSwData_v201;
PACK(typedef struct t_Open9xFuncSwData_v203 { // Function Switches data
@@ -287,8 +263,6 @@ PACK(typedef struct t_Open9xFuncSwData_v203 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xFuncSwData_v203)); }
t_Open9xFuncSwData_v203(FuncSwData&);
}) Open9xFuncSwData_v203;
PACK(typedef struct t_Open9xFuncSwData_v210 { // Function Switches data
@@ -299,8 +273,6 @@ PACK(typedef struct t_Open9xFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xFuncSwData_v210)); }
t_Open9xFuncSwData_v210(FuncSwData&);
}) Open9xFuncSwData_v210;
PACK(typedef struct t_Open9xFrSkyChannelData_v201 {
@@ -316,8 +288,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v201 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v201)); }
t_Open9xFrSkyChannelData_v201(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v201;
PACK(typedef struct t_Open9xFrSkyChannelData_v203 {
@@ -333,8 +303,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v203 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v203)); }
t_Open9xFrSkyChannelData_v203(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v203;
PACK(typedef struct t_Open9xFrSkyChannelData_v204 {
@@ -348,8 +316,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v204 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v204)); }
t_Open9xFrSkyChannelData_v204(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v204;
PACK(typedef struct t_Open9xFrSkyChannelData_v208 {
@@ -363,37 +329,30 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v208 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v208)); }
t_Open9xFrSkyChannelData_v208(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v208;
PACK(typedef struct t_Open9xFrSkyData_v201 {
Open9xFrSkyChannelData_v201 channels[2];
operator FrSkyData();
t_Open9xFrSkyData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyData_v201)); }
Open9xFrSkyChannelData_v201 channels[2];
operator FrSkyData();
t_Open9xFrSkyData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyData_v201)); }
}) Open9xFrSkyData_v201;
PACK(typedef struct t_Open9xFrSkyData_v202 {
Open9xFrSkyChannelData_v201 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t spare:6;
operator FrSkyData();
t_Open9xFrSkyData_v202() { memset(this, 0, sizeof(t_Open9xFrSkyData_v202)); }
t_Open9xFrSkyData_v202(FrSkyData&);
Open9xFrSkyChannelData_v201 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t spare:6;
operator FrSkyData();
t_Open9xFrSkyData_v202() { memset(this, 0, sizeof(t_Open9xFrSkyData_v202)); }
}) Open9xFrSkyData_v202;
PACK(typedef struct t_Open9xFrSkyData_v203 {
Open9xFrSkyChannelData_v203 channels[2];
uint8_t usrProto; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
operator FrSkyData();
t_Open9xFrSkyData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyData_v203)); }
t_Open9xFrSkyData_v203(FrSkyData&);
Open9xFrSkyChannelData_v203 channels[2];
uint8_t usrProto; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
operator FrSkyData();
t_Open9xFrSkyData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyData_v203)); }
}) Open9xFrSkyData_v203;
PACK(typedef struct t_Open9xFrSkyBarData_v204 {
@@ -403,8 +362,6 @@ PACK(typedef struct t_Open9xFrSkyBarData_v204 {
operator FrSkyBarData();
t_Open9xFrSkyBarData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyBarData_v204)); }
t_Open9xFrSkyBarData_v204(FrSkyBarData&);
}) Open9xFrSkyBarData_v204;
PACK(typedef struct t_Open9xFrSkyData_v204 {
@@ -417,7 +374,6 @@ PACK(typedef struct t_Open9xFrSkyData_v204 {
operator FrSkyData();
t_Open9xFrSkyData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyData_v204)); }
t_Open9xFrSkyData_v204(FrSkyData&);
}) Open9xFrSkyData_v204;
PACK(typedef struct t_Open9xFrSkyData_v205 {
@@ -431,7 +387,6 @@ PACK(typedef struct t_Open9xFrSkyData_v205 {
operator FrSkyData();
t_Open9xFrSkyData_v205() { memset(this, 0, sizeof(t_Open9xFrSkyData_v205)); }
t_Open9xFrSkyData_v205(FrSkyData&);
}) Open9xFrSkyData_v205;
PACK(typedef struct t_Open9xFrSkyData_v208 {
@@ -445,7 +400,6 @@ PACK(typedef struct t_Open9xFrSkyData_v208 {
operator FrSkyData();
t_Open9xFrSkyData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyData_v208)); }
t_Open9xFrSkyData_v208(FrSkyData&);
}) Open9xFrSkyData_v208;
PACK(typedef struct t_Open9xFrSkyData_v210 {
@@ -466,7 +420,6 @@ PACK(typedef struct t_Open9xFrSkyData_v210 {
operator FrSkyData();
t_Open9xFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xFrSkyData_v210)); }
t_Open9xFrSkyData_v210(FrSkyData&);
}) Open9xFrSkyData_v210;
PACK(typedef struct t_Open9xSwashRingData_v208 { // Swash Ring data
@@ -479,8 +432,6 @@ PACK(typedef struct t_Open9xSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xSwashRingData_v208)); }
t_Open9xSwashRingData_v208(SwashRingData&);
}) Open9xSwashRingData_v208;
PACK(typedef struct t_Open9xSwashRingData_v209 { // Swash Ring data
@@ -493,8 +444,6 @@ PACK(typedef struct t_Open9xSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xSwashRingData_v209)); }
t_Open9xSwashRingData_v209(SwashRingData&);
}) Open9xSwashRingData_v209;
PACK(typedef struct t_Open9xPhaseData_v201 {
@@ -507,7 +456,6 @@ PACK(typedef struct t_Open9xPhaseData_v201 {
operator PhaseData();
t_Open9xPhaseData_v201() { memset(this, 0, sizeof(t_Open9xPhaseData_v201)); }
t_Open9xPhaseData_v201(PhaseData &eepe);
}) Open9xPhaseData_v201;
PACK(typedef struct t_Open9xTimerData_v201 {
@@ -526,7 +474,6 @@ PACK(typedef struct t_Open9xTimerData_v202 {
operator TimerData();
t_Open9xTimerData_v202() { memset(this, 0, sizeof(t_Open9xTimerData_v202)); }
t_Open9xTimerData_v202(TimerData &eepe);
}) Open9xTimerData_v202;
PACK(typedef struct t_Open9xTimerDataExtra {
@@ -579,8 +526,6 @@ PACK(typedef struct t_Open9xModelData_v201 {
operator ModelData();
t_Open9xModelData_v201() { memset(this, 0, sizeof(t_Open9xModelData_v201)); }
t_Open9xModelData_v201(ModelData&);
}) Open9xModelData_v201;
PACK(typedef struct t_Open9xModelData_v202 {
@@ -615,8 +560,6 @@ PACK(typedef struct t_Open9xModelData_v202 {
operator ModelData();
t_Open9xModelData_v202() { memset(this, 0, sizeof(t_Open9xModelData_v202)); }
t_Open9xModelData_v202(ModelData&);
}) Open9xModelData_v202;
PACK(typedef struct t_Open9xModelData_v203 {
@@ -650,8 +593,6 @@ PACK(typedef struct t_Open9xModelData_v203 {
operator ModelData();
t_Open9xModelData_v203() { memset(this, 0, sizeof(t_Open9xModelData_v203)); }
t_Open9xModelData_v203(ModelData&);
}) Open9xModelData_v203;
PACK(typedef struct t_Open9xModelData_v204 {
@@ -686,8 +627,6 @@ PACK(typedef struct t_Open9xModelData_v204 {
operator ModelData();
t_Open9xModelData_v204() { memset(this, 0, sizeof(t_Open9xModelData_v204)); }
t_Open9xModelData_v204(ModelData&);
}) Open9xModelData_v204;
PACK(typedef struct t_Open9xModelData_v205 {
@@ -723,8 +662,6 @@ PACK(typedef struct t_Open9xModelData_v205 {
operator ModelData();
t_Open9xModelData_v205() { memset(this, 0, sizeof(t_Open9xModelData_v205)); }
t_Open9xModelData_v205(ModelData&);
}) Open9xModelData_v205;
PACK(typedef struct t_Open9xModelData_v208 {
@@ -764,8 +701,6 @@ PACK(typedef struct t_Open9xModelData_v208 {
operator ModelData();
t_Open9xModelData_v208() { memset(this, 0, sizeof(t_Open9xModelData_v208)); }
t_Open9xModelData_v208(ModelData&);
}) Open9xModelData_v208;
PACK(typedef struct t_Open9xModelData_v209 {
@@ -806,8 +741,6 @@ PACK(typedef struct t_Open9xModelData_v209 {
operator ModelData();
t_Open9xModelData_v209() { memset(this, 0, sizeof(t_Open9xModelData_v209)); }
t_Open9xModelData_v209(ModelData&);
}) Open9xModelData_v209;
PACK(typedef struct t_Open9xModelData_v210 {
@@ -846,8 +779,6 @@ PACK(typedef struct t_Open9xModelData_v210 {
operator ModelData();
t_Open9xModelData_v210() { memset(this, 0, sizeof(t_Open9xModelData_v210)); }
t_Open9xModelData_v210(ModelData&);
}) Open9xModelData_v210;
PACK(typedef struct t_Open9xModelData_v211 {
@@ -884,8 +815,6 @@ PACK(typedef struct t_Open9xModelData_v211 {
operator ModelData();
t_Open9xModelData_v211() { memset(this, 0, sizeof(t_Open9xModelData_v211)); }
t_Open9xModelData_v211(ModelData&);
}) Open9xModelData_v211;
#endif
@@ -14,9 +14,9 @@
*
*/
#include "open9xGruvin9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxGruvin9xsimulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS
@@ -98,7 +98,7 @@ bool hasExtendedTrims()
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
return limit<uint8_t>(0, g_eeGeneral.stickMode, 3);
}
}
@@ -160,7 +160,7 @@ void Open9xGruvin9xSimulator::setValues(TxInputs &inputs)
void Open9xGruvin9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xGruvin9x::modn12x3[4*getStickMode() + idx] - 1;
idx = Open9xGruvin9x::modn12x3[4*getStickMode() + idx];
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
@@ -174,7 +174,7 @@ void Open9xGruvin9xSimulator::getTrims(Trims & trims)
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xGruvin9x::modn12x3[4*getStickMode() + i] - 1;
uint8_t idx = Open9xGruvin9x::modn12x3[4*getStickMode() + i];
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
@@ -14,9 +14,9 @@
*
*/
#include "open9xM128simulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxM128simulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS
@@ -96,7 +96,7 @@ bool hasExtendedTrims()
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
return limit<uint8_t>(0, g_eeGeneral.stickMode, 3);
}
}
@@ -154,7 +154,7 @@ void Open9xM128Simulator::setValues(TxInputs &inputs)
void Open9xM128Simulator::setTrim(unsigned int idx, int value)
{
idx = Open9xM128::modn12x3[4*getStickMode() + idx] - 1;
idx = Open9xM128::modn12x3[4*getStickMode() + idx];
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
@@ -168,7 +168,7 @@ void Open9xM128Simulator::getTrims(Trims & trims)
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xM128::modn12x3[4*getStickMode() + i] - 1;
uint8_t idx = Open9xM128::modn12x3[4*getStickMode() + i];
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
@@ -14,8 +14,8 @@
*
*/
#include "open9xSky9xsimulator.h"
#include "open9xinterface.h"
#include "opentxSky9xsimulator.h"
#include "opentxinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
@@ -125,7 +125,7 @@ bool hasExtendedTrims()
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
return limit<uint8_t>(0, g_eeGeneral.stickMode, 3);
}
}
@@ -193,7 +193,7 @@ void Open9xSky9xSimulator::setValues(TxInputs &inputs)
void Open9xSky9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xSky9x::modn12x3[4*getStickMode() + idx] - 1;
idx = Open9xSky9x::modn12x3[4*getStickMode() + idx];
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
@@ -207,7 +207,7 @@ void Open9xSky9xSimulator::getTrims(Trims & trims)
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xSky9x::modn12x3[4*getStickMode() + i] - 1;
uint8_t idx = Open9xSky9x::modn12x3[4*getStickMode() + i];
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
@@ -15,7 +15,7 @@
*/
#include "opentxTaranisSimulator.h"
#include "open9xinterface.h"
#include "opentxinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
@@ -128,7 +128,7 @@ bool hasExtendedTrims()
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
return limit<uint8_t>(0, g_eeGeneral.stickMode, 3);
}
void resetTrims()
@@ -200,7 +200,7 @@ void OpentxTaranisSimulator::setValues(TxInputs &inputs)
void OpentxTaranisSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xX9D::modn12x3[4*getStickMode() + idx] - 1;
idx = Open9xX9D::modn12x3[4*getStickMode() + idx];
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
@@ -214,7 +214,7 @@ void OpentxTaranisSimulator::getTrims(Trims & trims)
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xX9D::modn12x3[4*getStickMode() + i] - 1;
uint8_t idx = Open9xX9D::modn12x3[4*getStickMode() + i];
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
@@ -1,7 +1,7 @@
#include <stdlib.h>
#include <algorithm>
#include "helpers.h"
#include "open9xeeprom.h"
#include "opentxeeprom.h"
#include <QObject>
#define IS_DBLEEPROM(board, version) ((board==BOARD_GRUVIN9X || board==BOARD_M128) && version >= 213)
@@ -18,10 +18,11 @@
#define MAX_PHASES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5))
#define MAX_MIXERS(board, version) (IS_ARM(board) ? 64 : 32)
#define MAX_CHANNELS(board, version) (IS_ARM(board) ? 32 : 16)
#define MAX_EXPOS(board, version) (IS_ARM(board) ? 32 : (IS_DBLRAM(board, version) ? 16 : 14))
#define MAX_EXPOS(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 216) ? 64 : 32) : (IS_DBLRAM(board, version) ? 16 : 14))
#define MAX_CUSTOM_SWITCHES(board, version) (IS_ARM(board) ? 32 : (IS_DBLEEPROM(board, version) ? 15 : 12))
#define MAX_CUSTOM_FUNCTIONS(board, version) (IS_ARM(board) ? 32 : (IS_DBLEEPROM(board, version) ? 24 : 16))
#define MAX_CURVES(board) (IS_ARM(board) ? O9X_ARM_MAX_CURVES : O9X_MAX_CURVES)
#define MAX_CURVES(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 216) ? 32 : 16) : O9X_MAX_CURVES)
#define MAX_GVARS(board, version) ((IS_ARM(board) && version >= 216) ? 9 : 5)
#define IS_RELEASE_21_MARCH_2013(board, version) (version >= 214 || (!IS_ARM(board) && version >= 213))
#define IS_RELEASE_23_MARCH_2013(board, version) (version >= 214 || (board==BOARD_STOCK && version >= 213))
@@ -134,6 +135,16 @@ class SourcesConversionTable: public ConversionTable {
addConversion(RawSource(SOURCE_TYPE_NONE), val++);
}
if (IS_TARANIS(board) && version >= 216) {
for (int i=0; i<32; i++)
addConversion(RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i), val++);
for (int i=0; i<3; i++) {
for (int j=0; j<6; j++) {
addConversion(RawSource(SOURCE_TYPE_LUA_INPUT, i*16+j), val++);
}
}
}
for (int i=0; i<4+MAX_POTS(board); i++)
addConversion(RawSource(SOURCE_TYPE_STICK, i), val++);
@@ -352,6 +363,36 @@ class SourceField: public ConversionField< UnsignedField<N> > {
unsigned int _source;
};
class CurveReferenceField: public TransformedField {
public:
CurveReferenceField(CurveReference & curve, BoardEnum board, unsigned int version):
TransformedField(internalField),
curve(curve),
_curve_type(0)
{
internalField.Append(new UnsignedField<8>(_curve_type));
internalField.Append(new SignedField<8>(curve.value));
}
virtual void beforeExport()
{
if (curve.value != 0)
_curve_type = (unsigned int)curve.type;
else
_curve_type = 0;
}
virtual void afterImport()
{
curve.type = (CurveReference::CurveRefType)_curve_type;
}
protected:
StructField internalField;
CurveReference & curve;
unsigned int _curve_type;
};
class HeliField: public StructField {
public:
HeliField(SwashRingData & heli, BoardEnum board, unsigned int version, unsigned int variant)
@@ -409,7 +450,7 @@ class PhaseField: public TransformedField {
}
if (board != BOARD_STOCK && (board != BOARD_M128 || version < 215)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
internalField.Append(new SignedField<16>(phase.gvars[i]));
}
}
@@ -595,7 +636,25 @@ class MixField: public TransformedField {
board(board),
version(version)
{
if (IS_ARM(board)) {
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new UnsignedField<8>((unsigned int &)mix.mltpx));
internalField.Append(new SignedField<16>(_weight));
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
internalField.Append(new CurveReferenceField(mix.curve, board, version));
internalField.Append(new UnsignedField<4>(mix.mixWarn));
internalField.Append(new UnsignedField<4>(mix.srcVariant));
internalField.Append(new UnsignedField<8>(mix.delayUp));
internalField.Append(new UnsignedField<8>(mix.delayDown));
internalField.Append(new UnsignedField<8>(mix.speedUp));
internalField.Append(new UnsignedField<8>(mix.speedDown));
internalField.Append(new SourceField<8>(mix.srcRaw, board, version, FLAG_NOTELEMETRY));
internalField.Append(new SignedField<16>(_offset));
internalField.Append(new ZCharField<8>(mix.name));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new BoolField<1>(_curveMode));
@@ -680,8 +739,18 @@ class MixField: public TransformedField {
{
if (mix.destCh && mix.srcRaw.type != SOURCE_TYPE_NONE) {
_destCh = mix.destCh - 1;
_curveMode = mix.curve;
_curveParam = (mix.curve ? mix.curve : smallGvarToEEPROM(mix.differential));
if (mix.curve.type == CurveReference::CURVE_REF_CUSTOM) {
_curveMode = true;
_curveParam = 6 + mix.curve.value;
}
else if (mix.curve.type == CurveReference::CURVE_REF_FUNC) {
_curveMode = true;
_curveParam = mix.curve.value;
}
else if (mix.curve.type == CurveReference::CURVE_REF_DIFF) {
_curveMode = 0;
_curveParam = smallGvarToEEPROM(mix.curve.value);
}
}
else {
mix.clear();
@@ -707,12 +776,14 @@ class MixField: public TransformedField {
{
if (mix.srcRaw.type != SOURCE_TYPE_NONE) {
mix.destCh = _destCh + 1;
mix.curve = 0;
mix.differential = 0;
if (_curveMode)
mix.curve = _curveParam;
else
mix.differential = smallGvarToC9x(_curveParam);
if (!IS_ARM(board) || version < 216) {
if (!_curveMode)
mix.curve = CurveReference(CurveReference::CURVE_REF_DIFF, smallGvarToC9x(_curveParam));
else if (_curveParam > 6)
mix.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam-6);
else
mix.curve = CurveReference(CurveReference::CURVE_REF_FUNC, _curveParam);
}
}
if (IS_ARM(board)) {
@@ -748,9 +819,23 @@ class ExpoField: public TransformedField {
TransformedField(internalField),
internalField("Expo"),
expo(expo),
board(board)
board(board),
version(version)
{
if (IS_ARM(board)) {
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0));
internalField.Append(new UnsignedField<16>(expo.scale));
internalField.Append(new UnsignedField<8>(expo.chn, "Channel"));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
internalField.Append(new UnsignedField<16>(expo.phases));
internalField.Append(new SignedField<8>(_weight, "Weight"));
internalField.Append(new SignedField<8>(expo.carryTrim));
internalField.Append(new ZCharField<8>(expo.name));
internalField.Append(new SignedField<8>(expo.offset, "Offset"));
internalField.Append(new CurveReferenceField(expo.curve, board, version));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(expo.mode));
internalField.Append(new UnsignedField<8>(expo.chn));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
@@ -789,22 +874,41 @@ class ExpoField: public TransformedField {
virtual void beforeExport()
{
_curveMode = (expo.curveMode && expo.curveParam);
_weight = smallGvarToEEPROM(expo.weight);
_curveParam = smallGvarToEEPROM(expo.curveParam);
if (!IS_TARANIS(board) || version < 216) {
if (expo.curve.type==CurveReference::CURVE_REF_FUNC && expo.curve.value) {
_curveMode = true;
_curveParam = expo.curve.value;
}
else if (expo.curve.type==CurveReference::CURVE_REF_CUSTOM && expo.curve.value) {
_curveMode = true;
_curveParam = expo.curve.value+6;
}
else {
_curveMode = false;
_curveParam = smallGvarToEEPROM(expo.curve.value);
}
}
}
virtual void afterImport()
{
expo.curveMode = _curveMode;
expo.weight = smallGvarToC9x(_weight);
expo.curveParam = smallGvarToC9x(_curveParam);
if (!IS_TARANIS(board) || version < 216) {
if (!_curveMode)
expo.curve = CurveReference(CurveReference::CURVE_REF_EXPO, smallGvarToC9x(_curveParam));
else if (_curveParam > 6)
expo.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam-6);
else
expo.curve = CurveReference(CurveReference::CURVE_REF_FUNC, _curveParam);
}
}
protected:
StructField internalField;
ExpoData & expo;
BoardEnum board;
unsigned int version;
bool _curveMode;
int _weight;
int _curveParam;
@@ -812,36 +916,56 @@ class ExpoField: public TransformedField {
class LimitField: public StructField {
public:
LimitField(LimitData & limit, BoardEnum board):
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
StructField("Limit")
{
Append(new ConversionField< SignedField<8> >(limit.min, +100));
Append(new ConversionField< SignedField<8> >(limit.max, -100));
if (IS_ARM(board) && version >= 216) {
Append(new ConversionField< SignedField<16> >(limit.min, +1000));
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
}
else {
Append(new ConversionField< SignedField<8> >(limit.min, +100, 10));
Append(new ConversionField< SignedField<8> >(limit.max, -100, 10));
}
Append(new SignedField<8>(limit.ppmCenter));
Append(new SignedField<14>(limit.offset));
Append(new BoolField<1>(limit.symetrical));
Append(new BoolField<1>(limit.revert));
if (HAS_LARGE_LCD(board))
if (HAS_LARGE_LCD(board)) {
Append(new ZCharField<6>(limit.name));
}
if (IS_TARANIS(board) && version >= 216) {
Append(new SignedField<8>(limit.curve.value));
}
}
};
class CurvesField: public TransformedField {
public:
CurvesField(CurveData * curves, BoardEnum board):
CurvesField(CurveData * curves, BoardEnum board, unsigned int version):
TransformedField(internalField),
internalField("Curves"),
curves(curves),
board(board),
maxCurves(MAX_CURVES(board)),
version(version),
maxCurves(MAX_CURVES(board, version)),
maxPoints(IS_ARM(board) ? O9X_ARM_NUM_POINTS : O9X_NUM_POINTS)
{
for (int i=0; i<maxCurves; i++) {
if (IS_ARM(board))
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<3>((unsigned int &)curves[i].type));
internalField.Append(new BoolField<1>(curves[i].smooth));
internalField.Append(new SpareBitsField<4>());
internalField.Append(new ConversionField< SignedField<8> >(curves[i].count, -5));
}
else if (IS_ARM(board)) {
internalField.Append(new SignedField<16>(_curves[i]));
else
}
else {
internalField.Append(new SignedField<8>(_curves[i]));
}
}
for (int i=0; i<maxPoints; i++) {
internalField.Append(new SignedField<8>(_points[i]));
}
@@ -853,46 +977,56 @@ class CurvesField: public TransformedField {
int * cur = &_points[0];
int offset = 0;
for (int i=0; i<maxCurves; i++) {
CurveData *curve = &curves[i];
offset += (curve->custom ? curve->count * 2 - 2 : curve->count) - 5;
if (offset > maxPoints - 5 * maxCurves) {
int size = (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count);
if (offset+size > maxPoints) {
EEPROMWarnings += ::QObject::tr("openTx only accepts %1 points in all curves").arg(maxPoints) + "\n";
break;
}
_curves[i] = offset;
if (!IS_TARANIS(board) || version < 216) {
_curves[i] = offset - (5*i);
}
for (int j=0; j<curve->count; j++) {
*cur++ = curve->points[j].y;
}
if (curve->custom) {
if (curve->type == CurveData::CURVE_TYPE_CUSTOM) {
for (int j=1; j<curve->count-1; j++) {
*cur++ = curve->points[j].x;
}
}
offset += size;
}
}
virtual void afterImport()
{
int * cur = &_points[0];
for (int i=0; i<maxCurves; i++) {
CurveData *curve = &curves[i];
int * cur = &_points[i==0 ? 0 : 5*i + _curves[i-1]];
int * next = &_points[5*(i+1) + _curves[i]];
int size = next - cur;
if (size % 2 == 0) {
curve->count = (size / 2) + 1;
curve->custom = true;
if (!IS_TARANIS(board) || version < 216) {
int * next = &_points[5*(i+1) + _curves[i]];
int size = next - cur;
if (size % 2 == 0) {
curve->count = (size / 2) + 1;
curve->type = CurveData::CURVE_TYPE_CUSTOM;
}
else {
curve->count = size;
curve->type = CurveData::CURVE_TYPE_STANDARD;
}
}
else {
curve->count = size;
curve->custom = false;
for (int j=0; j<curve->count; j++) {
curve->points[j].y = *cur++;
}
for (int j=0; j<curve->count; j++)
curve->points[j].y = cur[j];
if (curve->custom) {
if (curve->type == CurveData::CURVE_TYPE_CUSTOM) {
curve->points[0].x = -100;
for (int j=1; j<curve->count-1; j++)
curve->points[j].x = cur[curve->count+j-1];
curve->points[j].x = *cur++;
curve->points[curve->count-1].x = +100;
}
else {
@@ -906,10 +1040,11 @@ class CurvesField: public TransformedField {
StructField internalField;
CurveData *curves;
BoardEnum board;
unsigned int version;
int maxCurves;
int maxPoints;
int _curves[O9X_ARM_MAX_CURVES];
int _points[O9X_ARM_NUM_POINTS];
int _curves[C9X_MAX_CURVES];
int _points[C9X_MAX_CURVES*C9X_MAX_POINTS*2];
};
class CustomSwitchesFunctionsTable: public ConversionTable {
@@ -1238,7 +1373,7 @@ class CustomFunctionField: public TransformedField {
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) {
memcpy(_arm_param, fn.paramarm, sizeof(_arm_param));
}
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
unsigned int value;
if (version >= 214) {
_mode = fn.adjustMode;
@@ -1268,7 +1403,7 @@ class CustomFunctionField: public TransformedField {
/* the default behavior */
_param = fn.param;
_union_param = (fn.enabled ? 1 : 0);
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
if (version >= 213) {
_union_param += (fn.adjustMode << 1);
if (fn.adjustMode == 1)
@@ -1321,7 +1456,7 @@ class CustomFunctionField: public TransformedField {
else if (fn.func == FuncVolume) {
sourcesConversionTable->importValue(value, (int &)fn.param);
}
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
if (version >= 214) {
fn.adjustMode = _mode;
if (fn.adjustMode == 1)
@@ -1350,7 +1485,7 @@ class CustomFunctionField: public TransformedField {
if (version >= 213) {
fn.enabled = (_union_param & 0x01);
}
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
if (version >= 213) {
fn.adjustMode = ((_union_param >> 1) & 0x03);
if (fn.adjustMode == 1)
@@ -1551,7 +1686,14 @@ class FrskyField: public StructField {
Append(new UnsignedField<8>(frsky.channels[i].multiplier, 0, 5, "Multiplier"));
}
Append(new UnsignedField<8>(frsky.usrProto));
Append(new UnsignedField<8>(frsky.voltsSource));
if (version >= 216) {
Append(new UnsignedField<7>(frsky.voltsSource));
// TODO altitude displayed
Append(new SpareBitsField<1>());
}
else {
Append(new UnsignedField<8>(frsky.voltsSource));
}
Append(new UnsignedField<8>(frsky.blades));
Append(new UnsignedField<8>(frsky.currentSource));
@@ -1575,6 +1717,12 @@ class FrskyField: public StructField {
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI"));
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3));
}
if (version >= 216) {
// TODO uint16_t mAhPersistent:1;
// uint16_t storedMah:15;
// int8_t fasOffset;
Append(new SpareBitsField<24>());
}
}
else {
for (int i=0; i<2; i++) {
@@ -1598,7 +1746,7 @@ class FrskyField: public StructField {
Append(new SignedField<4>(frsky.varioMax));
for (int i=0; i<2; i++) {
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI level"));
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3, 0, 100, "RSSI value"));
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3, 0, 0, 100, "RSSI value"));
}
for (int i=0; i<2; i++) {
Append(new FrskyScreenField(frsky.screens[i], board, version));
@@ -1607,6 +1755,10 @@ class FrskyField: public StructField {
Append(new SignedField<5>(frsky.varioCenterMin));
Append(new UnsignedField<3>(frsky.currentSource));
Append(new SignedField<8>(frsky.varioCenterMax));
if (version >= 216) {
// TODO int8_t fasOffset;
Append(new SpareBitsField<8>());
}
}
}
@@ -1658,9 +1810,16 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
for (int i=0; i<O9X_MAX_TIMERS; i++) {
internalField.Append(new TimerModeField(modelData.timers[i].mode, board, version));
if (release21March2013) {
if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
internalField.Append(new BoolField<2>(modelData.timers[i].countdownBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].minuteBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].persistent));
internalField.Append(new SpareBitsField<4>());
internalField.Append(new SignedField<16>(modelData.timers[i].pvalue));
}
else if (release21March2013) {
internalField.Append(new UnsignedField<12>(modelData.timers[i].val));
internalField.Append(new BoolField<1>(modelData.timers[i].countdownBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].minuteBeep));
if (HAS_PERSISTENT_TIMERS(board)) {
@@ -1688,7 +1847,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.thrTrim));
if (IS_TARANIS(board))
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<4>());
else
internalField.Append(new ConversionField< SignedField<4> >(modelData.moduleData[0].channelsCount, &channelsConversionTable, "Channels number", ::QObject::tr("OpenTX doesn't allow this number of channels")));
@@ -1696,7 +1855,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new UnsignedField<3>(modelData.trimInc));
internalField.Append(new BoolField<1>(modelData.disableThrottleWarning));
if (IS_TARANIS(board))
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<1>());
else
internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol));
@@ -1704,7 +1863,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.extendedLimits));
internalField.Append(new BoolField<1>(modelData.extendedTrims));
internalField.Append(new BoolField<1>(modelData.throttleReversed));
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppmDelay, exportPpmDelay, importPpmDelay));
if (!IS_ARM(board) || version < 216) {
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppmDelay, exportPpmDelay, importPpmDelay));
}
if (IS_ARM(board) || board==BOARD_GRUVIN9X)
internalField.Append(new UnsignedField<16>(modelData.beepANACenter));
@@ -1714,10 +1876,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
for (int i=0; i<MAX_MIXERS(board, version); i++)
internalField.Append(new MixField(modelData.mixData[i], board, version));
for (int i=0; i<MAX_CHANNELS(board, version); i++)
internalField.Append(new LimitField(modelData.limitData[i], board));
internalField.Append(new LimitField(modelData.limitData[i], board, version));
for (int i=0; i<MAX_EXPOS(board, version); i++)
internalField.Append(new ExpoField(modelData.expoData[i], board, version));
internalField.Append(new CurvesField(modelData.curves, board));
internalField.Append(new CurvesField(modelData.curves, board, version));
for (int i=0; i<MAX_CUSTOM_SWITCHES(board, version); i++)
internalField.Append(new CustomSwitchField(modelData.customSw[i], board, version, variant));
for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++)
@@ -1725,11 +1887,16 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new HeliField(modelData.swashRingData, board, version, variant));
for (int i=0; i<MAX_PHASES(board, version); i++)
internalField.Append(new PhaseField(modelData.phaseData[i], i, board, version));
internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength));
if (!IS_ARM(board) || version < 216) {
internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength));
}
internalField.Append(new UnsignedField<8>(modelData.thrTraceSrc));
if (!release21March2013)
if (!release21March2013) {
internalField.Append(new UnsignedField<8>(modelData.modelId));
}
if (IS_TARANIS(board))
internalField.Append(new UnsignedField<16>(modelData.switchWarningStates));
@@ -1737,15 +1904,19 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version));
if ((board == BOARD_STOCK || (board == BOARD_M128 && version >= 215)) && (variant & GVARS_VARIANT)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
// on M64 GVARS are common to all phases, and there is no name
internalField.Append(new SignedField<16>(modelData.phaseData[0].gvars[i]));
}
}
if (board != BOARD_STOCK && (board != BOARD_M128 || version < 215)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.gvars_names[i]));
if (version >= 216) {
internalField.Append(new BoolField<1>(modelData.gvars_popups[i]));
internalField.Append(new SpareBitsField<7>());
}
}
}
@@ -1783,15 +1954,23 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
}
if (IS_TARANIS(board)) {
for (int i=0; i<MAX_CURVES(board); i++) {
for (int i=0; i<MAX_CURVES(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.curves[i].name));
}
}
if (IS_TARANIS(board) && version >= 216) {
// TODO ScriptData scriptsData[MAX_SCRIPTS];
internalField.Append(new SpareBitsField<720>());
// TODO char inputNames[MAX_INPUTS][4];
internalField.Append(new SpareBitsField<1024>());
}
}
void Open9xModelDataNew::beforeExport()
{
// qDebug() << QString("before export model") << modelData.name;
for (int module=0; module<3; module++) {
if (modelData.moduleData[module].protocol >= PXX_XJT_X16 && modelData.moduleData[module].protocol <= PXX_XJT_LR12)
subprotocols[module] = modelData.moduleData[module].protocol - PXX_XJT_X16;
@@ -1802,7 +1981,7 @@ void Open9xModelDataNew::beforeExport()
void Open9xModelDataNew::afterImport()
{
// qDebug() << QString("after import model") << modelData.name;
// qDebug() << QString("after import model") << modelData.name ;
for (int module=0; module<3; module++) {
if (modelData.moduleData[module].protocol == PXX_XJT_X16) {
@@ -1866,8 +2045,9 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
internalField.Append(new UnsignedField<8>(generalData.inactivityTimer));
if (IS_STOCK(board) && version >= 215) {
internalField.Append(new UnsignedField<3>(generalData.mavbaud));
} else {
internalField.Append(new BoolField<1>(generalData.throttleReversed));
}
else {
internalField.Append(new SpareBitsField<1>());
internalField.Append(new BoolField<1>(generalData.minuteBeep));
internalField.Append(new BoolField<1>(generalData.preBeep));
}
@@ -1892,9 +2072,9 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
internalField.Append(new UnsignedField<8>(generalData.speakerPitch));
if (IS_ARM(board))
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -12, 0, 23, "Volume"));
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -12, 0, 0, 23, "Volume"));
else
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -7, 0, 7, "Volume"));
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -7, 0, 0, 7, "Volume"));
if (version >= 214 || (!IS_ARM(board) && version >= 213)) {
internalField.Append(new SignedField<8>(generalData.vBatMin));
@@ -42,7 +42,6 @@
#define O9X_NUM_FSW 16 // number of functions assigned to switches
#define O9X_MAX_CURVES 8
#define O9X_NUM_POINTS (112-O9X_MAX_CURVES)
#define O9X_MAX_GVARS 5
#define O9X_ARM_MAX_PHASES 9
#define O9X_ARM_MAX_MIXERS 64
@@ -50,7 +49,6 @@
#define O9X_ARM_NUM_CHNOUT 32 // number of real output channels CH1-CH16
#define O9X_ARM_NUM_CSW 32 // number of custom switches
#define O9X_ARM_NUM_FSW 32 // number of functions assigned to switches
#define O9X_ARM_MAX_CURVES 16
#define O9X_ARM_NUM_POINTS 512
#define O9X_ARM_MAX_CSFUNCOLD 13
#define O9X_ARM_MAX_CSFUNC 15
@@ -16,14 +16,14 @@
#include <iostream>
#include <QMessageBox>
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#include "open9xGruvin9xeeprom.h"
#include "open9xSky9xeeprom.h"
#include "open9xsimulator.h"
#include "open9xM128simulator.h"
#include "open9xGruvin9xsimulator.h"
#include "open9xSky9xsimulator.h"
#include "opentxsimulator.h"
#include "opentxM128simulator.h"
#include "opentxGruvin9xsimulator.h"
#include "opentxSky9xsimulator.h"
#include "opentxTaranisSimulator.h"
#include "file.h"
@@ -278,15 +278,7 @@ bool Open9xInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, ui
}
template <class T>
bool Open9xInterface::saveModel(unsigned int index, ModelData &model)
{
T open9xModel(model);
int sz = efile->writeRlc2(FILE_MODEL(index), FILE_TYP_MODEL, (uint8_t*)&open9xModel, sizeof(T));
return (sz == sizeof(T));
}
template <class T>
bool Open9xInterface::saveModelVariant(unsigned int index, ModelData &model, unsigned int version, unsigned int variant)
bool Open9xInterface::saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant)
{
T open9xModel(model, board, version, variant);
// open9xModel.Dump();
@@ -371,16 +363,16 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
case BOARD_TARANIS:
case BOARD_TARANIS_REV4a:
case BOARD_SKY9X:
version = 215;
version = 216;
break;
case BOARD_GRUVIN9X:
version = 214;
version = 216;
break;
case BOARD_M128:
version = 215;
version = 216;
break;
case BOARD_STOCK:
version = 213;
version = 216;
break;
}
}
@@ -389,81 +381,21 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
efile->EeFsCreate(eeprom, size, board);
int result = 0;
if (board == BOARD_M128) {
variant |= M128_VARIANT;
}
result = saveGeneral<Open9xGeneralDataNew>(radioData.generalSettings, board, version, variant);
if (!result)
int result = saveGeneral<Open9xGeneralDataNew>(radioData.generalSettings, board, version, variant);
if (!result) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
result = 0;
switch(version) {
case 202:
result = saveModel<Open9xModelData_v202>(i, radioData.models[i]);
break;
case 203:
result = saveModel<Open9xModelData_v203>(i, radioData.models[i]);
break;
case 204:
result = saveModel<Open9xModelData_v204>(i, radioData.models[i]);
break;
case 205:
result = saveModel<Open9xModelData_v205>(i, radioData.models[i]);
break;
case 207:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v207>(i, radioData.models[i]);
break;
case 208:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v208>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v208>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v208>(i, radioData.models[i]);
break;
case 209:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v209>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v209>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v209>(i, radioData.models[i]);
break;
case 210:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v210>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v210>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v210>(i, radioData.models[i]);
break;
case 211:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v211>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v211>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v211>(i, radioData.models[i]);
break;
case 212:
if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v212>(i, radioData.models[i]);
else
result = saveModelVariant<Open9xModelDataNew>(i, radioData.models[i], version, variant);
break;
default:
result = saveModelVariant<Open9xModelDataNew>(i, radioData.models[i], version, variant);
break;
result = saveModel<Open9xModelDataNew>(i, radioData.models[i], version, variant);
if (!result) {
return 0;
}
if (!result)
return false;
}
}
@@ -488,7 +420,6 @@ int Open9xInterface::getSize(ModelData &model)
efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board);
Open9xModelDataNew open9xModel(model, board, 255, GetCurrentFirmwareVariant());
// open9xModel.Dump();
QByteArray eeprom;
open9xModel.Export(eeprom);
@@ -562,12 +493,14 @@ int Open9xInterface::getCapability(const Capability capability)
return 6;
else
return 5;
case FlightPhasesAreNamed:
case FlightPhasesHaveFades:
return 1;
case Gvars:
return IS_ARM(board) ? 9 : 5;
case FlightModesName:
case GvarsName:
return (IS_TARANIS(board) ? 10 : 6);
case GvarsInCS:
case GvarsAsWeight:
case ExpoIsCurve:
case HasFAIMode:
return 1;
case GvarsAreNamed:
@@ -663,13 +596,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 0;
case ExtraInputs:
return 1;
case HasNegCurves:
return 1;
case HasExpoCurves:
return true;
case ExpoCurve5:
case ExpoCurve9:
return 4;
case ExtendedTrims:
return 500;
case ExtraTrims:
@@ -680,10 +606,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 1;
case FSSwitch:
return 1;
case HasTTrace:
return 1;
case CustomCurves:
return 1;
case MixesWithoutExpo:
return 1;
case NumCurves:
@@ -692,14 +614,10 @@ int Open9xInterface::getCapability(const Capability capability)
return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false);
case HasExpoNames:
return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false);
case HasChNames:
return (IS_TARANIS(board) ? 1 : 0);
case ChannelsName:
return (IS_TARANIS(board) ? 6 : 0);
case HasCvNames:
return (IS_TARANIS(board) ? 1 : 0);
case NoTimerDirs:
return 1;
case NoThrExpo:
return 1;
case Telemetry:
return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH;
case TelemetryBars:
@@ -734,8 +652,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 1;
case TelemetryMaxMultiplier:
return (IS_ARM(board) ? 32 : 8);
case DiffMixers:
return 1;
case PPMCenter:
return 1;
case SYMLimits:
@@ -766,10 +682,6 @@ int Open9xInterface::getCapability(const Capability capability)
case HasBrightness:
return (IS_ARM(board) ? true : false);
case PerModelTimers:
case PerModelThrottleWarning:
case PerModelThrottleInvert:
return 1;
case pmSwitchMask:
return 1;
case SlowScale:
return (IS_ARM(board) ? 10 : 2);
@@ -777,15 +689,18 @@ int Open9xInterface::getCapability(const Capability capability)
return (IS_ARM(board) ? 250 : 15);
case CSFunc:
return 18;
case GvarsNum:
case GvarsOfsNum:
return 5;
case HasSDLogs:
return ((board == BOARD_GRUVIN9X || IS_ARM(board)) ? true : false);
case LCDWidth:
return (IS_TARANIS(board) ? 212 : 128) ;
case GetThrSwitch:
return (IS_TARANIS(board) ?DSW_SF1 : DSW_THR) ;
return (IS_TARANIS(board) ? DSW_SF1 : DSW_THR) ;
case VirtualInputs:
case LuaInputs:
case LimitsPer1000:
case EnhancedCurves:
case TelemetryInternalAlarms:
return IS_TARANIS(board);
default:
return 0;
}
@@ -814,12 +729,15 @@ int Open9xInterface::isAvailable(Protocol proto, int port)
case PXX_XJT_D8:
case PXX_XJT_LR12:
case PXX_DJT:
case LP45:
case DSM2:
case DSMX:
return 1;
default:
return 0;
}
break;
case 2:
case -1:
switch (proto) {
case PPM:
return 1;
@@ -954,6 +872,9 @@ bool Open9xInterface::checkVersion(unsigned int version)
case 215:
// M128 revert because too much RAM used!
break;
case 216:
// A lot of things (first github release)
break;
default:
return false;
}
@@ -67,10 +67,7 @@ class Open9xInterface : public EEPROMInterface
bool loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode=0);
template <class T>
bool saveModel(unsigned int index, ModelData &model);
template <class T>
bool saveModelVariant(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
bool saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
template <class T>
bool loadGeneral(GeneralSettings &settings, unsigned int version);
@@ -14,9 +14,9 @@
*
*/
#include "open9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxsimulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define HELI
#define SIMU
@@ -100,7 +100,7 @@ bool hasExtendedTrims()
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
return limit<uint8_t>(0, g_eeGeneral.stickMode, 3);
}
}
@@ -162,7 +162,7 @@ void Open9xSimulator::setValues(TxInputs &inputs)
void Open9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9x::modn12x3[4*getStickMode() + idx] - 1;
idx = Open9x::modn12x3[4*getStickMode() + idx];
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
@@ -176,7 +176,7 @@ void Open9xSimulator::getTrims(Trims & trims)
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9x::modn12x3[4*getStickMode() + i] - 1;
uint8_t idx = Open9x::modn12x3[4*getStickMode() + i];
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
+20 -222
View File
@@ -29,15 +29,6 @@ t_Th9xTrainerMix::t_Th9xTrainerMix()
memset(this, 0, sizeof(t_Th9xTrainerMix));
}
t_Th9xTrainerMix::t_Th9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerMix));
srcChn = c9x.src;
swtch = th9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Th9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
@@ -53,15 +44,6 @@ t_Th9xTrainerData::t_Th9xTrainerData()
memset(this, 0, sizeof(t_Th9xTrainerData));
}
t_Th9xTrainerData::t_Th9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Th9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
@@ -77,49 +59,6 @@ t_Th9xGeneral::t_Th9xGeneral()
memset(this, 0, sizeof(t_Th9xGeneral));
}
t_Th9xGeneral::t_Th9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Th9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
inactivityMin = c9x.inactivityTimer;
// iTrimSwitch =
// iTrimTme1
// iTrimTme2
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
// lightSw = th9xFromSwitch(c9x.lightSw);
trainer = c9x.trainer;
adcFilt = c9x.filterInput;
// keySpeed
thr0pos = c9x.throttleReversed;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else if (c9x.beeperLength < 2)
beeperVal = 2;
else
beeperVal = 3;
view = c9x.view;
stickMode = c9x.stickMode;
// naviMode
}
Th9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
@@ -158,7 +97,6 @@ Th9xGeneral::operator GeneralSettings ()
}
result.stickMode = stickMode;
result.inactivityTimer = inactivityMin;
result.throttleReversed = thr0pos;
result.filterInput = adcFilt;
return result;
}
@@ -169,35 +107,25 @@ t_Th9xExpoData::t_Th9xExpoData()
memset(this, 0, sizeof(t_Th9xExpoData));
}
t_Th9xExpoData::t_Th9xExpoData(ExpoData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
exp5 = c9x.expo;
mode3 = c9x.mode;
weight6 = c9x.weight;
chn = c9x.chn;
drSw = th9xFromSwitch(c9x.swtch);
if (c9x.curveMode==1)
curve = c9x.curveParam;
else
curve = 0;
}
t_Th9xExpoData::operator ExpoData ()
{
ExpoData c9x;
c9x.expo = exp5;
if (exp5) {
c9x.curve.type = CurveReference::CURVE_REF_EXPO;
c9x.curve.value = exp5;
}
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.mode = mode3;
c9x.weight = weight6;
c9x.chn = chn;
c9x.swtch = th9xToSwitch(drSw);
if (curve) {
c9x.curveMode=1;
c9x.curveParam = curve;
} else {
c9x.curveMode = 0;
c9x.curveParam = exp5;
}
return c9x;
}
@@ -206,15 +134,6 @@ t_Th9xLimitData::t_Th9xLimitData()
memset(this, 0, sizeof(t_Th9xLimitData));
}
t_Th9xLimitData::t_Th9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Th9xLimitData::operator LimitData ()
{
LimitData c9x;
@@ -225,36 +144,11 @@ t_Th9xLimitData::operator LimitData ()
return c9x;
}
t_Th9xMixData::t_Th9xMixData()
{
memset(this, 0, sizeof(t_Th9xMixData));
}
t_Th9xMixData::t_Th9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Th9xMixData));
destCh = c9x.destCh;
mixMode = c9x.mltpx;
if (c9x.srcRaw.type == SOURCE_TYPE_STICK)
srcRaw = c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX)
srcRaw = 10;
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM)
srcRaw = 24 + c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_CH)
srcRaw = 12 + c9x.srcRaw.index;
else
srcRaw = 0; // TODO
switchMode = 1;
curveNeg = 0;
weight = c9x.weight;
swtch = th9xFromSwitch(c9x.swtch);
curve = c9x.curve;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
}
t_Th9xMixData::operator MixData ()
{
MixData c9x;
@@ -273,41 +167,20 @@ t_Th9xMixData::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-24);
c9x.weight = weight;
c9x.swtch = th9xToSwitch(swtch);
c9x.curve = curve;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.speedUp = speedUp;
c9x.speedDown = speedDown;
c9x.mltpx = (MltpxValue)mixMode;
return c9x;
}
t_Th9xCustomSwData::t_Th9xCustomSwData(CustomSwData &c9x)
{
opCmp = c9x.func;
val1 = c9x.val1;
val2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
val1 = fromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
val2 = fromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
val1 = th9xFromSwitch(RawSwitch(c9x.val1));
val2 = th9xFromSwitch(RawSwitch(c9x.val2));
}
if (opCmp>TH9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("th9x does not support Custom Switch function %1").arg(getFuncName(opCmp)) + "\n";
opCmp=0;
val1=0;
val2=0;
}
}
t_Th9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@@ -388,76 +261,6 @@ t_Th9xModelData::t_Th9xModelData()
memset(this, 0, sizeof(t_Th9xModelData));
}
t_Th9xModelData::t_Th9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Th9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
mdVers = MDVERS;
if (c9x.timers[0].mode == TMRMODE_ABS)
tmrMode = 1;
if (c9x.timers[0].mode == TMRMODE_THs)
tmrMode = 2;
if (c9x.timers[0].mode == TMRMODE_THp)
tmrMode = 3;
else
tmrMode = 0;
// TODO tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
//protocol = c9x.protocol;
/*
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncTrims2Offsets && c9x.funcSw[i].swtch) trimSw = c9x.funcSw[i].swtch;
beepANACenter = c9x.beepANACenter;
pulsePol = c9x.pulsePol;*/
for (int i=0; i<TH9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
for (int i=0; i<TH9X_MAX_EXPOS; i++)
expoTab[i] = c9x.expoData[i];
for (int i=0; i<TH9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<NUM_STICKS; i++)
trimData[i].itrim = std::max(-30, std::min(30, c9x.phaseData[0].trim[i]));
for (int i=0; i<TH9X_MAX_CURVES3; i++)
if (c9x.curves[i].count==3) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<3; j++)
curves3[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES5; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3].count==5) {
if (c9x.curves[i+TH9X_MAX_CURVES3].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3].count).arg(i+1+TH9X_MAX_CURVES3) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES9; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count==9) {
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
for (int j=0; j<9; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count).arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];*/
}
}
t_Th9xModelData::operator ModelData ()
{
ModelData c9x;
@@ -507,7 +310,6 @@ t_Th9xModelData::operator ModelData ()
for (int i=0; i<NUM_STICKS; i++)
c9x.phaseData[0].trim[i] = trimData[i].itrim;
for (int i=0; i<TH9X_MAX_CURVES3; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 3;
for (int j=0; j<3; j++) {
c9x.curves[i].points[j].x = -100 + 100*i;
@@ -515,7 +317,6 @@ t_Th9xModelData::operator ModelData ()
}
}
for (int i=0; i<TH9X_MAX_CURVES5; i++) {
c9x.curves[i+TH9X_MAX_CURVES3].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3].count = 5;
for (int j=0; j<5; j++) {
c9x.curves[i+TH9X_MAX_CURVES3].points[j].x = -100 + 50*i;
@@ -523,15 +324,12 @@ t_Th9xModelData::operator ModelData ()
}
}
for (int i=0; i<TH9X_MAX_CURVES9; i++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count = 5;
for (int j=0; j<9; j++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].x = -100 + 50*i;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y = curves9[i][j];
}
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];*/
return c9x;
}
-13
View File
@@ -42,8 +42,6 @@ PACK(typedef struct t_Th9xTrainerMix {
operator TrainerMix();
t_Th9xTrainerMix();
t_Th9xTrainerMix(TrainerMix&);
}) Th9xTrainerMix; //
PACK(typedef struct t_Th9xTrainerData {
@@ -52,8 +50,6 @@ PACK(typedef struct t_Th9xTrainerData {
operator TrainerData();
t_Th9xTrainerData();
t_Th9xTrainerData(TrainerData&);
}) Th9xTrainerData;
PACK(typedef struct t_Th9xGeneral {
@@ -84,8 +80,6 @@ PACK(typedef struct t_Th9xGeneral {
operator GeneralSettings();
t_Th9xGeneral();
t_Th9xGeneral(GeneralSettings&);
}) Th9xGeneral;
/*
@@ -104,7 +98,6 @@ PACK(typedef struct t_Th9xExpoData {
operator ExpoData();
t_Th9xExpoData();
t_Th9xExpoData(ExpoData&);
}) Th9xExpoData;
@@ -118,7 +111,6 @@ PACK(typedef struct t_Th9xLimitData {
operator LimitData();
t_Th9xLimitData();
t_Th9xLimitData(LimitData&);
}) Th9xLimitData;
#define MLTPX_ADD 0
@@ -144,7 +136,6 @@ PACK(typedef struct t_Th9xMixData {
operator MixData();
t_Th9xMixData();
t_Th9xMixData(MixData&);
}) Th9xMixData;
PACK(typedef struct t_Th9xCustomSwData {
@@ -156,7 +147,6 @@ PACK(typedef struct t_Th9xCustomSwData {
operator CustomSwData();
t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); }
t_Th9xCustomSwData(CustomSwData &);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Th9xCustomSwData;
@@ -187,9 +177,6 @@ PACK(typedef struct t_Th9xModelData {
Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4
operator ModelData();
t_Th9xModelData();
t_Th9xModelData(ModelData&);
}) Th9xModelData;
#endif
/*eof*/
+5 -47
View File
@@ -124,56 +124,20 @@ bool Th9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize,
int Th9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO a warning
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(Th9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Th9xModelData th9xModel(radioData.models[i]);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
return 0;
}
int Th9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xModelData th9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return -1;
}
return efile->size(0);
return 0;
}
int Th9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(settings);
int sz = efile->writeRlc2(0, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(th9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Th9xInterface::getCapability(const Capability capability)
@@ -181,12 +145,6 @@ int Th9xInterface::getCapability(const Capability capability)
switch (capability) {
case Mixes:
return TH9X_MAX_MIXERS;
case NumCurves3:
return TH9X_MAX_CURVES3;
case NumCurves5:
return TH9X_MAX_CURVES5;
case NumCurves9:
return TH9X_MAX_CURVES9;
case OwnerName:
return 0;
case Timers:
+1 -49
View File
@@ -170,22 +170,10 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->crosstrimChkB->hide();
ui->crosstrimLB->hide();
}
if (!GetEepromInterface()->getCapability(HasPPMSim)) {
if (!GetEepromInterface()->getCapability(HasPPMSim)) {
ui->PPMSimLB->hide();
ui->PPMSimChkB->hide();
}
if (GetEepromInterface()->getCapability(PerModelThrottleWarning)) {
ui->thrwarnChkB->setDisabled(true);
ui->thrwarnChkB->hide();
ui->thrwarnLabel->hide();
}
if (GetEepromInterface()->getCapability(pmSwitchMask)) {
ui->swwarn_label->hide();
ui->swtchWarnCB->hide();
ui->swtchWarnChkB->hide();
layout()->removeItem(ui->swwarn_layout);
}
if (!GetEepromInterface()->getCapability( HasPxxCountry)) {
ui->countrycode_label->hide();
ui->countrycode_CB->hide();
@@ -322,11 +310,8 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->swID0ChkB->hide();
ui->swID1ChkB->hide();
ui->swID2ChkB->hide();
ui->swtchWarnChkB->hide();
this->layout()->removeItem(ui->switchMaskLayout);
} else {
ui->swtchWarnCB->setDisabled(true);
ui->swtchWarnCB->hide();
setSwitchDefPos();
}
if (!GetEepromInterface()->getCapability(TelemetryAlarm)) {
@@ -340,12 +325,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
} else {
populateRotEncCB(ui->re_CB, g_eeGeneral.reNavigation, renumber);
}
if (GetEepromInterface()->getCapability(PerModelThrottleInvert)) {
ui->label_thrrev->hide();
ui->thrrevChkB->hide();
} else {
ui->thrrevChkB->setChecked(g_eeGeneral.throttleReversed);
}
ui->telalarmsChkB->setChecked(g_eeGeneral.enableTelemetryAlarm);
ui->PotScrollEnableChkB->setChecked(!g_eeGeneral.disablePotScroll);
ui->BandGapEnableChkB->setChecked(!g_eeGeneral.disableBG);
@@ -359,9 +338,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->StickScrollChkB->setChecked(g_eeGeneral.stickScroll);
ui->PPMSimChkB->setChecked(g_eeGeneral.enablePpmsim);
ui->inputfilterCB->setCurrentIndex(g_eeGeneral.filterInput);
ui->thrwarnChkB->setChecked(!g_eeGeneral.disableThrottleWarning); //Default is zero=checked
ui->swtchWarnChkB->setChecked(g_eeGeneral.switchWarning == -1);
ui->swtchWarnCB->setCurrentIndex(g_eeGeneral.switchWarning == -1 ? 2 : g_eeGeneral.switchWarning);
ui->memwarnChkB->setChecked(!g_eeGeneral.disableMemoryWarning); //Default is zero=checked
ui->alarmwarnChkB->setChecked(!g_eeGeneral.disableAlarmWarning);//Default is zero=checked
ui->enableTelemetryAlarmChkB->setChecked(g_eeGeneral.enableTelemetryAlarm);
@@ -622,36 +598,12 @@ void GeneralEdit::on_inactimerSB_editingFinished()
updateSettings();
}
void GeneralEdit::on_thrrevChkB_stateChanged(int )
{
g_eeGeneral.throttleReversed = ui->thrrevChkB->isChecked() ? 1 : 0;
updateSettings();
}
void GeneralEdit::on_inputfilterCB_currentIndexChanged(int index)
{
g_eeGeneral.filterInput = index;
updateSettings();
}
void GeneralEdit::on_thrwarnChkB_stateChanged(int )
{
g_eeGeneral.disableThrottleWarning = ui->thrwarnChkB->isChecked() ? 0 : 1;
updateSettings();
}
void GeneralEdit::on_swtchWarnCB_currentIndexChanged(int index)
{
g_eeGeneral.switchWarning = (index == 2 ? -1 : index);
updateSettings();
}
void GeneralEdit::on_swtchWarnChkB_stateChanged(int )
{
g_eeGeneral.switchWarning = ui->swtchWarnChkB->isChecked() ? -1 : 0;
updateSettings();
}
void GeneralEdit::on_memwarnChkB_stateChanged(int )
{
g_eeGeneral.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1;
-4
View File
@@ -123,12 +123,8 @@ private slots:
void on_channelorderCB_currentIndexChanged(int index);
void on_beeperCB_currentIndexChanged(int index);
void on_memwarnChkB_stateChanged(int );
void on_swtchWarnCB_currentIndexChanged(int index);
void on_swtchWarnChkB_stateChanged(int );
void on_telalarmsChkB_stateChanged(int );
void on_thrwarnChkB_stateChanged(int );
void on_inputfilterCB_currentIndexChanged(int index);
void on_thrrevChkB_stateChanged(int );
void on_inactimerSB_editingFinished();
void on_backlightautoSB_editingFinished();
void on_backlightswCB_currentIndexChanged(int index);
+157 -261
View File
@@ -117,6 +117,13 @@ These will be relevant for all models in the same EEPROM.</string>
<string>Setup</string>
</attribute>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0">
<item row="19" column="4">
<widget class="QCheckBox" name="PPMSimChkB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="volume_SB">
<property name="sizePolicy">
@@ -130,7 +137,7 @@ These will be relevant for all models in the same EEPROM.</string>
</property>
</widget>
</item>
<item row="29" column="3" colspan="2">
<item row="28" column="3" colspan="2">
<layout class="QHBoxLayout" name="pxxCountry">
<item>
<widget class="QLabel" name="countrycode_label">
@@ -160,13 +167,6 @@ These will be relevant for all models in the same EEPROM.</string>
</item>
</layout>
</item>
<item row="19" column="4">
<widget class="QCheckBox" name="PPMSimChkB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="mavbaud_label">
<property name="text">
@@ -174,7 +174,7 @@ These will be relevant for all models in the same EEPROM.</string>
</property>
</widget>
</item>
<item row="30" column="3" colspan="2">
<item row="29" column="3" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="VoiceLang_label">
@@ -188,49 +188,7 @@ These will be relevant for all models in the same EEPROM.</string>
</item>
</layout>
</item>
<item row="25" column="1">
<layout class="QHBoxLayout" name="swwarn_layout">
<item>
<widget class="QComboBox" name="swtchWarnCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>Switches Up</string>
</property>
</item>
<item>
<property name="text">
<string>Switches Down</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="swtchWarnChkB">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="30" column="0">
<item row="29" column="0">
<widget class="QLabel" name="units_label">
<property name="text">
<string>Measurement Units</string>
@@ -476,13 +434,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_thrrev">
<property name="text">
<string>Reverse Throttle Operation</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_HL">
<property name="text">
@@ -490,7 +441,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="32" column="1">
<item row="31" column="1">
<widget class="QComboBox" name="stickmodeCB">
<property name="toolTip">
<string/>
@@ -551,26 +502,40 @@ Mode 4:
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<item row="18" column="4">
<widget class="QCheckBox" name="crosstrimChkB">
<property name="text">
<string>Beeper Mode</string>
<string/>
</property>
</widget>
</item>
<item row="13" column="4">
<widget class="QSpinBox" name="blOnStickMoveSB">
<property name="suffix">
<string> sec</string>
<item row="12" column="0">
<widget class="QLabel" name="label_displayType">
<property name="text">
<string>LCD Display Type</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="hapticStrengthSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="13" column="3">
<widget class="QLabel" name="label_blOnStickMove">
<property name="text">
<string>BackLight On Stick Move</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QSpinBox" name="speakerPitchSB">
<property name="toolTip">
@@ -598,23 +563,37 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QCheckBox" name="thrrevChkB">
<property name="whatsThis">
<string>Reverse throttle operation.
If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well.
</string>
<item row="13" column="4">
<widget class="QSpinBox" name="blOnStickMoveSB">
<property name="suffix">
<string> sec</string>
</property>
<property name="text">
<string/>
<property name="maximum">
<number>600</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="13" column="3">
<widget class="QLabel" name="label_blOnStickMove">
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>BackLight On Stick Move</string>
<string>Beeper Mode</string>
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="label_timezone">
<property name="text">
<string>Timeshift from UTC</string>
</property>
</widget>
</item>
<item row="17" column="3">
<widget class="QLabel" name="re_label">
<property name="text">
<string>RotEnc Navigation</string>
</property>
</widget>
</item>
@@ -637,47 +616,6 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="17" column="3">
<widget class="QLabel" name="re_label">
<property name="text">
<string>RotEnc Navigation</string>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QLabel" name="label_timezone">
<property name="text">
<string>Timeshift from UTC</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="hapticStrengthSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>5</number>
</property>
</widget>
</item>
<item row="18" column="4">
<widget class="QCheckBox" name="crosstrimChkB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_displayType">
<property name="text">
<string>LCD Display Type</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="label_frskyintalarm">
<property name="text">
@@ -685,14 +623,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="thrwarnLabel">
<property name="text">
<string>Throttle Startup Warning</string>
</property>
</widget>
</item>
<item row="26" column="0" colspan="5">
<item row="25" column="0" colspan="5">
<layout class="QHBoxLayout" name="switchMaskLayout">
<item>
<widget class="QCheckBox" name="swTHRChkB">
@@ -775,7 +706,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="31" column="3" colspan="2">
<item row="30" column="3" colspan="2">
<layout class="QHBoxLayout" name="gpsFormatLayout">
<item>
<widget class="QLabel" name="gpsFormatLabel">
@@ -800,7 +731,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="29" column="1">
<item row="28" column="1">
<widget class="QCheckBox" name="faimode_CB">
<property name="toolTip">
<string>If you enable FAI, you loose the vario, the play functions, the telemetry screen. This function cannot be disabled by the radio.</string>
@@ -810,7 +741,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="32" column="4">
<item row="31" column="4">
<widget class="QComboBox" name="channelorderCB">
<property name="toolTip">
<string/>
@@ -948,48 +879,6 @@ This is used by the templated to determine which channel goes to what number out
</item>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Alarm Warning</string>
</property>
</widget>
</item>
<item row="20" column="1">
<widget class="QCheckBox" name="alarmwarnChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These will define startup warnings.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Throttle warning - will alert if the throttle is not at idle during startup&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Switch warning - will alert if switches are not in their defaul position&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Memory warning - will alert if there's not a lot of memory left&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Silent mode warning - will alert you if the beeper is set to quiet (0)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="3">
<widget class="QLabel" name="label_hideOwnerName">
<property name="text">
@@ -1046,7 +935,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="29" column="0">
<item row="28" column="0">
<widget class="QLabel" name="label_faimode">
<property name="text">
<string>FAI Mode</string>
@@ -1163,7 +1052,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="31" column="1">
<item row="30" column="1">
<widget class="QSpinBox" name="timezoneSB">
<property name="minimum">
<number>-14</number>
@@ -1176,7 +1065,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="30" column="1">
<item row="29" column="1">
<widget class="QComboBox" name="units_CB">
<item>
<property name="text">
@@ -1190,7 +1079,7 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item row="32" column="3">
<item row="31" column="3">
<widget class="QLabel" name="label_13">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@@ -1203,7 +1092,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="32" column="0">
<item row="31" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Stick Mode</string>
@@ -1247,41 +1136,6 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="20" column="4">
<widget class="QCheckBox" name="memwarnChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These will define startup warnings.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Throttle warning - will alert if the throttle is not at idle during startup&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Switch warning - will alert if switches are not in their defaul position&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Memory warning - will alert if there's not a lot of memory left&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Silent mode warning - will alert you if the beeper is set to quiet (0)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="displayTypeCB">
<item>
@@ -1345,13 +1199,6 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item row="20" column="3">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Memory Startup Warning</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QSpinBox" name="BLBright_SB">
<property name="maximum">
@@ -1532,32 +1379,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="21" column="1">
<widget class="QCheckBox" name="thrwarnChkB">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These will define startup warnings.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Throttle warning - will alert if the throttle is not at idle during startup&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Switch warning - will alert if switches are not in their defaul position&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Memory warning - will alert if there's not a lot of memory left&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Silent mode warning - will alert you if the beeper is set to quiet (0)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_soundMode">
<property name="text">
@@ -1565,7 +1386,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="33" column="0" colspan="2">
<item row="32" column="0" colspan="2">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -1684,7 +1505,7 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="27" column="0">
<item row="26" column="0">
<widget class="QLabel" name="ro_label">
<property name="text">
<string>Readonly Unlock</string>
@@ -1726,13 +1547,6 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="swwarn_label">
<property name="text">
<string>Switch Startup Warning</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@@ -1740,7 +1554,7 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="27" column="1" colspan="3">
<item row="26" column="1" colspan="3">
<layout class="QGridLayout" name="TaranisReadOnlyUnlock" rowstretch="0,0" columnstretch="0,0,0,0,0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
@@ -2268,6 +2082,90 @@ Acceptable values are 5v..10v</string>
</item>
</layout>
</item>
<item row="19" column="1">
<widget class="QCheckBox" name="alarmwarnChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These will define startup warnings.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Throttle warning - will alert if the throttle is not at idle during startup&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Switch warning - will alert if switches are not in their defaul position&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Memory warning - will alert if there's not a lot of memory left&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Silent mode warning - will alert you if the beeper is set to quiet (0)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Alarm Warning</string>
</property>
</widget>
</item>
<item row="21" column="1">
<widget class="QCheckBox" name="memwarnChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These will define startup warnings.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Throttle warning - will alert if the throttle is not at idle during startup&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Switch warning - will alert if switches are not in their defaul position&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Memory warning - will alert if there's not a lot of memory left&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Silent mode warning - will alert you if the beeper is set to quiet (0)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Memory Startup Warning</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTrainer">
@@ -3607,8 +3505,6 @@ p, li { white-space: pre-wrap; }
<tabstop>beepMinuteChkB</tabstop>
<tabstop>beepCountDownChkB</tabstop>
<tabstop>beepFlashChkB</tabstop>
<tabstop>swtchWarnCB</tabstop>
<tabstop>swtchWarnChkB</tabstop>
<tabstop>swTHRChkB</tabstop>
<tabstop>swRUDChkB</tabstop>
<tabstop>swELEChkB</tabstop>
+171 -136
View File
@@ -155,16 +155,8 @@ QString getFuncName(unsigned int val)
return QObject::tr("Background Music");
else if (val == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (val == FuncAdjustGV1)
return QObject::tr("Adjust GV1");
else if (val == FuncAdjustGV2)
return QObject::tr("Adjust GV2");
else if (val == FuncAdjustGV3)
return QObject::tr("Adjust GV3");
else if (val == FuncAdjustGV4)
return QObject::tr("Adjust GV4");
else if (val == FuncAdjustGV5)
return QObject::tr("Adjust GV5");
else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
@@ -424,7 +416,7 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGV5 ) {
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
@@ -440,7 +432,6 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign
break;
}
}
else {
b->hide();
}
@@ -480,68 +471,133 @@ void populatePhasesCB(QComboBox *b, int value)
b->setCurrentIndex(value + GetEepromInterface()->getCapability(FlightPhases));
}
void populateCurvesCB(QComboBox *b, int value)
CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags):
QObject(),
curveTypeCB(curveTypeCB),
curveGVarCB(curveGVarCB),
curveValueCB(curveValueCB),
curveValueSB(curveValueSB),
curve(curve),
flags(flags),
lock(false),
lastType(-1)
{
b->clear();
int numcurves=GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
}
for (int i = -(numcurves)*GetEepromInterface()->getCapability(HasNegCurves); i < CURVE_BASE + numcurves; i++) {
if ((i==0) && GetEepromInterface()->getCapability(DiffMixers)) {
b->addItem(QObject::tr("Diff"));
} else {
b->addItem(getCurveStr(i));
}
}
b->setCurrentIndex(value+numcurves*GetEepromInterface()->getCapability(HasNegCurves));
b->setMaxVisibleItems(10);
curveTypeCB->addItem(tr("Diff"));
curveTypeCB->addItem(tr("Expo"));
curveTypeCB->addItem(tr("Func"));
curveTypeCB->addItem(tr("Curve"));
curveValueCB->setMaxVisibleItems(10);
connect(curveTypeCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(curveGVarCB, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
connect(curveValueCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(curveValueSB, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
update();
}
void populateExpoCurvesCB(QComboBox *b, int value)
void CurveGroup::update()
{
b->clear();
int numcurves=GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
}
if (GetEepromInterface()->getCapability(ExpoIsCurve)) {
b->addItem(QObject::tr("Expo"));
} else {
b->addItem(getCurveStr(0));
}
for (int i = 1; i < CURVE_BASE + numcurves; i++)
b->addItem(getCurveStr(i));
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
/* TODO
if (GetEepromInterface()->getCapability(ExpoCurve5)) {
int curve5=GetEepromInterface()->getCapability(ExpoCurve5);
for (int i=CURVE_BASE+curve5; i < CURVE_BASE + MAX_CURVE5; i++) {
// Get the index of the value to disable
QModelIndex index = b->model()->index(i, 0);
lock = true;
// This is the effective 'disable' flag
QVariant v(0);
curveTypeCB->setCurrentIndex(curve.type);
//the magic
b->model()->setData(index, v, Qt::UserRole - 1);
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
curveGVarCB->show();
if (curve.value > 100 || curve.value < -100) {
curveGVarCB->setChecked(true);
if (lastType != CurveReference::CURVE_REF_DIFF && lastType != CurveReference::CURVE_REF_EXPO) {
lastType = curve.type;
populateGVCB(curveValueCB, curve.value);
}
curveValueCB->show();
curveValueSB->hide();
}
else {
curveGVarCB->setChecked(false);
curveValueSB->setMinimum(-100);
curveValueSB->setMaximum(100);
curveValueSB->setValue(curve.value);
curveValueSB->show();
curveValueCB->hide();
}
}
if (GetEepromInterface()->getCapability(ExpoCurve9)) {
int curve9=GetEepromInterface()->getCapability(ExpoCurve9);
for (int i=CURVE_BASE+MAX_CURVE5+curve9; i < CURVE_BASE + MAX_CURVE5+ MAX_CURVE9; i++) {
// Get the index of the value to disable
QModelIndex index = b->model()->index(i, 0);
// This is the effective 'disable' flag
QVariant v(0);
//the magic
b->model()->setData(index, v, Qt::UserRole - 1);
else {
curveGVarCB->hide();
curveValueSB->hide();
curveValueCB->show();
switch (curve.type) {
case CurveReference::CURVE_REF_FUNC:
if (lastType != curve.type) {
lastType = curve.type;
curveValueCB->clear();
for (int i=0; i<=6/*TODO constant*/; i++) {
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_FUNC, i).toString());
}
}
curveValueCB->setCurrentIndex(curve.value);
break;
case CurveReference::CURVE_REF_CUSTOM:
{
int numcurves = GetEepromInterface()->getCapability(NumCurves);
if (lastType != curve.type) {
lastType = curve.type;
curveValueCB->clear();
for (int i=-numcurves; i<numcurves; i++) {
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, i).toString());
}
}
curveValueCB->setCurrentIndex(curve.value+numcurves);
break;
}
default:
break;
}
}
*/
lock = false;
}
void CurveGroup::gvarCBChanged(int state)
{
if (!lock) {
if (state) {
curve.value = 10000; // TODO constant in EEpromInterface ...
}
else {
curve.value = 0; // TODO could be better
}
update();
}
}
void CurveGroup::valuesChanged()
{
if (!lock) {
switch (curveTypeCB->currentIndex()) {
case 0:
case 1:
{
int value;
if (curveGVarCB->isChecked())
value = curveValueCB->itemData(curveValueCB->currentIndex()).toInt();
else
value = curveValueSB->value();
curve = CurveReference(curveTypeCB->currentIndex() == 0 ? CurveReference::CURVE_REF_DIFF : CurveReference::CURVE_REF_EXPO, value);
break;
}
case 2:
curve = CurveReference(CurveReference::CURVE_REF_FUNC, curveValueCB->currentIndex());
break;
case 3:
curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, curveValueCB->currentIndex() - GetEepromInterface()->getCapability(NumCurves));
break;
}
update();
}
}
void populateTrimUseCB(QComboBox *b, unsigned int phase)
@@ -560,73 +616,29 @@ void populateTrimUseCB(QComboBox *b, unsigned int phase)
void populateGvarUseCB(QComboBox *b, unsigned int phase)
{
b->addItem(QObject::tr("Own value"));
unsigned int num_phases = GetEepromInterface()->getCapability(FlightPhases);
if (num_phases>0) {
for (unsigned int i = 0; i < num_phases; i++) {
if (i != phase) {
b->addItem(QObject::tr("Flight mode %1 value").arg(i));
}
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (i != (int)phase) {
b->addItem(QObject::tr("Flight mode %1 value").arg(i));
}
}
}
void populateTimerSwitchCB(QComboBox *b, int value, int extrafields)
void populateTimerSwitchCB(QComboBox *b, int value)
{
b->clear();
uint8_t endvalue=128;
uint8_t count=0;
if (extrafields==2)
endvalue=192;
for (int i=-128; i<endvalue; i++) {
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);
if (extrafields==2 && (i<0 || (i>3 && i <TMRMODE_FIRST_CHPERC))) {
QModelIndex index = b->model()->index(count, 0);
// This is the effective 'disable' flag
QVariant v(0);
//the magic
b->model()->setData(index, v, Qt::UserRole - 1);
}
count++;
}
}
b->setMaxVisibleItems(10);
}
void populateTimerSwitchBCB(QComboBox *b, int value, int extrafields)
{
b->clear();
if (extrafields!=2) {
int startvalue=-128;
int endvalue=128;
if (extrafields==1) {
startvalue=-25;
endvalue=26;
}
for (int i=startvalue; i<endvalue; i++) {
QString timerMode = getTimerMode(i);
if (!timerMode.isEmpty()) {
b->addItem(getTimerMode(i), i);
if (i==value)
b->setCurrentIndex(b->count()-1);
}
}
} else {
for (int i=-33; i<66; i++) {
QString timerMode = getTimerModeB(i);
if (!timerMode.isEmpty()) {
b->addItem(timerMode, i);
if (i==value)
b->setCurrentIndex(b->count()-1);
}
}
}
b->setMaxVisibleItems(10);
}
QString getTimerMode(int tm) {
QString stt = "OFFABSTHsTH%THt";
@@ -868,8 +880,10 @@ void populateGVCB(QComboBox *b, int value)
{
int selected=0;
int nullitem;
b->clear();
int pgvars=GetEepromInterface()->getCapability(GvarsOfsNum);
int pgvars = GetEepromInterface()->getCapability(Gvars);
for (int i=-pgvars; i<=-1; i++) {
int16_t gval = (int16_t)(-10000+i);
b->addItem(QObject::tr("-GV%1").arg(-i), gval);
@@ -878,12 +892,15 @@ void populateGVCB(QComboBox *b, int value)
selected=1;
}
}
b->addItem("---", 0);
nullitem=b->count()-1;
if (value == 0) {
b->setCurrentIndex(b->count()-1);
selected=1;
}
for (int i=1; i<=pgvars; i++) {
int16_t gval = (int16_t)(10000+i);
b->addItem(QObject::tr("GV%1").arg(i), gval);
@@ -892,6 +909,7 @@ void populateGVCB(QComboBox *b, int value)
selected=1;
}
}
if (selected==0)
b->setCurrentIndex(nullitem);
}
@@ -983,7 +1001,7 @@ void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags)
}
if (flags & POPULATE_GVARS) {
for (int i=0; i<GetEepromInterface()->getCapability(GvarsNum); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(Gvars); i++) {
item = RawSource(SOURCE_TYPE_GVAR, i);
b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@@ -1061,25 +1079,20 @@ QString getSignedStr(int value)
return value > 0 ? QString("+%1").arg(value) : QString("%1").arg(value);
}
QString getCurveStr(int curve)
{
QString crvStr = "!c16!c15!c14!c13!c12!c11!c10!c9 !c8 !c7 !c6 !c5 !c4 !c3 !c2 !c1 ----x>0 x<0 |x| f>0 f<0 |f| c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 ";
return crvStr.mid((curve+C9X_MAX_CURVES) * 4, 4).remove(' ').replace("c", QObject::tr("Curve") + " ");
}
QString getGVarString(int16_t val, bool sign)
{
if (val >= -10000 && val <= 10000)
if (val >= -10000 && val <= 10000) {
if (sign)
return QString("(%1%)").arg(getSignedStr(val));
return QString("%1%").arg(getSignedStr(val));
else
return QString("(%1%)").arg(val);
else
if (val<0) {
return QObject::tr("(-GV%1)").arg(-val-10000);
} else {
return QObject::tr("(GV%1)").arg(val-10000);
}
return QString("%1%").arg(val);
}
else {
if (val<0)
return QObject::tr("-GV%1").arg(-val-10000);
else
return QObject::tr("GV%1").arg(val-10000);
}
}
QString image2qstring(QImage image)
@@ -1141,12 +1154,6 @@ int findmult(float value, float base)
return mult;
}
bool checkbit(int value, int bit)
{
return ((value & (1<<bit))==(1<<bit));
}
QString getFrSkyAlarmType(int alarm)
{
switch (alarm) {
@@ -1344,6 +1351,34 @@ QString getProtocol(ModelData * g_model)
return str;
}
QString getPhasesStr(unsigned int phases, ModelData & model)
{
int numphases = GetEepromInterface()->getCapability(FlightPhases);
if (numphases && phases) {
QString str;
int count = 0;
if (phases == (unsigned int)(1<<numphases) - 1) {
str = QObject::tr("None");
}
if (phases) {
for (int i=0; i<numphases;i++) {
if (!(phases & (1<<i))) {
if (count++ > 0) str += QString(", ");
str += getPhaseName(i+1, model.phaseData[i].name);
}
}
}
if (count > 1)
return QObject::tr("Flight modes(%1)").arg(str);
else
return QObject::tr("Flight mode(%1)").arg(str);
}
else {
return "";
}
}
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
+29 -9
View File
@@ -6,10 +6,10 @@
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1)
//convert from mode 1 to mode g_eeGeneral.stickMode
//convert from mode 1 to mode generalSettings.stickMode
//NOTICE! => 1..4 -> 1..4
#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[g_eeGeneral.stickMode][((x)-1)] : (x))
#define CHANNEL_ORDER(x) (chout_ar[g_eeGeneral.templateSetup*4 + (x)-1])
#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x))
#define CHANNEL_ORDER(x) (chout_ar[generalSettings.templateSetup*4 + (x)-1])
#define CURVE_BASE 7
#define CH(x) (SRC_CH1+(x)-1-(SRC_SWC-SRC_3POS))
@@ -29,6 +29,29 @@ void populateTTraceCB(QComboBox *b, int value);
void populateRotEncCB(QComboBox *b, int value, int renumber);
void populateBacklightCB(QComboBox *b, const uint8_t value);
class CurveGroup : public QObject {
Q_OBJECT
public:
CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags=0);
void update();
protected slots:
void gvarCBChanged(int);
void valuesChanged();
protected:
QComboBox *curveTypeCB;
QCheckBox *curveGVarCB;
QComboBox *curveValueCB;
QSpinBox *curveValueSB;
CurveReference & curve;
unsigned int flags;
bool lock;
int lastType;
};
#define POPULATE_ONOFF 0x01
#define POPULATE_MSWITCHES 0x02
#define POPULATE_AND_SWITCHES 0x04
@@ -42,13 +65,11 @@ void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QS
void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCurvesCB(QComboBox *b, int value);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateExpoCurvesCB(QComboBox *b, int value);
void populateTimerSwitchCB(QComboBox *b, int value, int extrafields=0);
void populateTimerSwitchBCB(QComboBox *b, int value, int extrafields=0);
void populateTimerSwitchCB(QComboBox *b, int value);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model);
#define POPULATE_SOURCES 1
#define POPULATE_TRIMS 2
@@ -72,12 +93,10 @@ QString getCSWFunc(int val);
QString getFuncName(unsigned int val);
QString getRepeatString(unsigned int val);
QString getSignedStr(int value);
QString getCurveStr(int curve);
QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image);
QImage qstring2image(QString imagestr);
int findmult(float value, float base);
bool checkbit(int value, int bit);
QString getTrimInc(ModelData * g_model);
QString getTimerStr(TimerData & timer);
@@ -95,4 +114,5 @@ float getBarValue(int barId, int value, FrSkyData *fd);
float c9xexpou(float point, float coeff);
float ValToTim(int value);
int TimToVal(float value);
#endif // HELPERS_H
+13 -13
View File
@@ -77,10 +77,10 @@ class MyProxyStyle : public QProxyStyle
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(companion9x);
QApplication app(argc, argv);
app.setApplicationName("Companion9x");
QApplication * app = new QApplication(argc, argv);
app->setApplicationName("Companion9x");
#ifdef __APPLE__
app.setStyle(new MyProxyStyle);
app->setStyle(new MyProxyStyle);
#endif
QString dir;
if(argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";
@@ -95,20 +95,20 @@ int main(int argc, char *argv[])
qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
// qDebug() << locale;
// qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&companion9xTranslator);
app.installTranslator(&qtTranslator);
app->installTranslator(&companion9xTranslator);
app->installTranslator(&qtTranslator);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
firmware_id.replace("open9x", "opentx");
firmware_id.replace("x9da", "taranis");
QPixmap pixmap;
QPixmap * pixmap;
if (firmware_id.contains("taranis"))
pixmap = QPixmap(":/images/splasht.png");
pixmap = new QPixmap(":/images/splasht.png");
else
pixmap = QPixmap(":/images/splash.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
pixmap = new QPixmap(":/images/splash.png");
QSplashScreen *splash = new QSplashScreen(*pixmap);
RegisterFirmwares();
@@ -116,15 +116,15 @@ int main(int argc, char *argv[])
current_firmware_variant = GetFirmwareVariant(firmware_id);
// qDebug() << current_firmware_variant;
MainWindow mainWin;
MainWindow * mainWin = new MainWindow();
if (showSplash) {
splash->show();
QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
QTimer::singleShot(1000*SPLASH_TIME, &mainWin, SLOT(show()));
QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));
}
else {
mainWin.show();
mainWin->show();
}
return app.exec();
return app->exec();
}
+1 -1
View File
@@ -59,7 +59,7 @@
#include "burndialog.h"
#include "hexinterface.h"
#include "warnings.h"
#include "firmwares/opentx/open9xinterface.h" // TODO get rid of this include
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
#ifdef __APPLE__
+13 -10
View File
@@ -44,7 +44,7 @@
#include "xmlinterface.h"
#include "hexinterface.h"
#include "mainwindow.h"
#include "modeledit.h"
#include "modeledit/modeledit.h"
#include "generaledit.h"
#include "avroutputdialog.h"
#include "burnconfigdialog.h"
@@ -144,13 +144,16 @@ void MdiChild::on_SimulateTxButton_clicked()
{
if (GetEepromInterface()->getSimulator()) {
if (GetEepromInterface()->getCapability(SimulatorType)==1) {
xsimulatorDialog sd(this);
sd.loadParams(radioData);
sd.exec();
} else {
simulatorDialog sd(this);
sd.loadParams(radioData);
sd.exec();
xsimulatorDialog * sd = new xsimulatorDialog(this);
sd->loadParams(radioData);
sd->exec();
delete sd;
}
else {
simulatorDialog * sd = new simulatorDialog(this);
sd->loadParams(radioData);
sd->exec();
delete sd;
}
}
else {
@@ -192,9 +195,9 @@ void MdiChild::OpenEditWindow(bool wizard=false)
}
}
ModelEdit *t = new ModelEdit(radioData, (row - 1), wizard, this);
if (isNew && !wizard) t->applyBaseTemplate();
// TODO if (isNew && !wizard) t->applyBaseTemplate();
t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name);
connect(t, SIGNAL(modelValuesChanged()), this, SLOT(setModified()));
connect(t, SIGNAL(modified()), this, SLOT(setModified()));
//t->exec();
t->show();
}
+2 -2
View File
@@ -9,7 +9,7 @@ modelConfigDialog::modelConfigDialog(RadioData &radioData, uint64_t * result, QW
ui(new Ui::modelConfigDialog),
radioData(radioData),
result(result),
g_eeGeneral(radioData.generalSettings)
generalSettings(radioData.generalSettings)
{
ui->setupUi(this);
rxLock=false;
@@ -930,4 +930,4 @@ void modelConfigDialog::asUpdate()
ui->asspo2_CB->hide();
}
rxLock=false;
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ private:
int ModelType;
RadioData &radioData;
uint64_t * result;
GeneralSettings g_eeGeneral;
GeneralSettings generalSettings;
QStringList ruddercolor;
QStringList aileroncolor;
QStringList elevatorcolor;
File diff suppressed because it is too large Load Diff
-393
View File
@@ -1,393 +0,0 @@
#ifndef MODELEDIT_H
#define MODELEDIT_H
#include <QDialog>
#include <QtGui>
#include <QPen>
#include "eeprominterface.h"
#include "mixerslist.h"
#ifdef PHONON
#include <phonon/audiooutput.h>
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#endif
namespace Ui {
class ModelEdit;
}
class ModelEdit : public QDialog
{
Q_OBJECT
public:
explicit ModelEdit(RadioData &radioData, uint8_t id , bool openWizard =false, bool inNew =false, QWidget *parent = 0);
~ModelEdit();
void applyBaseTemplate();
bool redrawCurve;
void drawCurve();
bool drawing;
bool mixInserted;
bool expoInserted;
bool openWizard;
bool isNew;
private:
Ui::ModelEdit *ui;
QSpinBox* spny[17];
QSpinBox* spnx[17];
QSpinBox* gvarsSB[9][5];
QSpinBox* reSB[9][2];
QGroupBox* barsGB[3];
QGroupBox* numsGB[3];
QComboBox* barsCB[12];
QDoubleSpinBox* minSB[12];
QDoubleSpinBox* maxSB[12];
QComboBox* csf[36];
QComboBox* csw[C9X_NUM_CSW];
MixersList *ExposlistWidget;
MixersList *MixerlistWidget;
RadioData &radioData;
int id_model;
ModelData g_model;
GeneralSettings g_eeGeneral;
bool protocolEditLock;
bool protocol2EditLock;
bool trainerEditLock;
bool switchEditLock;
bool heliEditLock;
bool limitEditLock;
bool phasesLock;
bool telemetryLock;
bool curvesLock;
bool phononLock;
bool fsLock;
bool modelImageLock;
bool plot_curve[16];
int selectedSwitch;
int selectedFunction;
QDoubleSpinBox * cswitchValue[C9X_NUM_CSW];
QDoubleSpinBox * cswitchOffset[C9X_NUM_CSW];
QComboBox * cswitchAnd[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDuration[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDelay[C9X_NUM_CSW];
QComboBox * cswitchSource1[C9X_NUM_CSW];
QComboBox * cswitchSource2[C9X_NUM_CSW];
QLabel * fswLabel[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS];
QDoubleSpinBox * fswtchParam[C9X_MAX_CUSTOM_FUNCTIONS];
QPushButton * playBT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
QSpinBox * safetySwitchValue[C9X_NUM_CHNOUT];
QComboBox * safetySwitchSwtch[C9X_NUM_CHNOUT];
QSlider * phasesTrimSliders[9][4];
QSpinBox * phasesTrimValues[9][4];
void setupExposListWidget();
void setupMixerListWidget();
float getBarStep(int barId);
void telBarUpdate();
void updateSettings();
void tabModelEditSetup();
void tabPhases();
void tabExpos();
void tabMixes();
void tabHeli();
void tabLimits();
void tabCurves();
void tabCustomSwitches();
void tabSafetySwitches();
void tabCustomFunctions();
void tabTelemetry();
void tabTemplates();
void updateCurvesTab();
void setSwitchWidgetVisibility(int i);
void setLimitMinMax();
void updateSelectedSwitch();
void updateSwitchesTab();
void updateHeliTab();
void updateA1Fields();
void updateA2Fields();
void launchSimulation();
void resizeEvent(QResizeEvent *event = 0);
int currentCurve;
void setCurrentCurve(int curveId);
QSpinBox *getNodeSB(int i);
QSpinBox *getNodeSBX(int i);
int getExpoIndex(unsigned int dch);
bool gm_insertExpo(int idx);
void gm_deleteExpo(int index);
void gm_openExpo(int index);
int gm_moveExpo(int idx, bool dir);
void exposDeleteList(QList<int> list);
QList<int> createExpoListFromSelected();
void setSelectedByExpoList(QList<int> list);
int getMixerIndex(unsigned int dch);
bool gm_insertMix(int idx);
void gm_deleteMix(int index);
void gm_openMix(int index);
int gm_moveMix(int idx, bool dir);
void mixersDeleteList(QList<int> list);
QList<int> createMixListFromSelected();
void setSelectedByMixList(QList<int> list);
void applyTemplate(uint8_t idx);
void applyNumericTemplate(uint64_t tpl);
MixData* setDest(uint8_t dch);
void setCurve(uint8_t c, int8_t ar[]);
void setSwitch(unsigned int idx, unsigned int func, int v1, int v2);
void on_phaseSwitch_currentIndexChanged(unsigned int phase, int index);
void on_phaseFadeIn_valueChanged(unsigned int phase, int value);
void on_phaseFadeOut_valueChanged(unsigned int phase, int value);
void on_phaseTrim_valueChanged(unsigned int phase, unsigned int stick, int value);
void on_phaseTrimUse_currentIndexChanged(unsigned int phase, unsigned int stick, int index, QSpinBox *trim, QSlider *slider);
void displayOnePhaseOneTrim(unsigned int phase_idx, unsigned int trim_idx, QComboBox *trimUse, QSpinBox *trimVal, QSlider *trimSlider);
void displayOnePhase(unsigned int phase_idx, QLineEdit *name, QComboBox *sw, QDoubleSpinBox *fadeIn, QDoubleSpinBox *fadeOut, QComboBox *trim1Use, QSpinBox *trim1, QLabel *trim1Label, QSlider *trim1Slider, QComboBox *trim2Use, QSpinBox *trim2, QLabel *trim2Label, QSlider *trim2Slider, QComboBox *trim3Use, QSpinBox *trim3, QLabel *trim3Label, QSlider *trim3Slider, QComboBox *trim4Use, QSpinBox *trim4, QLabel *trim4Label, QSlider *trim4Slider, QLabel *gv1Label, QComboBox *gv1Use,QSpinBox *gv1Value, QLabel *gv2Label, QComboBox *gv2Use,QSpinBox *gv2Value, QLabel *gv3Label, QComboBox *gv3Use,QSpinBox *gv3Value, QLabel *gv4Label, QComboBox *gv4Use,QSpinBox *gv4Value, QLabel *gv5Label, QComboBox *gv5Use,QSpinBox *gv5Value, QLabel *re1Label, QComboBox *re1Use,QSpinBox *re1Value, QLabel *re2Label, QComboBox *re2Use,QSpinBox *re2Value,bool doConnect);
void incSubtrim(uint8_t idx, int16_t inc);
#ifdef PHONON
Phonon::MediaObject *clickObject;
Phonon::AudioOutput *clickOutput;
#endif
signals:
void modelValuesChanged();
private slots:
void clearExpos(bool ask=true);
void clearMixes(bool ask=true);
void clearCurves(bool ask=true);
void on_modelVoice_SB_editingFinished();
void on_T2ThrTrgChkB_toggled(bool checked);
void on_ttraceCB_currentIndexChanged(int index);
void on_instantTrim_CB_currentIndexChanged(int index);
void on_extendedLimitsChkB_toggled(bool checked);
void on_extendedTrimsChkB_toggled(bool checked);
void on_thrwarnChkB_toggled(bool checked);
void on_thrrevChkB_toggled(bool checked);
void on_timer1Perm_toggled(bool checked);
void on_timer2Perm_toggled(bool checked);
void on_timer1Minute_toggled(bool checked);
void on_timer2Minute_toggled(bool checked);
void on_timer1CountDownBeep_toggled(bool checked);
void on_timer2CountDownBeep_toggled(bool checked);
void fssldEdited();
void fssbEdited();
void fssldValueChanged();
void fssbValueChanged();
void resetCurve();
void editCurve();
void playMusic();
#ifdef PHONON
void mediaPlayer_state(Phonon::State newState, Phonon::State oldState);
#endif
void plotCurve(bool checked);
//phases slots
void phaseName_editingFinished();
void phaseSwitch_currentIndexChanged();
void phaseFadeIn_editingFinished();
void phaseFadeOut_editingFinished();
void phaseTrimUse_currentIndexChanged();
void phaseTrim_valueChanged();
void phaseTrimSlider_valueChanged();
void GVName_editingFinished();
void GVSource_currentIndexChanged();
void phaseGVValue_editingFinished();
void phaseGVUse_currentIndexChanged();
void phaseREValue_editingFinished();
void phaseREUse_currentIndexChanged();
void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action);
void pasteMixerMimeData(const QMimeData * mimeData, int destIdx);
void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action);
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
void on_pushButton_clicked();
void exposDelete(bool ask=true);
void exposCut();
void exposCopy();
void exposPaste();
void exposDuplicate();
void expoOpen(QListWidgetItem *item = NULL);
void expoAdd();
void cswDelete();
void cswCopy();
void cswPaste();
void cswCut();
void fswDelete();
void fswCopy();
void fswPaste();
void fswCut();
void moveExpoUp();
void moveExpoDown();
void mixersDelete(bool ask=true);
void mixersCut();
void mixersCopy();
void mixersPaste();
void mixersDuplicate();
void mixerOpen();
void mixerAdd();
void moveMixUp();
void moveMixDown();
void expolistWidget_customContextMenuRequested(QPoint pos);
void expolistWidget_doubleClicked(QModelIndex index);
void expolistWidget_KeyPress(QKeyEvent *event);
void mixerlistWidget_customContextMenuRequested(QPoint pos);
void mixerlistWidget_doubleClicked(QModelIndex index);
void mixerlistWidget_KeyPress(QKeyEvent *event);
void csw_customContextMenuRequested(QPoint pos);
void fsw_customContextMenuRequested(QPoint pos);
void curvePointEdited();
void on_ca_ctype_CB_currentIndexChanged();
void on_ca_apply_PB_clicked();
void on_cname_LE_editingFinished();
void limitOffsetEdited();
void limitSymEdited();
void limitEdited();
void limitNameEdited();
void limitInvEdited();
void ppmcenterEdited();
void customSwitchesEdited();
void safetySwitchesEdited();
void customFunctionEdited();
void refreshCustomFunction(int index, bool modified=false);
void startupSwitchEdited();
void exposEdited();
void mixesEdited();
void heliEdited();
void on_bcRUDChkB_toggled(bool checked);
void on_bcELEChkB_toggled(bool checked);
void on_bcTHRChkB_toggled(bool checked);
void on_bcAILChkB_toggled(bool checked);
void on_bcP1ChkB_toggled(bool checked);
void on_bcP2ChkB_toggled(bool checked);
void on_bcP3ChkB_toggled(bool checked);
void on_bcP4ChkB_toggled(bool checked);
void on_bcREaChkB_toggled(bool checked);
void on_bcREbChkB_toggled(bool checked);
void on_thrExpoChkB_toggled(bool checked);
void on_thrTrimChkB_toggled(bool checked);
void on_a1UnitCB_currentIndexChanged(int index);
void on_a2UnitCB_currentIndexChanged(int index);
void on_a1RatioSB_editingFinished();
void on_a1RatioSB_valueChanged();
void on_a1CalibSB_editingFinished();
void on_a11LevelCB_currentIndexChanged(int index);
void on_a11GreaterCB_currentIndexChanged(int index);
void on_a11ValueSB_editingFinished();
void on_a12LevelCB_currentIndexChanged(int index);
void on_a12GreaterCB_currentIndexChanged(int index);
void on_a12ValueSB_editingFinished();
void on_a2RatioSB_editingFinished();
void on_a2RatioSB_valueChanged();
void on_a2CalibSB_editingFinished();
void on_a21LevelCB_currentIndexChanged(int index);
void on_a21GreaterCB_currentIndexChanged(int index);
void on_a21ValueSB_editingFinished();
void on_a22LevelCB_currentIndexChanged(int index);
void on_a22GreaterCB_currentIndexChanged(int index);
void on_a22ValueSB_editingFinished();
void on_frskyProtoCB_currentIndexChanged(int index);
void on_frskyUnitsCB_currentIndexChanged(int index);
void on_frskyBladesCB_currentIndexChanged(int index);
void on_frskyCurrentCB_currentIndexChanged(int index);
void on_frskyVoltCB_currentIndexChanged(int index);
void on_AltitudeToolbar_ChkB_toggled(bool checked);
void on_rssiAlarm1CB_currentIndexChanged(int index);
void on_rssiAlarm2CB_currentIndexChanged(int index);
void on_rssiAlarm1SB_editingFinished();
void on_rssiAlarm2SB_editingFinished();
void on_AltitudeGPS_ChkB_toggled(bool checked);
void on_showNames_Ckb_toggled(bool checked);
void on_varioSourceCB_currentIndexChanged(int index);
void on_varioLimitMin_DSB_editingFinished();
void on_varioLimitMax_DSB_editingFinished();
void on_varioLimitCenterMin_DSB_editingFinished();
void on_varioLimitMinOff_ChkB_toggled(bool checked);
void on_varioLimitCenterMax_DSB_editingFinished();
void telBarCBcurrentIndexChanged(int index);
void ScreenTypeCBcurrentIndexChanged(int index);
void telMaxSBeditingFinished();
void telMinSBeditingFinished();
void customFieldEdited();
void on_ppmDelaySB_editingFinished();
void on_ppmDelaySB_2_editingFinished();
void on_ppmDelaySB_3_editingFinished();
void on_numChannelsSB_editingFinished();
void on_numChannelsSB_2_editingFinished();
void on_numChannelsSB_3_editingFinished();
void on_numChannelsStart_editingFinished();
void on_numChannelsStart_2_editingFinished();
void on_numChannelsStart_3_editingFinished();
// void void ModelEdit::on_numChannelsStart_3_editingFinished();
void on_protocolCB_currentIndexChanged(int index);
void on_protocolCB_2_currentIndexChanged(int index);
void on_protocolCB_3_currentIndexChanged(int index);
void on_pulsePolCB_currentIndexChanged(int index);
void on_pulsePolCB_2_currentIndexChanged(int index);
void on_pulsePolCB_3_currentIndexChanged(int index);
void on_ppmFrameLengthDSB_editingFinished();
void on_ppmFrameLengthDSB_2_editingFinished();
void on_ppmFrameLengthDSB_3_editingFinished();
void on_DSM_Type_currentIndexChanged(int index);
void on_DSM_Type_2_currentIndexChanged(int index);
void on_pxxRxNum_editingFinished();
void on_pxxRxNum_2_editingFinished();
void on_fsm1CB_currentIndexChanged(int index);
void on_fsm2CB_currentIndexChanged(int index);
// TODO void on_trimSWCB_currentIndexChanged(int index);
void on_trimIncCB_currentIndexChanged(int index);
void on_timer1DirCB_currentIndexChanged(int index);
void on_timer1ModeCB_currentIndexChanged(int index);
void on_timer1ValTE_editingFinished();
void on_timer1ModeBCB_currentIndexChanged(int index);
void on_timer2DirCB_currentIndexChanged(int index);
void on_timer2ModeCB_currentIndexChanged(int index);
void on_timer2ValTE_editingFinished();
void on_timer2ModeBCB_currentIndexChanged(int index);
void on_modelNameLE_editingFinished();
void on_modelImage_CB_currentIndexChanged(int index);
void on_phases_currentChanged(int index);
void on_tabWidget_currentChanged(int index);
void on_templateList_doubleClicked(QModelIndex index);
void ControlCurveSignal(bool flag);
void shrink();
void wizard();
void closeEvent(QCloseEvent *event);
void on_curvetype_CB_currentIndexChanged(int index);
};
#endif // MODELEDIT_H
File diff suppressed because it is too large Load Diff
+56
View File
@@ -0,0 +1,56 @@
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(modeledit_NAMES
modeledit
setup
heli
curves
telemetry
expodialog
mixerdialog
)
set(modeledit_SRCS
modelpanel.cpp
flightmodes.cpp
inputs.cpp
mixes.cpp
channels.cpp
customswitches.cpp
customfunctions.cpp
# templates.cpp
mixerslist.cpp
node.cpp
edge.cpp
)
set(modeledit_HDRS
modelpanel.h
flightmodes.h
inputs.h
mixes.h
channels.h
customswitches.h
customfunctions.h
# templates.h
mixerslist.h
node.h
)
set(modeledit_UIS
setup_timer.ui
setup_module.ui
flightmode.ui
telemetry_analog.ui
)
foreach(name ${modeledit_NAMES})
set(modeledit_SRCS ${modeledit_SRCS} ${name}.cpp)
set(modeledit_HDRS ${modeledit_HDRS} ${name}.h)
set(modeledit_UIS ${modeledit_UIS} ${name}.ui)
endforeach()
qt4_wrap_ui(modeledit_SRCS ${modeledit_UIS})
qt4_wrap_cpp(modeledit_SRCS ${modeledit_HDRS})
add_library(modeledit ${modeledit_SRCS})
+179
View File
@@ -0,0 +1,179 @@
#include "channels.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
Channels::Channels(QWidget * parent, ModelData & model):
ModelPanel(parent, model)
{
QGridLayout * gridLayout = new QGridLayout(this);
int col = 1;
if (GetEepromInterface()->getCapability(ChannelsName))
addLabel(gridLayout, tr("Name"), col++);
addLabel(gridLayout, tr("Offset"), col++);
addLabel(gridLayout, tr("Min"), col++);
addLabel(gridLayout, tr("Max"), col++);
addLabel(gridLayout, tr("Invert"), col++);
if (GetEepromInterface()->getCapability(PPMCenter))
addLabel(gridLayout, tr("Center"), col++);
if (GetEepromInterface()->getCapability(SYMLimits))
addLabel(gridLayout, tr("Sym"), col++);
for (int i=0; i<GetEepromInterface()->getCapability(Outputs); i++) {
col = 0;
// Channel label
QLabel *label = new QLabel(this);
label->setText(tr("Channel %1").arg(i+1));
gridLayout->addWidget(label, i+1, col++, 1, 1);
// Channel name
int nameLen = GetEepromInterface()->getCapability(ChannelsName);
if (nameLen > 0) {
QLineEdit * name = new QLineEdit(this);
name->setProperty("index", i);
name->setMaxLength(nameLen);
QRegExp rx(CHAR_FOR_NAMES_REGEX);
name->setValidator(new QRegExpValidator(rx, this));
name->setText(model.limitData[i].name);
connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited()));
gridLayout->addWidget(name, i+1, col++, 1, 1);
}
// Channel offset
QDoubleSpinBox * offset = new QDoubleSpinBox(this);
offset->setProperty("index", i);
offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
offset->setAccelerated(true);
offset->setDecimals(1);
offset->setMinimum(-100);
offset->setSingleStep(0.1);
offset->setValue(float(model.limitData[i].offset) / 10);
connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
gridLayout->addWidget(offset, i+1, col++, 1, 1);
// Channel min
QSpinBox * minSB = new QSpinBox(this);
minSB->setProperty("index", i);
minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
minSB->setAccelerated(true);
minSB->setMinimum(model.extendedLimits ? -125 : -100);
minSB->setMaximum(0);
minSB->setValue(model.limitData[i].min);
connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
gridLayout->addWidget(minSB, i+1, col++, 1, 1);
// Channel max
QSpinBox * maxSB = new QSpinBox(this);
maxSB->setProperty("index", i);
maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxSB->setAccelerated(true);
maxSB->setMinimum(0);
maxSB->setMaximum(model.extendedLimits ? 125 : 100);
maxSB->setValue(model.limitData[i].max);
connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
// Channel inversion
QComboBox * invCB = new QComboBox(this);
invCB->insertItems(0, QStringList() << tr("---") << tr("INV"));
invCB->setProperty("index", i);
invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0);
connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited()));
gridLayout->addWidget(invCB, i+1, col++, 1, 1);
// PPM center
if (GetEepromInterface()->getCapability(PPMCenter)) {
QSpinBox * center = new QSpinBox(this);
center->setProperty("index", i);
center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
center->setMinimum(1375);
center->setMaximum(1625);
center->setValue(1500);
center->setValue(model.limitData[i].ppmCenter + 1500);
connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited()));
gridLayout->addWidget(center, i+1, col++, 1, 1);
}
// Symetrical limits
if (GetEepromInterface()->getCapability(SYMLimits)) {
QCheckBox * symlimits = new QCheckBox(this);
symlimits->setProperty("index", i);
symlimits->setChecked(model.limitData[i].symetrical);
connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited()));
gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
}
}
// setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}
Channels::~Channels()
{
}
void Channels::symlimitsEdited()
{
QCheckBox * ckb = qobject_cast<QCheckBox*>(sender());
int index = ckb->property("index").toInt();
model.limitData[index].symetrical = (ckb->checkState() ? 1 : 0);
emit modified();
}
void Channels::nameEdited()
{
if (!lock) {
lock = true;
QLineEdit *le = qobject_cast<QLineEdit*>(sender());
int index = le->property("index").toInt();
strcpy(model.limitData[index].name, le->text().toAscii());
lock = false;
emit modified();
}
}
void Channels::offsetEdited()
{
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
int index = dsb->property("index").toInt();
model.limitData[index].offset = round(dsb->value()*10);
emit modified();
}
void Channels::minEdited()
{
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].min = sb->value();
emit modified();
}
void Channels::maxEdited()
{
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].max = sb->value();
emit modified();
}
void Channels::invEdited()
{
QComboBox *cb = qobject_cast<QComboBox*>(sender());
int index = cb->property("index").toInt();
model.limitData[index].revert = cb->currentIndex();
emit modified();
}
void Channels::ppmcenterEdited()
{
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].ppmCenter = sb->value() - 1500;
emit modified();
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef CHANNELS_H
#define CHANNELS_H
#include "modelpanel.h"
class Channels : public ModelPanel
{
Q_OBJECT
public:
Channels(QWidget *parent, ModelData & model);
~Channels();
private slots:
void symlimitsEdited();
void nameEdited();
void offsetEdited();
void minEdited();
void maxEdited();
void invEdited();
void ppmcenterEdited();
};
#endif // CHANNELS_H
+217
View File
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="ca_ctype_label_2">
<property name="text">
<string>Curve type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="ca_coeff_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="ca_coeff_label_2">
<property name="text">
<string>Coefficient</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="ca_side_CB_2">
<item>
<property name="text">
<string>Both</string>
</property>
</item>
<item>
<property name="text">
<string>x&gt;0</string>
</property>
</item>
<item>
<property name="text">
<string>x&lt;0</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="ca_ymid_label_2">
<property name="text">
<string>Y at X=0</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="ca_ymax_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="ca_ymid_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="ca_side_label_2">
<property name="text">
<string>Side</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="ca_ymin_label_2">
<property name="text">
<string>Y at X=-100</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="ca_ymin_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ca_ymax_label_2">
<property name="text">
<string>Y at X=100</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="ca_ctype_CB_2">
<item>
<property name="text">
<string>Linear</string>
</property>
</item>
<item>
<property name="text">
<string>Single Expo</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetrical f(x)=-f(-x)</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetrical f(x)=f(-x)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+673
View File
@@ -0,0 +1,673 @@
#include "curves.h"
#include "ui_curves.h"
#include "node.h"
#include "edge.h"
#include <QSpinBox>
#include <QCheckBox>
#include <QPushButton>
#include <QMessageBox>
// TODO Capability CustomCurves to be removed
#define GFX_MARGIN 16
static const QColor colors[C9X_MAX_CURVES] = {
QColor(0,0,127),
QColor(0,127,0),
QColor(127,0,0),
QColor(0,127,127),
QColor(127,0,127),
QColor(127,127,0),
QColor(127,127,127),
QColor(0,0,255),
QColor(0,127,255),
QColor(127,0,255),
QColor(0,255,0),
QColor(0,255,127),
QColor(127,255,0),
QColor(255,0,0),
QColor(255,0,127),
QColor(255,127,0),
};
#if 0
#ifdef __APPLE__
ui->curveEdit_1->setStyleSheet("color: #00007f;");
ui->curveEdit_2->setStyleSheet("color: #007f00;");
ui->curveEdit_3->setStyleSheet("color: #7f0000;");
ui->curveEdit_4->setStyleSheet("color: #007f7f;");
ui->curveEdit_5->setStyleSheet("color: #7f007f;");
ui->curveEdit_6->setStyleSheet("color: #7f7f00;");
ui->curveEdit_7->setStyleSheet("color: #7f7f7f;");
ui->curveEdit_8->setStyleSheet("color: #0000ff;");
ui->curveEdit_9->setStyleSheet("color: #007fff;");
ui->curveEdit_10->setStyleSheet("color: #7f00ff;");
ui->curveEdit_11->setStyleSheet("color: #00ff00;");
ui->curveEdit_12->setStyleSheet("color: #00ff7f;");
ui->curveEdit_13->setStyleSheet("color: #7fff00;");
ui->curveEdit_14->setStyleSheet("color: #ff0000;");
ui->curveEdit_15->setStyleSheet("color: #ff007f;");
ui->curveEdit_16->setStyleSheet("color: #ff7f00;");
#else
ui->curveEdit_1->setStyleSheet("background-color: #00007f; color: white;");
ui->curveEdit_2->setStyleSheet("background-color: #007f00; color: white;");
ui->curveEdit_3->setStyleSheet("background-color: #7f0000; color: white;");
ui->curveEdit_4->setStyleSheet("background-color: #007f7f; color: white;");
ui->curveEdit_5->setStyleSheet("background-color: #7f007f; color: white;");
ui->curveEdit_6->setStyleSheet("background-color: #7f7f00; color: white;");
ui->curveEdit_7->setStyleSheet("background-color: #7f7f7f; color: white;");
ui->curveEdit_8->setStyleSheet("background-color: #0000ff; color: white;");
ui->curveEdit_9->setStyleSheet("background-color: #007fff; color: white;");
ui->curveEdit_10->setStyleSheet("background-color: #7f00ff; color: white;");
ui->curveEdit_11->setStyleSheet("background-color: #00ff00; color: white;");
ui->curveEdit_12->setStyleSheet("background-color: #00ff7f; color: white;");
ui->curveEdit_13->setStyleSheet("background-color: #7fff00; color: white;");
ui->curveEdit_14->setStyleSheet("background-color: #ff0000; color: white;");
ui->curveEdit_15->setStyleSheet("background-color: #ff007f; color: white;");
ui->curveEdit_16->setStyleSheet("background-color: #ff7f00; color: white;");
#endif
#endif
Curves::Curves(QWidget * parent, ModelData & model):
ModelPanel(parent, model),
ui(new Ui::Curves),
currentCurve(0)
{
ui->setupUi(this);
if (!GetEepromInterface()->getCapability(HasCvNames)) {
ui->cname_LE->hide();
ui->cname_label->hide();
}
QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
ui->curvePreview->setScene(scene);
QIcon clearIcon;
clearIcon.addFile(":/images/clear.png", QSize(), QIcon::Normal, QIcon::Off);
for (int i=0; i<GetEepromInterface()->getCapability(NumCurves); i++) {
visibleCurves[i] = false;
// The reset curve button
QPushButton * reset = new QPushButton(this);
reset->setProperty("index", i);
reset->setMinimumSize(QSize(0, 0));
reset->setIcon(clearIcon);
reset->setIconSize(QSize(14, 14));
connect(reset, SIGNAL(clicked()), this, SLOT(resetCurve()));
ui->curvesLayout->addWidget(reset, i, 0, 1, 1);
// The edit curve button
QPushButton * edit = new QPushButton(this);
edit->setProperty("index", i);
QPalette palette;
palette.setBrush(QPalette::Active, QPalette::Button, QBrush(colors[i]));
palette.setBrush(QPalette::Active, QPalette::ButtonText, QBrush(Qt::white));
edit->setPalette(palette);
edit->setText(tr("Curve %1").arg(i+1));
connect(edit, SIGNAL(clicked()), this, SLOT(editCurve()));
ui->curvesLayout->addWidget(edit, i, 1, 1, 1);
// The curve plot checkbox
QCheckBox * plot = new QCheckBox(this);
plot->setProperty("index", i);
plot->setPalette(palette);
connect(plot, SIGNAL(toggled(bool)), this, SLOT(plotCurve(bool)));
ui->curvesLayout->addWidget(plot, i, 2, 1, 1);
}
for (int i=0; i<C9X_MAX_POINTS; i++) {
spny[i] = new QSpinBox(this);
spny[i]->setProperty("index", i);
spny[i]->setMinimum(-100);
spny[i]->setMaximum(+100);
spny[i]->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
spny[i]->setAccelerated(true);
connect(spny[i], SIGNAL(valueChanged(int)), this, SLOT(onPointEdited()));
ui->pointsLayout->addWidget(spny[i], i, 0, 1, 1);
spnx[i] = new QSpinBox(this);
spnx[i]->setProperty("index", i);
spnx[i]->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
spnx[i]->setAccelerated(true);
connect(spnx[i], SIGNAL(valueChanged(int)), this, SLOT(onPointEdited()));
ui->pointsLayout->addWidget(spnx[i], i, 1, 1, 1);
}
}
Curves::~Curves()
{
delete ui;
}
void Curves::editCurve()
{
QPushButton *button = (QPushButton *)sender();
int index = button->property("index").toInt();
setCurrentCurve(index);
update();
}
void Curves::resetCurve()
{
QPushButton *button = (QPushButton *)sender();
int index = button->property("index").toInt();
int res = QMessageBox::question(this, "companion9x", tr("Are you sure you want to reset curve %1 ?").arg(index+1), QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::Yes) {
model.curves[index].clear(5);
update();
emit modified();
}
}
void Curves::plotCurve(bool checked)
{
QCheckBox *chk = (QCheckBox *)sender();
int index = chk->property("index").toInt();
visibleCurves[index] = checked;
updateCurve();
}
void Curves::update()
{
lock = true;
if (GetEepromInterface()->getCapability(HasCvNames)) {
ui->cname_LE->setText(model.curves[currentCurve].name);
}
int count = model.curves[currentCurve].count;
for (int i=0; i<count; i++) {
spny[i]->show();
spny[i]->setValue(model.curves[currentCurve].points[i].y);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spnx[i]->show();
if (i==0 || i==model.curves[currentCurve].count-1) {
spnx[i]->setDisabled(true);
spnx[i]->setMaximum(+100);
spnx[i]->setMinimum(-100);
}
else {
spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x);
spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x);
}
spnx[i]->setValue(model.curves[currentCurve].points[i].x);
}
else {
spnx[i]->hide();
}
}
for (int i=count; i<C9X_MAX_POINTS; i++) {
spny[i]->hide();
spnx[i]->hide();
}
updateCurveType();
updateCurve();
lock = false;
}
void Curves::setCurrentCurve(int index)
{
currentCurve = index;
}
void Curves::updateCurveType()
{
int index = (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM ? 1 : 0);
if (model.curves[currentCurve].count==5)
index += 2;
else if (model.curves[currentCurve].count==9)
index += 4;
else if (model.curves[currentCurve].count==17)
index += 6;
ui->curvetype_CB->setCurrentIndex(index);
}
void Curves::updateCurve()
{
Node * nodel = 0;
Node * nodex = 0;
QColor color;
QGraphicsScene *scene = ui->curvePreview->scene();
scene->clear();
qreal width = scene->sceneRect().width();
qreal height = scene->sceneRect().height();
qreal centerX = scene->sceneRect().left() + width/2; //center X
qreal centerY = scene->sceneRect().top() + height/2; //center Y
QGraphicsSimpleTextItem *ti = scene->addSimpleText(tr("Editing curve %1").arg(currentCurve+1));
ti->setPos(3, 3);
scene->addLine(centerX, GFX_MARGIN, centerX, height+GFX_MARGIN);
scene->addLine(GFX_MARGIN, centerY, width+GFX_MARGIN, centerY);
QPen pen;
pen.setWidth(1);
pen.setStyle(Qt::SolidLine);
int numcurves = GetEepromInterface()->getCapability(NumCurves);
for (int k=0; k<numcurves; k++) {
pen.setColor(colors[k]);
if (currentCurve!=k && visibleCurves[k]) {
int numpoints = model.curves[k].count;
for (int i=0; i<numpoints-1; i++) {
if (model.curves[k].type == CurveData::CURVE_TYPE_CUSTOM)
scene->addLine(centerX + (qreal)model.curves[k].points[i].x*width/200,centerY - (qreal)model.curves[k].points[i].y*height/200,centerX + (qreal)model.curves[k].points[i+1].x*width/200,centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
else
scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
}
}
}
int numpoints = model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
nodel = nodex;
nodex = new Node();
nodex->setProperty("index", i);
nodex->setColor(colors[currentCurve]);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
if (i>0 && i<numpoints-1) {
nodex->setFixedX(false);
nodex->setMinX(model.curves[currentCurve].points[i-1].x);
nodex->setMaxX(model.curves[currentCurve].points[i+1].x);
}
else {
nodex->setFixedX(true);
}
nodex->setPos(centerX + (qreal)model.curves[currentCurve].points[i].x*width/200,centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
}
else {
nodex->setFixedX(true);
nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
}
connect(nodex, SIGNAL(moved(int, int)), this, SLOT(onNodeMoved(int, int)));
connect(nodex, SIGNAL(focus()), this, SLOT(onNodeFocus()));
connect(nodex, SIGNAL(unfocus()), this, SLOT(onNodeUnfocus()));
scene->addItem(nodex);
if (i>0) scene->addItem(new Edge(nodel, nodex));
}
}
void Curves::onPointEdited()
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
model.curves[currentCurve].points[index].x = spnx[index]->value();
model.curves[currentCurve].points[index].y = spny[index]->value();
updateCurve();
emit modified();
lock = false;
}
}
void Curves::onNodeMoved(int x, int y)
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
model.curves[currentCurve].points[index].x = x;
model.curves[currentCurve].points[index].y = y;
spnx[index]->setValue(x);
spny[index]->setValue(y);
emit modified();
lock = false;
}
}
void Curves::onNodeFocus()
{
int index = sender()->property("index").toInt();
spny[index]->setFocus();
}
void Curves::onNodeUnfocus()
{
int index = sender()->property("index").toInt();
spny[index]->clearFocus();
updateCurve();
}
void Curves::on_curvetype_CB_currentIndexChanged(int index)
{
static const int numpoint[] = {3,3,5,5,9,9,17,17};
static const CurveData::CurveType types[] = {CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM};
if (!lock) {
lock = true;
int numcurves = GetEepromInterface()->getCapability(NumCurves);
// int currpoints = model.curves[currentCurve].count;
// bool currcustom = model.curves[currentCurve].custom;
int totalpoints=0;
for (int i=0; i<numcurves; i++) {
if (i!=currentCurve) {
totalpoints += model.curves[i].count;
if (model.curves[i].type == CurveData::CURVE_TYPE_CUSTOM) {
totalpoints += model.curves[i].count-2;
}
}
}
totalpoints += numpoint[index];
if (types[index] == CurveData::CURVE_TYPE_CUSTOM) {
totalpoints += numpoint[index]-2;
}
int fwpoints = GetEepromInterface()->getCapability(NumCurvePoints);
if (fwpoints!=0) {
if (fwpoints < totalpoints) {
QMessageBox::warning(this, "companion9x", tr("Not enough free points in EEPROM to store the curve."));
updateCurveType();
lock = false;
return;
}
}
model.curves[currentCurve].count = numpoint[index];
model.curves[currentCurve].type = types[index];
// TODO something better!
for (int i=0; i<C9X_MAX_POINTS; i++) {
model.curves[currentCurve].points[i].x = (i >= model.curves[currentCurve].count-1 ? +100 : -100 + (200*i)/(numpoint[index]-1));
model.curves[currentCurve].points[i].y = 0;
}
update();
emit modified();
lock = false;
}
}
void Curves::on_cname_LE_editingFinished()
{
memset(model.curves[currentCurve].name, 0, sizeof(model.curves[currentCurve].name));
strcpy(model.curves[currentCurve].name, ui->cname_LE->text().toAscii());
emit modified();
}
void Curves::resizeEvent(QResizeEvent *event)
{
QRect qr = ui->curvePreview->contentsRect();
ui->curvePreview->scene()->setSceneRect(GFX_MARGIN, GFX_MARGIN, qr.width()-GFX_MARGIN*2, qr.height()-GFX_MARGIN*2);
updateCurve();
ModelPanel::resizeEvent(event);
}
#if 0
void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
{
int index=ui->ca_ctype_CB->currentIndex();
switch (index) {
case 0:
ui->ca_coeff_SB->hide();
ui->ca_coeff_label->hide();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->show();
ui->ca_ymin_label->show();
ui->ca_ymin_SB->setValue(-100);
ui->ca_ymax_SB->setValue(100);
break;
case 1:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->show();
ui->ca_ymin_label->show();
ui->ca_ymin_SB->setValue(-100);
ui->ca_ymax_SB->setValue(100);
break;
case 2:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->hide();
ui->ca_ymin_label->hide();
ui->ca_ymax_SB->setValue(100);
break;
case 3:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->show();
ui->ca_ymid_label->show();
ui->ca_ymin_SB->hide();
ui->ca_ymin_label->hide();
ui->ca_ymid_SB->setValue(0);
ui->ca_ymax_SB->setValue(100);
break;
}
}
void ModelEdit::on_ca_apply_PB_clicked()
{
int index=ui->ca_ctype_CB->currentIndex();
float x;
int y;
int invert=0;
float a;
if (index==0) {
a=(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/200.0;
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x+100);
} else {
x=(200.0/(numpoints-1))*i;
}
y=ui->ca_ymin_SB->value()+a*x;
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (x>=100) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (x<100) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
} else if (index==1) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=((model.curves[currentCurve].points[i].x)+100)/2.0;
} else {
x=(100.0/(numpoints-1))*i;
}
a=ui->ca_coeff_SB->value();
if (a>=0) {
y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value());
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value());
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (x>=50) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (x<50) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
} else if (index==2) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
}
a=ui->ca_coeff_SB->value();
if (x<0) {
x=-x;
invert=1;
} else {
invert=0;
}
if (a>=0) {
y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()/100.0));
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()/100.0));
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
if (invert==1) {
model.curves[currentCurve].points[i].y=-y;
} else {
model.curves[currentCurve].points[i].y=y;
}
break;
case 1:
if (invert==0) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (invert==1) {
model.curves[currentCurve].points[i].y=-y;
}
break;
}
}
} else if (index==3) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
}
int pos=(x>=0);
a=ui->ca_coeff_SB->value();
if (x<0) {
x=-x;
}
if (a>=0) {
y=round(c9xexpou(x,a)*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value());
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value());
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (pos) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (!pos) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
}
updateSettings();
setCurrentCurve(currentCurve);
drawCurve();
}
void ModelEdit::clearCurves(bool ask)
{
if(ask) {
int res = QMessageBox::question(this,tr("Clear Curves?"),tr("Really clear all the curves?"),QMessageBox::Yes | QMessageBox::No);
if(res!=QMessageBox::Yes) return;
}
curvesLock=true;
for (int j=0; j<16; j++) {
model.curves[j].count = 5;
model.curves[j].custom = false;
memset(model.curves[j].name, 0, sizeof(model.curves[j].name));
for (int i=0; i<17; i++) {
model.curves[j].points[i].x = 0;
model.curves[j].points[i].y = 0;
}
}
for (int i=0; i<17; i++) {
spnx[i]->setMinimum(-100);
spnx[i]->setMaximum(100);
spnx[i]->setValue(0);
spny[i]->setValue(0);
}
currentCurve=0;
curvesLock=false;
ui->curvetype_CB->setCurrentIndex(2);
ui->cname_LE->clear();
updateSettings();
drawCurve();
}
void ModelEdit::setCurve(uint8_t c, int8_t ar[])
{
int len=sizeof(ar)/sizeof(int8_t);
if (GetEepromInterface()->getCapability(CustomCurves)) {
if (GetEepromInterface()->getCapability(NumCurves)>c) {
if (len<9) {
model.curves[c].count=5;
model.curves[c].custom=false;
for (int i=0; i< 5; i++) {
model.curves[c].points[i].y=ar[i];
}
} else {
model.curves[c].count=5;
model.curves[c].custom=false;
for (int i=0; i< 5; i++) {
model.curves[c].points[i].y=ar[i];
}
}
}
} else {
if (len<9) {
model.curves[c].count=5;
model.curves[c].custom=false;
for (int i=0; i< 5; i++) {
model.curves[c].points[i].y=ar[i];
}
} else {
model.curves[c+8].count=5;
model.curves[c+8].custom=false;
for (int i=0; i< 5; i++) {
model.curves[c+8].points[i].y=ar[i];
}
}
}
}
void ModelEdit::ControlCurveSignal(bool flag)
{
foreach(QSpinBox *sb, findChildren<QSpinBox *>(QRegExp("curvePt[0-9]+"))) {
sb->blockSignals(flag);
}
}
#endif
+47
View File
@@ -0,0 +1,47 @@
#ifndef CURVES_H
#define CURVES_H
#include "modelpanel.h"
#include <QSpinBox>
namespace Ui {
class Curves;
}
class Curves : public ModelPanel
{
Q_OBJECT
public:
Curves(QWidget *parent, ModelData & model);
virtual ~Curves();
virtual void update();
private slots:
void resetCurve();
void editCurve();
void plotCurve(bool checked);
void on_cname_LE_editingFinished();
void on_curvetype_CB_currentIndexChanged(int index);
void onPointEdited();
void onNodeMoved(int x, int y);
void onNodeFocus();
void onNodeUnfocus();
protected:
virtual void resizeEvent(QResizeEvent *event);
private:
Ui::Curves *ui;
int currentCurve;
bool visibleCurves[C9X_MAX_CURVES];
QSpinBox * spnx[C9X_MAX_POINTS];
QSpinBox * spny[C9X_MAX_POINTS];
void setCurrentCurve(int index);
void updateCurve();
void updateCurveType();
};
#endif // CURVES_H
+167
View File
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Curves</class>
<widget class="QWidget" name="Curves">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>638</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_80" columnstretch="0,0,0,0,0">
<item row="0" column="0" rowspan="3">
<layout class="QGridLayout" name="curvesLayout"/>
</item>
<item row="0" column="1" rowspan="3">
<layout class="QGridLayout" name="gridLayout_8" rowstretch="0,0,0" columnstretch="1,1">
<item row="1" column="0">
<widget class="QLabel" name="curvetype_label">
<property name="text">
<string>Curve type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="curvetype_CB">
<item>
<property name="text">
<string>3 points</string>
</property>
</item>
<item>
<property name="text">
<string>3 points custom</string>
</property>
</item>
<item>
<property name="text">
<string>5 points</string>
</property>
</item>
<item>
<property name="text">
<string>5 points custom</string>
</property>
</item>
<item>
<property name="text">
<string>9 points</string>
</property>
</item>
<item>
<property name="text">
<string>9 points custom</string>
</property>
</item>
<item>
<property name="text">
<string>17 points</string>
</property>
</item>
<item>
<property name="text">
<string>17 points custom</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="cname_label">
<property name="text">
<string>Curve name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="cname_LE">
<property name="maxLength">
<number>6</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGraphicsView" name="curvePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2" rowspan="3" colspan="2">
<layout class="QGridLayout" name="pointsLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="4" column="0" colspan="5">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4" rowspan="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+474
View File
@@ -0,0 +1,474 @@
#include "customfunctions.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include "helpers.h"
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
generalSettings(generalSettings),
phononLock(false)
{
QGridLayout * gridLayout = new QGridLayout(this);
int col = 1;
addLabel(gridLayout, tr("Switch"), col++);
addLabel(gridLayout, tr("Function"), col++);
addLabel(gridLayout, tr("Parameters"), col++);
addLabel(gridLayout, tr("Enable"), col++);
lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
QStringList paramarmList;
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
QString temp = model.funcSw[i].paramarm;
if (!temp.isEmpty()) {
if (!paramarmList.contains(temp)) {
paramarmList.append(temp);
}
}
}
}
QSettings settings("companion9x", "companion9x");
QString path = settings.value("sdPath", ".").toString();
path.append("/SOUNDS/");
QString lang = generalSettings.ttsLanguage;
if (lang.isEmpty())
lang="en";
path.append(lang);
QDir qd(path);
int vml= GetEepromInterface()->getCapability(VoicesMaxLength)+4;
if (qd.exists()) {
QStringList filters;
filters << "*.wav" << "*.WAV";
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
QFileInfo fi(file);
QString temp=fi.completeBaseName();
if (!paramarmList.contains(temp) && temp.length()<=vml) {
paramarmList.append(temp);
}
}
}
}
for (int i=0; i<num_fsw; i++) {
AssignFunc func = model.funcSw[i].func;
// The label
QLabel * label = new QLabel(this);
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
label->setProperty("index", i);
label->setText(tr("CF%1").arg(i+1));
gridLayout->addWidget(label, i+1, 0);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
// The switch
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
// The function
fswtchFunc[i] = new QComboBox(this);
fswtchFunc[i]->setProperty("index", i);
connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchFunc[i], i+1, 2);
populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
QHBoxLayout *paramLayout = new QHBoxLayout();
gridLayout->addLayout(paramLayout, i+1, 3);
fswtchGVmode[i] = new QComboBox(this);
fswtchGVmode[i]->setProperty("index", i);
connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
paramLayout->addWidget(fswtchGVmode[i]);
populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode);
fswtchParamGV[i] = new QCheckBox(this);
fswtchParamGV[i]->setProperty("index", i);
fswtchParamGV[i]->setText("GV");
fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
paramLayout->addWidget(fswtchParamGV[i]);
fswtchParam[i] = new QDoubleSpinBox(this);
fswtchParam[i]->setProperty("index", i);
fswtchParam[i]->setAccelerated(true);
fswtchParam[i]->setDecimals(0);
connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited()));
paramLayout->addWidget(fswtchParam[i]);
fswtchParamT[i] = new QComboBox(this);
fswtchParamT[i]->setProperty("index", i);
paramLayout->addWidget(fswtchParamT[i]);
populateFuncParamCB(fswtchParamT[i], func, model.funcSw[i].param, model.funcSw[i].adjustMode);
connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i);
populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList);
fswtchParamArmT[i]->setEditable(true);
paramLayout->addWidget(fswtchParamArmT[i]);
connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
#ifdef PHONON
playBT[i] = new QPushButton(this);
playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(QIcon(":/images/play.png"));
paramLayout->addWidget(playBT[i]);
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif
QHBoxLayout *repeatLayout = new QHBoxLayout();
gridLayout->addLayout(repeatLayout, i+1, 4);
fswtchRepeat[i] = new QComboBox(this);
fswtchRepeat[i]->setProperty("index", i);
connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
repeatLayout->addWidget(fswtchRepeat[i], i+1);
populateRepeatCB(fswtchRepeat[i], model.funcSw[i].repeatParam);
fswtchEnable[i] = new QCheckBox(this);
fswtchEnable[i]->setProperty("index", i);
fswtchEnable[i]->setText(tr("ON"));
repeatLayout->addWidget(fswtchEnable[i], i+1);
fswtchEnable[i]->setChecked(model.funcSw[i].enabled);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
}
lock = false;
}
CustomFunctionsPanel::~CustomFunctionsPanel()
{
}
#ifdef PHONON
void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState)
{
if (phononLock)
return;
phononLock=true;
if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
clickObject->stop();
clickObject->clearQueue();
clickObject->clear();
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(QIcon(":/images/play.png"));
}
}
if (newState==Phonon::ErrorState) {
clickObject->stop();
clickObject->clearQueue();
clickObject->clear();
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(QIcon(":/images/play.png"));
}
}
phononLock=false;
}
#endif
void CustomFunctionsPanel::playMusic()
{
QPushButton *playButton = qobject_cast<QPushButton*>(sender());
int index=playButton->objectName().mid(5,2).toInt();
QString function=playButton->objectName().left(4);
QSettings settings("companion9x", "companion9x");
QString path=settings.value("sdPath", ".").toString();
QDir qd(path);
QString track;
if (qd.exists()) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0');
} else {
path.append("/SOUNDS/");
QString lang = generalSettings.ttsLanguage;
if (lang.isEmpty())
lang="en";
path.append(lang);
if (fswtchParamArmT[index]->currentText()!="----") {
track=path+"/"+fswtchParamArmT[index]->currentText()+".wav";
}
}
QFile file(track);
if (!file.exists()) {
QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
track.clear();
}
#ifdef PHONON
if (function=="play" && !track.isEmpty()) {
clickObject->clear();
clickObject->setCurrentSource(Phonon::MediaSource(track));
clickObject->play();
playBT[index]->setObjectName(QString("stop_%1").arg(index));
playBT[index]->setIcon(QIcon(":/images/stop.png"));
} else {
clickObject->stop();
clickObject->clear();
playBT[index]->setObjectName(QString("play_%1").arg(index));
playBT[index]->setIcon(QIcon(":/images/play.png"));
}
#endif
}
}
#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0)
#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1)
#define CUSTOM_FUNCTION_FILE_PARAM (1<<2)
#define CUSTOM_FUNCTION_GV_MODE (1<<3)
#define CUSTOM_FUNCTION_GV_TOOGLE (1<<4)
#define CUSTOM_FUNCTION_ENABLE (1<<5)
#define CUSTOM_FUNCTION_REPEAT (1<<6)
#define CUSTOM_FUNCTION_PLAY (1<<7)
void CustomFunctionsPanel::customFunctionEdited()
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
refreshCustomFunction(index, true);
emit modified();
lock = false;
}
}
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
{
unsigned int widgetsMask = 0;
if (modified) {
model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt());
model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex();
model.funcSw[i].enabled =fswtchEnable[i]->isChecked();
model.funcSw[i].repeatParam = (AssignFunc)fswtchRepeat[i]->currentIndex();
model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
}
int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125);
fswtchParam[i]->setMaximum(125);
if (modified) {
model.funcSw[i].param = fswtchParam[i]->value();
}
fswtchParam[i]->setValue(model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
} else if (index==FuncLogs) {
fswtchParam[i]->setDecimals(1);
fswtchParam[i]->setMinimum(0);
fswtchParam[i]->setMaximum(25.5);
fswtchParam[i]->setSingleStep(0.1);
if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0;
fswtchParam[i]->setValue(model.funcSw[i].param/10.0);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) {
if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex();
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
if (model.funcSw[i].adjustMode==0) {
if (modified) model.funcSw[i].param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125);
fswtchParam[i]->setMaximum(125);
fswtchParam[i]->setValue(model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
} else {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param, model.funcSw[i].adjustMode);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
} else if (index==FuncReset) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
} else if (index==FuncVolume) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
} else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (modified) model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt();
if (index != FuncBackgroundMusic) {
if (GetEepromInterface()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
}
}
if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
} else if (index==FuncPlayPrompt || index==FuncPlayBoth) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(0);
if (index==FuncPlayPrompt) {
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE;
} else {
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT;
fswtchParamGV[i]->setChecked(false);
}
fswtchParam[i]->setMaximum(index==FuncPlayBoth ? 254 : 255);
if (modified) {
if (fswtchParamGV[i]->isChecked()) {
fswtchParam[i]->setMinimum(1);
model.funcSw[i].param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0);
} else {
model.funcSw[i].param = fswtchParam[i]->value();
}
}
if (model.funcSw[i].param>250 && (index!=FuncPlayBoth)) {
fswtchParamGV[i]->setChecked(true);
fswtchParam[i]->setValue(model.funcSw[i].param-250);
fswtchParam[i]->setMaximum(5);
} else {
fswtchParamGV[i]->setChecked(false);
fswtchParam[i]->setValue(model.funcSw[i].param);
}
if (model.funcSw[i].param < 251)
widgetsMask |= CUSTOM_FUNCTION_PLAY;
} else {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
}
}
}
}
} else if (index==FuncBackgroundMusic) {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
}
}
}
} else if (index==FuncPlaySound) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
} else if (index==FuncPlayHaptic) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
} else if (model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
if (modified) model.funcSw[i].param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setValue(model.funcSw[i].param);
if (index<=FuncInstantTrim) {
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
}
}
fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM);
fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE);
fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM);
fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM);
fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE);
if (!(widgetsMask & CUSTOM_FUNCTION_ENABLE)) fswtchEnable[i]->setChecked(false);
fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT);
fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE);
#ifdef PHONON
playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY);
#endif
}
void CustomFunctionsPanel::update()
{
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
refreshCustomFunction(i);
}
}
void CustomFunctionsPanel::fswPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion9x-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion9x-fsw");
FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
emit modified();
}
}
void CustomFunctionsPanel::fswDelete()
{
model.funcSw[selectedFunction].clear();
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
emit modified();
}
void CustomFunctionsPanel::fswCopy()
{
QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion9x-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void CustomFunctionsPanel::fswCut()
{
fswCopy();
fswDelete();
}
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
{
QLabel *label = (QLabel *)sender();
selectedFunction = label->property("index").toInt();
QPoint globalPos = label->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion9x-fsw");
QMenu contextMenu;
contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));
contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.exec(globalPos);
}
+61
View File
@@ -0,0 +1,61 @@
#ifndef CUSTOMFUNCTIONS_H
#define CUSTOMFUNCTIONS_H
#include "modelpanel.h"
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#ifdef PHONON
#include <phonon/audiooutput.h>
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#endif
class CustomFunctionsPanel : public ModelPanel
{
Q_OBJECT
public:
CustomFunctionsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings);
~CustomFunctionsPanel();
virtual void update();
private slots:
void customFunctionEdited();
void fsw_customContextMenuRequested(QPoint pos);
void refreshCustomFunction(int index, bool modified=false);
void playMusic();
#ifdef PHONON
void mediaPlayer_state(Phonon::State newState, Phonon::State oldState);
#endif
void fswDelete();
void fswCopy();
void fswPaste();
void fswCut();
private:
GeneralSettings & generalSettings;
bool phononLock;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS];
QDoubleSpinBox * fswtchParam[C9X_MAX_CUSTOM_FUNCTIONS];
QPushButton * playBT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON
Phonon::MediaObject *clickObject;
Phonon::AudioOutput *clickOutput;
#endif
int selectedFunction;
};
#endif // CUSTOMFUNCTIONS_H
+399
View File
@@ -0,0 +1,399 @@
#include "customswitches.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include "helpers.h"
CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
ModelPanel(parent, model),
selectedSwitch(0)
{
QGridLayout * gridLayout = new QGridLayout(this);
int col = 1;
addLabel(gridLayout, tr("Function"), col++);
addLabel(gridLayout, tr("V1"), col++);
addLabel(gridLayout, tr("V2"), col++);
addLabel(gridLayout, tr("AND"), col++);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
addLabel(gridLayout, tr("Duration"), col++);
addLabel(gridLayout, tr("Delay"), col++);
}
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
// The label
QLabel * label = new QLabel(this);
label->setProperty("index", i);
if (i < 9)
label->setText(tr("CS%1").arg(i+1));
else
label->setText(tr("CS%1").arg(QChar('A'+i-9)));
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0);
// The function
csw[i] = new QComboBox(this);
csw[i]->setProperty("index", i);
connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
gridLayout->addWidget(csw[i], i+1, 1);
// V1
cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i);
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this);
cswitchValue[i]->setMaximum(125);
cswitchValue[i]->setMinimum(-125);
cswitchValue[i]->setAccelerated(true);
cswitchValue[i]->setDecimals(0);
cswitchValue[i]->setProperty("index", i);
connect(cswitchValue[i], SIGNAL(editingFinished()), this, SLOT(edited()));
gridLayout->addWidget(cswitchValue[i], i+1, 2);
cswitchValue[i]->setVisible(false);
// V2
cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this);
cswitchOffset[i]->setProperty("index",i);
cswitchOffset[i]->setMaximum(125);
cswitchOffset[i]->setMinimum(-125);
cswitchOffset[i]->setAccelerated(true);
cswitchOffset[i]->setDecimals(0);
connect(cswitchOffset[i], SIGNAL(editingFinished()), this, SLOT(edited()));
gridLayout->addWidget(cswitchOffset[i], i+1, 3);
cswitchOffset[i]->setVisible(false);
// AND
cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i);
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
gridLayout->addWidget(cswitchAnd[i], i+1, 4);
cswitchAnd[i]->setVisible(false);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
// Duration
cswitchDuration[i] = new QDoubleSpinBox(this);
cswitchDuration[i]->setProperty("index", i);
cswitchDuration[i]->setSingleStep(0.5);
cswitchDuration[i]->setMaximum(50);
cswitchDuration[i]->setMinimum(0);
cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1);
connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited()));
gridLayout->addWidget(cswitchDuration[i], i+1, 5);
cswitchDuration[i]->setVisible(false);
// Delay
cswitchDelay[i] = new QDoubleSpinBox(this);
cswitchDelay[i]->setProperty("index", i);
cswitchDelay[i]->setSingleStep(0.5);
cswitchDelay[i]->setMaximum(50);
cswitchDelay[i]->setMinimum(0);
cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1);
connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited()));
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
cswitchDelay[i]->setVisible(false);
}
}
lock = false;
}
CustomSwitchesPanel::~CustomSwitchesPanel()
{
}
void CustomSwitchesPanel::edited()
{
if (!lock) {
lock = true;
int i = sender()->property("index").toInt();
bool chAr;
float value, step;
int newval;
chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt()));
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
if(chAr) {
if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) {
model.customSw[i].val1 = -119;
model.customSw[i].val2 = -119;
} else {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0;
}
model.customSw[i].andsw = 0;
setSwitchWidgetVisibility(i);
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2);
model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2);
}
RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func))
{
case (CS_FAMILY_VOFS):
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) {
source=RawSource(model.customSw[i].val1);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
RawSource newSource = RawSource(model.customSw[i].val1);
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 {
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value()/source.getStep(model));
} else {
model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model);
}
}
setSwitchWidgetVisibility(i);
} else {
source=RawSource(model.customSw[i].val1);
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value()/source.getStep(model));
cswitchOffset[i]->setValue(model.customSw[i].val2*source.getStep(model));
} else {
model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model);
cswitchOffset[i]->setValue((model.customSw[i].val2 +source.getRawOffset(model))*source.getStep(model)+source.getOffset(model));
}
}
break;
case (CS_FAMILY_TIMERS): {
value=cswitchOffset[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val2) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val2=TimToVal(value);
value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setValue(value);
cswitchOffset[i]->setSingleStep(step);
value=cswitchValue[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val1) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val1=TimToVal(value);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setValue(value);
cswitchValue[i]->setSingleStep(step);
break;
}
case (CS_FAMILY_VBOOL):
case (CS_FAMILY_VCOMP):
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt();
break;
}
model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt();
emit modified();
lock = false;
}
}
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
{
RawSource source = RawSource(model.customSw[i].val1);
switch (getCSFunctionFamily(model.customSw[i].func))
{
case CS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(true);
populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(source.getDecimals(model));
cswitchOffset[i]->setSingleStep(source.getStep(model));
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
cswitchOffset[i]->setMinimum(source.getStep(model)*-127);
cswitchOffset[i]->setMaximum(source.getStep(model)*127);
cswitchOffset[i]->setValue(source.getStep(model)*model.customSw[i].val2);
} else {
cswitchOffset[i]->setMinimum(source.getMin(model));
cswitchOffset[i]->setMaximum(source.getMax(model));
cswitchOffset[i]->setValue(source.getStep(model)*(model.customSw[i].val2+source.getRawOffset(model))+source.getOffset(model));
}
break;
case CS_FAMILY_VBOOL:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(false);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break;
case CS_FAMILY_VCOMP:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(false);
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break;
case CS_FAMILY_TIMERS:
cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(true);
cswitchOffset[i]->setVisible(true);
cswitchOffset[i]->setDecimals(1);
cswitchOffset[i]->setMinimum(0.1);
cswitchOffset[i]->setMaximum(175);
float value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setSingleStep(0.1);
if (value>60) {
cswitchOffset[i]->setSingleStep(1);
} else if (value>2) {
cswitchOffset[i]->setSingleStep(0.5);
}
cswitchOffset[i]->setValue(value);
cswitchValue[i]->setDecimals(1);
cswitchValue[i]->setMinimum(0.1);
cswitchValue[i]->setMaximum(175);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setSingleStep(0.1);
if (value>60) {
cswitchValue[i]->setSingleStep(1);
} else if (value>2) {
cswitchValue[i]->setSingleStep(0.5);
}
cswitchValue[i]->setValue(value);
break;
}
cswitchAnd[i]->setVisible(true);
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES);
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()
{
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
populateCSWCB(csw[i], model.customSw[i].func);
setSwitchWidgetVisibility(i);
}
lock = false;
}
void CustomSwitchesPanel::cswPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion9x-csw")) {
QByteArray cswData = mimeData->data("application/x-companion9x-csw");
CustomSwData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData));
emit modified();
updateSelectedSwitch();
}
}
void CustomSwitchesPanel::cswDelete()
{
model.customSw[selectedSwitch].clear();
emit modified();
updateSelectedSwitch();
}
void CustomSwitchesPanel::cswCopy()
{
QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion9x-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void CustomSwitchesPanel::updateSelectedSwitch()
{
lock = true;
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
setSwitchWidgetVisibility(selectedSwitch);
lock = false;
}
void CustomSwitchesPanel::cswCut()
{
cswCopy();
cswDelete();
}
// TODO make something generic here!
void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
{
QLabel *label = (QLabel *)sender();
selectedSwitch = label->property("index").toInt();
QPoint globalPos = label->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion9x-csw");
QMenu contextMenu;
contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(cswDelete()),tr("Delete"));
contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C"));
contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X"));
contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.exec(globalPos);
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef CUSTOMSWITCHES_H
#define CUSTOMSWITCHES_H
#include "modelpanel.h"
#include <QComboBox>
#include <QDoubleSpinBox>
class CustomSwitchesPanel : public ModelPanel
{
Q_OBJECT
public:
CustomSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~CustomSwitchesPanel();
virtual void update();
private slots:
void edited();
void csw_customContextMenuRequested(QPoint pos);
void cswDelete();
void cswCopy();
void cswPaste();
void cswCut();
private:
QComboBox * csw[C9X_NUM_CSW];
QDoubleSpinBox * cswitchValue[C9X_NUM_CSW];
QDoubleSpinBox * cswitchOffset[C9X_NUM_CSW];
QComboBox * cswitchAnd[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDuration[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDelay[C9X_NUM_CSW];
QComboBox * cswitchSource1[C9X_NUM_CSW];
QComboBox * cswitchSource2[C9X_NUM_CSW];
void setSwitchWidgetVisibility(int i);
int selectedSwitch;
void updateSelectedSwitch();
};
#endif // CUSTOMSWITCHES_H
+235
View File
@@ -0,0 +1,235 @@
#include "expodialog.h"
#include "ui_expodialog.h"
#include "eeprominterface.h"
#include "helpers.h"
ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
QDialog(parent),
ui(new Ui::ExpoDialog),
ed(expoData)
{
ui->setupUi(this);
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==0) {
ui->weightGV->setDisabled(true);
ui->curveGVarCB->hide();
if ((ed->curve.type == CurveReference::CURVE_REF_EXPO || ed->curve.type == CurveReference::CURVE_REF_DIFF) && ed->curve.value > 100) {
ed->curve.value = 0;
}
if (ed->weight>100 || ed->weight<-100) {
ed->weight = 100;
}
}
populateGVCB(ui->weightCB, ed->weight);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (ed->weight>100 || ed->weight<0) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(ed->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
populateSwitchCB(ui->switchesCB,ed->swtch);
// TODO keep this group, same in MixerDialog
CurveGroup * curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve);
ui->sideCB->setCurrentIndex(ed->mode-1);
if (!GetEepromInterface()->getCapability(FlightPhases)) {
ui->label_phases->hide();
for (int i=0; i<9; i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
} else {
int mask=1;
for (int i=0; i<9 ; i++) {
if ((ed->phases & mask)==0) {
cb_fp[i]->setChecked(true);
}
mask <<= 1;
}
for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
}
if (GetEepromInterface()->getCapability(VirtualInputs)) {
ui->sideLabel->hide();
ui->sideCB->hide();
}
else {
ui->sourceLabel->hide();
ui->sourceCB->hide();
ui->scaleLabel->hide();
ui->scaleSB->hide();
ui->trimLabel->hide();
ui->trimCB->hide();
}
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
if (!expolength) {
ui->label_name->hide();
ui->expoName->hide();
} else {
ui->expoName->setMaxLength(expolength);
}
ui->expoName->setValidator(new QRegExpValidator(rx, this));
ui->expoName->setText(ed->name);
valuesChanged();
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->sideCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
for (int i=0; i<9; i++) {
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
ExpoDialog::~ExpoDialog()
{
delete ui;
}
void ExpoDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void ExpoDialog::widgetChanged()
{
// TODO so many times duplicated :(
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
/* TODO if (gvars==1) {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
} */
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
void ExpoDialog::valuesChanged()
{
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
if (ui->weightGV->isChecked()) {
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
} else {
ed->weight = ui->weightSB->value();
}
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
ed->mode = ui->sideCB->currentIndex() + 1;
int i=0;
for (i=0; i<ui->expoName->text().toAscii().length(); i++) {
ed->name[i]=ui->expoName->text().toAscii().at(i);
}
ed->name[i]=0;
ed->phases=0;
for (int i=8; i>=0 ; i--) {
if (!cb_fp[i]->checkState()) {
ed->phases+=1;
}
ed->phases<<=1;
}
ed->phases>>=1;
if (GetEepromInterface()->getCapability(FlightPhases)) {
int zeros=0;
int ones=0;
int phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
ones++;
}
else {
zeros++;
}
phtemp >>=1;
}
if (zeros==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if ((phtemp & 1)==0) {
break;
}
phtemp >>=1;
}
}
else if (ones==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
break;
}
phtemp >>=1;
}
}
} else {
ed->phases=0;
}
}
void ExpoDialog::shrink()
{
resize(0,0);
}
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>370</width>
<height>289</height>
<height>331</height>
</rect>
</property>
<property name="sizePolicy">
@@ -26,7 +26,7 @@
<string/>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<iconset>
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -44,14 +44,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
<item>
<widget class="QCheckBox" name="weightGV">
@@ -85,55 +85,14 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_expo">
<property name="text">
<string>Expo</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,1,0">
<item>
<widget class="QCheckBox" name="expoGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="expoSB"/>
</item>
<item>
<widget class="QComboBox" name="expoCB">
<property name="whatsThis">
<string>Phase used by the expo.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="6" column="1">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lb_FP0">
@@ -290,14 +249,14 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="switchesCB">
<property name="whatsThis">
<string>Switch used by the expo.
@@ -305,53 +264,15 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_curves">
<property name="text">
<string>Curve/Exponential</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,1">
<item>
<widget class="QComboBox" name="curvesCB">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string>The curve used by the expo</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="expoCurveGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="expoCurveSB"/>
</item>
<item>
<widget class="QComboBox" name="expoCurveCB">
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<item row="9" column="0">
<widget class="QLabel" name="sideLabel">
<property name="text">
<string>Stick Side</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="modeCB">
<item row="9" column="1">
<widget class="QComboBox" name="sideCB">
<item>
<property name="text">
<string>NEG</string>
@@ -369,7 +290,7 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
</item>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
@@ -388,7 +309,7 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -396,11 +317,114 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="sourceCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="scaleSB">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Delay ans Slow&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600; text-decoration: underline;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These values control the speed and delay of the output of the mix. &lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If Delay is not zero the actuation of the mix will be delayed by the specified amount of seconds.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If Slow is not zero then the speed of the mix will be set by the value specified -&amp;gt; the value states the number of seconds it takes to transit from -100 to 100.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="scaleLabel">
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="trimLabel">
<property name="text">
<string>Include Trim</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="sourceLabel">
<property name="text">
<string>Source</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="trimCB">
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Yes</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_curves">
<property name="text">
<string>Curve</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1,0">
<item>
<widget class="QComboBox" name="curveTypeCB">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string>The curve used by the expo</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="curveGVarCB">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="curveValueCB">
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="curveValueSB"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
+449
View File
@@ -0,0 +1,449 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FlightMode</class>
<widget class="QWidget" name="FlightMode">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>610</width>
<height>499</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="paramsLayout">
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Fade In</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="fadeIn">
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="fadeOut">
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Fade Out</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name">
<property name="maxLength">
<number>6</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="4" rowspan="2">
<spacer name="spacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="swtch"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="trimsLayout">
<item row="2" column="1">
<widget class="QSlider" name="trim1Slider">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QSlider" name="trim2Slider">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSlider" name="trim3Slider">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSlider" name="trim4Slider">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="leftTrims_3" columnstretch="0,1" columnminimumwidth="80,0">
<item row="1" column="0">
<widget class="QLabel" name="trim1Label">
<property name="text">
<string>trim1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_5c_3">
<item>
<spacer name="verticalSpacer_3c_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="trim2Use"/>
</item>
<item>
<widget class="QSpinBox" name="trim2Value">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="minimum">
<number>-896</number>
</property>
<property name="maximum">
<number>896</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4a_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_6b_3">
<item>
<spacer name="verticalSpacer_5b_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="trim1Use"/>
</item>
<item>
<widget class="QSpinBox" name="trim1Value">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="minimum">
<number>-896</number>
</property>
<property name="maximum">
<number>896</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6b_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="trim2Label">
<property name="text">
<string>trim2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="righTrims_2" columnstretch="0,1" columnminimumwidth="80,0">
<item row="1" column="0">
<widget class="QLabel" name="trim4Label">
<property name="text">
<string>trim4</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="trim3Label">
<property name="text">
<string>trim3</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_7b_2">
<item>
<spacer name="verticalSpacer_7b_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="trim3Use"/>
</item>
<item>
<widget class="QSpinBox" name="trim3Value">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="minimum">
<number>-896</number>
</property>
<property name="maximum">
<number>896</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_8d_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_8d_2">
<item>
<spacer name="verticalSpacer_9d_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="trim4Use"/>
</item>
<item>
<widget class="QSpinBox" name="trim4Value">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="minimum">
<number>-896</number>
</property>
<property name="maximum">
<number>896</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_10c_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gvNreLayout" columnstretch="1,1">
<item row="0" column="0">
<widget class="QGroupBox" name="gvGB"/>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="reGB"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+484
View File
@@ -0,0 +1,484 @@
#include "flightmodes.h"
#include "ui_flightmode.h"
// #include "firmwares/opentx/opentxeeprom.h" // TODO shouldn't be there
#include "helpers.h"
#include <QComboBox>
#include <QGridLayout>
FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings):
ModelPanel(parent, model),
ui(new Ui::FlightMode),
generalSettings(generalSettings),
phaseIdx(phaseIdx),
phase(model.phaseData[phaseIdx]),
reCount(GetEepromInterface()->getCapability(RotaryEncoders)),
gvCount(((!GetEepromInterface()->getCapability(HasVariants)) || (GetCurrentFirmwareVariant() & GVARS_VARIANT)) ?
GetEepromInterface()->getCapability(Gvars) : 0)
{
ui->setupUi(this);
// Phase name
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(FlightPhases)) {
ui->name->setValidator(new QRegExpValidator(rx, this));
ui->name->setMaxLength(GetEepromInterface()->getCapability(FlightModesName));
connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished()));
}
else {
ui->name->setDisabled(true);
}
// Phase switch
if (phaseIdx > 0) {
populateSwitchCB(ui->swtch, phase.swtch);
connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int)));
}
else {
ui->swtch->hide();
}
// FadeIn / FadeOut
if (GetEepromInterface()->getCapability(FlightPhasesHaveFades)) {
int scale = GetEepromInterface()->getCapability(SlowScale);
int range = GetEepromInterface()->getCapability(SlowRange);
ui->fadeIn->setMaximum(float(range)/scale);
ui->fadeIn->setSingleStep(1.0/scale);
ui->fadeIn->setDecimals((scale==1 ? 0 :1) );
connect(ui->fadeIn, SIGNAL(editingFinished()), this, SLOT(phaseFadeIn_editingFinished()));
ui->fadeOut->setMaximum(float(range)/scale);
ui->fadeOut->setSingleStep(1.0/scale);
ui->fadeOut->setDecimals((scale==1 ? 0 :1));
connect(ui->fadeOut, SIGNAL(editingFinished()), this, SLOT(phaseFadeOut_editingFinished()));
}
else {
ui->fadeIn->setDisabled(true);
ui->fadeOut->setDisabled(true);
}
// The trims
QString labels[] = { tr("Rud"), tr("Ele"), tr("Thr"), tr("Ail") }; // TODO is elsewhere for sure
trimsLabel << ui->trim1Label << ui->trim2Label << ui->trim3Label << ui->trim4Label;
trimsUse << ui->trim1Use << ui->trim2Use << ui->trim3Use << ui->trim4Use;
trimsValue << ui->trim1Value << ui->trim2Value << ui->trim3Value << ui->trim4Value;
trimsSlider << ui->trim1Slider << ui->trim2Slider << ui->trim3Slider << ui->trim4Slider;
for (int i=0; i<4; i++) {
trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]);
if (phaseIdx > 0) {
trimsUse[i]->setProperty("index", i);
populateTrimUseCB(trimsUse[i], phaseIdx);
connect(trimsUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int)));
}
else {
trimsUse[i]->hide();
}
trimsValue[i]->setProperty("index", i);
connect(trimsValue[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrim_valueChanged()));
trimsSlider[i]->setProperty("index", i);
connect(trimsSlider[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrimSlider_valueChanged()));
}
// Rotary encoders
if (reCount > 0) {
QGridLayout *reLayout = new QGridLayout(ui->reGB);
for (int i=0; i<reCount; i++) {
// RE label
QLabel *label = new QLabel(ui->reGB);
label->setText(tr("Rotary Encoder %1").arg(i+1));
reLayout->addWidget(label, i, 0, 1, 1);
if (phaseIdx > 0) {
// RE link to another RE
QComboBox *link = new QComboBox(ui->gvGB);
link->setProperty("index", i);
populateGvarUseCB(link, phaseIdx);
connect(link, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseREUse_currentIndexChanged(int)));
if (phase.rotaryEncoders[i] > 1024) {
link->setCurrentIndex(phase.rotaryEncoders[i] - 1024);
}
reLayout->addWidget(link, i, 1, 1, 1);
}
// RE value
reValues[i] = new QSpinBox(ui->reGB);
reValues[i]->setProperty("index", i);
reValues[i]->setMinimum(-1024);
reValues[i]->setMaximum(1024);
connect(reValues[i], SIGNAL(editingFinished()), this, SLOT(phaseREValue_editingFinished()));
reLayout->addWidget(reValues[i], i, 2, 1, 1);
}
}
else {
ui->reGB->hide();
}
// GVars
if (gvCount > 0) {
QGridLayout *gvLayout = new QGridLayout(ui->gvGB);
for (int i=0; i<gvCount; i++) {
int col = 0;
// GVar label
QLabel *label = new QLabel(ui->gvGB);
label->setText(tr("GVAR%1").arg(i+1));
gvLayout->addWidget(label, i, col++, 1, 1);
#if 0
// TODO remove this capability?
// GVar source (er9x/ersky9x)
if (GetEepromInterface()->getCapability(GvarsHaveSources)) {
QComboBox *source = new QComboBox(ui->gvGB);
source->setProperty("index", i);
populateGvSourceCB(source, model.gvsource[i]);
// connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVSource_currentIndexChanged(int)));
gvLayout->addWidget(source, i, col++, 1, 1);
}
#endif
// GVar name
int nameLen = GetEepromInterface()->getCapability(GvarsName);
if (nameLen > 0) {
gvNames[i] = new QLineEdit(ui->gvGB);
gvNames[i]->setProperty("index", i);
gvNames[i]->setMaxLength(nameLen);
connect(gvNames[i], SIGNAL(editingFinished()), this, SLOT(GVName_editingFinished()));
gvLayout->addWidget(gvNames[i], i, col++, 1, 1);
}
if (phaseIdx > 0) {
// GVar link to another GVar
QComboBox *link = new QComboBox(ui->gvGB);
link->setProperty("index", i);
populateGvarUseCB(link, phaseIdx);
if (phase.gvars[i] > 1024) {
link->setCurrentIndex(phase.gvars[i] - 1024);
}
connect(link, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVUse_currentIndexChanged(int)));
gvLayout->addWidget(link, i, col++, 1, 1);
}
// GVar value
gvValues[i] = new QSpinBox(ui->gvGB);
gvValues[i]->setProperty("index", i);
connect(gvValues[i], SIGNAL(editingFinished()), this, SLOT(phaseGVValue_editingFinished()));
gvValues[i]->setMinimum(-1024);
gvValues[i]->setMaximum(1024);
gvLayout->addWidget(gvValues[i], i, col++, 1, 1);
}
}
else {
ui->gvGB->hide();
}
update();
}
FlightMode::~FlightMode()
{
delete ui;
}
void FlightMode::update()
{
ui->name->setText(phase.name);
int scale = GetEepromInterface()->getCapability(SlowScale);
ui->fadeIn->setValue(float(phase.fadeIn)/scale);
ui->fadeOut->setValue(float(phase.fadeOut)/scale);
for (int i=0; i<4; i++) {
int trimsMax = GetEepromInterface()->getCapability(ExtendedTrims);
if (trimsMax == 0 || !model.extendedTrims) {
trimsMax = 125;
}
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
trimsValue[i]->setRange(-trimsMax, +trimsMax);
int chn = CONVERT_MODE(i+1)-1;
if (chn == 2/*TODO constant*/ && model.throttleReversed)
trimsSlider[i]->setInvertedAppearance(true);
trimUpdate(i);
}
for (int i=0; i<gvCount; i++) {
gvNames[i]->setText(model.gvars_names[i]);
if (phase.gvars[i] < 1024) {
gvValues[i]->setValue(phase.gvars[i]);
gvValues[i]->setDisabled(false);
}
else {
int idx = phase.gvars[i] - 1025;
if (idx >= i) idx++;
// TODO no!!!!
PhaseData *phasegvar = &model.phaseData[idx];
gvValues[i]->setValue(phasegvar->gvars[i]);
gvValues[i]->setDisabled(true);
}
}
for (int i=0; i<reCount; i++) {
if (phase.rotaryEncoders[i] < 1024) {
reValues[i]->setValue(phase.rotaryEncoders[i]);
reValues[i]->setDisabled(false);
}
else {
int idx = phase.rotaryEncoders[i] - 1025;
if (idx >= i) idx++;
// TODO no!!!!
PhaseData *phasere = &model.phaseData[idx];
reValues[i]->setValue(phasere->rotaryEncoders[i]);
reValues[i]->setDisabled(true);
}
}
}
void FlightMode::phaseName_editingFinished()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender());
strcpy(phase.name, lineEdit->text().toAscii());
emit modified();
emit nameModified();
}
void FlightMode::phaseSwitch_currentIndexChanged(int index)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
phase.swtch = RawSwitch(comboBox->itemData(index).toInt());
emit modified();
}
void FlightMode::phaseFadeIn_editingFinished()
{
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
int scale = GetEepromInterface()->getCapability(SlowScale);
phase.fadeIn = round(spinBox->value()*scale);
emit modified();
}
void FlightMode::phaseFadeOut_editingFinished()
{
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
int scale = GetEepromInterface()->getCapability(SlowScale);
phase.fadeOut = round(spinBox->value()*scale);
emit modified();
}
void FlightMode::trimUpdate(unsigned int trim)
{
lock = true;
int chn = CONVERT_MODE(trim+1)-1;
int value = phase.trim[chn];
if (phaseIdx > 0 && phase.trimRef[chn] >= 0) {
trimsUse[trim]->setCurrentIndex(1 + phase.trimRef[chn] - (phase.trimRef[chn] >= phaseIdx ? 1 : 0));
value = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn];
trimsValue[trim]->setEnabled(false);
trimsSlider[trim]->setEnabled(false);
}
else {
if (phaseIdx > 0) trimsUse[trim]->setCurrentIndex(0);
trimsValue[trim]->setEnabled(true);
trimsSlider[trim]->setEnabled(true);
}
trimsSlider[trim]->setValue(value);
trimsValue[trim]->setValue(value);
lock = false;
}
void FlightMode::phaseGVValue_editingFinished()
{
if (!lock) {
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
int gvar = spinBox->property("index").toInt();
phase.gvars[gvar] = spinBox->value();
emit modified();
}
}
void FlightMode::GVName_editingFinished()
{
if (!lock) {
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
int gvar = lineedit->property("index").toInt();
memset(&model.gvars_names[gvar], 0, sizeof(model.gvars_names[gvar]));
strcpy(model.gvars_names[gvar], lineedit->text().toAscii());
emit modified();
}
}
void FlightMode::GVSource_currentIndexChanged(int index)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int gvar = comboBox->property("index").toInt();
model.gvsource[gvar] = index;
emit modified();
}
void FlightMode::phaseGVUse_currentIndexChanged(int index)
{
if (!lock) {
lock = true;
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int gvar = comboBox->property("index").toInt();
if (index == 0) {
int value = phase.gvars[gvar];
if (value>1024) {
value=0;
}
gvValues[gvar]->setValue(value);
gvValues[gvar]->setEnabled(true);
phase.gvars[gvar]=value;
}
else {
phase.gvars[gvar] = 1024+index;
// TOTO it's wrong!!!
int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].gvars[gvar];
gvValues[gvar]->setValue(value);
gvValues[gvar]->setDisabled(true);
}
emit modified();
lock = false;
}
}
void FlightMode::phaseREValue_editingFinished()
{
if (!lock) {
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
int gvar = spinBox->property("index").toInt();
phase.rotaryEncoders[gvar] = spinBox->value();
emit modified();
}
}
void FlightMode::phaseREUse_currentIndexChanged(int index)
{
if (!lock) {
lock = true;
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int re = comboBox->property("index").toInt();
if (index == 0) {
// TODO no!!!
int value = phase.rotaryEncoders[re];
if (value > 1024) {
value = 0;
}
reValues[re]->setValue(value);
reValues[re]->setEnabled(true);
phase.rotaryEncoders[re] = value;
}
else {
phase.rotaryEncoders[re] = 1024 + index;
int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].rotaryEncoders[re];
reValues[re]->setValue(value);
reValues[re]->setDisabled(true) ;
}
lock = false;
emit modified();
}
}
void FlightMode::phaseTrimUse_currentIndexChanged(int index)
{
if (!lock) {
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int trim = comboBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
if (index == 0) {
phase.trim[chn] = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn];
phase.trimRef[chn] = -1;
}
else {
phase.trim[chn] = 0;
phase.trimRef[chn] = index - 1 + (index > (int)phaseIdx ? 1 : 0);
}
trimUpdate(trim);
emit modified();
}
}
void FlightMode::phaseTrim_valueChanged()
{
if (!lock) {
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
int trim = spinBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = spinBox->value();
phase.trim[chn] = value;
lock = true;
trimsSlider[trim]->setValue(value);
lock = false;
emit modified();
}
}
void FlightMode::phaseTrimSlider_valueChanged()
{
if (!lock) {
QSlider *slider = qobject_cast<QSlider*>(sender());
int trim = slider->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = slider->value();
phase.trim[chn] = value;
lock = true;
trimsValue[trim]->setValue(value);
lock = false;
emit modified();
}
}
/**********************************************************/
FlightModes::FlightModes(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
modesCount(GetEepromInterface()->getCapability(FlightPhases))
{
QGridLayout * gridLayout = new QGridLayout(this);
tabWidget = new QTabWidget(this);
for (int i=0; i<modesCount; i++) {
FlightMode *tab = new FlightMode(tabWidget, model, i, generalSettings);
tab->setProperty("index", i);
panels << tab;
connect(tab, SIGNAL(modified()), this, SLOT(onPhaseModified()));
connect(tab, SIGNAL(nameModified()), this, SLOT(onPhaseNameChanged()));
tabWidget->addTab(tab, getTabName(i));
}
gridLayout->addWidget(tabWidget, 0, 0, 1, 1);
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(on_tabWidget_currentChanged(int)));
}
FlightModes::~FlightModes()
{
}
void FlightModes::onPhaseModified()
{
emit modified();
}
QString FlightModes::getTabName(int index)
{
QString result = tr("Flight Mode %1").arg(index);
const char *name = model.phaseData[index].name;
if (GetEepromInterface()->getCapability(FlightModesName) && strlen(name) > 0) {
result += tr(" (%1)").arg(name);
}
else if (index == 0) {
result += tr(" (default)");
}
return result;
}
void FlightModes::onPhaseNameChanged()
{
int index = sender()->property("index").toInt();
tabWidget->setTabText(index, getTabName(index));
}
void FlightModes::update()
{
on_tabWidget_currentChanged(tabWidget->currentIndex());
}
void FlightModes::on_tabWidget_currentChanged(int index)
{
panels[index]->update();
}
+86
View File
@@ -0,0 +1,86 @@
#ifndef FLIGHTMODES_H
#define FLIGHTMODES_H
#include "modelpanel.h"
#include <QVector>
#include <QLabel>
#include <QTabWidget>
#include <QSpinBox>
#include <QComboBox>
namespace Ui {
class FlightMode;
}
class FlightMode : public ModelPanel
{
Q_OBJECT
public:
FlightMode(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings);
virtual ~FlightMode();
virtual void update();
signals:
void nameModified();
private slots:
void phaseName_editingFinished();
void phaseSwitch_currentIndexChanged(int index);
void phaseFadeIn_editingFinished();
void phaseFadeOut_editingFinished();
void phaseTrimUse_currentIndexChanged(int index);
void phaseTrim_valueChanged();
void phaseTrimSlider_valueChanged();
void GVName_editingFinished();
void GVSource_currentIndexChanged(int index);
void phaseGVValue_editingFinished();
void phaseGVUse_currentIndexChanged(int index);
void phaseREValue_editingFinished();
void phaseREUse_currentIndexChanged(int index);
private:
Ui::FlightMode *ui;
GeneralSettings & generalSettings;
int phaseIdx;
PhaseData & phase;
int reCount;
int gvCount;
QVector<QLabel *> trimsLabel;
QLineEdit * gvNames[C9X_MAX_GVARS];
QSpinBox * gvValues[C9X_MAX_GVARS];
QSpinBox * reValues[C9X_MAX_ENCODERS];
QVector<QComboBox *> trimsUse;
QVector<QSpinBox *> trimsValue;
QVector<QSlider *> trimsSlider;
void trimUpdate(unsigned int trim);
};
class FlightModes : public ModelPanel
{
Q_OBJECT
public:
FlightModes(QWidget *parent, ModelData & model, GeneralSettings & generalSettings);
virtual ~FlightModes();
virtual void update();
private slots:
void onPhaseModified();
void onPhaseNameChanged();
void on_tabWidget_currentChanged(int index);
private:
int modesCount;
QTabWidget *tabWidget;
QString getTabName(int index);
QVector<FlightMode *> panels;
};
#endif // FLIGHTMODES_H
+49
View File
@@ -0,0 +1,49 @@
#include "heli.h"
#include "ui_heli.h"
#include "helpers.h"
HeliPanel::HeliPanel(QWidget *parent, ModelData & model):
ModelPanel(parent, model),
ui(new Ui::Heli)
{
ui->setupUi(this);
connect(ui->swashTypeCB, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(ui->swashCollectiveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(ui->swashRingValSB, SIGNAL(editingFinished()), this, SLOT(edited()));
connect(ui->swashInvertELE, SIGNAL(stateChanged(int)), this, SLOT(edited()));
connect(ui->swashInvertAIL, SIGNAL(stateChanged(int)), this, SLOT(edited()));
connect(ui->swashInvertCOL, SIGNAL(stateChanged(int)), this, SLOT(edited()));
}
HeliPanel::~HeliPanel()
{
delete ui;
}
void HeliPanel::update()
{
lock = true;
ui->swashTypeCB->setCurrentIndex(model.swashRingData.type);
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashRingValSB->setValue(model.swashRingData.value);
ui->swashInvertELE->setChecked(model.swashRingData.invertELE);
ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL);
ui->swashInvertCOL->setChecked(model.swashRingData.invertCOL);
lock = false;
}
void HeliPanel::edited()
{
if (!lock) {
model.swashRingData.type = ui->swashTypeCB->currentIndex();
model.swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt();
model.swashRingData.value = ui->swashRingValSB->value();
model.swashRingData.invertELE = ui->swashInvertELE->isChecked();
model.swashRingData.invertAIL = ui->swashInvertAIL->isChecked();
model.swashRingData.invertCOL = ui->swashInvertCOL->isChecked();
emit modified();
}
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef HELI_H
#define HELI_H
#include "modelpanel.h"
namespace Ui {
class Heli;
}
class HeliPanel : public ModelPanel
{
Q_OBJECT
public:
HeliPanel(QWidget *parent, ModelData & model);
~HeliPanel();
void update();
private slots:
void edited();
private:
Ui::Heli *ui;
};
#endif // HELI_H
+141
View File
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Heli</class>
<widget class="QWidget" name="Heli">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>795</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1" columnminimumwidth="100,0">
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="3" column="1">
<layout class="QGridLayout" name="gridLayout_21">
<item row="0" column="0">
<widget class="QCheckBox" name="swashInvertELE">
<property name="text">
<string>Invert Elevator</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="swashInvertAIL">
<property name="text">
<string>Invert Aileron</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="swashInvertCOL">
<property name="text">
<string>Invert Collective</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_108">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="swashTypeCB">
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>120</string>
</property>
</item>
<item>
<property name="text">
<string>120X</string>
</property>
</item>
<item>
<property name="text">
<string>140</string>
</property>
</item>
<item>
<property name="text">
<string>90</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_106">
<property name="text">
<string>Collective</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="swashCollectiveCB"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_103">
<property name="text">
<string>Swash Type</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="swashRingValSB">
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_107">
<property name="text">
<string>Swash Ring</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_21">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+450
View File
@@ -0,0 +1,450 @@
#include "inputs.h"
#include <QMessageBox>
#include "expodialog.h"
#include "helpers.h"
InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
generalSettings(generalSettings),
expoInserted(false)
{
QGridLayout * exposLayout = new QGridLayout(this);
ExposlistWidget = new MixersList(this, true);
QPushButton * qbUp = new QPushButton(this);
QPushButton * qbDown = new QPushButton(this);
QPushButton * qbClear = new QPushButton(this);
qbUp->setText(tr("Move Up"));
qbUp->setIcon(QIcon(":/images/moveup.png"));
qbUp->setShortcut(QKeySequence(tr("Ctrl+Up")));
qbDown->setText(tr("Move Down"));
qbDown->setIcon(QIcon(":/images/movedown.png"));
qbDown->setShortcut(QKeySequence(tr("Ctrl+Down")));
qbClear->setText(tr("Clear Expo Settings"));
qbClear->setIcon(QIcon(":/images/clear.png"));
exposLayout->addWidget(ExposlistWidget,1,1,1,3);
exposLayout->addWidget(qbUp,2,1);
exposLayout->addWidget(qbClear,2,2);
exposLayout->addWidget(qbDown,2,3);
connect(ExposlistWidget, SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(expolistWidget_customContextMenuRequested(QPoint)));
connect(ExposlistWidget, SIGNAL(doubleClicked(QModelIndex)),this,SLOT(expolistWidget_doubleClicked(QModelIndex)));
connect(ExposlistWidget, SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeExpoDropped(int,const QMimeData*,Qt::DropAction)));
connect(qbUp, SIGNAL(pressed()),SLOT(moveExpoUp()));
connect(qbDown, SIGNAL(pressed()),SLOT(moveExpoDown()));
connect(qbClear, SIGNAL(pressed()),SLOT(clearExpos()));
connect(ExposlistWidget, SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(expolistWidget_KeyPress(QKeyEvent*)));
}
InputsPanel::~InputsPanel()
{
}
void InputsPanel::update()
{
lock = true;
// curDest -> destination channel
// i -> mixer number
QByteArray qba;
ExposlistWidget->clear();
int curDest = -1;
for(int i=0; i<C9X_MAX_EXPOS; i++) {
ExpoData *md = &model.expoData[i];
if (md->mode==0) break;
QString str = "";
while(curDest<(int)md->chn-1) {
curDest++;
str = getStickStr(curDest);
qba.clear();
qba.append((quint8)-curDest-1);
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba);
ExposlistWidget->addItem(itm);
}
if(curDest!=(int)md->chn) {
str = getStickStr(md->chn);
curDest = md->chn;
} else {
str = " ";
}
if (!GetEepromInterface()->getCapability(VirtualInputs)) {
switch (md->mode) {
case (1): str += " <-"; break;
case (2): str += " ->"; break;
default: str += " "; break;
};
}
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight));
if (md->curve.value) str += " " + md->curve.toString();
QString phasesStr = getPhasesStr(md->phases, model);
if (!phasesStr.isEmpty()) str += " " + phasesStr;
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString());
if (GetEepromInterface()->getCapability(HasExpoNames)) {
QString ExpoName;
ExpoName.append(md->name);
if (!ExpoName.isEmpty()) {
str+=QString("(%1)").arg(ExpoName);
}
}
qba.clear();
qba.append((quint8)i);
qba.append((const char*)md, sizeof(ExpoData));
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba); // expo number
ExposlistWidget->addItem(itm); //(str);
}
while(curDest<NUM_STICKS-1) {
curDest++;
QString str = getStickStr(curDest);
qba.clear();
qba.append((quint8)-curDest-1);
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba); // add new expo
ExposlistWidget->addItem(itm);
}
lock = false;
}
bool InputsPanel::gm_insertExpo(int idx)
{
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
QMessageBox::information(this, "companion9x", tr("Not enough available expos!"));
return false;
}
int chn = model.expoData[idx].chn;
memmove(&model.expoData[idx+1],&model.expoData[idx],
(C9X_MAX_EXPOS-(idx+1))*sizeof(ExpoData) );
memset(&model.expoData[idx],0,sizeof(ExpoData));
model.expoData[idx].chn = chn;
model.expoData[idx].weight = 100;
model.expoData[idx].mode = 3 /* TODO enum */;
return true;
}
void InputsPanel::gm_deleteExpo(int index)
{
memmove(&model.expoData[index],&model.expoData[index+1],
(C9X_MAX_EXPOS-(index+1))*sizeof(ExpoData));
memset(&model.expoData[C9X_MAX_EXPOS-1],0,sizeof(ExpoData));
}
void InputsPanel::gm_openExpo(int index)
{
if(index<0 || index>=C9X_MAX_EXPOS) return;
ExpoData mixd(model.expoData[index]);
emit modified();
update();
ExpoDialog *g = new ExpoDialog(this, &mixd, generalSettings.stickMode);
if(g->exec()) {
model.expoData[index] = mixd;
emit modified();
update();
} else {
if (expoInserted) {
gm_deleteExpo(index);
}
expoInserted=false;
emit modified();
update();
}
}
int InputsPanel::getExpoIndex(unsigned int dch)
{
unsigned int i = 0;
while (model.expoData[i].chn<=dch && model.expoData[i].mode && i<C9X_MAX_EXPOS) i++;
if(i==C9X_MAX_EXPOS) return -1;
return i;
}
QList<int> InputsPanel::createExpoListFromSelected()
{
QList<int> list;
foreach(QListWidgetItem *item, ExposlistWidget->selectedItems()) {
int idx= item->data(Qt::UserRole).toByteArray().at(0);
if(idx>=0 && idx<C9X_MAX_EXPOS) list << idx;
}
return list;
}
void InputsPanel::setSelectedByExpoList(QList<int> list)
{
for(int i=0; i<ExposlistWidget->count(); i++) {
int t = ExposlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0);
if(list.contains(t))
ExposlistWidget->item(i)->setSelected(true);
}
}
void InputsPanel::exposDelete(bool ask)
{
QMessageBox::StandardButton ret = QMessageBox::No;
if(ask)
ret = QMessageBox::warning(this, "companion9x",
tr("Delete Selected Expos?"),
QMessageBox::Yes | QMessageBox::No);
if ((ret == QMessageBox::Yes) || (!ask)) {
exposDeleteList(createExpoListFromSelected());
emit modified();
update();
}
}
void InputsPanel::exposCut()
{
exposCopy();
exposDelete(false);
}
void InputsPanel::exposCopy()
{
QList<int> list = createExpoListFromSelected();
QByteArray mxData;
foreach(int idx, list) {
mxData.append((char*)&model.expoData[idx],sizeof(ExpoData));
}
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion9x-expo", mxData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void InputsPanel::mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction /*action*/)
{
int idx = ExposlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0);
pasteExpoMimeData(data, idx);
}
#include <iostream>
#include <QtGui/qwidget.h>
void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
{
if (mimeData->hasFormat("application/x-companion9x-expo")) {
int idx; // mixer index
int dch;
if (destIdx < 0) {
dch = -destIdx - 1;
idx = getExpoIndex(dch) - 1; //get expo index to insert
} else {
idx = destIdx;
dch = model.expoData[idx].chn;
}
QByteArray mxData = mimeData->data("application/x-companion9x-expo");
int i = 0;
while (i < mxData.size()) {
idx++;
if (!gm_insertExpo(idx))
break;
ExpoData *md = &model.expoData[idx];
memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData));
md->chn = dch;
i += sizeof(ExpoData);
}
emit modified();
update();
}
}
void InputsPanel::exposPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
QListWidgetItem *item = ExposlistWidget->currentItem();
if (item)
pasteExpoMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0));
}
void InputsPanel::exposDuplicate()
{
exposCopy();
exposPaste();
}
void InputsPanel::expoOpen(QListWidgetItem *item)
{
if (!item)
item = ExposlistWidget->currentItem();
int idx = item->data(Qt::UserRole).toByteArray().at(0);
if (idx<0) {
int ch = -idx-1;
idx = getExpoIndex(ch); // get expo index to insert
if (!gm_insertExpo(idx))
return;
model.expoData[idx].chn = ch;
expoInserted=true;
} else {
expoInserted=false;
}
gm_openExpo(idx);
}
void InputsPanel::expoAdd()
{
int index = ExposlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0);
if(index<0) { // if empty then return relevant index
expoOpen();
} else {
index++;
if (!gm_insertExpo(index))
return;
model.expoData[index].chn = model.expoData[index-1].chn;
}
gm_openExpo(index);
}
void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos)
{
QPoint globalPos = ExposlistWidget->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion9x-expo");
QMenu contextMenu;
contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A"));
contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(expoOpen()),tr("Enter"));
contextMenu.addSeparator();
contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(exposDelete()),tr("Delete"));
contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C"));
contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X"));
contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U"));
contextMenu.addSeparator();
contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up"));
contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down"));
contextMenu.exec(globalPos);
}
void InputsPanel::expolistWidget_KeyPress(QKeyEvent *event)
{
if(event->matches(QKeySequence::SelectAll)) expoAdd(); //Ctrl A
if(event->matches(QKeySequence::Delete)) exposDelete();
if(event->matches(QKeySequence::Copy)) exposCopy();
if(event->matches(QKeySequence::Cut)) exposCut();
if(event->matches(QKeySequence::Paste)) exposPaste();
if(event->matches(QKeySequence::Underline)) exposDuplicate();
if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) expoOpen();
if(event->matches(QKeySequence::MoveToNextLine))
ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()+1);
if(event->matches(QKeySequence::MoveToPreviousLine))
ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()-1);
}
int InputsPanel::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up
{
if(idx>C9X_MAX_EXPOS || (idx==C9X_MAX_EXPOS && dir)) return idx;
int tdx = dir ? idx+1 : idx-1;
ExpoData temp;
temp.clear();
ExpoData &src=model.expoData[idx];
ExpoData &tgt=model.expoData[tdx];
if (!dir && tdx<0 && src.chn>0) {
src.chn--;
return idx;
} else if (!dir && tdx<0) {
return idx;
}
if(memcmp(&src,&temp,sizeof(ExpoData))==0) return idx;
bool tgtempty=(memcmp(&tgt,&temp,sizeof(ExpoData))==0 ? 1:0);
if(tgt.chn!=src.chn || tgtempty) {
if ((dir) && (src.chn<(NUM_STICKS-1))) src.chn++;
if ((!dir) && (src.chn>0)) src.chn--;
return idx;
}
//flip between idx and tgt
memcpy(&temp,&src,sizeof(ExpoData));
memcpy(&src,&tgt,sizeof(ExpoData));
memcpy(&tgt,&temp,sizeof(ExpoData));
return tdx;
}
void InputsPanel::moveExpoUp()
{
QList<int> list = createExpoListFromSelected();
QList<int> highlightList;
foreach(int idx, list) {
highlightList << gm_moveExpo(idx, false);
}
emit modified();
update();
setSelectedByExpoList(highlightList);
}
void InputsPanel::moveExpoDown()
{
QList<int> list = createExpoListFromSelected();
QList<int> highlightList;
foreach(int idx, list) {
highlightList << gm_moveExpo(idx, true);
}
emit modified();
update();
setSelectedByExpoList(highlightList);
}
void InputsPanel::expolistWidget_doubleClicked(QModelIndex index)
{
expoOpen(ExposlistWidget->item(index.row()));
}
void InputsPanel::exposDeleteList(QList<int> list)
{
qSort(list.begin(), list.end());
int iDec = 0;
foreach(int idx, list) {
gm_deleteExpo(idx-iDec);
iDec++;
}
}
void InputsPanel::clearExpos()
{
if (QMessageBox::question(this, tr("Clear Expos?"), tr("Really clear all the expos?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
model.clearInputs();
emit modified();
update();
}
}
+50
View File
@@ -0,0 +1,50 @@
#ifndef INPUTS_H
#define INPUTS_H
#include "modelpanel.h"
#include "mixerslist.h"
class InputsPanel : public ModelPanel
{
Q_OBJECT
public:
InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings);
virtual ~InputsPanel();
virtual void update();
private slots:
void clearExpos();
void moveExpoUp();
void moveExpoDown();
void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action);
void expolistWidget_customContextMenuRequested(QPoint pos);
void expolistWidget_doubleClicked(QModelIndex index);
void expolistWidget_KeyPress(QKeyEvent *event);
void exposDelete(bool ask=true);
void exposCut();
void exposCopy();
void exposPaste();
void exposDuplicate();
void expoOpen(QListWidgetItem *item = NULL);
void expoAdd();
private:
GeneralSettings & generalSettings;
bool expoInserted;
MixersList *ExposlistWidget;
int getExpoIndex(unsigned int dch);
bool gm_insertExpo(int idx);
void gm_deleteExpo(int index);
void gm_openExpo(int index);
int gm_moveExpo(int idx, bool dir);
void exposDeleteList(QList<int> list);
QList<int> createExpoListFromSelected();
void setSelectedByExpoList(QList<int> list);
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
};
#endif // INPUTS_H
@@ -6,7 +6,8 @@
MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
QDialog(parent),
ui(new Ui::MixerDialog),
md(mixdata)
md(mixdata),
lock(false)
{
ui->setupUi(this);
QRegExp rx(CHAR_FOR_NAMES_REGEX);
@@ -17,109 +18,71 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
this->setWindowTitle(tr("DEST -> X%1").arg(md->destCh-GetEepromInterface()->getCapability(Outputs)));
else
this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10));
populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
ui->sourceCB->removeItem(0);
int limit=GetEepromInterface()->getCapability(OffsetWeight);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
if (gvars==0) {
ui->offsetGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->differentialGV->setDisabled(true);
if (md->weight>limit || md->weight<-limit) {
md->weight=100;
}
if (md->sOffset>limit || md->sOffset<-limit) {
md->sOffset=0;
}
if (md->differential>100 || md->weight<-100) {
md->differential=0;
}
}
populateGVCB(ui->offsetCB,md->sOffset);
populateGVCB(ui->weightCB,md->weight);
populateGVCB(ui->differentialCB,md->differential);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
if (md->weight>limit || md->weight<-limit) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(md->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
if (md->sOffset>limit || md->sOffset<-limit) {
ui->offsetGV->setChecked(true);
ui->offsetSB->hide();
ui->offsetCB->show();
} else {
ui->offsetGV->setChecked(false);
ui->offsetSB->setValue(md->sOffset);
ui->offsetSB->show();
ui->offsetCB->hide();
}
ui->differentialSB->setMinimum(-100);
ui->differentialSB->setMaximum(100);
if (md->differential>100 || md->differential<-100) {
ui->differentialGV->setChecked(true);
ui->differentialSB->hide();
ui->differentialCB->show();
} else {
ui->differentialGV->setChecked(false);
ui->differentialSB->setValue(md->differential);
ui->differentialSB->show();
ui->differentialCB->hide();
}
} else {
ui->offsetGV->hide();
ui->weightGV->hide();
ui->differentialGV->hide();
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
ui->offsetSB->setValue(md->sOffset);
ui->differentialSB->setMinimum(-100);
ui->differentialSB->setMaximum(100);
ui->differentialSB->setValue(md->differential);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
ui->weightSB->setValue(md->weight);
gvars=1;
}
ui->FixOffsetChkB->setChecked(md->lateOffset);
ui->MixDR_CB->setChecked(md->noExpo==0);
if (md->enableFmTrim==1) {
ui->label_4->setText(tr("FM Trim Value"));
if (gvars==0) {
ui->offsetGV->setDisabled(true);
ui->weightGV->setDisabled(true);
if (md->weight>limit || md->weight<-limit) {
md->weight=100;
}
if (md->sOffset>limit || md->sOffset<-limit) {
md->sOffset=0;
}
}
populateGVCB(ui->offsetCB,md->sOffset);
populateGVCB(ui->weightCB,md->weight);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
if (md->weight>limit || md->weight<-limit) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
}
else {
ui->label_4->setText(tr("Offset"));
ui->weightGV->setChecked(false);
ui->weightSB->setValue(md->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
if (md->sOffset>limit || md->sOffset<-limit) {
ui->offsetGV->setChecked(true);
ui->offsetSB->hide();
ui->offsetCB->show();
}
else {
ui->offsetGV->setChecked(false);
ui->offsetSB->setValue(md->sOffset);
ui->offsetSB->show();
ui->offsetCB->hide();
}
if (GetEepromInterface()->getCapability(VirtualInputs)) {
ui->trimLabel->hide();
ui->trimCB->hide();
}
CurveGroup * curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve);
ui->MixDR_CB->setChecked(md->noExpo==0);
if (!GetEepromInterface()->getCapability(MixesWithoutExpo)) {
ui->MixDR_CB->hide();
ui->label_MixDR->hide();
}
if (!GetEepromInterface()->getCapability(MixFmTrim)) {
ui->FMtrimChkB->hide();
ui->label_FMtrim->hide();
ui->label_4->setText(tr("Offset"));
}
if (!GetEepromInterface()->getCapability(HasFixOffset)) {
ui->FixOffsetChkB->hide();
ui->label_FixOffset->hide();
}
if (GetEepromInterface()->getCapability(ExtraTrims)) {
ui->trimCB->addItem(tr("Rud"),1);
ui->trimCB->addItem(tr("Ele"),2);
@@ -127,12 +90,6 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
ui->trimCB->addItem(tr("Ail"),4);
}
ui->trimCB->setCurrentIndex((-md->carryTrim)+1);
if (!GetEepromInterface()->getCapability(DiffMixers)) {
ui->differentialGV->hide();
ui->differentialSB->hide();
ui->differentialCB->hide();
ui->label_curve->setText(tr("Curve"));
}
int namelength=GetEepromInterface()->getCapability(HasMixerNames);
if (!namelength) {
ui->label_name->hide();
@@ -146,7 +103,8 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
lb_fp[i]->hide();
cb_fp[i]->hide();
}
} else {
}
else {
int mask=1;
for (int i=0; i<9 ; i++) {
if ((md->phases & mask)==0) {
@@ -159,9 +117,10 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
cb_fp[i]->hide();
}
}
ui->mixerName->setValidator(new QRegExpValidator(rx, this));
ui->mixerName->setText(md->name);
populateCurvesCB(ui->curvesCB,md->curve);
populateSwitchCB(ui->switchesCB,md->swtch);
ui->warningCB->setCurrentIndex(md->mixWarn);
ui->mltpxCB->setCurrentIndex(md->mltpx);
@@ -190,18 +149,12 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->offsetCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->differentialCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->offsetSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->differentialSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); // TODO why the same slot?
connect(ui->offsetGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->differentialGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->trimCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->MixDR_CB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->FMtrimChkB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->FixOffsetChkB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->warningCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->mltpxCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
@@ -233,47 +186,43 @@ void MixerDialog::changeEvent(QEvent *e)
void MixerDialog::widgetChanged()
{
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==1) {
if (!GetEepromInterface()->getCapability(DiffMixers)) {
if (ui->differentialGV->isChecked()) {
ui->differentialCB->show();
ui->differentialSB->hide();
} else {
ui->differentialCB->hide();
ui->differentialSB->show();
}
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
if (ui->offsetGV->isChecked()) {
ui->offsetCB->show();
ui->offsetSB->hide();
} else {
ui->offsetCB->hide();
ui->offsetSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
int gvars = 0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars = 1;
}
}
else {
gvars = 1;
}
if (gvars == 1) {
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
}
else {
ui->weightCB->hide();
ui->weightSB->show();
}
if (ui->offsetGV->isChecked()) {
ui->offsetCB->show();
ui->offsetSB->hide();
}
else {
ui->offsetCB->hide();
ui->offsetSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
void MixerDialog::valuesChanged()
{
if (!lock) {
lock = true;
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) {
@@ -300,29 +249,6 @@ void MixerDialog::valuesChanged()
}
md->carryTrim = -(ui->trimCB->currentIndex()-1);
md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1;
md->lateOffset = ui->FixOffsetChkB->checkState() ? 1 : 0;
md->enableFmTrim = ui->FMtrimChkB->checkState() ? 1 : 0;
int numcurves=GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
}
if (GetEepromInterface()->getCapability(DiffMixers) && (ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves))==0){
ui->differentialGV->show();
if (ui->differentialGV->isChecked()) {
ui->differentialSB->hide();
ui->differentialCB->show();
} else {
ui->differentialSB->show();
ui->differentialCB->hide();
}
} else {
ui->differentialGV->hide();
ui->differentialGV->setChecked(false);
ui->differentialSB->hide();
ui->differentialSB->setValue(0);
ui->differentialCB->hide();
}
md->curve = ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves);
md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
md->mixWarn = ui->warningCB->currentIndex();
md->mltpx = (MltpxValue)ui->mltpxCB->currentIndex();
@@ -331,16 +257,7 @@ void MixerDialog::valuesChanged()
md->delayUp = round(ui->delayUpSB->value()*scale);
md->speedDown = round(ui->slowDownSB->value()*scale);
md->speedUp = round(ui->slowUpSB->value()*scale);
if (ui->differentialGV->isChecked()) {
md->differential = ui->differentialCB->itemData(ui->differentialCB->currentIndex()).toInt();
} else {
md->differential = ui->differentialSB->value();
}
if (GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1) {
ui->label_4->setText(tr("FM Trim Value"));
} else {
ui->label_4->setText(tr("Offset"));
}
int i=0;
for (i=0; i<ui->mixerName->text().toAscii().length(); i++) {
md->name[i]=ui->mixerName->text().toAscii().at(i);
@@ -354,6 +271,9 @@ void MixerDialog::valuesChanged()
md->phases<<=1;
}
md->phases>>=1;
lock = false;
}
}
void MixerDialog::shrink() {
@@ -26,6 +26,7 @@ private slots:
private:
Ui::MixerDialog *ui;
MixData *md;
bool lock;
};
#endif // MIXERDIALOG_H
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>475</height>
<width>342</width>
<height>434</height>
</rect>
</property>
<property name="sizePolicy">
@@ -20,7 +20,7 @@
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<iconset resource="../companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@@ -178,42 +178,28 @@ p, li { white-space: pre-wrap; }
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
<item row="12" column="1" colspan="2">
<widget class="QComboBox" name="mltpxCB">
<property name="whatsThis">
<string>Multiplexer
This determines how mixer values are added.
&quot;+&quot; means the value of the current mix is added to the previous mixes in the same channel.
&quot;*&quot; means the value of the current mix is amultiplied with the previous mixes in the same channel.
&quot;R&quot; means the value replaces the previous values. If the switch is off the value will be ignored.</string>
</property>
<item>
<property name="text">
<string>ADD</string>
</property>
</item>
<item>
<property name="text">
<string>MULTIPLY</string>
</property>
</item>
<item>
<property name="text">
<string>REPLACE</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="sourceCB">
<property name="whatsThis">
<string>The source for the mixer</string>
<item row="5" column="0">
<widget class="QLabel" name="trimLabel">
<property name="text">
<string>Include Trim</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lb_FP0">
@@ -370,20 +356,6 @@ This determines how mixer values are added.
</item>
</layout>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Warning</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Multiplex</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_name">
<property name="text">
@@ -398,52 +370,24 @@ This determines how mixer values are added.
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<item row="10" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_curve">
<property name="text">
<string>Curve/Differential</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Include Trim</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_FMtrim">
<property name="text">
<string>Enable FM Trim</string>
<string>Multiplex</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_phases">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Flight modes</string>
<string>Warning</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
<item row="4" column="1">
<widget class="QComboBox" name="curveTypeCB">
<property name="whatsThis">
<string>The curve used by the mix</string>
</property>
</widget>
</item>
@@ -454,14 +398,28 @@ This determines how mixer values are added.
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_FixOffset">
<item row="7" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Fix Offset</string>
<string>Flight modes</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<item row="8" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="MixDR_CB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="warningCB">
<property name="whatsThis">
<string>Mixer warning.
@@ -489,38 +447,18 @@ Setting this value will cause a beep to be emmitted when this value is active.</
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="curvesCB">
<property name="whatsThis">
<string>The curve used by the mix</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="MixDR_CB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="FixOffsetChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="FMtrimChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="5" column="1">
<widget class="QComboBox" name="trimCB">
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Yes</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1" colspan="2">
@@ -557,18 +495,46 @@ Setting this value will cause a beep to be emmitted when this value is active.</
</item>
</layout>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="trimCB">
<item row="10" column="1" colspan="2">
<widget class="QComboBox" name="mltpxCB">
<property name="whatsThis">
<string>Multiplexer
This determines how mixer values are added.
&quot;+&quot; means the value of the current mix is added to the previous mixes in the same channel.
&quot;*&quot; means the value of the current mix is amultiplied with the previous mixes in the same channel.
&quot;R&quot; means the value replaces the previous values. If the switch is off the value will be ignored.</string>
</property>
<item>
<property name="text">
<string>No</string>
<string>ADD</string>
</property>
</item>
<item>
<property name="text">
<string>Yes</string>
<string>MULTIPLY</string>
</property>
</item>
<item>
<property name="text">
<string>REPLACE</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="sourceCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_curve">
<property name="text">
<string>Curve</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
@@ -605,7 +571,7 @@ Setting this value will cause a beep to be emmitted when this value is active.</
</item>
</layout>
</item>
<item row="10" column="1" colspan="2">
<item row="8" column="1" colspan="2">
<widget class="QComboBox" name="switchesCB">
<property name="whatsThis">
<string>Switch used by the mix.
@@ -623,21 +589,21 @@ If blank then the mix is considered to be &quot;ON&quot; all the time.</string>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0">
<item>
<widget class="QCheckBox" name="differentialGV">
<widget class="QCheckBox" name="curveGVarCB">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="differentialCB">
<widget class="QComboBox" name="curveValueCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="differentialSB"/>
<widget class="QSpinBox" name="curveValueSB"/>
</item>
</layout>
</item>
@@ -646,7 +612,7 @@ If blank then the mix is considered to be &quot;ON&quot; all the time.</string>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
<include location="../companion9x.qrc"/>
</resources>
<connections>
<connection>
+514
View File
@@ -0,0 +1,514 @@
#include "mixes.h"
#include "helpers.h"
// #include <QMessageBox>
// #include "expodialog.h"
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
generalSettings(generalSettings),
mixInserted(false)
{
QGridLayout * mixesLayout = new QGridLayout(this);
MixerlistWidget = new MixersList(this, false); // TODO enum
QPushButton * qbUp = new QPushButton(this);
QPushButton * qbDown = new QPushButton(this);
QPushButton * qbClear = new QPushButton(this);
qbUp->setText(tr("Move Up"));
qbUp->setIcon(QIcon(":/images/moveup.png"));
qbUp->setShortcut(QKeySequence(tr("Ctrl+Up")));
qbDown->setText(tr("Move Down"));
qbDown->setIcon(QIcon(":/images/movedown.png"));
qbDown->setShortcut(QKeySequence(tr("Ctrl+Down")));
qbClear->setText(tr("Clear Mixes"));
qbClear->setIcon(QIcon(":/images/clear.png"));
mixesLayout->addWidget(MixerlistWidget,1,1,1,3);
mixesLayout->addWidget(qbUp,2,1);
mixesLayout->addWidget(qbClear,2,2);
mixesLayout->addWidget(qbDown,2,3);
connect(MixerlistWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(mixerlistWidget_customContextMenuRequested(QPoint)));
connect(MixerlistWidget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(mixerlistWidget_doubleClicked(QModelIndex)));
connect(MixerlistWidget,SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeMixerDropped(int,const QMimeData*,Qt::DropAction)));
connect(qbUp,SIGNAL(pressed()),SLOT(moveMixUp()));
connect(qbDown,SIGNAL(pressed()),SLOT(moveMixDown()));
connect(qbClear,SIGNAL(pressed()),SLOT(clearMixes()));
connect(MixerlistWidget,SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(mixerlistWidget_KeyPress(QKeyEvent*)));
}
MixesPanel::~MixesPanel()
{
}
void MixesPanel::update()
{
// curDest -> destination channel4
// i -> mixer number
QByteArray qba;
MixerlistWidget->clear();
unsigned int curDest = 0;
int i;
unsigned int outputs = GetEepromInterface()->getCapability(Outputs);
int showNames = false; // TODO in a menu ui->showNames_Ckb->isChecked();
for(i=0; i<GetEepromInterface()->getCapability(Mixes); i++) {
MixData *md = &model.mixData[i];
if ((md->destCh==0) || (md->destCh>outputs+(unsigned int)GetEepromInterface()->getCapability(ExtraChannels))) continue;
QString str = "";
while(curDest<(md->destCh-1)) {
curDest++;
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
} else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
qba.clear();
qba.append((quint8)-curDest);
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba);
MixerlistWidget->addItem(itm);
}
if (md->destCh > outputs) {
str = tr("X%1 ").arg(md->destCh-outputs);
} else {
str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10);
str.append(" ");
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[md->destCh-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
if (curDest != md->destCh) {
curDest = md->destCh;
} else {
str.fill(' ');
}
switch(md->mltpx) {
case (1): str += " *"; break;
case (2): str += " R"; break;
default: str += " "; break;
};
str += " " + md->srcRaw.toString();
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight, true));
QString phasesStr = getPhasesStr(md->phases, model);
if (!phasesStr.isEmpty()) str += " " + phasesStr;
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString());
if (md->carryTrim>0) {
str += " " + tr("No Trim");
}
else if (md->carryTrim<0) {
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
}
if (md->noExpo) str += " " + tr("No DR/Expo");
if (md->sOffset) str += " " + tr("Offset(%1)").arg(getGVarString(md->sOffset));
if (md->curve.value) str += " " + md->curve.toString();
int scale=GetEepromInterface()->getCapability(SlowScale);
if (scale==0)
scale=1;
if (md->delayDown || md->delayUp)
str += tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale);
if (md->speedDown || md->speedUp)
str += tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale);
if (md->mixWarn) str += tr(" Warn(%1)").arg(md->mixWarn);
if (GetEepromInterface()->getCapability(HasMixerNames)) {
QString MixerName;
MixerName.append(md->name);
if (!MixerName.isEmpty()) {
str += QString("(%1)").arg(MixerName);
}
}
qba.clear();
qba.append((quint8)i);
qba.append((const char*)md, sizeof(MixData));
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba); // mix number
MixerlistWidget->addItem(itm);//(str);
}
while(curDest<outputs+GetEepromInterface()->getCapability(ExtraChannels)) {
curDest++;
QString str;
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
}
else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
qba.clear();
qba.append((quint8)-curDest);
QListWidgetItem *itm = new QListWidgetItem(str);
itm->setData(Qt::UserRole,qba); // add new mixer
MixerlistWidget->addItem(itm);
}
}
bool MixesPanel::gm_insertMix(int idx)
{
if (idx<0 || idx>=GetEepromInterface()->getCapability(Mixes) || model.mixData[GetEepromInterface()->getCapability(Mixes)-1].destCh > 0) {
QMessageBox::information(this, "companion9x", tr("Not enough available mixers!"));
return false;
}
int i = model.mixData[idx].destCh;
memmove(&model.mixData[idx+1],&model.mixData[idx],
(GetEepromInterface()->getCapability(Mixes)-(idx+1))*sizeof(MixData) );
memset(&model.mixData[idx],0,sizeof(MixData));
model.mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE);
model.mixData[idx].destCh = i;
model.mixData[idx].weight = 100;
return true;
}
void MixesPanel::gm_deleteMix(int index)
{
memmove(&model.mixData[index],&model.mixData[index+1],
(GetEepromInterface()->getCapability(Mixes)-(index+1))*sizeof(MixData));
memset(&model.mixData[GetEepromInterface()->getCapability(Mixes)-1],0,sizeof(MixData));
}
void MixesPanel::gm_openMix(int index)
{
if(index<0 || index>=GetEepromInterface()->getCapability(Mixes)) return;
MixData mixd(model.mixData[index]);
emit modified();
update();
MixerDialog *g = new MixerDialog(this, &mixd, generalSettings.stickMode);
if(g->exec()) {
model.mixData[index] = mixd;
emit modified();
update();
} else {
if (mixInserted) {
gm_deleteMix(index);
}
mixInserted=false;
emit modified();
update();
}
}
int MixesPanel::getMixerIndex(unsigned int dch)
{
int i = 0;
while ((model.mixData[i].destCh<=dch) && (model.mixData[i].destCh) && (i<GetEepromInterface()->getCapability(Mixes))) i++;
if(i==GetEepromInterface()->getCapability(Mixes)) return -1;
return i;
}
void MixesPanel::mixerlistWidget_doubleClicked(QModelIndex index)
{
int idx= MixerlistWidget->item(index.row())->data(Qt::UserRole).toByteArray().at(0);
if (idx<0) {
int i = -idx;
idx = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(idx))
return;
model.mixData[idx].destCh = i;
mixInserted=true;
} else {
mixInserted=false;
}
gm_openMix(idx);
}
void MixesPanel::mixersDeleteList(QList<int> list)
{
qSort(list.begin(), list.end());
int iDec = 0;
foreach(int idx, list) {
gm_deleteMix(idx-iDec);
iDec++;
}
}
QList<int> MixesPanel::createMixListFromSelected()
{
QList<int> list;
foreach(QListWidgetItem *item, MixerlistWidget->selectedItems()) {
int idx= item->data(Qt::UserRole).toByteArray().at(0);
if(idx>=0 && idx<GetEepromInterface()->getCapability(Mixes)) list << idx;
}
return list;
}
// TODO duplicated code
void MixesPanel::setSelectedByMixList(QList<int> list)
{
for(int i=0; i<MixerlistWidget->count(); i++) {
int t = MixerlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0);
if(list.contains(t))
MixerlistWidget->item(i)->setSelected(true);
}
}
void MixesPanel::mixersDelete(bool ask)
{
QMessageBox::StandardButton ret = QMessageBox::No;
if(ask)
ret = QMessageBox::warning(this, "companion9x",
tr("Delete Selected Mixes?"),
QMessageBox::Yes | QMessageBox::No);
if ((ret == QMessageBox::Yes) || (!ask)) {
mixersDeleteList(createMixListFromSelected());
emit modified();
update();
}
}
void MixesPanel::mixersCut()
{
mixersCopy();
mixersDelete(false);
}
void MixesPanel::mixersCopy()
{
QList<int> list = createMixListFromSelected();
QByteArray mxData;
foreach(int idx, list) {
mxData.append((char*)&model.mixData[idx],sizeof(MixData));
}
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion9x-mix", mxData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
{
if(mimeData->hasFormat("application/x-companion9x-mix")) {
int idx; // mixer index
int dch;
if(destIdx<0) {
dch = -destIdx;
idx = getMixerIndex(dch) - 1; //get mixer index to insert
} else {
idx = destIdx;
dch = model.mixData[idx].destCh;
}
QByteArray mxData = mimeData->data("application/x-companion9x-mix");
int i = 0;
while(i<mxData.size()) {
idx++;
if(idx==GetEepromInterface()->getCapability(Mixes)) break;
if (!gm_insertMix(idx))
break;
MixData *md = &model.mixData[idx];
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
md->destCh = dch;
i += sizeof(MixData);
}
emit modified();
update();
}
}
void MixesPanel::mixersPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
QListWidgetItem *item = MixerlistWidget->currentItem();
if (item)
pasteMixerMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0));
}
void MixesPanel::mixersDuplicate()
{
mixersCopy();
mixersPaste();
}
void MixesPanel::mixerOpen()
{
int idx = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0);
if(idx<0) {
int i = -idx;
idx = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(idx))
return;
model.mixData[idx].destCh = i;
mixInserted=true;
} else {
mixInserted=false;
}
gm_openMix(idx);
}
void MixesPanel::mixerAdd()
{
if (!MixerlistWidget->currentItem())
return;
int index = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0);
if(index<0) { // if empty then return relavent index
int i = -index;
index = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(index))
return;
model.mixData[index].destCh = i;
mixInserted=true;
} else {
index++;
if (!gm_insertMix(index))
return;
model.mixData[index].destCh = model.mixData[index-1].destCh;
mixInserted=true;
}
gm_openMix(index);
}
void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos)
{
QPoint globalPos = MixerlistWidget->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion9x-mix");
QMenu contextMenu;
contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A"));
contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter"));
contextMenu.addSeparator();
contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete"));
contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C"));
contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X"));
contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U"));
contextMenu.addSeparator();
contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up"));
contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down"));
contextMenu.exec(globalPos);
}
void MixesPanel::mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction /*action*/)
{
int idx= MixerlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0);
pasteMixerMimeData(data, idx);
}
void MixesPanel::mixesEdited()
{
emit modified();
}
void MixesPanel::mixerlistWidget_KeyPress(QKeyEvent *event)
{
if(event->matches(QKeySequence::SelectAll)) mixerAdd(); //Ctrl A
if(event->matches(QKeySequence::Delete)) mixersDelete();
if(event->matches(QKeySequence::Copy)) mixersCopy();
if(event->matches(QKeySequence::Cut)) mixersCut();
if(event->matches(QKeySequence::Paste)) mixersPaste();
if(event->matches(QKeySequence::Underline)) mixersDuplicate();
if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) mixerOpen();
if(event->matches(QKeySequence::MoveToNextLine))
MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()+1);
if(event->matches(QKeySequence::MoveToPreviousLine))
MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()-1);
}
int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up
{
if(idx>GetEepromInterface()->getCapability(Mixes) || (idx==0 && !dir) || (idx==GetEepromInterface()->getCapability(Mixes) && dir)) return idx;
int tdx = dir ? idx+1 : idx-1;
MixData &src=model.mixData[idx];
MixData &tgt=model.mixData[tdx];
unsigned int outputs = GetEepromInterface()->getCapability(Outputs);
if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx;
if (tgt.destCh!=src.destCh) {
if ((dir) && (src.destCh<outputs)) src.destCh++;
if ((!dir) && (src.destCh>0)) src.destCh--;
return idx;
}
//flip between idx and tgt
MixData temp;
memcpy(&temp,&src,sizeof(MixData));
memcpy(&src,&tgt,sizeof(MixData));
memcpy(&tgt,&temp,sizeof(MixData));
return tdx;
}
void MixesPanel::moveMixUp()
{
QList<int> list = createMixListFromSelected();
QList<int> highlightList;
foreach(int idx, list) {
highlightList << gm_moveMix(idx, false);
}
emit modified();
update();
setSelectedByMixList(highlightList);
}
void MixesPanel::moveMixDown()
{
QList<int> list = createMixListFromSelected();
QList<int> highlightList;
foreach(int idx, list) {
highlightList << gm_moveMix(idx, true);
}
emit modified();
update();
setSelectedByMixList(highlightList);
}
void MixesPanel::clearMixes()
{
if (QMessageBox::question(this, tr("Clear Mixes?"), tr("Really clear all the mixes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
model.clearMixes();
emit modified();
update();
}
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef MIXES_H
#define MIXES_H
#include "modelpanel.h"
#include "mixerslist.h"
#include "mixerdialog.h"
class MixesPanel : public ModelPanel
{
Q_OBJECT
public:
MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings);
virtual ~MixesPanel();
virtual void update();
private slots:
// TODO all slots?
void clearMixes();
void mixersDelete(bool ask=true);
void mixersCut();
void mixersCopy();
void mixersPaste();
void mixersDuplicate();
void mixerOpen();
void mixerAdd();
void moveMixUp();
void moveMixDown();
void mixerlistWidget_customContextMenuRequested(QPoint pos);
void mixerlistWidget_doubleClicked(QModelIndex index);
void mixerlistWidget_KeyPress(QKeyEvent *event);
void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action);
void pasteMixerMimeData(const QMimeData * mimeData, int destIdx);
void mixesEdited();
private:
GeneralSettings & generalSettings;
MixersList *MixerlistWidget;
bool mixInserted;
int getMixerIndex(unsigned int dch);
bool gm_insertMix(int idx);
void gm_deleteMix(int index);
void gm_openMix(int index);
int gm_moveMix(int idx, bool dir);
void mixersDeleteList(QList<int> list);
QList<int> createMixListFromSelected();
void setSelectedByMixList(QList<int> list);
};
#endif // MIXES_H
+130
View File
@@ -0,0 +1,130 @@
#include "modeledit.h"
#include "ui_modeledit.h"
#include "setup.h"
#include "heli.h"
#include "flightmodes.h"
#include "inputs.h"
#include "mixes.h"
#include "channels.h"
#include "curves.h"
#include "customswitches.h"
#include "customfunctions.h"
#include "telemetry.h"
#include <QScrollArea>
ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool isNew, QWidget *parent) :
QDialog(parent),
ui(new Ui::ModelEdit),
modelId(modelId),
model(radioData.models[modelId]),
generalSettings(generalSettings)
{
ui->setupUi(this);
addTab(new Setup(this, model), tr("Setup"));
addTab(new HeliPanel(this, model), tr("Heli"));
addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes"));
addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs"));
addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes"));
addTab(new Channels(this, model), tr("Channels"));
addTab(new CustomSwitchesPanel(this, model), tr("Custom Switches"));
if (GetEepromInterface()->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Assignable Functions"));
addTab(new Curves(this, model), tr("Curves"));
// TODO remove this capability if (!GetEepromInterface()->getCapability(FSSwitch))
if (GetEepromInterface()->getCapability(Telemetry) & TM_HASTELEMETRY)
addTab(new TelemetryPanel(this, model), tr("Telemetry"));
}
ModelEdit::~ModelEdit()
{
delete ui;
}
class VerticalScrollArea : public QScrollArea
{
public:
VerticalScrollArea(QWidget * parent, ModelPanel * panel);
protected:
virtual bool eventFilter(QObject *o, QEvent *e);
private:
ModelPanel * panel;
QWidget * parent;
};
VerticalScrollArea::VerticalScrollArea(QWidget * parent, ModelPanel * panel):
QScrollArea(parent),
panel(panel),
parent(parent)
{
setWidgetResizable(true);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setWidget(panel);
panel->installEventFilter(this);
}
bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e)
{
if (o == panel && e->type() == QEvent::Resize) {
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
}
return false;
}
void ModelEdit::addTab(ModelPanel *panel, QString text)
{
panels << panel;
QWidget * widget = new QWidget(ui->tabWidget);
QVBoxLayout *baseLayout = new QVBoxLayout(widget);
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
baseLayout->addWidget(area);
ui->tabWidget->addTab(widget, text);
connect(panel, SIGNAL(modified()), this, SLOT(onTabModified()));
}
void ModelEdit::onTabModified()
{
emit modified();
}
void ModelEdit::on_tabWidget_currentChanged(int index)
{
panels[index]->update();
}
void ModelEdit::on_pushButton_clicked()
{
launchSimulation();
}
// TODO merge both
#include "simulatordialog.h"
#include "xsimulatordialog.h"
void ModelEdit::launchSimulation()
{
if (GetEepromInterface()->getSimulator()) {
RadioData *simuData = new RadioData();
simuData->generalSettings = generalSettings;
simuData->models[modelId] = model;
if (GetEepromInterface()->getCapability(SimulatorType)) {
xsimulatorDialog sd(this);
sd.loadParams(*simuData, modelId);
sd.exec();
}
else {
simulatorDialog sd(this);
sd.loadParams(*simuData, modelId);
sd.exec();
}
delete simuData;
}
else {
QMessageBox::warning(NULL,
QObject::tr("Warning"),
QObject::tr("Simulator for this firmware is not yet available"));
}
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef MODELEDIT_H
#define MODELEDIT_H
#include <QDialog>
#include "modelpanel.h"
namespace Ui {
class ModelEdit;
}
class ModelEdit : public QDialog
{
Q_OBJECT
public:
explicit ModelEdit(RadioData & radioData, int modelId , bool openWizard =false, bool inNew =false, QWidget *parent = 0);
~ModelEdit();
signals:
void modified();
private slots:
void onTabModified();
void on_pushButton_clicked();
void on_tabWidget_currentChanged(int index);
private:
Ui::ModelEdit *ui;
int modelId;
ModelData & model;
GeneralSettings & generalSettings;
QVector<ModelPanel *> panels;
void addTab(ModelPanel *panel, QString text);
void launchSimulation();
};
#endif // MODELEDIT_H
+67
View File
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModelEdit</class>
<widget class="QDialog" name="ModelEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>339</width>
<height>385</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Simulate</string>
</property>
<property name="icon">
<iconset resource="../companion9x.qrc">
<normaloff>:/images/simulate.png</normaloff>:/images/simulate.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../companion9x.qrc"/>
</resources>
<connections/>
</ui>
+30
View File
@@ -0,0 +1,30 @@
#include "modelpanel.h"
#include <QLabel>
ModelPanel::ModelPanel(QWidget * parent, ModelData & model):
QWidget(parent),
model(model),
lock(false)
{
}
ModelPanel::~ModelPanel()
{
}
void ModelPanel::update()
{
}
void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col)
{
QLabel *label = new QLabel(this);
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter);
label->setMargin(3);
label->setText(text);
gridLayout->addWidget(label, 0, col, 1, 1);
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef MODELPANEL_H
#define MODELPANEL_H
#include <QWidget>
#include <QGridLayout>
#include "eeprominterface.h"
class ModelPanel : public QWidget
{
Q_OBJECT
public:
ModelPanel(QWidget *parent, ModelData & model);
virtual ~ModelPanel();
signals:
void modified();
public slots:
virtual void update();
protected:
ModelData & model;
bool lock;
void addLabel(QGridLayout * gridLayout, QString text, int col);
};
#endif // CHANNELS_H
@@ -46,32 +46,28 @@
#include "edge.h"
#include "node.h"
#include "modeledit.h"
Node::Node(QSpinBox *sb,QSpinBox *sbx)
Node::Node():
minX(-100),
maxX(+100)
{
setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges);
setCacheMode(DeviceCoordinateCache);
setZValue(-1);
nodecolor = QColor(Qt::yellow);
qsb = sb;
qsbx = sbx;
bPressed = false;
centerX = true;
centerY = true;
fixedX = false;
fixedY = false;
ballSize = DEFAULT_BALL_SIZE;
minX=-100;
maxX=100;
setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges);
setCacheMode(DeviceCoordinateCache);
setZValue(-1);
nodecolor = QColor(Qt::yellow);
bPressed = false;
centerX = true;
centerY = true;
fixedX = false;
fixedY = false;
ballSize = DEFAULT_BALL_SIZE;
}
void Node::addEdge(Edge *edge)
{
edgeList << edge;
edge->adjust();
edgeList << edge;
edge->adjust();
}
void Node::stepToCenter(qreal step)
@@ -105,7 +101,7 @@ void Node::stepToCenter(qreal step)
}
void Node::setColor(QColor color)
void Node::setColor(const QColor & color)
{
nodecolor=color;
}
@@ -190,26 +186,23 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
if(fixedY) newPos.setY(y());//make sure x doesn't change
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));// bound X
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));// bound Y
if (qsb) {
ModelEdit* modeledit = qobject_cast<ModelEdit*>(qsb->parent()->parent()->parent()->parent()->parent()->parent()->parent());
modeledit->redrawCurve = false;
qsb->setValue(100+(rect.top()-y())*200/rect.height());
if (qsbx && !getFixedX()) {
int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width();
if (newX < minX) newX = minX;
if (newX > maxX) newX = maxX;
newPos.setX(((newX+100)*rect.width()/200+rect.left()));
qsbx->setValue(newX);
}
modeledit->redrawCurve = true;
int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width();
int newY = 100+(rect.top()-y())*200/rect.height();
if (newX < minX) newX = minX;
if (newX > maxX) newX = maxX;
if (!getFixedX()) {
newPos.setX(((newX+100)*rect.width()/200+rect.left()));
}
emit moved(newX, newY);
return newPos;
}
break;
case ItemPositionHasChanged:
foreach (Edge *edge, edgeList)
edge->adjust();
edge->adjust();
break;
default:
break;
@@ -222,25 +215,19 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
update();
bPressed = true;
if(qsb) qsb->setFocus();
QGraphicsItem::mousePressEvent(event);
emit focus();
}
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
update();
bPressed = false;
if(scene()) {
if(qsb) {
qsb->clearFocus();
ModelEdit* modeledit = qobject_cast<ModelEdit*>(qsb->parent()->parent()->parent()->parent()->parent()->parent()->parent());
QGraphicsItem::mouseReleaseEvent(event);
modeledit->drawCurve();
} else {
QGraphicsItem::mouseReleaseEvent(event);
}
//need to tell SB that it needs to write the value
} else {
if (scene()) {
QGraphicsItem::mouseReleaseEvent(event);
emit unfocus();
}
else {
QGraphicsItem::mouseReleaseEvent(event);
}
}
@@ -52,11 +52,12 @@ QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
QT_END_NAMESPACE
class Node : public QGraphicsItem
class Node : public QGraphicsObject
{
Q_OBJECT
public:
Node(QSpinBox *sb = 0, QSpinBox *sbx = 0);
public:
Node();
void addEdge(Edge *edge);
QList<Edge *> edges() const;
@@ -80,16 +81,19 @@ public:
bool getFixedY() {return fixedY;}
void setMinX(int val) {minX = val;};
void setMaxX(int val) {maxX = val;};
void setColor(QColor color);
void setColor(const QColor & color);
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
signals:
void moved(int x, int y);
void focus();
void unfocus();
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
private:
bool bPressed;
bool centerX;
bool centerY;
@@ -98,8 +102,6 @@ private:
int ballSize;
int minX;
int maxX;
QSpinBox *qsb;
QSpinBox *qsbx;
QList<Edge *> edgeList;
QPointF newPos;
QColor nodecolor;
+652
View File
@@ -0,0 +1,652 @@
#include "setup.h"
#include "ui_setup.h"
#include "ui_setup_timer.h"
#include "ui_setup_module.h"
#include "helpers.h"
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
ModelPanel(parent, model),
timer(timer),
ui(new Ui::Timer)
{
ui->setupUi(this);
// Mode
populateTimerSwitchCB(ui->mode, timer.mode);
if (!GetEepromInterface()->getCapability(PermTimers)) {
ui->persistent->hide();
ui->persistentValue->hide();
}
if (!GetEepromInterface()->getCapability(minuteBeep)) {
ui->minuteBeep->hide();
}
if (!GetEepromInterface()->getCapability(countdownBeep)) {
ui->countdownBeep->hide();
}
}
TimerPanel::~TimerPanel()
{
delete ui;
}
void TimerPanel::update()
{
int min = timer.val / 60;
int sec = timer.val % 60;
ui->value->setTime(QTime(0, min, sec));
if (GetEepromInterface()->getCapability(PermTimers)) {
int sign = 1;
int pvalue = timer.pvalue;
if (pvalue < 0) {
pvalue = -pvalue;
sign = -1;
}
int hours = pvalue / 3600;
pvalue -= hours * 3600;
int minutes = pvalue / 60;
int seconds = pvalue % 60;
ui->persistent->setChecked(timer.persistent);
ui->persistentValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
}
if (GetEepromInterface()->getCapability(minuteBeep)) {
ui->minuteBeep->setChecked(timer.minuteBeep);
}
if (GetEepromInterface()->getCapability(countdownBeep)) {
ui->countdownBeep->setChecked(timer.countdownBeep);
}
}
void TimerPanel::on_value_editingFinished()
{
timer.val = ui->value->time().minute()*60 + ui->value->time().second();
emit modified();
}
void TimerPanel::on_mode_currentIndexChanged(int index)
{
timer.mode = TimerMode(ui->mode->itemData(index).toInt());
emit modified();
}
void TimerPanel::on_persistent_toggled(bool checked)
{
timer.persistent = checked;
emit modified();
}
void TimerPanel::on_minuteBeep_toggled(bool checked)
{
timer.minuteBeep = checked;
emit modified();
}
void TimerPanel::on_countdownBeep_toggled(bool checked)
{
timer.countdownBeep = checked;
emit modified();
}
/******************************************************************************/
ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, int moduleIdx):
ModelPanel(parent, model),
module(module),
moduleIdx(moduleIdx),
ui(new Ui::Module)
{
lock = true;
ui->setupUi(this);
QString label;
if (moduleIdx < 0) {
label = tr("Trainer Module");
ui->trainerMode->setCurrentIndex(model.trainerMode);
}
else {
ui->label_trainerMode->hide();
ui->trainerMode->hide();
if (moduleIdx == 0)
label = tr("Internal Module");
else
label = tr("External Module");
}
ui->label_module->setText(label);
// The protocols available on this board
for (int i=0; i<PROTO_LAST; i++) {
if (GetEepromInterface()->isAvailable((Protocol)i, moduleIdx)) {
ui->protocol->addItem(getProtocolStr(i), (QVariant)i);
if (i == module.protocol) ui->protocol->setCurrentIndex(ui->protocol->count()-1);
}
}
if (GetEepromInterface()->getCapability(HasFailsafe)) {
for (int i=0; i<16; i++) {
QSlider * slider = new QSlider(this);
slider->setMinimumSize(QSize(30, 50));
slider->setRange(-100, 100);
QSpinBox * spinbox = new QSpinBox(this);
spinbox->setMinimumSize(QSize(20, 0));
spinbox->setRange(-100, 100);
slider->setProperty("index", i);
spinbox->setProperty("index", i);
failsafeSliders << slider;
failsafeSpins << spinbox;
ui->failsafesLayout->addWidget(slider, 2*(i/8), i%8, Qt::AlignHCenter);
ui->failsafesLayout->addWidget(spinbox, 1+2*(i/8), i%8, Qt::AlignHCenter);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
}
}
lock = false;
}
ModulePanel::~ModulePanel()
{
delete ui;
}
#define MASK_PROTOCOL 1
#define MASK_CHANNELS_COUNT 2
#define MASK_RX_NUMBER 4
#define MASK_CHANNELS_RANGE 8
#define MASK_PPM_FIELDS 16
#define MASK_FAILSAFES 32
void ModulePanel::update()
{
unsigned int mask = 0;
Protocol protocol = (Protocol)module.protocol;
if (moduleIdx >= 0 || model.trainerMode != 0) {
mask |= MASK_PROTOCOL;
switch (protocol) {
case OFF:
break;
case PXX_XJT_X16:
case PXX_XJT_D8:
case PXX_XJT_LR12:
case PXX_DJT:
mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER;
if (protocol==PXX_XJT_X16) mask |= MASK_FAILSAFES;
break;
case LP45:
case DSM2:
case DSMX:
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
module.channelsCount = 8;
break;
default:
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
break;
}
}
ui->label_protocol->setVisible(mask & MASK_PROTOCOL);
ui->protocol->setVisible(mask & MASK_PROTOCOL);
ui->label_rxNumber->setVisible(mask & MASK_PROTOCOL);
ui->rxNumber->setVisible(mask & MASK_PROTOCOL);
ui->rxNumber->setEnabled(mask & MASK_RX_NUMBER);
ui->rxNumber->setValue(model.modelId);
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsStart->setValue(module.channelsStart+1);
ui->label_channelsCount->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsCount->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsCount->setEnabled(mask & MASK_CHANNELS_COUNT);
ui->channelsCount->setValue(module.channelsCount);
ui->channelsCount->setSingleStep(GetEepromInterface()->getCapability(HasPPMStart) ? 1 : 2);
// PPM settings fields
ui->label_ppmPolarity->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmPolarity->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmPolarity->setCurrentIndex(module.ppmPulsePol);
ui->label_ppmDelay->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmDelay->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmDelay->setValue(module.ppmDelay);
ui->label_ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmFrameLength->setMinimum(module.channelsCount*(model.extendedLimits ? 2.250 :2)+3.5);
ui->ppmFrameLength->setMaximum(GetEepromInterface()->getCapability(PPMFrameLength));
ui->ppmFrameLength->setValue(22.5+((double)module.ppmFrameLength)*0.5);
if (GetEepromInterface()->getCapability(HasFailsafe)) {
ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES);
ui->failsafeMode->setVisible(mask & MASK_FAILSAFES);
ui->failsafeMode->setCurrentIndex(module.failsafeMode);
ui->label_failsafeFrame->setVisible(mask & MASK_FAILSAFES);
ui->failsafesFrame->setVisible(mask & MASK_FAILSAFES);
ui->failsafesFrame->setEnabled(module.failsafeMode == 1);
for (int i=0; i<failsafeSliders.size(); i++) {
failsafeSliders[i]->setValue(module.failsafeChannels[i]);
failsafeSpins[i]->setValue(module.failsafeChannels[i]);
}
}
}
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
{
if (!lock) {
model.trainerMode = index;
update();
emit modified();
}
}
void ModulePanel::on_protocol_currentIndexChanged(int index)
{
if (!lock) {
module.protocol = ui->protocol->itemData(index).toInt();
update();
emit modified();
}
}
void ModulePanel::on_ppmPolarity_currentIndexChanged(int index)
{
module.ppmPulsePol = index;
emit modified();
}
void ModulePanel::on_channelsCount_editingFinished()
{
if (!lock) {
module.channelsCount = ui->channelsCount->value();
update();
emit modified();
}
}
void ModulePanel::on_channelsStart_editingFinished()
{
if (!lock) {
module.channelsStart = ui->channelsStart->value() - 1;
update();
emit modified();
}
}
void ModulePanel::on_ppmDelay_editingFinished()
{
if (!lock) {
// TODO only accept valid values
module.ppmDelay = ui->ppmDelay->value();
emit modified();
}
}
void ModulePanel::on_rxNumber_editingFinished()
{
model.modelId = ui->rxNumber->value();
emit modified();
}
void ModulePanel::on_ppmFrameLength_editingFinished()
{
module.ppmFrameLength = (ui->ppmFrameLength->value()-22.5) / 0.5;
emit modified();
}
void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
{
if (!lock) {
module.failsafeMode = value;
update();
emit modified();
}
}
void ModulePanel::onFailsafeChannelChanged(int value)
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
module.failsafeChannels[index] = value;
failsafeSpins[index]->setValue(value);
failsafeSliders[index]->setValue(value);
emit modified();
lock = false;
}
}
/******************************************************************************/
Setup::Setup(QWidget *parent, ModelData & model):
ModelPanel(parent, model),
ui(new Ui::Setup)
{
lock = true;
memset(modules, 0, sizeof(modules));
ui->setupUi(this);
ui->name->setMaxLength(IS_TARANIS(GetEepromInterface()->getBoard()) ? 12 : 10);
for (int i=0; i<C9X_MAX_TIMERS; i++) {
timers[i] = new TimerPanel(this, model, model.timers[i]);
ui->gridLayout->addWidget(timers[i], 1+i, 1);
connect(timers[i], SIGNAL(modified()), this, SLOT(onChildModified()));
}
for (int i=0; i<GetEepromInterface()->getCapability(NumModules); i++) {
modules[i] = new ModulePanel(this, model, model.moduleData[i], i);
ui->modulesLayout->addWidget(modules[i]);
connect(modules[i], SIGNAL(modified()), this, SLOT(onChildModified()));
}
if (GetEepromInterface()->getCapability(ModelTrainerEnable)) {
modules[C9X_NUM_MODULES] = new ModulePanel(this, model, model.moduleData[C9X_NUM_MODULES], -1);
ui->modulesLayout->addWidget(modules[C9X_NUM_MODULES]);
}
if (GetEepromInterface()->getCapability(ModelImage)) {
QStringList items;
items.append("");
QSettings settings("companion9x", "companion9x");
QString path = settings.value("sdPath", ".").toString();
path.append("/BMP/");
QDir qd(path);
int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4;
if (qd.exists()) {
QStringList filters;
filters << "*.bmp" << "*.bmp";
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
QFileInfo fi(file);
QString temp = fi.completeBaseName();
if (!items.contains(temp) && temp.length() <= vml) {
items.append(temp);
}
}
}
if (!items.contains(model.bitmap)) {
items.append(model.bitmap);
}
items.sort();
foreach ( QString file, items ) {
ui->image->addItem(file);
if (file == model.bitmap) {
ui->image->setCurrentIndex(ui->image->count()-1);
QString fileName = path;
fileName.append(model.bitmap);
fileName.append(".bmp");
QImage image(fileName);
if (image.isNull()) {
fileName = path;
fileName.append(model.bitmap);
fileName.append(".BMP");
image.load(fileName);
}
if (!image.isNull()) {
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
}
}
}
}
else {
ui->image->hide();
ui->modelImage_label->hide();
ui->imagePreview->hide();
}
// Beep Center checkboxes
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
QCheckBox * checkbox = new QCheckBox(this);
checkbox->setProperty("index", i);
checkbox->setText(i<analogs ? AnalogString(i) : RotaryEncoderString(i-analogs));
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
// Startup switches warnings
ui->switchesStartupWarning->setProperty("index", 0);
connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int)));
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QLabel * label = new QLabel();
QSlider * slider = new QSlider();
slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setInvertedAppearance(true);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval(1);
slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
label->setText(switchesX9D[i]);
slider->setMaximum(i==5 ? 1 : 2);
}
else {
label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1);
}
ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
startupSwitchesSliders << slider;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
lock = false;
}
Setup::~Setup()
{
delete ui;
}
void Setup::on_extendedLimits_toggled(bool checked)
{
model.extendedLimits = checked;
emit modified();
}
void Setup::on_throttleWarning_toggled(bool checked)
{
model.disableThrottleWarning = checked;
emit modified();
}
void Setup::on_throttleReverse_toggled(bool checked)
{
model.throttleReversed = checked;
emit modified();
}
void Setup::on_extendedTrims_toggled(bool checked)
{
model.extendedTrims = checked;
emit modified();
}
void Setup::on_trimIncrement_currentIndexChanged(int index)
{
model.trimInc = index;
emit modified();
}
void Setup::on_throttleSource_currentIndexChanged(int index)
{
model.thrTraceSrc = index;
emit modified();
}
void Setup::on_name_editingFinished()
{
int length = ui->name->maxLength();
strncpy(model.name, ui->name->text().toAscii(), length);
emit modified();
}
void Setup::on_image_currentIndexChanged(int index)
{
if (!lock) {
strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength));
QSettings settings("companion9x", "companion9x");
QString path=settings.value("sdPath", ".").toString();
path.append("/BMP/");
QDir qd(path);
if (qd.exists()) {
QString fileName=path;
fileName.append(model.bitmap);
fileName.append(".bmp");
QImage image(fileName);
if (image.isNull()) {
fileName=path;
fileName.append(model.bitmap);
fileName.append(".BMP");
image.load(fileName);
}
if (!image.isNull()) {
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
}
else {
ui->imagePreview->clear();
}
}
else {
ui->imagePreview->clear();
}
emit modified();
}
}
void Setup::update()
{
ui->name->setText(model.name);
ui->throttleReverse->setChecked(model.throttleReversed);
populateTTraceCB(ui->throttleSource, model.thrTraceSrc);
ui->throttleWarning->setChecked(model.disableThrottleWarning);
//trim inc, thro trim, thro expo, instatrim
ui->trimIncrement->setCurrentIndex(model.trimInc);
ui->throttleTrim->setChecked(model.thrTrim);
ui->extendedLimits->setChecked(model.extendedLimits);
ui->extendedTrims->setChecked(model.extendedTrims);
updateBeepCenter();
updateStartupSwitches();
for (int i=0; i<C9X_MAX_TIMERS; i++)
timers[i]->update();
for (int i=0; i<C9X_NUM_MODULES+1; i++)
if (modules[i])
modules[i]->update();
}
void Setup::updateBeepCenter()
{
for (int i=0; i<centerBeepCheckboxes.size(); i++) {
centerBeepCheckboxes[i]->setChecked(model.beepANACenter & (0x01 << i));
}
}
void Setup::updateStartupSwitches()
{
lock = true;
unsigned int switchStates = model.switchWarningStates;
bool enabled = !(switchStates & 0x01);
ui->switchesStartupWarning->setCurrentIndex(switchStates & 0x01);
switchStates >>= 1;
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QSlider * slider = startupSwitchesSliders[i];
slider->setEnabled(enabled);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3);
switchStates >>= 2;
}
else {
slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1);
switchStates >>= (i==0 ? 2 : 1);
}
}
lock = false;
}
void Setup::startupSwitchEdited(int value)
{
if (!lock) {
int shift = 0;
unsigned int mask;
int index = sender()->property("index").toInt();
if (index == 0) {
mask = 0x01;
}
else if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (index == 6)
mask = 0x02 << (index*2 - 1);
else {
shift = index*2 - 1;
mask = 0x03 << shift;
}
}
else {
if (index == 1) {
shift = 1;
mask = 0x03 << shift;
}
else {
mask = 0x01 << (index+1);
}
}
model.switchWarningStates &= ~mask;
if (value) {
if (shift == 0) {
model.switchWarningStates |= mask;
}
else {
model.switchWarningStates |= (value << shift);
}
}
updateStartupSwitches();
emit modified();
}
}
void Setup::on_throttleTrim_toggled(bool checked)
{
model.thrTrim = checked;
emit modified();
}
void Setup::onBeepCenterToggled(bool checked)
{
if (!lock) {
int index = sender()->property("index").toInt();
unsigned int mask = (0x01 << index);
if (checked)
model.beepANACenter |= mask;
else
model.beepANACenter &= ~mask;
emit modified();
}
}
void Setup::onChildModified()
{
emit modified();
}
+102
View File
@@ -0,0 +1,102 @@
#ifndef SETUP_H
#define SETUP_H
#include "modelpanel.h"
#include <QVector>
#include <QCheckBox>
#include <QSlider>
#include <QSpinBox>
namespace Ui {
class Setup;
class Timer;
class Module;
}
class TimerPanel : public ModelPanel
{
Q_OBJECT
public:
TimerPanel(QWidget *parent, ModelData & model, TimerData & timer);
virtual ~TimerPanel();
virtual void update();
private slots:
void on_mode_currentIndexChanged(int index);
void on_value_editingFinished();
void on_persistent_toggled(bool checked);
void on_minuteBeep_toggled(bool checked);
void on_countdownBeep_toggled(bool checked);
private:
TimerData & timer;
Ui::Timer *ui;
};
class ModulePanel : public ModelPanel
{
Q_OBJECT
public:
ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, int moduleIdx);
virtual ~ModulePanel();
virtual void update();
private slots:
void on_trainerMode_currentIndexChanged(int index);
void on_protocol_currentIndexChanged(int index);
void on_ppmDelay_editingFinished();
void on_channelsCount_editingFinished();
void on_channelsStart_editingFinished();
void on_ppmPolarity_currentIndexChanged(int index);
void on_ppmFrameLength_editingFinished();
void on_rxNumber_editingFinished();
void on_failsafeMode_currentIndexChanged(int value);
void onFailsafeChannelChanged(int value);
private:
ModuleData & module;
int moduleIdx;
Ui::Module *ui;
QVector<QSpinBox *> failsafeSpins;
QVector<QSlider *> failsafeSliders;
};
class Setup : public ModelPanel
{
Q_OBJECT
public:
Setup(QWidget *parent, ModelData & model);
virtual ~Setup();
virtual void update();
private slots:
void on_name_editingFinished();
void on_throttleSource_currentIndexChanged(int index);
void on_throttleTrim_toggled(bool checked);
void on_extendedLimits_toggled(bool checked);
void on_extendedTrims_toggled(bool checked);
void on_throttleWarning_toggled(bool checked);
void on_throttleReverse_toggled(bool checked);
void on_image_currentIndexChanged(int index);
void on_trimIncrement_currentIndexChanged(int index);
void onBeepCenterToggled(bool checked);
void startupSwitchEdited(int value);
void onChildModified();
private:
Ui::Setup *ui;
QVector<QSlider *> startupSwitchesSliders;
QVector<QCheckBox *> centerBeepCheckboxes;
ModulePanel * modules[C9X_NUM_MODULES+1];
TimerPanel * timers[C9X_MAX_TIMERS];
void updateStartupSwitches();
void updateBeepCenter();
};
#endif // SETUP_H
+378
View File
@@ -0,0 +1,378 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Setup</class>
<widget class="QWidget" name="Setup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>782</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Model Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_timer2">
<property name="text">
<string>Timer2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Timer1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_ttrace">
<property name="text">
<string>Throttle Source</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="swwarn_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Switch startup Warning</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Center beep</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QGridLayout" name="centerBeepLayout"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Trim Increment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0,0" columnstretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QComboBox" name="switchesStartupWarning">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>ON</string>
</property>
</item>
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="switchesStartupWarning_Label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Check</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0">
<item row="0" column="3">
<widget class="QComboBox" name="image"/>
</item>
<item row="0" column="4">
<widget class="QLabel" name="imagePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_26">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_24">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QLabel" name="modelImage_label">
<property name="text">
<string>Model Image</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="name">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="trimIncrement">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Exponential</string>
</property>
</item>
<item>
<property name="text">
<string>Extra Fine</string>
</property>
</item>
<item>
<property name="text">
<string>Fine</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Coarse</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="extendedLimits">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Extended Limits</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="extendedTrims">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Extended Trims</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="throttleSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleTrim">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Throttle Trim</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleWarning">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Throttle Warning</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleReverse">
<property name="whatsThis">
<string>Reverse throttle operation.
If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well.
</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Reverse Throttle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="modulesLayout"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+497
View File
@@ -0,0 +1,497 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Module</class>
<widget class="QWidget" name="Module">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>694</width>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="moduleGB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_69" rowstretch="0,0,0,0,0,0,0,0,0" columnstretch="0,0,0,0,0,0,0">
<item row="7" column="1" colspan="5">
<widget class="QFrame" name="failsafesFrame">
<property name="maximumSize">
<size>
<width>700</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="failsafesLayout"/>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_failsafeMode">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Failsafe Mode</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="2" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_channelsStart">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="protocol">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="4" column="4" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmDelay">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>PPM delay</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QSpinBox" name="ppmDelay">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> usec</string>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>800</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>300</number>
</property>
</widget>
</item>
<item row="4" column="3" alignment="Qt::AlignLeft">
<widget class="QComboBox" name="ppmPolarity">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Negative</string>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_rxNumber">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>RX Number</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="trainerMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Master</string>
</property>
</item>
<item>
<property name="text">
<string>Slave</string>
</property>
</item>
</widget>
</item>
<item row="4" column="2" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmPolarity">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Polarity</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_trainerMode">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Trainer Mode</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="rxNumber">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="ppmFrameLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string> mSec</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>12.500000000000000</double>
</property>
<property name="maximum">
<double>32.500000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="value">
<double>22.500000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmFrameLength">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>PPM Frame Length</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="QLabel" name="label_module">
<property name="styleSheet">
<string notr="true">font-weight: bold;</string>
</property>
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="3" column="5" alignment="Qt::AlignLeft">
<widget class="QSpinBox" name="channelsCount">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string>ch</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="singleStep">
<number>2</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
<item row="3" column="3" alignment="Qt::AlignLeft">
<widget class="QSpinBox" name="channelsStart">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string>ch</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="4" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_channelsCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Channels</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1" alignment="Qt::AlignLeft">
<widget class="QComboBox" name="failsafeMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Hold</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
<item>
<property name="text">
<string>No Pulses</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_failsafeFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Failsafe Positions</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_protocol">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Protocol</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+81
View File
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Timer</class>
<widget class="QWidget" name="Timer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>54</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTimeEdit" name="value">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="currentSection">
<enum>QDateTimeEdit::MinuteSection</enum>
</property>
<property name="displayFormat">
<string>mm:ss</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mode"/>
</item>
<item>
<widget class="QCheckBox" name="persistent">
<property name="text">
<string>Persistent</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="persistentValue">
<property name="text">
<string> (00:00:00)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="minuteBeep">
<property name="text">
<string>MinuteBeep</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="countdownBeep">
<property name="text">
<string>CountDownBeep</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>255</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+939
View File
@@ -0,0 +1,939 @@
#include "telemetry.h"
#include "ui_telemetry.h"
#include "ui_telemetry_analog.h"
#include "helpers.h"
TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
QWidget(parent),
ui(new Ui::TelemetryAnalog),
analog(analog),
lock(false)
{
ui->setupUi(this);
float ratio;
if (analog.type==0 || analog.type==1 || analog.type==2) {
ratio = (analog.ratio<<analog.multiplier)/10.0;
ui->RatioSB->setDecimals(1);
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
}
else {
ratio = analog.ratio<<analog.multiplier;
ui->RatioSB->setDecimals(0);
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
}
ui->RatioSB->setValue(ratio);
update();
ui->UnitCB->setCurrentIndex(analog.type);
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
if (!(GetEepromInterface()->getCapability(Telemetry) & TM_HASOFFSET)) {
ui->CalibSB->hide();
ui->CalibLabel->hide();
}
else {
ui->label_Max->setText(tr("Range"));
}
}
void TelemetryAnalog::update()
{
float ratio, alarm1value, alarm2value;
if (analog.ratio==0) {
ui->alarm1ValueSB->setMinimum(0);
ui->alarm1ValueSB->setMaximum(0);
ui->alarm2ValueSB->setMinimum(0);
ui->alarm2ValueSB->setMaximum(0);
ui->CalibSB->setMinimum(0);
ui->CalibSB->setMaximum(0);
ui->CalibSB->setValue(0);
ui->alarm1ValueSB->setValue(0);
ui->alarm2ValueSB->setValue(0);
return;
}
if (analog.type==0 || analog.type==1 || analog.type==2) {
ratio=(analog.ratio<<analog.multiplier)/10.0;
ui->alarm1ValueSB->setDecimals(2);
ui->alarm1ValueSB->setSingleStep(ratio/255.0);
ui->alarm2ValueSB->setDecimals(2);
ui->alarm2ValueSB->setSingleStep(ratio/255.0);
ui->alarm1ValueSB->setMinimum((analog.ratio*1.0*analog.offset)/2550.0);
ui->alarm1ValueSB->setMaximum(ratio+(analog.ratio*1.0*analog.offset)/2550.0);
ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/2550.0);
ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/2550.0);
}
else {
ratio=analog.ratio<<analog.multiplier;
ui->alarm1ValueSB->setDecimals(2);
ui->alarm1ValueSB->setSingleStep(ratio/255.0);
ui->alarm2ValueSB->setDecimals(2);
ui->alarm2ValueSB->setSingleStep(ratio/255.0);
ui->alarm1ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0);
ui->alarm1ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0);
ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0);
ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0);
}
ui->CalibSB->setDecimals(2);
ui->CalibSB->setMaximum((ratio*127)/255.0);
ui->CalibSB->setMinimum((-ratio*128)/255.0);
ui->CalibSB->setSingleStep(ratio/255.0);
ui->CalibSB->setValue((analog.offset*ratio)/255);
alarm1value=ratio*(analog.alarms[0].value/255.0+analog.offset/255.0);
alarm2value=ratio*(analog.alarms[1].value/255.0+analog.offset/255.0);;
ui->alarm1ValueSB->setValue(alarm1value);
ui->alarm2ValueSB->setValue(alarm2value);
}
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
{
float ratio;
analog.type=index;
switch (index) {
case 0:
case 1:
case 2:
ui->RatioSB->setDecimals(1);
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
ratio=(analog.ratio<<analog.multiplier)/10.0;
break;
default:
ui->RatioSB->setDecimals(0);
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
ratio=(analog.ratio<<analog.multiplier);
break;
}
ui->RatioSB->setValue(ratio);
update();
emit modified();
}
void TelemetryAnalog::on_RatioSB_valueChanged()
{
if (!lock) {
if (analog.type==0 || analog.type==1 || analog.type==2) {
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
float singlestep =(1<<analog.multiplier)/10.0;
lock=true;
ui->RatioSB->setSingleStep(singlestep);
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
lock=false;
}
else {
analog.multiplier = findmult(ui->RatioSB->value(), 255);
float singlestep =(1<<analog.multiplier);
lock = true;
ui->RatioSB->setSingleStep(singlestep);
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
lock = false;
}
emit modified();
}
}
void TelemetryAnalog::on_RatioSB_editingFinished()
{
float ratio, calib, alarm1value,alarm2value;
if (lock) return;
if (analog.type==0 || analog.type==1 || analog.type==2) {
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
ui->CalibSB->setSingleStep((1<<analog.multiplier)/10.0);
ui->alarm1ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
ui->alarm2ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
analog.ratio = ((int)(round(ui->RatioSB->value()*10))/(1 <<analog.multiplier));
} else {
analog.multiplier = findmult(ui->RatioSB->value(), 255);
ui->CalibSB->setSingleStep(1<<analog.multiplier);
ui->alarm1ValueSB->setSingleStep(1<<analog.multiplier);
ui->alarm2ValueSB->setSingleStep(1<<analog.multiplier);
analog.ratio = (ui->RatioSB->value()/(1 << analog.multiplier));
}
ui->CalibSB->setMaximum((ui->RatioSB->value()*127)/255);
ui->CalibSB->setMinimum((ui->RatioSB->value()*-128)/255);
ui->alarm1ValueSB->setMaximum(ui->RatioSB->value());
ui->alarm2ValueSB->setMaximum(ui->RatioSB->value());
repaint();
ratio=analog.ratio * (1 << analog.multiplier);
calib=ui->CalibSB->value();
alarm1value=ui->alarm1ValueSB->value();
alarm2value=ui->alarm2ValueSB->value();
if (analog.type==0) {
calib*=10;
alarm1value*=10;
alarm2value*=10;
}
if (calib>0) {
if (calib>((ratio*127)/255)) {
analog.offset=127;
} else {
analog.offset=round(calib*255/ratio);
}
}
if (calib<0) {
if (calib<((ratio*-128)/255)) {
analog.offset=-128;
} else {
analog.offset=round(calib*255/ratio);
}
}
analog.alarms[0].value=round((alarm1value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
analog.alarms[1].value=round((alarm2value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
update();
// TODO ? telBarUpdate();
emit modified();
}
void TelemetryAnalog::on_CalibSB_editingFinished()
{
float ratio,calib,alarm1value,alarm2value;
if (analog.type==0 || analog.type==1 || analog.type==2) {
ratio=(analog.ratio<<analog.multiplier)/10.0;
} else {
ratio=analog.ratio<<analog.multiplier;
}
if (ratio!=0) {
analog.offset = round((255*ui->CalibSB->value()/ratio));
calib=ratio*analog.offset/255.0;
alarm1value=ui->alarm1ValueSB->value();
alarm2value=ui->alarm2ValueSB->value();
if (alarm1value<calib) {
alarm1value=calib;
} else if (alarm1value>(ratio+calib)) {
alarm1value=ratio+calib;
}
if (alarm2value<calib) {
alarm2value=calib;
} else if (alarm2value>(ratio+calib)) {
alarm2value=ratio+calib;
}
analog.alarms[0].value=round(((alarm1value-calib)*255)/ratio);
analog.alarms[1].value=round(((alarm2value-calib)*255)/ratio);
} else {
analog.offset=0;
analog.alarms[0].value=0;
analog.alarms[1].value=0;
}
update();
// TODO ? telBarUpdate();
emit modified();
}
void TelemetryAnalog::on_alarm1LevelCB_currentIndexChanged(int index)
{
analog.alarms[0].level = index;
emit modified();
}
void TelemetryAnalog::on_alarm1GreaterCB_currentIndexChanged(int index)
{
analog.alarms[0].greater = index;
emit modified();
}
void TelemetryAnalog::on_alarm1ValueSB_editingFinished()
{
float ratio, calib, alarm1value;
ratio=analog.ratio<<analog.multiplier;
calib=analog.offset;
alarm1value=ui->alarm1ValueSB->value();
if (analog.type==0) {
ratio/=10;
}
if (alarm1value<((calib*ratio)/255)) {
analog.alarms[0].value=0;
} else if (alarm1value>(ratio+(calib*ratio)/255)) {
analog.alarms[0].value=255;
} else {
analog.alarms[0].value = round((alarm1value-((calib*ratio)/255))/ratio*255);
}
update();
emit modified();
}
void TelemetryAnalog::on_alarm2LevelCB_currentIndexChanged(int index)
{
analog.alarms[1].level = index;
emit modified();
}
void TelemetryAnalog::on_alarm2GreaterCB_currentIndexChanged(int index)
{
analog.alarms[1].greater = index;
emit modified();
}
void TelemetryAnalog::on_alarm2ValueSB_editingFinished()
{
float ratio, calib, alarm2value;
ratio = analog.ratio<<analog.multiplier;
calib = analog.offset;
alarm2value = ui->alarm2ValueSB->value();
if (analog.type==0) {
ratio/=10;
}
if (alarm2value<((calib*ratio)/255)) {
analog.alarms[1].value=0;
} else if (alarm2value>(ratio+(calib*ratio)/255)) {
analog.alarms[1].value=255;
} else {
analog.alarms[1].value = round((alarm2value-((calib*ratio)/255))/ratio*255);
}
update();
emit modified();
}
TelemetryAnalog::~TelemetryAnalog()
{
delete ui;
}
/******************************************************/
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model):
ModelPanel(parent, model),
ui(new Ui::Telemetry)
{
ui->setupUi(this);
analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0]);
ui->A1Layout->addWidget(analogs[0]);
connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified()));
analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1]);
ui->A2Layout->addWidget(analogs[1]);
connect(analogs[1], SIGNAL(modified()), this, SLOT(onAnalogModified()));
QGroupBox* barsgb[3] = { ui->CS1Bars, ui->CS2Bars, ui->CS3Bars };
QGroupBox* numsgb[3] = { ui->CS1Nums, ui->CS2Nums, ui->CS3Nums };
QComboBox* barscb[12] = { ui->telBarCS1B1_CB, ui->telBarCS1B2_CB, ui->telBarCS1B3_CB, ui->telBarCS1B4_CB,
ui->telBarCS2B1_CB, ui->telBarCS2B2_CB, ui->telBarCS2B3_CB, ui->telBarCS2B4_CB,
ui->telBarCS3B1_CB, ui->telBarCS3B2_CB, ui->telBarCS3B3_CB, ui->telBarCS3B4_CB};
QDoubleSpinBox* minSB[12] = { ui->telMinCS1SB1, ui->telMinCS1SB2, ui->telMinCS1SB3, ui->telMinCS1SB4,
ui->telMinCS2SB1, ui->telMinCS2SB2, ui->telMinCS2SB3, ui->telMinCS2SB4,
ui->telMinCS3SB1, ui->telMinCS3SB2, ui->telMinCS3SB3, ui->telMinCS3SB4};
QDoubleSpinBox* maxSB[12] = { ui->telMaxCS1SB1, ui->telMaxCS1SB2, ui->telMaxCS1SB3, ui->telMaxCS1SB4,
ui->telMaxCS2SB1, ui->telMaxCS2SB2, ui->telMaxCS2SB3, ui->telMaxCS2SB4,
ui->telMaxCS3SB1, ui->telMaxCS3SB2, ui->telMaxCS3SB3, ui->telMaxCS3SB4};
QComboBox* tmp[36] = { ui->telemetryCS1F1_CB, ui->telemetryCS1F2_CB, ui->telemetryCS1F3_CB, ui->telemetryCS1F4_CB, ui->telemetryCS1F5_CB, ui->telemetryCS1F6_CB, ui->telemetryCS1F7_CB, ui->telemetryCS1F8_CB, ui->telemetryCS1F9_CB, ui->telemetryCS1F10_CB, ui->telemetryCS1F11_CB, ui->telemetryCS1F12_CB,
ui->telemetryCS2F1_CB, ui->telemetryCS2F2_CB, ui->telemetryCS2F3_CB, ui->telemetryCS2F4_CB, ui->telemetryCS2F5_CB, ui->telemetryCS2F6_CB, ui->telemetryCS2F7_CB, ui->telemetryCS2F8_CB, ui->telemetryCS2F9_CB, ui->telemetryCS2F10_CB, ui->telemetryCS2F11_CB, ui->telemetryCS2F12_CB,
ui->telemetryCS3F1_CB, ui->telemetryCS3F2_CB, ui->telemetryCS3F3_CB, ui->telemetryCS3F4_CB, ui->telemetryCS3F5_CB, ui->telemetryCS3F6_CB, ui->telemetryCS3F7_CB, ui->telemetryCS3F8_CB, ui->telemetryCS3F9_CB, ui->telemetryCS3F10_CB, ui->telemetryCS3F11_CB, ui->telemetryCS3F12_CB};
memcpy(barsGB, barsgb, sizeof(barsGB));
memcpy(numsGB, numsgb, sizeof(numsGB));
memcpy(barsCB, barscb, sizeof(barsCB));
memcpy(this->maxSB, maxSB, sizeof(this->maxSB));
memcpy(this->minSB, minSB, sizeof(this->minSB));
memcpy(csf, tmp, sizeof(csf));
setup();
}
TelemetryPanel::~TelemetryPanel()
{
delete ui;
}
void TelemetryPanel::setup()
{
QSettings settings("companion9x", "companion9x");
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
lock=true;
ui->telemetryCSType1->setCurrentIndex(model.frsky.screens[0].type);
ui->telemetryCSType2->setCurrentIndex(model.frsky.screens[1].type);
ui->telemetryCSType3->setCurrentIndex(model.frsky.screens[2].type);
for (int i=0; i<3; i++) {
bool isNum = (model.frsky.screens[i].type==0);
barsGB[i]->setVisible(!isNum);
numsGB[i]->setVisible(isNum);
}
connect(ui->telemetryCSType1,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
connect(ui->telemetryCSType2,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
connect(ui->telemetryCSType3,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
//frsky Settings
if (!GetEepromInterface()->getCapability(TelemetryRSSIModel) ) {
ui->RSSIGB->hide();
}
ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value);
ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value);
ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
if (!GetEepromInterface()->getCapability(HasAltitudeSel)) {
ui->AltitudeGPS_ChkB->hide();
} else {
ui->AltitudeGPS_ChkB->setChecked(model.frsky.FrSkyGpsAlt);
}
int varioCap=GetEepromInterface()->getCapability(HasVario);
// if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (false) {
ui->AltitudeToolbar_ChkB->setChecked(model.frsky.altitudeDisplayed);
} else {
ui->AltitudeToolbar_ChkB->hide();
}
if (!varioCap) {
ui->varioLimitMax_DSB->hide();
ui->varioLimitMinOff_ChkB->hide();
ui->varioLimitMin_DSB->hide();
ui->varioLimitCenterMin_DSB->hide();
ui->varioLimitCenterMax_DSB->hide();
ui->varioLimit_label->hide();
ui->VarioLabel_1->hide();
ui->VarioLabel_2->hide();
ui->VarioLabel_3->hide();
ui->VarioLabel_4->hide();
ui->varioSourceCB->hide();
ui->varioSource_label->hide();
} else {
if (!GetEepromInterface()->getCapability(HasVarioSink)) {
ui->varioLimitMinOff_ChkB->hide();
ui->varioLimitMin_DSB->hide();
ui->varioLimitCenterMin_DSB->hide();
ui->VarioLabel_1->hide();
ui->VarioLabel_2->hide();
}
ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10);
ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10);
ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5);
ui->varioSourceCB->setCurrentIndex(model.frsky.varioSource);
if (model.frsky.varioCenterMin==-16) {
ui->varioLimitMinOff_ChkB->setChecked(true);
ui->varioLimitCenterMin_DSB->setValue(-2.0);
ui->varioLimitCenterMin_DSB->setDisabled(true);
} else {
ui->varioLimitMinOff_ChkB->setChecked(false);
ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
}
int mask=1;
for (int i=0; i< ui->varioSourceCB->count(); i++) {
if (!(varioCap&mask)) {
QModelIndex index = ui->varioSourceCB->model()->index(i, 0);
QVariant v(0);
ui->varioSourceCB->model()->setData(index, v, Qt::UserRole - 1);
}
mask <<=1;
}
}
if (!(GetEepromInterface()->getCapability(HasAltitudeSel)||GetEepromInterface()->getCapability(HasVario))) {
ui->altimetryGB->hide();
}
if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) {
model.frsky.usrProto=1;
ui->frskyProtoCB->setDisabled(true);
} else {
ui->frskyProtoCB->setEnabled(true);
}
if (GetEepromInterface()->getCapability(TelemetryCSFields)==0) {
ui->groupBox_5->hide();
} else {
if (GetEepromInterface()->getCapability(TelemetryCSFields)==8) {
ui->tabCsView->removeTab(1);
ui->tabCsView->removeTab(2);
}
if (GetEepromInterface()->getCapability(TelemetryCSFields)==16) {
ui->tabCsView->removeTab(2);
}
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
if (cols==0) cols=2;
for (int screen=0; screen<(GetEepromInterface()->getCapability(TelemetryCSFields)/(4*cols)); screen++) {
for (int c=0; c<cols; c++) {
for (int r=0; r<4; r++) {
int index=screen*12+c*4+r;
if (model.frsky.screens[screen].type==0) {
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[r].source[c], (r<4), model.frsky.usrProto);
} else {
populateCustomScreenFieldCB(csf[index], 0, (r<4), model.frsky.usrProto);
}
connect(csf[index], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldEdited()));
}
}
for (int c=cols; c<3; c++) {
for (int r=0; r<4; r++) {
int index=screen*12+c*4+r;
csf[index]->hide();
}
}
}
}
if (!GetEepromInterface()->getCapability(TelemetryUnits)) {
ui->frskyUnitsCB->setDisabled(true);
int index=0;
if (firmware_id.contains("imperial")) {
index=1;
}
ui->frskyUnitsCB->setCurrentIndex(index);
}
if ((GetEepromInterface()->getCapability(Telemetry)&TM_HASWSHH)) {
ui->frskyProtoCB->addItem(tr("Winged Shadow How High"));
} else {
ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)"));
}
ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto);
ui->frskyUnitsCB->setCurrentIndex(model.frsky.imperial);
ui->frskyBladesCB->setCurrentIndex(model.frsky.blades);
ui->frskyCurrentCB->setCurrentIndex(model.frsky.currentSource);
ui->frskyVoltCB->setCurrentIndex(model.frsky.voltsSource);
for (int screen=0; screen<2;screen++) {
for (int rows=0; rows<4; rows++) {
for (int cols=0; cols<3; cols++) {
int index=screen*12+cols*4+rows;
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto);
}
}
}
for (int j=0; j<12; j++) {
int screen = j/4;
int field = j%4;
populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto);
switch (model.frsky.screens[screen].body.bars[field].source-1) {
case TELEMETRY_SOURCE_TX_BATT:
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A1_MIN:
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_A2_MIN:
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_CURRENT_MAX:
case TELEMETRY_SOURCE_CURRENT:
minSB[j]->setDecimals(1);
maxSB[j]->setDecimals(1);
break;
case TELEMETRY_SOURCE_CELL:
minSB[j]->setDecimals(2);
maxSB[j]->setDecimals(2);
break;
default:
minSB[j]->setDecimals(0);
maxSB[j]->setDecimals(0);
}
minSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky));
minSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky));
minSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source));
minSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, model.frsky.screens[screen].body.bars[field].barMin, &model.frsky));
maxSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky));
maxSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky));
maxSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source));
maxSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, (255-model.frsky.screens[screen].body.bars[field].barMax), &model.frsky));
if (model.frsky.screens[screen].body.bars[field].source==0 || model.frsky.screens[screen].type==0) {
minSB[j]->setDisabled(true);
maxSB[j]->setDisabled(true);
}
connect(barsCB[j],SIGNAL(currentIndexChanged(int)),this,SLOT(telBarCBcurrentIndexChanged(int)));
connect(maxSB[j],SIGNAL(editingFinished()),this,SLOT(telMaxSBeditingFinished()));
connect(minSB[j],SIGNAL(editingFinished()),this,SLOT(telMinSBeditingFinished()));
}
lock=false;
}
void TelemetryPanel::onAnalogModified()
{
emit modified();
}
void TelemetryPanel::on_frskyUnitsCB_currentIndexChanged(int index)
{
model.frsky.imperial=index;
emit modified();
}
void TelemetryPanel::on_frskyBladesCB_currentIndexChanged(int index)
{
model.frsky.blades=index;
emit modified();
}
void TelemetryPanel::on_frskyCurrentCB_currentIndexChanged(int index)
{
model.frsky.currentSource=index;
emit modified();
}
void TelemetryPanel::on_frskyVoltCB_currentIndexChanged(int index)
{
model.frsky.voltsSource=index;
emit modified();
}
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
{
if (lock) return;
int bindex[12];
lock=true;
for (int i=0; i<12; i++) {
bindex[i]=barsCB[i]->currentIndex();
model.frsky.usrProto=index;
populateCustomScreenFieldCB(barsCB[i], bindex[i], false, model.frsky.usrProto);
}
if (!GetEepromInterface()->getCapability(TelemetryCSFields)) {
ui->groupBox_5->hide();
} else {
for (int screen=0; screen<2;screen++) {
for (int rows=0; rows<4; rows++) {
for (int cols=0; cols<3; cols++) {
int index=screen*12+cols*4+rows;
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto);
}
}
}
}
lock=false;
if (index==0) {
for (int i=0; i<12; i++) {
if (bindex[i]>2) {
barsCB[i]->setCurrentIndex(0);
} else {
barsCB[i]->setCurrentIndex(bindex[i]);
}
}
} else if (index==2) {
for (int i=0; i<12; i++) {
if (bindex[i]>3) {
barsCB[i]->setCurrentIndex(0);
} else {
barsCB[i]->setCurrentIndex(bindex[i]);
}
}
} else {
for (int i=0; i<12; i++) {
barsCB[i]->setCurrentIndex(bindex[i]);
}
}
emit modified();
}
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index) {
if (lock) return;
model.frsky.rssiAlarms[0].level=index;
emit modified();
}
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index) {
if (lock) return;
model.frsky.rssiAlarms[1].level=index;
emit modified();
}
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
{
if (lock) return;
model.frsky.rssiAlarms[0].value=(ui->rssiAlarm1SB->value());
emit modified();
}
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
{
if (lock) return;
model.frsky.rssiAlarms[1].value=(ui->rssiAlarm2SB->value());
emit modified();
}
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
{
if (lock) return;
model.frsky.FrSkyGpsAlt = checked;
emit modified();
//AltitudeGPS_CB
}
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
{
model.frsky.altitudeDisplayed = checked;
emit modified();
}
void TelemetryPanel::on_varioSourceCB_currentIndexChanged(int index)
{
if (lock) return;
model.frsky.varioSource = index;
emit modified();
}
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
{
if (lock) return;
model.frsky.varioMin= round(ui->varioLimitMin_DSB->value()+10);
emit modified();
}
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
{
if (lock) return;
model.frsky.varioMax= round(ui->varioLimitMax_DSB->value()-10);
emit modified();
}
void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
{
if (lock) return;
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
}
model.frsky.varioCenterMin= round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
emit modified();
}
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
{
if (lock) return;
model.frsky.varioCenterMin = -16;
if (!checked) {
lock=true;
ui->varioLimitCenterMin_DSB->setValue(-2.0);
ui->varioLimitCenterMin_DSB->setEnabled(true);
lock=false;
} else {
ui->varioLimitCenterMin_DSB->setValue(-2.0);
ui->varioLimitCenterMin_DSB->setDisabled(true);
}
emit modified();
}
void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
{
if (lock) return;
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
}
model.frsky.varioCenterMax= round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
emit modified();
}
void TelemetryPanel::telBarUpdate()
{
int index;
lock=true;
for (int i=0; i<12; i++) {
int screen=i/4;
index=barsCB[i]->currentIndex();
if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) {
minSB[i]->setMinimum(getBarValue(index, 0, &model.frsky));
minSB[i]->setMaximum(getBarValue(index, 255, &model.frsky));
minSB[i]->setSingleStep(getBarStep(index));
maxSB[i]->setMinimum(getBarValue(index, 0, &model.frsky));
maxSB[i]->setMaximum(getBarValue(index, 255, &model.frsky));
maxSB[i]->setSingleStep(getBarStep(index));
minSB[i]->setValue(getBarValue(index, model.frsky.screens[screen].body.bars[i%4].barMin, &model.frsky));
maxSB[i]->setValue(getBarValue(index, 255-model.frsky.screens[screen].body.bars[i%4].barMax, &model.frsky));
}
}
lock=false;
}
void TelemetryPanel::ScreenTypeCBcurrentIndexChanged(int index)
{
if (lock) return;
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int screen = comboBox->objectName().right(1).toInt() -1;
lock=true;
model.frsky.screens[screen].type=index;
for (int i=0; i<3; i++) {
bool isNum = (model.frsky.screens[i].type==0);
barsGB[i]->setVisible(!isNum);
numsGB[i]->setVisible(isNum);
}
lock=false;
emit modified();
}
void TelemetryPanel::telBarCBcurrentIndexChanged(int index)
{
if (lock) return;
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int screenId = comboBox->objectName().mid(8,1).toInt() - 1;
int barId = comboBox->objectName().mid(10,1).toInt() - 1;
int bar=barId+screenId*4;
model.frsky.screens[screenId].body.bars[barId].source=index;
lock=true;
if (index==0) {
model.frsky.screens[screenId].body.bars[barId].barMin=0;
model.frsky.screens[screenId].body.bars[barId].barMax=0;
minSB[bar]->setDisabled(true);
maxSB[bar]->setDisabled(true);
} else {
minSB[bar]->setEnabled(true);
maxSB[bar]->setEnabled(true);
}
switch (index-1) {
case TELEMETRY_SOURCE_TX_BATT:
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A1_MIN:
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_A2_MIN:
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_CURRENT_MAX:
case TELEMETRY_SOURCE_CURRENT:
minSB[bar]->setDecimals(1);
maxSB[bar]->setDecimals(1);
break;
case TELEMETRY_SOURCE_CELL:
minSB[bar]->setDecimals(2);
maxSB[bar]->setDecimals(2);
break;
default:
minSB[bar]->setDecimals(0);
maxSB[bar]->setDecimals(0);
}
minSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky));
minSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky));
minSB[bar]->setSingleStep(getBarStep(index));
maxSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky));
maxSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky));
maxSB[bar]->setSingleStep(getBarStep(index));
minSB[bar]->setValue(getBarValue(index, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky));
maxSB[bar]->setValue(getBarValue(index, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky));
lock=false;
emit modified();
}
void TelemetryPanel::telMinSBeditingFinished()
{
if (lock) return;
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
int screenId = spinBox->objectName().mid(8,1).toInt() - 1;
int barId = spinBox->objectName().right(1).toInt() - 1;
int minId = barId+screenId*4;
lock=true;
if (model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) {
model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
} else if (model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) {
model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
} else {
model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
}
spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky));
if (maxSB[minId]->value()<minSB[minId]->value()) {
model.frsky.screens[screenId].body.bars[minId].barMax=(255-model.frsky.screens[screenId].body.bars[barId].barMin+1);
maxSB[minId]->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky));
}
maxSB[minId]->setMinimum(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (model.frsky.screens[screenId].body.bars[barId].barMin+1), &model.frsky));
lock=false;
emit modified();
}
void TelemetryPanel::telMaxSBeditingFinished()
{
if (lock) return;
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
int screenId = spinBox->objectName().mid(8,1).toInt() - 1;
int barId = spinBox->objectName().right(1).toInt() - 1;
lock=true;
if (model.frsky.screens[screenId].body.bars[barId].source==5) {
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)));
} else if (model.frsky.screens[screenId].body.bars[barId].source==6) {
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)));
} else {
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source) ));
}
spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (255-model.frsky.screens[screenId].body.bars[barId].barMax), &model.frsky));
lock=false;
emit modified();
}
void TelemetryPanel::customFieldEdited()
{
if (!lock) {
lock = true;
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
if (cols==0) cols=2;
for (int i=0; i<GetEepromInterface()->getCapability(TelemetryCSFields); i++) {
int screen=i/(4*cols);
int r=((i%(4*cols))%4);
int c=((i%(4*cols))/4);
if (model.frsky.screens[screen].type==0) {
model.frsky.screens[screen].body.lines[r].source[c]=csf[i]->currentIndex();
}
}
emit modified();
lock = false;
}
}
float TelemetryPanel::getBarStep(int barId)
{
switch (barId-1) {
case TELEMETRY_SOURCE_TX_BATT:
return 0.1;
break;
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
return 3;
break;
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A1_MIN:
return (analogs[0]->ui->RatioSB->value()/255);
break;
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_A2_MIN:
return (analogs[1]->ui->RatioSB->value()/255);
break;
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT:
case TELEMETRY_SOURCE_ALT_MAX:
case TELEMETRY_SOURCE_ALT_MIN:
return 8;
break;
case TELEMETRY_SOURCE_RPM:
case TELEMETRY_SOURCE_RPM_MAX:
return 50;
break;
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
return 0.1;
break;
case TELEMETRY_SOURCE_CELL:
return 0.02;
break;
case TELEMETRY_SOURCE_HDG:
return 2;
break;
case TELEMETRY_SOURCE_DIST:
case TELEMETRY_SOURCE_DIST_MAX:
return 8;
break;
case TELEMETRY_SOURCE_CURRENT_MAX:
case TELEMETRY_SOURCE_CURRENT:
return 0.5;
break;
case TELEMETRY_SOURCE_POWER:
return 5;
break;
case TELEMETRY_SOURCE_CONSUMPTION:
return 20;
break;
case TELEMETRY_SOURCE_SPEED:
case TELEMETRY_SOURCE_SPEED_MAX:
if (model.frsky.imperial==1) {
return 1;
} else {
return 1.852;
}
break;
default:
return 1;
break;
}
}
+98
View File
@@ -0,0 +1,98 @@
#ifndef TELEMETRY_H
#define TELEMETRY_H
#include "modelpanel.h"
#include <QGroupBox>
#include <QComboBox>
#include <QDoubleSpinBox>
namespace Ui {
class TelemetryAnalog;
class Telemetry;
}
class TelemetryAnalog : public QWidget
{
Q_OBJECT
friend class TelemetryPanel;
public:
TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog);
virtual ~TelemetryAnalog();
signals:
void modified();
private slots:
void on_UnitCB_currentIndexChanged(int index);
void on_RatioSB_editingFinished();
void on_RatioSB_valueChanged();
void on_CalibSB_editingFinished();
void on_alarm1LevelCB_currentIndexChanged(int index);
void on_alarm1GreaterCB_currentIndexChanged(int index);
void on_alarm1ValueSB_editingFinished();
void on_alarm2LevelCB_currentIndexChanged(int index);
void on_alarm2GreaterCB_currentIndexChanged(int index);
void on_alarm2ValueSB_editingFinished();
private:
Ui::TelemetryAnalog *ui;
FrSkyChannelData & analog;
bool lock;
void update();
};
class TelemetryPanel : public ModelPanel
{
Q_OBJECT
public:
TelemetryPanel(QWidget *parent, ModelData & model);
virtual ~TelemetryPanel();
signals:
void modified();
private slots:
void onAnalogModified();
void on_frskyProtoCB_currentIndexChanged(int index);
void on_frskyUnitsCB_currentIndexChanged(int index);
void on_frskyBladesCB_currentIndexChanged(int index);
void on_frskyCurrentCB_currentIndexChanged(int index);
void on_frskyVoltCB_currentIndexChanged(int index);
void on_AltitudeToolbar_ChkB_toggled(bool checked);
void on_rssiAlarm1CB_currentIndexChanged(int index);
void on_rssiAlarm2CB_currentIndexChanged(int index);
void on_rssiAlarm1SB_editingFinished();
void on_rssiAlarm2SB_editingFinished();
void on_AltitudeGPS_ChkB_toggled(bool checked);
void on_varioSourceCB_currentIndexChanged(int index);
void on_varioLimitMin_DSB_editingFinished();
void on_varioLimitMax_DSB_editingFinished();
void on_varioLimitCenterMin_DSB_editingFinished();
void on_varioLimitMinOff_ChkB_toggled(bool checked);
void on_varioLimitCenterMax_DSB_editingFinished();
void telBarCBcurrentIndexChanged(int index);
void ScreenTypeCBcurrentIndexChanged(int index);
void telMaxSBeditingFinished();
void telMinSBeditingFinished();
void customFieldEdited();
private:
Ui::Telemetry *ui;
TelemetryAnalog * analogs[2];
QGroupBox* barsGB[3];
QGroupBox* numsGB[3];
QComboBox* barsCB[12];
QDoubleSpinBox* minSB[12];
QDoubleSpinBox* maxSB[12];
QComboBox* csf[36];
void setup();
float getBarStep(int barId);
void telBarUpdate();
};
#endif // TELEMETRY_H
File diff suppressed because it is too large Load Diff
+324
View File
@@ -0,0 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TelemetryAnalog</class>
<widget class="QWidget" name="TelemetryAnalog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<height>118</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_11" columnstretch="1,1,1,1" columnminimumwidth="0,0,0,0">
<item row="0" column="0">
<widget class="QLabel" name="label_918">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_Max">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Max Value</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_919">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Alarm 1 </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="alarm1LevelCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>----</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="alarm1GreaterCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>&lt;</string>
</property>
</item>
<item>
<property name="text">
<string>&gt;</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_921">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Alarm 2</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="alarm2LevelCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>----</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="alarm2GreaterCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>&lt;</string>
</property>
</item>
<item>
<property name="text">
<string>&gt;</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="RatioSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>255.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="CalibSB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>-12.800000000000001</double>
</property>
<property name="maximum">
<double>12.699999999999999</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="alarm1ValueSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>255.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QDoubleSpinBox" name="alarm2ValueSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>255.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="CalibLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Min Value</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="UnitCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Volts (V)</string>
</property>
</item>
<item>
<property name="text">
<string>Amps (A)</string>
</property>
</item>
<item>
<property name="text">
<string>Speed (m/s or ft/s)</string>
</property>
</item>
<item>
<property name="text">
<string>Raw (-)</string>
</property>
</item>
<item>
<property name="text">
<string>Speed (km/h or miles/h)</string>
</property>
</item>
<item>
<property name="text">
<string>Meters (m or ft)</string>
</property>
</item>
<item>
<property name="text">
<string>Temp (°)</string>
</property>
</item>
<item>
<property name="text">
<string>Fuel (%)</string>
</property>
</item>
<item>
<property name="text">
<string>mAmps (mA)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+852
View File
@@ -0,0 +1,852 @@
#include "templates.h"
#include <QListWidget>
#include <QMessageBox>
Templates::Templates(QWidget * parent, ModelData & model):
QWidget(parent),
model(model)
{
QGridLayout * gridLayout = new QGridLayout(this);
QListWidget * templateList = new QListWidget(this);
gridLayout->addWidget(templateList, 0, 0, 1, 1);
templateList->addItem(tr("Simple 4-CH"));
templateList->addItem(tr("T-Cut"));
templateList->addItem(tr("Sticky T-Cut"));
templateList->addItem(tr("V-Tail"));
templateList->addItem(tr("Elevon\\Delta"));
templateList->addItem(tr("Heli Setup"));
templateList->addItem(tr("Heli Setup with gyro gain control"));
templateList->addItem(tr("Gyro gain control"));
templateList->addItem(tr("Heli Setup (Futaba's channel assignment style)"));
templateList->addItem(tr("Heli Setup with gyro gain control (Futaba's channel assignment style)"));
templateList->addItem(tr("Gyro gain control (Futaba's channel assignment style)"));
templateList->addItem(tr("Servo Test"));
templateList->addItem(tr("MultiCopter"));
templateList->addItem(tr("Use Model Config Wizard"));
connect(templateList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClicked(QModelIndex)));
}
Templates::~Templates()
{
}
void Templates::setSwitch(unsigned int idx, unsigned int func, int v1, int v2)
{
g_model.customSw[idx-1].func = func;
g_model.customSw[idx-1].val1 = v1;
g_model.customSw[idx-1].val2 = v2;
}
void Templates::onDoubleClicked(QModelIndex index)
{
QString text = ui->templateList->item(index.row())->text();
if (index.row()==13) {
uint64_t result=0xffffffff;
modelConfigDialog *mcw = new modelConfigDialog(radioData, &result, this);
mcw->exec();
if (result!=0xffffffff) {
applyNumericTemplate(result);
updateSettings();
tabMixes();
}
} else {
int res = QMessageBox::question(this,tr("Apply Template?"),tr("Apply template \"%1\"?").arg(text),QMessageBox::Yes | QMessageBox::No);
if(res!=QMessageBox::Yes) return;
applyTemplate(index.row());
updateSettings();
tabMixes();
}
}
void Templates::applyNumericTemplate(uint64_t tpl)
{
clearCurves();
clearExpos(false);
clearMixes(false);
int8_t heli_ar1[] = {-100, -20, 30, 70, 90};
int8_t heli_ar2[] = {80, 70, 60, 70, 100};
int8_t heli_ar3[] = {100, 90, 80, 90, 100};
int8_t heli_ar4[] = {-30, -15, 0, 50, 100};
int8_t heli_ar5[] = {-100, -50, 0, 50, 100};
bool rx[10];
for (int i=0; i<10 ; i++) {
rx[i]=false;
}
int thrsw=GetEepromInterface()->getCapability(GetThrSwitch);
MixData *md = &model.mixData[0];
uint8_t spo2ch=(tpl & 0x0F);
tpl>>=4;
uint8_t spo1ch=(tpl & 0x0F);
tpl>>=4;
uint8_t fla2ch=(tpl & 0x0F);
tpl>>=4;
uint8_t fla1ch=(tpl & 0x0F);
tpl>>=4;
uint8_t rud2ch=(tpl & 0x0F);
tpl>>=4;
uint8_t ele2ch=(tpl & 0x0F);
tpl>>=4;
uint8_t ail2ch=(tpl & 0x0F);
tpl>>=4;
uint8_t chstyle=(tpl & 0x03);
tpl>>=2;
uint8_t gyro=(tpl & 0x03);
tpl>>=2;
uint8_t tailtype=(tpl & 0x03);
tpl>>=2;
uint8_t swashtype=(tpl & 0x07);
tpl>>=3;
uint8_t ruddertype=(tpl & 0x03);
tpl>>=2;
uint8_t spoilertype=(tpl & 0x3);
tpl>>=2;
uint8_t flaptype=(tpl & 0x03);
tpl>>=2;
uint8_t ailerontype=(tpl & 0x03);
tpl>>=2;
uint8_t enginetype=(tpl & 0x03);
tpl>>=2;
uint8_t modeltype=(tpl & 0x03);
#define ICC(x) icc[(x)-1]
uint8_t icc[4] = {0};
for(uint8_t i=1; i<=4; i++) //generate inverse array
for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i;
int ailerons;
int flaps;
int throttle;
int spoilers;
int elevators;
int rudders;
int sign;
uint8_t rxch;
switch (modeltype) {
case 0:
ailerons=ailerontype;
flaps=flaptype;
throttle=1;
switch (tailtype) {
case 0:
case 1:
rudders=1;
elevators=1;
break;
case 2:
rudders=1;
elevators=2;
break;
}
rxch=ICC(STK_RUD);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
if (tailtype==1) {
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
}
rx[rxch-1]=true;
rxch=ICC(STK_ELE);
if (tailtype==1) {
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
}
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
rx[rxch-1]=true;
rxch=ICC(STK_THR);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6);
rx[rxch-1]=true;
if (ail2ch > 0) {
rx[ail2ch-1]=true;
}
if (ele2ch > 0) {
rx[ele2ch-1]=true;
}
if (fla1ch > 0) {
rx[fla1ch-1]=true;
}
if (fla2ch > 0) {
rx[fla2ch-1]=true;
}
if (ailerons>0) {
rxch=ICC(STK_AIL);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
rx[rxch-1]=true;
}
if (ailerons>1) {
if (ail2ch==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6);
}
}
if (elevators>1) {
if (ele2ch==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6);
rx[j]=true;
break;
}
}
}else{
md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6);
}
}
if (flaps>0) {
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4;
}
sign=-1;
for (uint8_t i=0; i< flaps; i++) {
sign*=-1;
int index;
if (i==0) {
index=fla1ch;
} else {
index=fla2ch;
}
if (index==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
}
}
break;
case 1:
setCurve(CURVE5(1),heli_ar1);
setCurve(CURVE5(2),heli_ar2);
setCurve(CURVE5(3),heli_ar3);
setCurve(CURVE5(4),heli_ar4);
setCurve(CURVE5(5),heli_ar5);
setCurve(CURVE5(6),heli_ar5);
switch (swashtype) {
case 0:
model.swashRingData.type = HELI_SWASH_TYPE_90;
break;
case 1:
model.swashRingData.type = HELI_SWASH_TYPE_120;
break;
case 2:
model.swashRingData.type = HELI_SWASH_TYPE_120X;
break;
case 3:
model.swashRingData.type = HELI_SWASH_TYPE_140;
break;
case 4:
model.swashRingData.type = HELI_SWASH_TYPE_NONE;
break;
}
model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10);
if (chstyle==0) {
if (swashtype!=4) {
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6);
} else {
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6);
}
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
switch (gyro) {
case 1:
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6);
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6);
break;
case 2:
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6);
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6);
break;
}
} else {
if (swashtype!=4) {
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6);
} else {
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6);
}
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
switch (gyro) {
case 1:
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6);
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6);
break;
case 2:
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6);
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6);
break;
}
}
// collective
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF;
break;
case 2:
ailerons=ailerontype;
flaps=flaptype;
spoilers=spoilertype;
throttle=enginetype;
switch (tailtype) {
case 0:
case 1:
rudders=1;
elevators=1;
break;
case 2:
rudders=1;
elevators=2;
break;
}
if (throttle==1) {
rxch=ICC(STK_THR);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6);
rx[rxch-1]=true;
}
rxch=ICC(STK_RUD);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
if (tailtype==1) {
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
}
rx[rxch-1]=true;
rxch=ICC(STK_ELE);
if (tailtype==1) {
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
}
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
rx[rxch-1]=true;
if (ail2ch > 0) {
rx[ail2ch-1]=true;
}
if (ele2ch > 0) {
rx[ele2ch-1]=true;
}
if (fla1ch > 0) {
rx[fla1ch-1]=true;
}
if (fla2ch > 0) {
rx[fla2ch-1]=true;
}
if (spo1ch > 0) {
rx[spo1ch-1]=true;
}
if (spo2ch > 0) {
rx[spo2ch-1]=true;
}
if (ailerons>0) {
rxch=ICC(STK_AIL);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
rx[rxch-1]=true;
}
if (ailerons>1) {
if (ail2ch==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6);
}
}
if (elevators>1) {
if (ele2ch==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6);
}
}
if (flaps>0) {
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4;
}
sign=-1;
for (uint8_t i=0; i< flaps; i++) {
sign*=-1;
int index;
if (i==0) {
index=fla1ch;
} else {
index=fla2ch;
}
if (index==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
}
}
if (spoilers>0) {
md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6); md->speedUp=4;;md->speedDown=4;
md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6);md->speedUp=4;md->speedDown=4;
}
sign=-1;
for (uint8_t i=0; i< spoilers; i++) {
sign*=-1;
int index;
if (i==0) {
index=spo1ch;
} else {
index=spo2ch;
}
if (index==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6);
}
}
break;
case 3:
flaps=flaptype;
throttle=enginetype;
rudders=ruddertype;
if (throttle==1) {
rxch=ICC(STK_THR);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6);
rx[rxch-1]=true;
}
rxch=ICC(STK_ELE);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6);
rx[rxch-1]=true;
rxch=ICC(STK_AIL);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6);
rx[rxch-1]=true;
if (rudders>0) {
rxch=ICC(STK_RUD);
md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6);
rx[rxch-1]=true;
}
if (rud2ch > 0) {
rx[rud2ch-1]=true;
}
if (fla1ch > 0) {
rx[fla1ch-1]=true;
}
if (fla2ch > 0) {
rx[fla2ch-1]=true;
}
if (rudders>1) {
if (rud2ch==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(rud2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6);
}
}
if (flaps>0) {
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4;
}
sign=-1;
for (uint8_t i=0; i< flaps; i++) {
sign*=-1;
int index;
if (i==0) {
index=fla1ch;
} else {
index=fla2ch;
}
if (index==0) {
for (int j=0; j<10 ; j++) {
if (!rx[j]) {
md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
rx[j]=true;
break;
}
}
} else {
md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6);
}
}
break;
}
updateHeliTab();
updateCurvesTab();
if (modeltype==1 && swashtype!=4) {
ui->tabWidget->setCurrentIndex(1);
} else {
ui->tabWidget->setCurrentIndex(4);
}
resizeEvent();
}
void Templates::applyTemplate(uint8_t idx)
{
int8_t heli_ar1[] = {-100, -20, 30, 70, 90};
int8_t heli_ar2[] = {80, 70, 60, 70, 100};
int8_t heli_ar3[] = {100, 90, 80, 90, 100};
int8_t heli_ar4[] = {-30, -15, 0, 50, 100};
int8_t heli_ar5[] = {-100, -50, 0, 50, 100};
int thrsw=GetEepromInterface()->getCapability(GetThrSwitch);
MixData *md = &model.mixData[0];
//CC(STK) -> vSTK
//ICC(vSTK) -> STK
#define ICC(x) icc[(x)-1]
uint8_t icc[4] = {0};
for(uint8_t i=1; i<=4; i++) //generate inverse array
for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i;
uint8_t j = 0;
//Simple 4-Ch
if(idx==j++) {
if (md->destCh)
clearMixes();
md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();
}
//T-Cut
if(idx==j++) {
md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
}
//sticky t-cut
if(idx==j++) {
md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 12); md->mltpx=MLTPX_REP;
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch();
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP;
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
updateSwitchesTab();
}
//V-Tail
if(idx==j++) {
clearMixes();
md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();
md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();
}
//Elevon\\Delta
if(idx==j++) {
clearMixes();
md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();
md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();
md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();
md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();
}
//Heli Setup
if(idx==j++) {
clearMixes(); //This time we want a clean slate
clearCurves();
// Set up Mixes
// 3 cyclic channels
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();
// rudder
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
// throttle
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
// gyro gain
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);
// collective
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF;
model.swashRingData.type = HELI_SWASH_TYPE_120;
model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10);
// set up Curves
setCurve(CURVE5(1),heli_ar1);
setCurve(CURVE5(2),heli_ar2);
setCurve(CURVE5(3),heli_ar3);
setCurve(CURVE5(4),heli_ar4);
setCurve(CURVE5(5),heli_ar5);
setCurve(CURVE5(6),heli_ar5);
// make sure curves are redrawn
updateHeliTab();
updateCurvesTab();
resizeEvent();
}
//Heli Setup gyro gain control
if(idx==j++) {
clearMixes(); //This time we want a clean slate
clearCurves();
// Set up Mixes
// 3 cyclic channels
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();
// rudder
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
// throttle
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
// gyro gain
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;
// collective
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF;
model.swashRingData.type = HELI_SWASH_TYPE_120;
model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10);
// set up Curves
setCurve(CURVE5(1),heli_ar1);
setCurve(CURVE5(2),heli_ar2);
setCurve(CURVE5(3),heli_ar3);
setCurve(CURVE5(4),heli_ar4);
setCurve(CURVE5(5),heli_ar5);
setCurve(CURVE5(6),heli_ar5);
// make sure curves are redrawn
updateHeliTab();
updateCurvesTab();
resizeEvent();
}
// gyro gain control
if(idx==j++) {
int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH6?"),QMessageBox::Yes | QMessageBox::No);
if(res!=QMessageBox::Yes) return;
// first clear mix on ch6
bool found=true;
while (found) {
found=false;
for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) {
if (model.mixData[i].destCh==6) {
gm_deleteMix(i);
found=true;
break;
}
}
}
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;
}
//Heli Setup futaba style
if(idx==j++) {
clearMixes(); //This time we want a clean slate
clearCurves();
// Set up Mixes
// 3 cyclic channels
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();
// rudder
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
// throttle
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
// gyro gain
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);
// collective
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF;
model.swashRingData.type = HELI_SWASH_TYPE_120;
model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10);
// set up Curves
setCurve(CURVE5(1),heli_ar1);
setCurve(CURVE5(2),heli_ar2);
setCurve(CURVE5(3),heli_ar3);
setCurve(CURVE5(4),heli_ar4);
setCurve(CURVE5(5),heli_ar5);
setCurve(CURVE5(6),heli_ar5);
// make sure curves are redrawn
updateHeliTab();
updateCurvesTab();
resizeEvent();
}
// Heli setup futaba style with gyro gain control
if(idx==j++) {
clearMixes(); //This time we want a clean slate
clearCurves();
// Set up Mixes
// 3 cyclic channels
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();
md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();
// rudder
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();
// throttle
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF;
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
// gyro gain
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;
// collective
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF;
md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF;
model.swashRingData.type = HELI_SWASH_TYPE_120;
model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10);
// set up Curves
setCurve(CURVE5(1),heli_ar1);
setCurve(CURVE5(2),heli_ar2);
setCurve(CURVE5(3),heli_ar3);
setCurve(CURVE5(4),heli_ar4);
setCurve(CURVE5(5),heli_ar5);
setCurve(CURVE5(6),heli_ar5);
// make sure curves are redrawn
updateHeliTab();
updateCurvesTab();
resizeEvent();
}
// gyro gain control futaba style
if(idx==j++) {
int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH5?"),QMessageBox::Yes | QMessageBox::No);
if(res!=QMessageBox::Yes) return;
// first clear mix on ch6
bool found=true;
while (found) {
found=false;
for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) {
if (model.mixData[i].destCh==5) {
gm_deleteMix(i);
found=true;
break;
}
}
}
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;
md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;
}
//Servo Test
if(idx==j++) {
md=setDest(15); md->srcRaw=RawSource(SOURCE_TYPE_CH, 15); md->weight= 100; md->speedUp = 8; md->speedDown = 8; md->swtch=RawSwitch();
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch();
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP;
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP;
setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
// redraw switches tab
updateSwitchesTab();
}
//MultiCopter
if(idx==j++) {
if (md->destCh)
clearMixes();
md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=50; md->swtch=RawSwitch(); //CH1 AIL
md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-50; md->swtch=RawSwitch(); //CH2 ELE
md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); //CH3 THR
md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); //CH4 RUD
}
}
MixData* Templates::setDest(uint8_t dch)
{
uint8_t i = 0;
while ((g_model.mixData[i].destCh<=dch) && (g_model.mixData[i].destCh) && (i<GetEepromInterface()->getCapability(Mixes))) i++;
if(i==GetEepromInterface()->getCapability(Mixes)) return &g_model.mixData[0];
memmove(&g_model.mixData[i+1],&g_model.mixData[i],
(GetEepromInterface()->getCapability(Mixes)-(i+1))*sizeof(MixData) );
memset(&g_model.mixData[i],0,sizeof(MixData));
g_model.mixData[i].destCh = dch;
return &g_model.mixData[i];
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef TEMPLATES_H
#define TEMPLATES_H
#include <QWidget>
#include "eeprominterface.h"
class Templates : public QWidget
{
Q_OBJECT
public:
Templates(QWidget *parent, ModelData & model);
~Templates();
private slots:
void onDoubleClicked(QModelIndex index);
private:
void applyNumericTemplate(uint64_t tpl);
ModelData & model;
};
#endif // TEMPLATES_H

Some files were not shown because too many files have changed in this diff Show More