committed by
Bertrand Songis
parent
093025f444
commit
3ec6498155
@@ -44,14 +44,14 @@ WizMix::WizMix(const GeneralSettings & settings, unsigned int modelId, const Mod
|
|||||||
originalModelData(modelData),
|
originalModelData(modelData),
|
||||||
vehicle(NOVEHICLE)
|
vehicle(NOVEHICLE)
|
||||||
{
|
{
|
||||||
strncpy(name, originalModelData.name, WIZ_MODEL_NAME_LENGTH);
|
memset(name, 0, sizeof(name));
|
||||||
|
strncpy(name, originalModelData.name, sizeof(name)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int weight)
|
void WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int weight)
|
||||||
{
|
{
|
||||||
strncpy(mix.name, name, MIXDATA_NAME_LEN);
|
memset(mix.name, 0, sizeof(mix.name));
|
||||||
mix.name[MIXDATA_NAME_LEN] = '\0';
|
strncpy(mix.name, name, sizeof(mix.name)-1);
|
||||||
mix.destCh = channel;
|
mix.destCh = channel;
|
||||||
mix.srcRaw = RawSource(SOURCE_TYPE_MAX);
|
mix.srcRaw = RawSource(SOURCE_TYPE_MAX);
|
||||||
mix.swtch = RawSwitch(SWITCH_TYPE_SWITCH, sw);
|
mix.swtch = RawSwitch(SWITCH_TYPE_SWITCH, sw);
|
||||||
@@ -75,7 +75,7 @@ void WizMix::addMix(ModelData &model, Input input, int weight, int channel, int
|
|||||||
}
|
}
|
||||||
else if (input==FLAPS_INPUT){
|
else if (input==FLAPS_INPUT){
|
||||||
// There ought to be some kind of constants for switches somewhere...
|
// There ought to be some kind of constants for switches somewhere...
|
||||||
maxMixSwitch((char *)"Flaps Up", model.mixData[mixIndex++], channel+1, isHorusOrTaranis ? SWITCH_SA0 :-SWITCH_ELE , weight); //Taranis-Horus SA-UP, 9X ELE-UP
|
maxMixSwitch((char *)"Flaps Up", model.mixData[mixIndex++], channel+1, isHorusOrTaranis ? SWITCH_SA0 :-SWITCH_ELE , weight); //Taranis-Horus SA-UP, 9X ELE-UP
|
||||||
maxMixSwitch((char *)"Flaps Dn", model.mixData[mixIndex++], channel+1, isHorusOrTaranis ? SWITCH_SA2 : SWITCH_ELE , -weight); //Taranis-Horus SA-DOWN, 9X ELE-DOWN
|
maxMixSwitch((char *)"Flaps Dn", model.mixData[mixIndex++], channel+1, isHorusOrTaranis ? SWITCH_SA2 : SWITCH_ELE , -weight); //Taranis-Horus SA-DOWN, 9X ELE-DOWN
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,6 @@ WizMix::operator ModelData()
|
|||||||
int throttleChannel = -1;
|
int throttleChannel = -1;
|
||||||
|
|
||||||
ModelData model;
|
ModelData model;
|
||||||
//ModelData model(originalModelData);
|
|
||||||
model.category = originalModelData.category;
|
model.category = originalModelData.category;
|
||||||
model.used = true;
|
model.used = true;
|
||||||
model.moduleData[0].modelId = modelId;
|
model.moduleData[0].modelId = modelId;
|
||||||
@@ -101,8 +100,8 @@ WizMix::operator ModelData()
|
|||||||
int timerIndex = 0;
|
int timerIndex = 0;
|
||||||
|
|
||||||
// Safe copy model name
|
// Safe copy model name
|
||||||
strncpy(model.name, name, WIZ_MODEL_NAME_LENGTH);
|
memset(model.name, 0, sizeof(model.name));
|
||||||
model.name[WIZ_MODEL_NAME_LENGTH] = 0;
|
strncpy(model.name, name, sizeof(model.name)-1);
|
||||||
|
|
||||||
// Add the channel mixes
|
// Add the channel mixes
|
||||||
for (int i=0; i<WIZ_MAX_CHANNELS; i++ )
|
for (int i=0; i<WIZ_MAX_CHANNELS; i++ )
|
||||||
@@ -112,29 +111,36 @@ WizMix::operator ModelData()
|
|||||||
addMix(model, ch.input1, ch.weight1, i, mixIndex);
|
addMix(model, ch.input1, ch.weight1, i, mixIndex);
|
||||||
addMix(model, ch.input2, ch.weight2, i, mixIndex);
|
addMix(model, ch.input2, ch.weight2, i, mixIndex);
|
||||||
|
|
||||||
if ((ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT) && options[THROTTLE_CUT_OPTION]) {
|
if (ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT) {
|
||||||
// Add the Throttle Cut option
|
throttleChannel++;
|
||||||
MixData & mix = model.mixData[mixIndex++];
|
if (options[THROTTLE_CUT_OPTION]) {
|
||||||
mix.destCh = i+1;
|
// Add the Throttle Cut option
|
||||||
mix.srcRaw = SOURCE_TYPE_MAX;
|
MixData & mix = model.mixData[mixIndex++];
|
||||||
mix.weight = -100;
|
mix.destCh = i+1;
|
||||||
mix.swtch.type = SWITCH_TYPE_SWITCH;
|
mix.srcRaw = SOURCE_TYPE_MAX;
|
||||||
mix.swtch.index = IS_ARM(getCurrentBoard()) ? SWITCH_SF0 : SWITCH_THR;
|
mix.weight = -100;
|
||||||
mix.mltpx = MLTPX_REP;
|
mix.swtch.type = SWITCH_TYPE_SWITCH;
|
||||||
strncpy(mix.name, "Cut", MIXDATA_NAME_LEN);
|
mix.swtch.index = IS_ARM(getCurrentBoard()) ? SWITCH_SF0 : SWITCH_THR;
|
||||||
mix.name[MIXDATA_NAME_LEN] = '\0';
|
mix.mltpx = MLTPX_REP;
|
||||||
|
memset(mix.name, 0, sizeof(mix.name));
|
||||||
|
strncpy(mix.name, "Cut", MIXDATA_NAME_LEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Flight Timer option
|
// Add the Flight Timer option
|
||||||
if (options[FLIGHT_TIMER_OPTION] ){
|
if (options[FLIGHT_TIMER_OPTION] && throttleChannel >= 0){
|
||||||
|
memset(model.timers[timerIndex].name, 0, sizeof(model.timers[timerIndex].name));
|
||||||
|
strncpy(model.timers[timerIndex].name, "Flt", sizeof(model.timers[timerIndex].name)-1);
|
||||||
model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE;
|
model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE;
|
||||||
model.timers[timerIndex].mode.index = TMRMODE_THR_TRG;
|
model.timers[timerIndex].mode.index = TMRMODE_THR_TRG;
|
||||||
timerIndex++;
|
timerIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Throttle Timer option
|
// Add the Throttle Timer option
|
||||||
if (options[THROTTLE_TIMER_OPTION] && throttleChannel >=0){
|
if (options[THROTTLE_TIMER_OPTION] && throttleChannel >= 0){
|
||||||
|
memset(model.timers[timerIndex].name, 0, sizeof(model.timers[timerIndex].name));
|
||||||
|
strncpy(model.timers[timerIndex].name, "Thr", sizeof(model.timers[timerIndex].name)-1);
|
||||||
model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE;
|
model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE;
|
||||||
model.timers[timerIndex].mode.index = TMRMODE_THR;
|
model.timers[timerIndex].mode.index = TMRMODE_THR;
|
||||||
timerIndex++;
|
timerIndex++;
|
||||||
|
|||||||
@@ -306,8 +306,8 @@ bool ModelSelectionPage::validatePage()
|
|||||||
QString newName(nameLineEdit->text());
|
QString newName(nameLineEdit->text());
|
||||||
newName = (newName.normalized(QString::NormalizationForm_D));
|
newName = (newName.normalized(QString::NormalizationForm_D));
|
||||||
newName = newName.replace(QRegExp("[^ A-Za-z0-9_.-,\\s]"), "");
|
newName = newName.replace(QRegExp("[^ A-Za-z0-9_.-,\\s]"), "");
|
||||||
strncpy( wizDlg->mix.name, newName.toLatin1(), WIZ_MODEL_NAME_LENGTH);
|
memset(wizDlg->mix.name, 0, sizeof(wizDlg->mix.name));
|
||||||
wizDlg->mix.name[WIZ_MODEL_NAME_LENGTH] = 0;
|
strncpy( wizDlg->mix.name, newName.toLatin1(), sizeof(wizDlg->mix.name)-1);
|
||||||
|
|
||||||
if (multirotorRB->isChecked())
|
if (multirotorRB->isChecked())
|
||||||
wizDlg->mix.vehicle = MULTICOPTER;
|
wizDlg->mix.vehicle = MULTICOPTER;
|
||||||
@@ -1053,7 +1053,7 @@ QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, in
|
|||||||
|
|
||||||
QString WizardPrinter::print()
|
QString WizardPrinter::print()
|
||||||
{
|
{
|
||||||
QString str = tr("Model Name: ") + mix->name + "\n";
|
QString str = tr("Model Name: ") + QString::fromUtf8(mix->name) + "\n";
|
||||||
str += tr("Model Type: ") + vehicleName(mix->vehicle) + "\n";
|
str += tr("Model Type: ") + vehicleName(mix->vehicle) + "\n";
|
||||||
|
|
||||||
str += tr("Options: ") + "[";
|
str += tr("Options: ") + "[";
|
||||||
@@ -1075,6 +1075,3 @@ QString WizardPrinter::print()
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user