Merge branch 'origin/next'

Conflicts:
	companion/src/mdichild.cpp
This commit is contained in:
Kjell Kernen
2014-03-03 17:54:43 +01:00
56 changed files with 996 additions and 697 deletions
+60 -10
View File
@@ -195,12 +195,12 @@ 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") };
static const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), 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));
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsTaranis, index-4) : CHECK_IN_ARRAY(pots9X, index-4));
}
QString RotaryEncoderString(int index)
@@ -242,10 +242,13 @@ QString RawSource::toString()
}
switch (type) {
case SOURCE_TYPE_VIRTUAL_INPUT:
if (model && strlen(model->inputNames[index]) > 0)
return QString(model->inputNames[index]);
else
return QObject::tr("Input %1").arg(index+1);
{
QString result = QObject::tr("[I%1]").arg(index+1);
if (model && strlen(model->inputNames[index]) > 0) {
result += QString(model->inputNames[index]);
}
return result;
}
case SOURCE_TYPE_STICK:
return AnalogString(index);
case SOURCE_TYPE_TRIM:
@@ -316,7 +319,8 @@ QString RawSwitch::toString()
static const QString multiposPots[] = {
QObject::tr("S11"), QObject::tr("S12"), QObject::tr("S13"), QObject::tr("S14"), QObject::tr("S15"), QObject::tr("S16"),
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26"),
QObject::tr("S31"), QObject::tr("S32"), QObject::tr("S33"), QObject::tr("S34"), QObject::tr("S35"), QObject::tr("S36")
};
static const QString trimsSwitches[] = {
@@ -791,7 +795,8 @@ GeneralSettings::GeneralSettings()
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
return;
} else {
}
else {
QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
@@ -887,11 +892,30 @@ GeneralSettings::GeneralSettings()
}
RawSource GeneralSettings::getDefaultSource(unsigned int channel)
{
unsigned int stick_index = chout_ar[4*templateSetup + channel] - 1;
return RawSource(SOURCE_TYPE_STICK, stick_index);
}
ModelData::ModelData()
{
clear();
}
ExpoData * ModelData::insertInput(const int idx)
{
memmove(&expoData[idx+1], &expoData[idx], (C9X_MAX_EXPOS-(idx+1))*sizeof(ExpoData));
expoData[idx].clear();
return &expoData[idx];
}
void ModelData::removeInput(const int idx)
{
memmove(&expoData[idx], &expoData[idx+1], (C9X_MAX_EXPOS-(idx+1))*sizeof(ExpoData));
expoData[C9X_MAX_EXPOS-1].clear();
}
void ModelData::clearInputs()
{
for (int i=0; i<C9X_MAX_EXPOS; i++)
@@ -913,7 +937,7 @@ void ModelData::clear()
moduleData[0].ppmDelay = 300;
moduleData[1].ppmDelay = 300;
moduleData[2].ppmDelay = 300;
int board=GetEepromInterface()->getBoard();
int board = GetEepromInterface()->getBoard();
if (IS_TARANIS(board)) {
moduleData[0].protocol=PXX_XJT_X16;
moduleData[1].protocol=OFF;
@@ -947,12 +971,38 @@ bool ModelData::isempty()
return !used;
}
void ModelData::setDefault(uint8_t id)
void ModelData::setDefaultMixes(GeneralSettings & settings)
{
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
for (int i=0; i<NUM_STICKS; i++) {
ExpoData * expo = &expoData[i];
expo->chn = i;
expo->mode = INPUT_MODE_BOTH;
expo->srcRaw = settings.getDefaultSource(i);
expo->weight = 100;
strncpy(inputNames[i], expo->srcRaw.toString().toLatin1().constData(), sizeof(inputNames[i])-1);
MixData * mix = &mixData[i];
mix->destCh = i+1;
mix->weight = 100;
mix->srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i, this);
}
}
else {
for (int i=0; i<NUM_STICKS; i++) {
mixData[i].destCh = i+1;
mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i);
mixData[i].weight = 100;
}
}
}
void ModelData::setDefaultValues(unsigned int id, GeneralSettings & settings)
{
clear();
used = true;
sprintf(name, "MODEL%02d", id+1);
modelId = id+1;
setDefaultMixes(settings);
}
int ModelData::getTrimValue(int phaseIdx, int trimIdx)
+25 -10
View File
@@ -107,10 +107,11 @@ const uint8_t modn12x3[4][4]= {
#define DSW_SG2 20
const uint8_t chout_ar[] = { //First number is 0..23 -> template setup, Second is relevant channel out
1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2,
2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1,
3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1,
4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1 }; // TODO delete it?
1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2,
2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1,
3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1,
4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1
}; // TODO delete it?
// Beep center bits
#define BC_BIT_RUD (0x01)
@@ -159,10 +160,8 @@ enum HeliSwashTypes {
#define NUM_STICKS 4
#define BOARD_9X_NUM_POTS 3
#define BOARD_X9D_NUM_POTS 4
#define C9X_NUM_POTS 4
#define C9X_NUM_POTS 5
#define NUM_CAL_PPM 4
#define NUM_PPM(board) (IS_ARM(board) ? 16 : 8)
#define NUM_CYC 3
#define C9X_NUM_SWITCHES 10
#define C9X_NUM_KEYS 6
@@ -402,6 +401,9 @@ enum BeeperMode {
class GeneralSettings {
public:
GeneralSettings();
RawSource getDefaultSource(unsigned int channel);
unsigned int version;
unsigned int variant;
int calibMid[NUM_STICKS+C9X_NUM_POTS];
@@ -439,7 +441,7 @@ class GeneralSettings {
unsigned int backlightDelay;
bool blightinv;
bool stickScroll;
unsigned int templateSetup; //RETA order according to chout_ar array // TODO enum
unsigned int templateSetup; //RETA order according to chout_ar array
int PPM_Multiplier;
int hapticLength;
unsigned int reNavigation;
@@ -504,12 +506,19 @@ class CurveReference {
QString toString();
};
enum InputMode {
INPUT_MODE_NONE,
INPUT_MODE_POS,
INPUT_MODE_NEG,
INPUT_MODE_BOTH
};
class ExpoData {
public:
ExpoData() { clear(); }
RawSource srcRaw;
unsigned int scale;
unsigned int mode; // 0=end, 1=pos, 2=neg, 3=both
unsigned int mode;
unsigned int chn;
RawSwitch swtch;
unsigned int phases; // -5=!FP4, 0=normal, 5=FP4
@@ -882,6 +891,10 @@ class ScriptData {
class ModelData {
public:
ModelData();
ExpoData * insertInput(const int idx);
void removeInput(const int idx);
bool used;
char name[12+1];
uint8_t modelVoice;
@@ -937,7 +950,8 @@ class ModelData {
void clear();
bool isempty();
void setDefault(uint8_t id);
void setDefaultMixes(GeneralSettings & settings);
void setDefaultValues(unsigned int id, GeneralSettings & settings);
int getTrimValue(int phaseIdx, int trimIdx);
void setTrimValue(int phaseIdx, int trimIdx, int value);
@@ -1063,6 +1077,7 @@ enum Capability {
GetThrSwitch,
HasDisplayText,
VirtualInputs,
TrainerInputs,
LuaInputs,
LimitsPer1000,
EnhancedCurves,
@@ -148,7 +148,7 @@ inline int geteepromsize() {
#include "radio/src/lua/src/lcorolib.c"
int16_t g_anas[NUM_STICKS+BOARD_X9D_NUM_POTS];
int16_t g_anas[NUM_STICKS+5];
uint16_t anaIn(uint8_t chan)
{
+75 -30
View File
@@ -11,7 +11,7 @@
#define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || board == BOARD_GRUVIN9X)
#define HAS_LARGE_LCD(board) IS_TARANIS(board)
#define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256)
#define MAX_POTS(board) (IS_TARANIS(board) ? 4 : 3)
#define MAX_POTS(board, version) (IS_TARANIS(board) ? (version>=216 ? 5 : 4) : 3)
#define MAX_SWITCHES(board) (IS_TARANIS(board) ? 8 : 7)
#define MAX_SWITCHES_POSITION(board) (IS_TARANIS(board) ? 22 : 9)
#define MAX_ROTARY_ENCODERS(board) (board==BOARD_GRUVIN9X ? 2 : (board==BOARD_SKY9X ? 1 : 0))
@@ -60,8 +60,8 @@ class SwitchesConversionTable: public ConversionTable {
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++);
}
if (version >= 216) {
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
if (IS_TARANIS(board) && version >= 216) {
for (int i=1; i<=3*6; i++) {
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i), val++);
}
@@ -172,7 +172,7 @@ class SourcesConversionTable: public ConversionTable {
}
}
for (int i=0; i<4+MAX_POTS(board); i++)
for (int i=0; i<4+MAX_POTS(board, version); i++)
addConversion(RawSource(SOURCE_TYPE_STICK, i), val++);
for (int i=0; i<MAX_ROTARY_ENCODERS(board); i++)
@@ -733,12 +733,13 @@ void importGvarParam(int & gvar, const int _gvar)
class MixField: public TransformedField {
public:
MixField(MixData & mix, BoardEnum board, unsigned int version):
MixField(MixData & mix, BoardEnum board, unsigned int version, ModelData * model):
TransformedField(internalField),
internalField("Mix"),
mix(mix),
board(board),
version(version)
version(version),
model(model)
{
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(_destCh));
@@ -878,6 +879,14 @@ class MixField: public TransformedField {
virtual void afterImport()
{
if (IS_TARANIS(board) || version < 216) {
if (mix.srcRaw.type == SOURCE_TYPE_STICK && mix.srcRaw.index < NUM_STICKS) {
if (!mix.noExpo) {
mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, mix.srcRaw.index, model);
}
}
}
if (mix.srcRaw.type != SOURCE_TYPE_NONE) {
mix.destCh = _destCh + 1;
if (!IS_ARM(board) || version < 216) {
@@ -908,6 +917,7 @@ class MixField: public TransformedField {
MixData & mix;
BoardEnum board;
unsigned int version;
ModelData * model;
unsigned int _destCh;
bool _curveMode;
int _curveParam;
@@ -917,11 +927,11 @@ class MixField: public TransformedField {
unsigned int _offsetMode;
};
class ExpoField: public TransformedField {
class InputField: public TransformedField {
public:
ExpoField(ExpoData & expo, BoardEnum board, unsigned int version):
InputField(ExpoData & expo, BoardEnum board, unsigned int version):
TransformedField(internalField),
internalField("Expo"),
internalField("Input"),
expo(expo),
board(board),
version(version)
@@ -940,11 +950,11 @@ class ExpoField: public TransformedField {
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 UnsignedField<8>(expo.mode, "Mode"));
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));
internalField.Append(new UnsignedField<16>(expo.phases, "Phases"));
internalField.Append(new SignedField<8>(_weight, "Weight"));
internalField.Append(new BoolField<8>(_curveMode));
if (HAS_LARGE_LCD(board)) {
internalField.Append(new ZCharField<8>(expo.name));
@@ -979,6 +989,7 @@ class ExpoField: public TransformedField {
virtual void beforeExport()
{
_weight = smallGvarToEEPROM(expo.weight);
if (!IS_TARANIS(board) || version < 216) {
if (expo.curve.type==CurveReference::CURVE_REF_FUNC && expo.curve.value) {
_curveMode = true;
@@ -998,7 +1009,9 @@ class ExpoField: public TransformedField {
virtual void afterImport()
{
if (IS_TARANIS(board) && version < 216) {
expo.srcRaw = RawSource(SOURCE_TYPE_STICK, expo.chn);
if (expo.mode) {
expo.srcRaw = RawSource(SOURCE_TYPE_STICK, expo.chn);
}
}
expo.weight = smallGvarToC9x(_weight);
@@ -1091,7 +1104,7 @@ class CurvesField: public TransformedField {
CurveData *curve = &curves[i];
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";
EEPROMWarnings += ::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints) + "\n";
break;
}
if (!IS_TARANIS(board) || version < 216) {
@@ -1128,6 +1141,16 @@ class CurvesField: public TransformedField {
}
}
if (curve->count > 17) {
qDebug() << "Wrong points count" << curve->count;
curve->count = 0;
for (int j=0; j<maxCurves; j++) {
CurveData *curve = &curves[j];
curve->clear(5);
}
return;
}
for (int j=0; j<curve->count; j++) {
curve->points[j].y = *cur++;
}
@@ -1268,13 +1291,14 @@ class AndSwitchesConversionTable: public ConversionTable {
class LogicalSwitchField: public TransformedField {
public:
LogicalSwitchField(LogicalSwitchData & csw, BoardEnum board, unsigned int version, unsigned int variant):
LogicalSwitchField(LogicalSwitchData & csw, BoardEnum board, unsigned int version, unsigned int variant, ModelData * model=NULL):
TransformedField(internalField),
internalField("LogicalSwitch"),
csw(csw),
board(board),
version(version),
variant(variant),
model(model),
functionsConversionTable(board, version),
sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, (version >= 214 || (!IS_ARM(board) && version >= 213)) ? 0 : FLAG_NOSWITCHES)),
switchesConversionTable(SwitchesConversionTable::getInstance(board, version)),
@@ -1364,7 +1388,7 @@ class LogicalSwitchField: public TransformedField {
else if (csw.func != LS_FN_OFF) {
sourcesConversionTable->importValue((uint8_t)v1, csw.val1);
csw.val2 = v2;
RawSource val1(csw.val1);
RawSource val1(csw.val1, model);
if (IS_ARM(board) && version < 216 && val1.type == SOURCE_TYPE_TELEMETRY) {
switch (val1.index) {
case TELEMETRY_SOURCE_TIMER1:
@@ -1416,6 +1440,7 @@ class LogicalSwitchField: public TransformedField {
BoardEnum board;
unsigned int version;
unsigned int variant;
ModelData * model;
LogicalSwitchesFunctionsTable functionsConversionTable;
SourcesConversionTable * sourcesConversionTable;
SwitchesConversionTable * switchesConversionTable;
@@ -2133,11 +2158,12 @@ class MavlinkField: public StructField {
int exportPpmDelay(int delay) { return (delay - 300) / 50; }
int importPpmDelay(int delay) { return 300 + 50 * delay; }
Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant):
OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant):
TransformedField(internalField),
internalField("ModelData"),
modelData(modelData),
board(board),
version(version),
variant(variant),
protocolsConversionTable(board)
{
@@ -2227,14 +2253,14 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new UnsignedField<8>(modelData.beepANACenter));
for (int i=0; i<MAX_MIXERS(board, version); i++)
internalField.Append(new MixField(modelData.mixData[i], board, version));
internalField.Append(new MixField(modelData.mixData[i], board, version, &modelData));
for (int i=0; i<MAX_CHANNELS(board, version); i++)
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 InputField(modelData.expoData[i], board, version));
internalField.Append(new CurvesField(modelData.curves, board, version));
for (int i=0; i<MAX_CUSTOM_SWITCHES(board, version); i++)
internalField.Append(new LogicalSwitchField(modelData.customSw[i], board, version, variant));
internalField.Append(new LogicalSwitchField(modelData.customSw[i], board, version, variant, &modelData));
for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++) {
if (IS_ARM(board))
internalField.Append(new ArmCustomFunctionField(modelData.funcSw[i], board, version, variant));
@@ -2346,7 +2372,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
}
}
void Open9xModelDataNew::beforeExport()
void OpenTxModelData::beforeExport()
{
// qDebug() << QString("before export model") << modelData.name;
@@ -2360,10 +2386,29 @@ void Open9xModelDataNew::beforeExport()
}
}
void Open9xModelDataNew::afterImport()
void OpenTxModelData::afterImport()
{
// qDebug() << QString("after import model") << modelData.name ;
if (IS_TARANIS(board) && version < 216) {
for (unsigned int i=0; i<NUM_STICKS; i++) {
for (int j=0; j<64; j++) {
ExpoData * expo = &modelData.expoData[j];
if (expo->mode == INPUT_MODE_BOTH && expo->chn == i && expo->phases == 0 && expo->swtch.type == SWITCH_TYPE_NONE)
break;
if (expo->mode == 0 || expo->chn > i) {
ExpoData * newExpo = modelData.insertInput(j);
newExpo->mode = INPUT_MODE_BOTH;
newExpo->srcRaw = RawSource(SOURCE_TYPE_STICK, i);
newExpo->chn = i;
newExpo->weight = 100;
break;
}
}
strncpy(modelData.inputNames[i], AnalogString(i).toLatin1().constData(), sizeof(modelData.inputNames[i])-1);
}
}
for (int module=0; module<3; module++) {
if (modelData.moduleData[module].protocol == PXX_XJT_X16 || modelData.moduleData[module].protocol == LP45) {
if (subprotocols[module] >= 0)
@@ -2374,13 +2419,13 @@ void Open9xModelDataNew::afterImport()
}
}
Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant):
OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant):
TransformedField(internalField),
internalField("General Settings"),
generalData(generalData),
board(board),
version(version),
inputsCount(IS_TARANIS(board) ? 8 : 7)
inputsCount(4 + MAX_POTS(board, version))
{
generalData.version = version;
generalData.variant = variant;
@@ -2511,18 +2556,18 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
}
}
void Open9xGeneralDataNew::beforeExport()
void OpenTxGeneralData::beforeExport()
{
uint16_t sum = 0;
if (version >= 216) {
int count = 0;
for (int i=0; i<inputsCount; i++) {
sum += generalData.calibMid[i];
if (++count == inputsCount+5) break;
if (++count == 12) break;
sum += generalData.calibSpanNeg[i];
if (++count == inputsCount+5) break;
if (++count == 12) break;
sum += generalData.calibSpanPos[i];
if (++count == inputsCount+5) break;
if (++count == 12) break;
}
}
else {
@@ -2534,6 +2579,6 @@ void Open9xGeneralDataNew::beforeExport()
chkSum = sum;
}
void Open9xGeneralDataNew::afterImport()
void OpenTxGeneralData::afterImport()
{
}
@@ -51,9 +51,9 @@
#define O9X_ARM_MAX_CSFUNCOLD 13
#define O9X_ARM_MAX_CSFUNC 15
class Open9xGeneralDataNew: public TransformedField {
class OpenTxGeneralData: public TransformedField {
public:
Open9xGeneralDataNew(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant=0);
OpenTxGeneralData(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant=0);
protected:
virtual void beforeExport();
@@ -113,9 +113,9 @@ class ChannelsConversionTable: public ConversionTable
};
class Open9xModelDataNew: public TransformedField {
class OpenTxModelData: public TransformedField {
public:
Open9xModelDataNew(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant);
OpenTxModelData(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant);
const char * getName() { return name; }
@@ -126,6 +126,7 @@ class Open9xModelDataNew: public TransformedField {
StructField internalField;
ModelData & modelData;
BoardEnum board;
unsigned int version;
unsigned int variant;
private:
@@ -236,11 +236,11 @@ bool OpenTxInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data
return loadModel<Open9xArmModelData_v212>(model, data, index);
}
else {
return loadModelVariant<Open9xModelDataNew>(index, model, data, version, variant);
return loadModelVariant<OpenTxModelData>(index, model, data, version, variant);
}
}
else if (version >= 213) {
return loadModelVariant<Open9xModelDataNew>(index, model, data, version, variant);
return loadModelVariant<OpenTxModelData>(index, model, data, version, variant);
}
std::cout << " ko\n";
@@ -336,7 +336,7 @@ bool OpenTxInterface::load(RadioData &radioData, const uint8_t *eeprom, int size
return false;
}
if (!loadGeneral<Open9xGeneralDataNew>(radioData.generalSettings, version)) {
if (!loadGeneral<OpenTxGeneralData>(radioData.generalSettings, version)) {
std::cout << " ko\n";
return false;
}
@@ -383,14 +383,14 @@ int OpenTxInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
variant |= M128_VARIANT;
}
int result = saveGeneral<Open9xGeneralDataNew>(radioData.generalSettings, board, version, variant);
int result = saveGeneral<OpenTxGeneralData>(radioData.generalSettings, board, version, variant);
if (!result) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
result = saveModel<Open9xModelDataNew>(i, radioData.models[i], version, variant);
result = saveModel<OpenTxModelData>(i, radioData.models[i], version, variant);
if (!result) {
return 0;
}
@@ -417,7 +417,7 @@ int OpenTxInterface::getSize(ModelData &model)
uint8_t tmp[EESIZE_RLC_MAX];
efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board);
Open9xModelDataNew open9xModel(model, board, 255, GetCurrentFirmwareVariant());
OpenTxModelData open9xModel(model, board, 255, GetCurrentFirmwareVariant());
QByteArray eeprom;
open9xModel.Export(eeprom);
@@ -436,7 +436,7 @@ int OpenTxInterface::getSize(GeneralSettings &settings)
uint8_t tmp[EESIZE_RLC_MAX];
efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board);
Open9xGeneralDataNew open9xGeneral(settings, board, 255, GetCurrentFirmwareVariant());
OpenTxGeneralData open9xGeneral(settings, board, 255, GetCurrentFirmwareVariant());
// open9xGeneral.Dump();
QByteArray eeprom;
@@ -511,7 +511,7 @@ int OpenTxInterface::getCapability(const Capability capability)
else
return 0;
case Pots:
return (IS_TARANIS(board) ? 4 : 3);
return (IS_TARANIS(board) ? 5 : 3);
case Switches:
return (IS_TARANIS(board) ? 8 : 7);
case SwitchesPositions:
@@ -671,6 +671,8 @@ int OpenTxInterface::getCapability(const Capability capability)
case HasDisplayText:
case VirtualInputs:
return IS_TARANIS(board) ? 32 : 0;
case TrainerInputs:
return IS_ARM(board) ? 16 : 8;
case LuaInputs:
case LimitsPer1000:
case EnhancedCurves:
@@ -681,7 +683,7 @@ int OpenTxInterface::getCapability(const Capability capability)
case HasMahPersistent:
return (IS_ARM(board) ? true : false);
case MultiposPots:
return IS_TARANIS(board) ? 2 : 0;
return IS_TARANIS(board) ? 3 : 0;
case MultiposPotsPositions:
return IS_TARANIS(board) ? 6 : 0;
case SimulatorVariant:
+1 -1
View File
@@ -599,7 +599,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<NUM_PPM(GetEepromInterface()->getBoard()); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(TrainerInputs); i++) {
item = RawSource(SOURCE_TYPE_PPM, i);
b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
+1 -1
View File
@@ -151,7 +151,7 @@ void MdiChild::checkAndInitModel( int row )
{
ModelData &model = radioData.models[row - 1];
if (model.isempty()) {
model.setDefault(row - 1);
model.setDefaultValues(row - 1, radioData.generalSettings);
setModified();
}
}
+17 -19
View File
@@ -29,9 +29,9 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g
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(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()));
@@ -58,7 +58,7 @@ void InputsPanel::update()
ExposlistWidget->clear();
int curDest = -1;
for(int i=0; i<C9X_MAX_EXPOS; i++) {
for (int i=0; i<C9X_MAX_EXPOS; i++) {
ExpoData *md = &model.expoData[i];
if (md->mode==0) break;
@@ -144,26 +144,24 @@ void InputsPanel::update()
bool InputsPanel::gm_insertExpo(int idx)
{
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
QMessageBox::information(this, "companion", tr("Not enough available inputs!"));
return false;
}
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
QMessageBox::information(this, "Companion", tr("Not enough available inputs!"));
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;
int chn = model.expoData[idx].chn;
ExpoData * newExpo = model.insertInput(idx);
newExpo->chn = chn;
newExpo->weight = 100;
newExpo->mode = INPUT_MODE_BOTH;
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));
model.removeInput(index);
}
void InputsPanel::gm_openExpo(int index)
+5 -10
View File
@@ -6,24 +6,19 @@
class MixersList : public QListWidget
{
Q_OBJECT
public:
explicit MixersList(QWidget *parent, bool expo);
// QMimeData * mimeData ( const QList<QListWidgetItem *> items );
public:
explicit MixersList(QWidget *parent, bool expo);
void keyPressEvent(QKeyEvent *event);
signals:
signals:
void mimeDropped(int index, const QMimeData *data, Qt::DropAction action);
void keyWasPressed(QKeyEvent *event);
protected:
public slots:
public slots:
bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
private:
private:
QPoint dragStartPosition;
bool expo;
+15 -11
View File
@@ -53,15 +53,16 @@ void MixesPanel::update()
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++) {
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)) {
while (curDest<(md->destCh-1)) {
curDest++;
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
} else {
}
else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;
@@ -80,7 +81,8 @@ void MixesPanel::update()
if (md->destCh > outputs) {
str = tr("X%1 ").arg(md->destCh-outputs);
} else {
}
else {
str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10);
str.append(" ");
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
@@ -97,7 +99,7 @@ void MixesPanel::update()
str.fill(' ');
}
switch(md->mltpx) {
switch (md->mltpx) {
case (1): str += " *"; break;
case (2): str += " R"; break;
default: str += " "; break;
@@ -110,7 +112,9 @@ void MixesPanel::update()
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->swtch.type != SWITCH_TYPE_NONE) {
str += " " + tr("Switch(%1)").arg(md->swtch.toString());
}
if (!GetEepromInterface()->getCapability(VirtualInputs)) {
if (md->carryTrim>0) {
@@ -125,9 +129,9 @@ void MixesPanel::update()
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;
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)
@@ -144,8 +148,8 @@ void MixesPanel::update()
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);
itm->setData(Qt::UserRole, qba); // mix number
MixerlistWidget->addItem(itm); //(str);
}
while(curDest<outputs+GetEepromInterface()->getCapability(ExtraChannels)) {
+22 -22
View File
@@ -44,36 +44,36 @@
#include "helpers.h"
class DragDropHeader {
public:
DragDropHeader():
general_settings(false),
models_count(0)
{
}
bool general_settings;
uint8_t models_count;
uint8_t models[C9X_MAX_MODELS];
public:
DragDropHeader():
general_settings(false),
models_count(0)
{
}
bool general_settings;
uint8_t models_count;
uint8_t models[C9X_MAX_MODELS];
};
ModelsListWidget::ModelsListWidget(QWidget *parent):
QListWidget(parent)
{
this->setFont(QFont("Courier New",12));
radioData = &((MdiChild *)parent)->radioData;
refreshList();
setFont(QFont("Courier New",12));
radioData = &((MdiChild *)parent)->radioData;
refreshList();
connect(this, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(OpenEditWindow()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));
connect(this, SIGNAL(currentRowChanged(int)), this, SLOT(viableModelSelected(int)));
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OpenEditWindow()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));
connect(this, SIGNAL(currentRowChanged(int)), this, SLOT(viableModelSelected(int)));
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setDragEnabled(true);
setAcceptDrops(true);
setDragDropOverwriteMode(true);
setDropIndicatorShown(true);
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setDragEnabled(true);
setAcceptDrops(true);
setDragDropOverwriteMode(true);
setDropIndicatorShown(true);
active_highlight_color = this->palette().color(QPalette::Active, QPalette::Highlight);
active_highlight_color = palette().color(QPalette::Active, QPalette::Highlight);
}
void ModelsListWidget::ShowContextMenu(const QPoint& pos)