1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Issue #731 fixed - Default mixes/expos created on an empty model

This commit is contained in:
bsongis 2014-03-03 13:01:17 +01:00
parent bf7919bd8d
commit adf08a59fb
3 changed files with 48 additions and 10 deletions

View file

@ -795,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();
@ -891,6 +892,12 @@ 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();
@ -964,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)

View file

@ -110,7 +110,8 @@ const uint8_t chout_ar[] = { //First number is 0..23 -> template setup, Second
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?
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)
@ -400,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];
@ -437,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;
@ -946,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);

View file

@ -155,7 +155,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
ModelData &model = radioData.models[row - 1];
if (model.isempty()) {
model.setDefault(row - 1);
model.setDefaultValues(row - 1, radioData.generalSettings);
isNew = true; //modeledit - clear mixes, apply first template
setModified();
}