mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
New plce holder function in eeprominterface for importing wizard data. Need help from Bertrand since the format of the real mixes is mysterious.
This commit is contained in:
parent
11565e05e9
commit
b133a990f1
7 changed files with 121 additions and 87 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "firmwares/ersky9x/ersky9xinterface.h"
|
#include "firmwares/ersky9x/ersky9xinterface.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "wizarddata.h"
|
||||||
|
|
||||||
QString EEPROMWarnings;
|
QString EEPROMWarnings;
|
||||||
|
|
||||||
|
@ -971,6 +972,25 @@ bool ModelData::isempty()
|
||||||
return !used;
|
return !used;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelData::importWizardData( unsigned int id, const WizMix mix )
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
used = true;
|
||||||
|
modelId = id+1;
|
||||||
|
|
||||||
|
// Safe copy model name
|
||||||
|
strncpy ( name, mix.name, WIZ_MODEL_NAME_LENGTH);
|
||||||
|
name[WIZ_MODEL_NAME_LENGTH] = 0;
|
||||||
|
|
||||||
|
for (int i=0; i<WIZ_MAX_CHANNELS; i++ ){
|
||||||
|
Channel ch = mix.channel[i];
|
||||||
|
if (ch.sourceDlg > 0){
|
||||||
|
|
||||||
|
//**** INSERT MIXER HERE ****
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelData::setDefaultMixes(GeneralSettings & settings)
|
void ModelData::setDefaultMixes(GeneralSettings & settings)
|
||||||
{
|
{
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "wizarddata.h"
|
||||||
|
|
||||||
#if __GNUC__
|
#if __GNUC__
|
||||||
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
||||||
|
@ -950,6 +951,7 @@ class ModelData {
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool isempty();
|
bool isempty();
|
||||||
|
void importWizardData(unsigned int, const WizMix);
|
||||||
void setDefaultMixes(GeneralSettings & settings);
|
void setDefaultMixes(GeneralSettings & settings);
|
||||||
void setDefaultValues(unsigned int id, GeneralSettings & settings);
|
void setDefaultValues(unsigned int id, GeneralSettings & settings);
|
||||||
|
|
||||||
|
|
|
@ -189,15 +189,7 @@ void MdiChild::wizardEdit()
|
||||||
wizard->exec();
|
wizard->exec();
|
||||||
if (wizard->mix.complete){
|
if (wizard->mix.complete){
|
||||||
ModelData &model = radioData.models[row - 1];
|
ModelData &model = radioData.models[row - 1];
|
||||||
|
model.importWizardData(row - 1, wizard->mix);
|
||||||
// Remove dicritics and filter off anything but chars from the new model name
|
|
||||||
QString newName(wizard->mix.name.normalized(QString::NormalizationForm_D));
|
|
||||||
newName = newName.replace(QRegExp("[^a-zA-Z\\s]"), "");
|
|
||||||
strncpy(model.name, newName.toAscii(), sizeof(model.name));
|
|
||||||
model.name[sizeof(model.name)-1]=0;
|
|
||||||
|
|
||||||
//TODO Save the rest of the wizard->mix data to model.
|
|
||||||
|
|
||||||
setModified();
|
setModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,32 +11,9 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include <string.h>
|
||||||
#include "wizarddata.h"
|
#include "wizarddata.h"
|
||||||
|
|
||||||
QString inputName(Input input)
|
|
||||||
{
|
|
||||||
switch (input){
|
|
||||||
case THROTTLE: return "THR";
|
|
||||||
case RUDDER: return "RUD";
|
|
||||||
case ELEVATOR: return "ELE";
|
|
||||||
case AILERON: return "AIL";
|
|
||||||
case FLAP: return "FLP";
|
|
||||||
case AIRBREAK: return "AIR";
|
|
||||||
default: return "---";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString vehicleName(Vehicle vehicle)
|
|
||||||
{
|
|
||||||
switch (vehicle){
|
|
||||||
case PLANE: return "Plane";
|
|
||||||
case MULTICOPTER: return "Multicopter";
|
|
||||||
case HELICOPTER: return "Helicopter";
|
|
||||||
default: return "---";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel::Channel()
|
Channel::Channel()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
@ -51,38 +28,11 @@ void Channel::clear()
|
||||||
weight2 = 0;
|
weight2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channel::isEmpty()
|
WizMix::WizMix()
|
||||||
{
|
|
||||||
return sourceDlg < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Channel::toString()
|
|
||||||
{
|
|
||||||
QString str;
|
|
||||||
str = QString("[%1, %2]").arg(inputName(input1)).arg(weight1);
|
|
||||||
if ( input2 != NOINPUT )
|
|
||||||
str += QString("[%1, %2]").arg(inputName(input2)).arg(weight2);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mix::Mix()
|
|
||||||
{
|
{
|
||||||
complete = false;
|
complete = false;
|
||||||
name = "";
|
strcpy(name, " ");
|
||||||
vehicle = NOVEHICLE;
|
vehicle = NOVEHICLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Mix::toString()
|
|
||||||
{
|
|
||||||
QString str;
|
|
||||||
str = QString(tr("Model Name: ")) + name + "\n";
|
|
||||||
str += QString(tr("Model Type: ")) + vehicleName(vehicle) + "\n";
|
|
||||||
for (int i=0; i<MAX_CHANNELS; i++){
|
|
||||||
if (!channel[i].isEmpty()){
|
|
||||||
str += QString(tr("Channel %1: ").arg(i+1));
|
|
||||||
str += channel[i].toString();
|
|
||||||
str += QString("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,15 +14,13 @@
|
||||||
|
|
||||||
#ifndef WIZARDDATA_H
|
#ifndef WIZARDDATA_H
|
||||||
#define WIZARDDATA_H
|
#define WIZARDDATA_H
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#define MAX_CHANNELS 8
|
#define WIZ_MAX_CHANNELS 8
|
||||||
|
#define WIZ_MODEL_NAME_LENGTH 12
|
||||||
|
|
||||||
enum Input {NOINPUT, THROTTLE, RUDDER, ELEVATOR, AILERON, FLAP, AIRBREAK};
|
enum Input {NOINPUT, THROTTLE, RUDDER, ELEVATOR, AILERON, FLAP, AIRBREAK};
|
||||||
enum Vehicle {NOVEHICLE, PLANE, MULTICOPTER, HELICOPTER };
|
enum Vehicle {NOVEHICLE, PLANE, MULTICOPTER, HELICOPTER };
|
||||||
|
|
||||||
QString inputName(Input);
|
|
||||||
QString vehicleName(Input);
|
|
||||||
|
|
||||||
class Channel
|
class Channel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,23 +31,18 @@ public:
|
||||||
int weight2;
|
int weight2;
|
||||||
|
|
||||||
Channel();
|
Channel();
|
||||||
bool isEmpty();
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
QString toString();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mix:QObject
|
class WizMix
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
bool complete;
|
bool complete;
|
||||||
QString name;
|
char name[WIZ_MODEL_NAME_LENGTH + 1];
|
||||||
Vehicle vehicle;
|
Vehicle vehicle;
|
||||||
Channel channel[MAX_CHANNELS];
|
Channel channel[WIZ_MAX_CHANNELS];
|
||||||
|
|
||||||
Mix();
|
WizMix();
|
||||||
QString toString();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIZARDDATA_H
|
#endif // WIZARDDATA_H
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "wizarddialog.h"
|
#include "wizarddialog.h"
|
||||||
|
#include "wizarddata.h"
|
||||||
|
|
||||||
WizardDialog::WizardDialog(QWidget *parent)
|
WizardDialog::WizardDialog(QWidget *parent)
|
||||||
: QWizard(parent)
|
: QWizard(parent)
|
||||||
|
@ -139,12 +140,12 @@ StandardPage::StandardPage(int currentPage, WizardDialog *dlg, QString image, QS
|
||||||
|
|
||||||
void StandardPage::populateCB( QComboBox *CB )
|
void StandardPage::populateCB( QComboBox *CB )
|
||||||
{
|
{
|
||||||
for (int j=0; j<MAX_CHANNELS; j++)
|
for (int j=0; j<WIZ_MAX_CHANNELS; j++)
|
||||||
CB->removeItem(0);
|
CB->removeItem(0);
|
||||||
|
|
||||||
for (int i=0; i<MAX_CHANNELS; i++)
|
for (int i=0; i<WIZ_MAX_CHANNELS; i++)
|
||||||
{
|
{
|
||||||
if (wizDlg->mix.channel[i].isEmpty()){
|
if (wizDlg->mix.channel[i].sourceDlg < 0){
|
||||||
CB->addItem(tr("Channel ") + QString("%1").arg(i+1), i);
|
CB->addItem(tr("Channel ") + QString("%1").arg(i+1), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,9 +155,9 @@ bool StandardPage::bookChannel(QString label, Input input1, int weight1, Input i
|
||||||
{
|
{
|
||||||
int index = label.right(1).toInt() - 1;
|
int index = label.right(1).toInt() - 1;
|
||||||
|
|
||||||
if (index<0 || index >= MAX_CHANNELS)
|
if (index<0 || index >= WIZ_MAX_CHANNELS)
|
||||||
return false;
|
return false;
|
||||||
if (!wizDlg->mix.channel[index].isEmpty())
|
if (!(wizDlg->mix.channel[index].sourceDlg < 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wizDlg->mix.channel[index].sourceDlg = pageCurrent;
|
wizDlg->mix.channel[index].sourceDlg = pageCurrent;
|
||||||
|
@ -170,7 +171,7 @@ bool StandardPage::bookChannel(QString label, Input input1, int weight1, Input i
|
||||||
|
|
||||||
void StandardPage::releaseChannels()
|
void StandardPage::releaseChannels()
|
||||||
{
|
{
|
||||||
for (int i=0; i<MAX_CHANNELS; i++)
|
for (int i=0; i<WIZ_MAX_CHANNELS; i++)
|
||||||
{
|
{
|
||||||
if (wizDlg->mix.channel[i].sourceDlg == pageCurrent){
|
if (wizDlg->mix.channel[i].sourceDlg == pageCurrent){
|
||||||
wizDlg->mix.channel[i].clear();
|
wizDlg->mix.channel[i].clear();
|
||||||
|
@ -211,7 +212,13 @@ ModelSelectionPage::ModelSelectionPage(WizardDialog *dlg, QString image, QString
|
||||||
|
|
||||||
bool ModelSelectionPage::validatePage()
|
bool ModelSelectionPage::validatePage()
|
||||||
{
|
{
|
||||||
wizDlg->mix.name = nameLineEdit->text();
|
//Filter and insert model name in mix data
|
||||||
|
QString newName(nameLineEdit->text());
|
||||||
|
newName = (newName.normalized(QString::NormalizationForm_D));
|
||||||
|
newName = newName.replace(QRegExp("[^ A-Za-z0-9_.-,\\s]"), "");
|
||||||
|
strncpy( wizDlg->mix.name, newName.toAscii(), WIZ_MODEL_NAME_LENGTH);
|
||||||
|
wizDlg->mix.name[WIZ_MODEL_NAME_LENGTH]=0;
|
||||||
|
|
||||||
if (multirotorRB->isChecked())
|
if (multirotorRB->isChecked())
|
||||||
wizDlg->mix.vehicle = MULTICOPTER;
|
wizDlg->mix.vehicle = MULTICOPTER;
|
||||||
else if (helicopterRB->isChecked())
|
else if (helicopterRB->isChecked())
|
||||||
|
@ -719,8 +726,8 @@ ConclusionPage::ConclusionPage(WizardDialog *dlg, QString image, QString title,
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConclusionPage::initializePage(){
|
void ConclusionPage::initializePage(){
|
||||||
|
WizardPrinter p(&wizDlg->mix);
|
||||||
textLabel->setText(wizDlg->mix.toString());
|
textLabel->setText(p.print());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConclusionPage::validatePage() {
|
bool ConclusionPage::validatePage() {
|
||||||
|
@ -729,3 +736,58 @@ bool ConclusionPage::validatePage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString WizardPrinter::inputName(Input input)
|
||||||
|
{
|
||||||
|
switch (input){
|
||||||
|
case THROTTLE: return "THR";
|
||||||
|
case RUDDER: return "RUD";
|
||||||
|
case ELEVATOR: return "ELE";
|
||||||
|
case AILERON: return "AIL";
|
||||||
|
case FLAP: return "FLP";
|
||||||
|
case AIRBREAK: return "AIR";
|
||||||
|
default: return "---";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WizardPrinter::vehicleName(Vehicle vehicle)
|
||||||
|
{
|
||||||
|
switch (vehicle){
|
||||||
|
case PLANE: return "Plane";
|
||||||
|
case MULTICOPTER: return "Multicopter";
|
||||||
|
case HELICOPTER: return "Helicopter";
|
||||||
|
default: return "---";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WizardPrinter::WizardPrinter(WizMix *wizMix)
|
||||||
|
{
|
||||||
|
mix = wizMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 )
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
str = QString("[%1, %2]").arg(inputName(input1)).arg(weight1);
|
||||||
|
if ( input2 != NOINPUT )
|
||||||
|
str += QString("[%1, %2]").arg(inputName(input2)).arg(weight2);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WizardPrinter::print()
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
str = QString(tr("Model Name: ")) + mix->name + "\n";
|
||||||
|
str += QString(tr("Model Type: ")) + vehicleName(mix->vehicle) + "\n";
|
||||||
|
for (int i=0; i<WIZ_MAX_CHANNELS; i++){
|
||||||
|
if (!(mix->channel[i].sourceDlg < 0 )){
|
||||||
|
Channel ch = mix->channel[i];
|
||||||
|
str += QString(tr("Channel %1: ").arg(i+1));
|
||||||
|
str += printChannel(ch.input1, ch.weight1, ch.input2, ch.weight2 );
|
||||||
|
str += QString("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
Page_Fblheli, Page_Helictrl, Page_Multirotor,
|
Page_Fblheli, Page_Helictrl, Page_Multirotor,
|
||||||
Page_Conclusion };
|
Page_Conclusion };
|
||||||
|
|
||||||
Mix mix;
|
WizMix mix;
|
||||||
WizardDialog(QWidget *parent = 0);
|
WizardDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -308,4 +308,19 @@ private:
|
||||||
QLabel *textLabel;
|
QLabel *textLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WizardPrinter:QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
WizardPrinter( WizMix * );
|
||||||
|
QString print();
|
||||||
|
private:
|
||||||
|
WizMix *mix;
|
||||||
|
QString inputName( Input );
|
||||||
|
QString vehicleName( Vehicle );
|
||||||
|
QString printChannel( Input, int, Input, int );
|
||||||
|
};
|
||||||
#endif // WIZARDDIALOG_H
|
#endif // WIZARDDIALOG_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue