mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
[Companion] Another simplification
This commit is contained in:
parent
d82ec0fe9c
commit
0ca0785912
17 changed files with 126 additions and 124 deletions
|
@ -1415,11 +1415,13 @@ class EEPROMInterface
|
|||
|
||||
virtual unsigned long loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index) = 0;
|
||||
|
||||
virtual bool loadModelFromByteArray(ModelData & model, const QByteArray & data) { return false; }
|
||||
virtual bool loadRadioSettings(GeneralSettings & model, const QByteArray & data) { return false; }
|
||||
|
||||
virtual bool loadModel(ModelData & model, const QByteArray & data) { return false; }
|
||||
|
||||
virtual unsigned long loadxml(RadioData &radioData, QDomDocument &doc) = 0;
|
||||
|
||||
virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0) = 0;
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint8_t version=0, uint32_t variant=0) = 0;
|
||||
|
||||
virtual int getSize(const ModelData &) = 0;
|
||||
|
||||
|
@ -1621,9 +1623,9 @@ class Firmware {
|
|||
|
||||
virtual void addOptions(Option options[]);
|
||||
|
||||
inline int saveEEPROM(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, unsigned int version=0)
|
||||
inline int saveEEPROM(uint8_t * eeprom, RadioData & radioData, uint8_t version=0, uint32_t variant=0)
|
||||
{
|
||||
return eepromInterface->save(eeprom, radioData, variant, version);
|
||||
return eepromInterface->save(eeprom, radioData, version, variant);
|
||||
}
|
||||
|
||||
virtual QString getStampUrl() = 0;
|
||||
|
|
|
@ -100,15 +100,15 @@ unsigned long Er9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
|
|||
|
||||
Er9xGeneral er9xGeneral;
|
||||
memset(&er9xGeneral,0,sizeof(er9xGeneral));
|
||||
if(!loadGeneralDataXML(&doc, &er9xGeneral)) {
|
||||
if (!loadRadioSettingsDataXML(&doc, &er9xGeneral)) {
|
||||
errors.set(UNKNOWN_ERROR);
|
||||
return errors.to_ulong();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
radioData.generalSettings=er9xGeneral;
|
||||
std::cout << "version " << (unsigned int)er9xGeneral.myVers << " ";
|
||||
}
|
||||
for(int i=0; i<getMaxModels(); i++)
|
||||
{
|
||||
for (int i=0; i<getMaxModels(); i++) {
|
||||
Er9xModelData er9xModel;
|
||||
memset(&er9xModel,0,sizeof(er9xModel));
|
||||
if(loadModelDataXML(&doc, &er9xModel, i)) {
|
||||
|
@ -200,14 +200,6 @@ unsigned long Er9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, i
|
|||
return errors.to_ulong();
|
||||
}
|
||||
|
||||
int Er9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
|
||||
{
|
||||
std::cout << "NO!\n";
|
||||
// TODO an error
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Er9xInterface::getSize(const ModelData &model)
|
||||
{
|
||||
return 0;
|
||||
|
@ -279,7 +271,7 @@ QDomElement Er9xInterface::getModelDataXML(QDomDocument * qdoc, Er9xModelData *
|
|||
return md;
|
||||
}
|
||||
|
||||
bool Er9xInterface::loadGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen)
|
||||
bool Er9xInterface::loadRadioSettingsDataXML(QDomDocument * qdoc, Er9xGeneral * tgen)
|
||||
{
|
||||
//look for "GENERAL_DATA" tag
|
||||
QDomElement gde = qdoc->elementsByTagName("GENERAL_DATA").at(0).toElement();
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
|
||||
#ifndef _ER9XINTERFACE_H_
|
||||
#define _ER9XINTERFACE_H_
|
||||
|
||||
#include <QtXml>
|
||||
#include "eeprominterface.h"
|
||||
#include "er9xeeprom.h"
|
||||
|
||||
class RleFile;
|
||||
|
||||
class Er9xInterface : public EEPROMInterface
|
||||
|
@ -45,7 +47,10 @@ class Er9xInterface : public EEPROMInterface
|
|||
|
||||
virtual unsigned long loadxml(RadioData &radioData, QDomDocument &doc);
|
||||
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint32_t variant=0, uint8_t version=0);
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint8_t version=0, uint32_t variant=0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int getSize(const ModelData &);
|
||||
|
||||
|
@ -68,7 +73,7 @@ class Er9xInterface : public EEPROMInterface
|
|||
|
||||
QDomElement getModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum, int mdver); //parse out data to XML format
|
||||
|
||||
bool loadGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen); // get data from XML
|
||||
bool loadRadioSettingsDataXML(QDomDocument * qdoc, Er9xGeneral * tgen); // get data from XML
|
||||
|
||||
bool loadModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum = -1); // get data from XML
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ unsigned long Ersky9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
|
|||
|
||||
Ersky9xGeneral ersky9xGeneral;
|
||||
memset(&ersky9xGeneral,0,sizeof(ersky9xGeneral));
|
||||
if(!loadGeneralDataXML(&doc, &ersky9xGeneral)) {
|
||||
if(!loadRadioSettingsDataXML(&doc, &ersky9xGeneral)) {
|
||||
errors.set(UNKNOWN_ERROR);
|
||||
return errors.to_ulong();
|
||||
}
|
||||
|
@ -244,14 +244,6 @@ unsigned long Ersky9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom
|
|||
return errors.to_ulong();
|
||||
}
|
||||
|
||||
int Ersky9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
|
||||
{
|
||||
std::cout << "NO!\n";
|
||||
// TODO an error
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Ersky9xInterface::getSize(const ModelData & model)
|
||||
{
|
||||
return 0;
|
||||
|
@ -323,7 +315,7 @@ QDomElement Ersky9xInterface::getModelDataXML(QDomDocument * qdoc, Ersky9xModelD
|
|||
return md;
|
||||
}
|
||||
|
||||
bool Ersky9xInterface::loadGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
|
||||
bool Ersky9xInterface::loadRadioSettingsDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
|
||||
{
|
||||
//look for "GENERAL_DATA" tag
|
||||
QDomElement gde = qdoc->elementsByTagName("GENERAL_DATA").at(0).toElement();
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
|
||||
#ifndef _ERSKY9XINTERFACE_H_
|
||||
#define _ERSKY9XINTERFACE_H_
|
||||
|
||||
#include <QtXml>
|
||||
#include "eeprominterface.h"
|
||||
#include "ersky9xeeprom.h"
|
||||
|
||||
class RleFile;
|
||||
|
||||
class Ersky9xInterface : public EEPROMInterface
|
||||
|
@ -45,7 +47,10 @@ class Ersky9xInterface : public EEPROMInterface
|
|||
|
||||
virtual unsigned long loadxml(RadioData &radioData, QDomDocument &doc);
|
||||
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint32_t variant=0, uint8_t version=0);
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint8_t version=0, uint32_t variant=0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int getSize(const ModelData &);
|
||||
|
||||
|
@ -68,7 +73,7 @@ class Ersky9xInterface : public EEPROMInterface
|
|||
|
||||
QDomElement getModelDataXML(QDomDocument * qdoc, Ersky9xModelData_v11 * tmod, int modelNum, int mdver); //parse out data to XML format
|
||||
|
||||
bool loadGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen); // get data from XML
|
||||
bool loadRadioSettingsDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen); // get data from XML
|
||||
|
||||
template <class T>
|
||||
bool loadModelDataXML(QDomDocument * qdoc, ModelData * model, int modelNum, int stickMode); // get data from XML
|
||||
|
|
|
@ -108,10 +108,9 @@ const int OpenTxEepromInterface::getEEpromSize()
|
|||
case BOARD_TARANIS_X9DP:
|
||||
case BOARD_TARANIS_X9E:
|
||||
case BOARD_FLAMENCO:
|
||||
case BOARD_HORUS:
|
||||
return EESIZE_TARANIS;
|
||||
default:
|
||||
return 0;
|
||||
return 0; // unlimited
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,10 +126,9 @@ const int OpenTxEepromInterface::getMaxModels()
|
|||
return 16;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData & model, uint8_t *data, unsigned int version, unsigned int variant)
|
||||
bool OpenTxEepromInterface::loadModel(uint8_t version, ModelData & model, uint8_t * data, int index, unsigned int variant)
|
||||
{
|
||||
T open9xModel(model, board, version, variant);
|
||||
OpenTxModelData modelDataFactory(model, board, version, variant);
|
||||
|
||||
if (!data) {
|
||||
// load from EEPROM
|
||||
|
@ -138,8 +136,8 @@ bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData & mod
|
|||
efile->openRd(FILE_MODEL(index));
|
||||
int numbytes = efile->readRlc2((uint8_t *)eepromData.data(), eepromData.size());
|
||||
if (numbytes) {
|
||||
open9xModel.Import(eepromData);
|
||||
// open9xModel.Dump();
|
||||
modelDataFactory.Import(eepromData);
|
||||
// modelDataFactory.Dump();
|
||||
model.used = true;
|
||||
}
|
||||
else {
|
||||
|
@ -155,8 +153,8 @@ bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData & mod
|
|||
else
|
||||
importRlc(modelData, backupData);
|
||||
if (modelData.size()) {
|
||||
open9xModel.Import(modelData);
|
||||
// open9xModel.Dump();
|
||||
modelDataFactory.Import(modelData);
|
||||
// modelDataFactory.Dump();
|
||||
model.used = true;
|
||||
}
|
||||
else {
|
||||
|
@ -167,7 +165,17 @@ bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData & mod
|
|||
return true;
|
||||
}
|
||||
|
||||
bool OpenTxEepromInterface::loadModelFromByteArray(ModelData & model, const QByteArray & data)
|
||||
bool OpenTxEepromInterface::loadRadioSettings(GeneralSettings & settings, const QByteArray & data)
|
||||
{
|
||||
// TODO check the 8 first bytes (fourcc + version + 'M' + size)
|
||||
QByteArray raw = data.right(data.size() - 8);
|
||||
OpenTxGeneralData importer(settings, board, 218, 0); // TODO board and 218 should be the version taken from the header
|
||||
importer.Import(raw);
|
||||
importer.Dump(); // Dumps the structure so that it's easy to check with firmware datastructs.h
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenTxEepromInterface::loadModel(ModelData & model, const QByteArray & data)
|
||||
{
|
||||
// TODO check the 8 first bytes (fourcc + version + 'M' + size)
|
||||
QByteArray raw = data.right(data.size() - 8);
|
||||
|
@ -178,16 +186,10 @@ bool OpenTxEepromInterface::loadModelFromByteArray(ModelData & model, const QByt
|
|||
return true;
|
||||
}
|
||||
|
||||
bool OpenTxEepromInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode)
|
||||
{
|
||||
return loadModelVariant<OpenTxModelData>(index, model, data, version, variant);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool OpenTxEepromInterface::loadGeneral(GeneralSettings &settings, unsigned int version)
|
||||
bool OpenTxEepromInterface::loadRadioSettings(GeneralSettings & settings, uint8_t version)
|
||||
{
|
||||
QByteArray eepromData(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct
|
||||
T open9xSettings(settings, board, version);
|
||||
OpenTxGeneralData open9xSettings(settings, board, version);
|
||||
efile->openRd(FILE_GENERAL);
|
||||
int sz = efile->readRlc2((uint8_t *)eepromData.data(), eepromData.size());
|
||||
if (sz) {
|
||||
|
@ -200,7 +202,7 @@ bool OpenTxEepromInterface::loadGeneral(GeneralSettings &settings, unsigned int
|
|||
}
|
||||
|
||||
template <class T>
|
||||
bool OpenTxEepromInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant)
|
||||
bool OpenTxEepromInterface::saveRadioSettings(GeneralSettings & settings, BoardEnum board, uint8_t version, uint32_t variant)
|
||||
{
|
||||
T open9xSettings(settings, board, version, variant);
|
||||
// open9xSettings.Dump();
|
||||
|
@ -211,7 +213,7 @@ bool OpenTxEepromInterface::saveGeneral(GeneralSettings &settings, BoardEnum boa
|
|||
}
|
||||
|
||||
template <class T>
|
||||
bool OpenTxEepromInterface::saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant)
|
||||
bool OpenTxEepromInterface::saveModel(unsigned int index, ModelData & model, uint8_t version, uint32_t variant)
|
||||
{
|
||||
T open9xModel(model, board, version, variant);
|
||||
// open9xModel.Dump();
|
||||
|
@ -286,7 +288,7 @@ unsigned long OpenTxEepromInterface::load(RadioData & radioData, const uint8_t *
|
|||
return errors.to_ulong();
|
||||
}
|
||||
|
||||
if (!loadGeneral<OpenTxGeneralData>(radioData.generalSettings, version)) {
|
||||
if (!loadRadioSettings(radioData.generalSettings, version)) {
|
||||
std::cout << " ko\n";
|
||||
errors.set(UNKNOWN_ERROR);
|
||||
return errors.to_ulong();
|
||||
|
@ -294,7 +296,7 @@ unsigned long OpenTxEepromInterface::load(RadioData & radioData, const uint8_t *
|
|||
|
||||
std::cout << " variant " << radioData.generalSettings.variant;
|
||||
for (int i=0; i<getMaxModels(); i++) {
|
||||
if (!loadModel(version, radioData.models[i], NULL, i, radioData.generalSettings.variant, radioData.generalSettings.stickMode+1)) {
|
||||
if (!loadModel(version, radioData.models[i], NULL, i, radioData.generalSettings.variant)) {
|
||||
std::cout << " ko\n";
|
||||
errors.set(UNKNOWN_ERROR);
|
||||
return errors.to_ulong();
|
||||
|
@ -305,11 +307,11 @@ unsigned long OpenTxEepromInterface::load(RadioData & radioData, const uint8_t *
|
|||
return errors.to_ulong();
|
||||
}
|
||||
|
||||
int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
|
||||
int OpenTxEepromInterface::save(uint8_t * eeprom, RadioData & radioData, uint8_t version, uint32_t variant)
|
||||
{
|
||||
EEPROMWarnings.clear();
|
||||
|
||||
if (!version) {
|
||||
if (version == 0) {
|
||||
switch (board) {
|
||||
case BOARD_X7D:
|
||||
case BOARD_TARANIS_X9D:
|
||||
|
@ -346,7 +348,7 @@ int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t
|
|||
variant |= TARANIS_X9E_VARIANT;
|
||||
}
|
||||
|
||||
int result = saveGeneral<OpenTxGeneralData>(radioData.generalSettings, board, version, variant);
|
||||
int result = saveRadioSettings<OpenTxGeneralData>(radioData.generalSettings, board, version, variant);
|
||||
if (!result) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,11 @@ class OpenTxEepromInterface : public EEPROMInterface
|
|||
|
||||
virtual unsigned long loadxml(RadioData & radioData, QDomDocument & doc);
|
||||
|
||||
virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0);
|
||||
virtual bool loadRadioSettings(GeneralSettings & model, const QByteArray & data);
|
||||
|
||||
virtual bool loadModel(ModelData & model, const QByteArray & data);
|
||||
|
||||
virtual int save(uint8_t * eeprom, RadioData & radioData, uint8_t version=0, uint32_t variant=0);
|
||||
|
||||
virtual int getSize(const ModelData &);
|
||||
|
||||
|
@ -57,24 +61,15 @@ class OpenTxEepromInterface : public EEPROMInterface
|
|||
|
||||
bool checkVariant(unsigned int version, unsigned int variant);
|
||||
|
||||
bool loadModelFromByteArray(ModelData & model, const QByteArray & data);
|
||||
bool loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant);
|
||||
|
||||
template <class T>
|
||||
bool loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode=0);
|
||||
bool saveModel(unsigned int index, ModelData & model, uint8_t version, uint32_t variant);
|
||||
|
||||
bool loadRadioSettings(GeneralSettings & settings, uint8_t version);
|
||||
|
||||
template <class T>
|
||||
bool loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant);
|
||||
|
||||
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, unsigned int version, unsigned int variant);
|
||||
|
||||
template <class T>
|
||||
bool loadGeneral(GeneralSettings &settings, unsigned int version);
|
||||
|
||||
template <class T>
|
||||
bool saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant);
|
||||
bool saveRadioSettings(GeneralSettings & settings, BoardEnum board, uint8_t version, uint32_t variant);
|
||||
|
||||
RleFile *efile;
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ void FlashEEpromDialog::on_burnButton_clicked()
|
|||
QString filename = generateProcessUniqueTempFileName("temp.bin");
|
||||
QFile file(filename);
|
||||
uint8_t *eeprom = (uint8_t*)malloc(GetEepromInterface()->getEEpromSize());
|
||||
int eeprom_size = GetEepromInterface()->save(eeprom, *radioData, GetCurrentFirmware()->getVariantNumber());
|
||||
int eeprom_size = GetEepromInterface()->save(eeprom, *radioData, 0, GetCurrentFirmware()->getVariantNumber());
|
||||
if (!eeprom_size) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Cannot write file %1:\n%2.").arg(filename).arg(file.errorString()));
|
||||
return;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "simulatordialog.h"
|
||||
#include "simulatorinterface.h"
|
||||
#include "firmwareinterface.h"
|
||||
#include "storage/storage_sdcard.h"
|
||||
|
||||
Stopwatch gStopwatch("global");
|
||||
|
||||
|
@ -805,8 +806,9 @@ CompanionIcon::CompanionIcon(const QString &baseimage)
|
|||
|
||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||
{
|
||||
SimulatorInterface * si = GetCurrentFirmwareSimulator();
|
||||
if (si) {
|
||||
Firmware * firmware = GetCurrentFirmware();
|
||||
SimulatorInterface * simulator = GetCurrentFirmwareSimulator();
|
||||
if (simulator) {
|
||||
RadioData * simuData = new RadioData(radioData);
|
||||
unsigned int flags = 0;
|
||||
if (modelIdx >= 0) {
|
||||
|
@ -817,12 +819,19 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
|||
flags |= SIMULATOR_FLAGS_STICK_MODE_LEFT;
|
||||
}
|
||||
BoardEnum board = GetCurrentFirmware()->getBoard();
|
||||
SimulatorDialog * sd;
|
||||
SimulatorDialog * dialog;
|
||||
if (board == BOARD_HORUS) {
|
||||
sd = new SimulatorDialogHorus(parent, si, flags);
|
||||
dialog = new SimulatorDialogHorus(parent, simulator, flags);
|
||||
StorageSdcard storage;
|
||||
QString sdPath = g.profile[g.id()].sdPath();
|
||||
storage.write(sdPath);
|
||||
dialog->start(NULL);
|
||||
}
|
||||
else if (board == BOARD_FLAMENCO) {
|
||||
sd = new SimulatorDialogFlamenco(parent, si, flags);
|
||||
dialog = new SimulatorDialogFlamenco(parent, simulator, flags);
|
||||
QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0);
|
||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
|
||||
dialog->start(eeprom);
|
||||
}
|
||||
else if (board == BOARD_TARANIS_X9D || board == BOARD_TARANIS_X9DP || board == BOARD_TARANIS_X9E) {
|
||||
for (int i=0; i<GetCurrentFirmware()->getCapability(Pots); i++) {
|
||||
|
@ -833,17 +842,21 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
|||
}
|
||||
}
|
||||
}
|
||||
sd = new SimulatorDialogTaranis(parent, si, flags);
|
||||
dialog = new SimulatorDialogTaranis(parent, simulator, flags);
|
||||
QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0);
|
||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
|
||||
dialog->start(eeprom);
|
||||
}
|
||||
else {
|
||||
sd = new SimulatorDialog9X(parent, si, flags);
|
||||
}
|
||||
dialog = new SimulatorDialog9X(parent, simulator, flags);
|
||||
QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0);
|
||||
GetEepromInterface()->save((uint8_t *)eeprom.data(), *simuData, GetCurrentFirmware()->getCapability(SimulatorVariant));
|
||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData, 0, firmware->getCapability(SimulatorVariant));
|
||||
dialog->start(eeprom);
|
||||
}
|
||||
|
||||
dialog->exec();
|
||||
delete dialog;
|
||||
delete simuData;
|
||||
sd->start(eeprom);
|
||||
sd->exec();
|
||||
delete sd;
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(NULL,
|
||||
|
|
|
@ -336,19 +336,24 @@ bool MdiChild::loadFile(const QString & fileName, bool resetCurrentFile)
|
|||
}
|
||||
|
||||
ui->modelsList->refreshList();
|
||||
if (resetCurrentFile) setCurrentFile(fileName);
|
||||
if (resetCurrentFile)
|
||||
setCurrentFile(fileName);
|
||||
|
||||
free(eeprom);
|
||||
return true;
|
||||
}
|
||||
else if (fileType == FILE_TYPE_OTX) { //read zip archive
|
||||
return loadOtxFile(fileName, resetCurrentFile);
|
||||
if (loadOtxFile(fileName)) {
|
||||
ui->modelsList->refreshList();
|
||||
if (resetCurrentFile)
|
||||
setCurrentFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MdiChild::loadOtxFile(const QString &fileName, bool resetCurrentFile)
|
||||
bool MdiChild::loadOtxFile(const QString & fileName)
|
||||
{
|
||||
// example of StorageSdcard usage
|
||||
|
||||
|
@ -375,16 +380,12 @@ bool MdiChild::loadOtxFile(const QString &fileName, bool resetCurrentFile)
|
|||
}
|
||||
#endif
|
||||
|
||||
for (QList<ModelFile>::iterator i = storage.models.begin(); i != storage.models.end(); ++i) {
|
||||
GetEepromInterface()->loadModelFromByteArray(radioData.models[0], i->data);
|
||||
int index = 0;
|
||||
for (QList<ModelFile>::iterator i = storage.models.begin(); i != storage.models.end(); ++i, ++index) {
|
||||
GetEepromInterface()->loadModel(radioData.models[index], i->data);
|
||||
}
|
||||
|
||||
ui->modelsList->refreshList();
|
||||
|
||||
// for test immediately save to another file
|
||||
// storage.write(fileName + "test.otx");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool MdiChild::save()
|
||||
|
@ -441,7 +442,7 @@ bool MdiChild::saveFile(const QString &fileName, bool setCurrent)
|
|||
int eeprom_size = 0;
|
||||
|
||||
if (fileType != FILE_TYPE_XML) {
|
||||
eeprom_size = GetEepromInterface()->save(eeprom, radioData, GetCurrentFirmware()->getVariantNumber(), 0/*last version*/);
|
||||
eeprom_size = GetEepromInterface()->save(eeprom, radioData, 0, GetCurrentFirmware()->getVariantNumber());
|
||||
if (!eeprom_size) {
|
||||
QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(myFile).arg(file.errorString()));
|
||||
return false;
|
||||
|
|
|
@ -51,7 +51,6 @@ class MdiChild : public QWidget
|
|||
bool hasSelection();
|
||||
QString userFriendlyCurrentFile();
|
||||
QString currentFile() { return curFile; }
|
||||
// void keyPressEvent(QKeyEvent *event);
|
||||
bool hasPasteData();
|
||||
void viableModelSelected(bool viable);
|
||||
void eepromInterfaceChanged();
|
||||
|
@ -89,9 +88,7 @@ class MdiChild : public QWidget
|
|||
bool maybeSave();
|
||||
void setCurrentFile(const QString & fileName);
|
||||
QString strippedName(const QString & fullFileName);
|
||||
void saveSelection();
|
||||
void restoreSelection();
|
||||
bool loadOtxFile(const QString &fileName, bool resetCurrentFile);
|
||||
bool loadOtxFile(const QString & fileName);
|
||||
|
||||
Ui::mdiChild * ui;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "firmwareinterface.h"
|
||||
#include "storage_eeprom.h"
|
||||
|
||||
|
||||
unsigned long LoadEeprom(RadioData & radioData, const uint8_t * eeprom, const int size)
|
||||
{
|
||||
std::bitset<NUM_ERRORS> errors;
|
||||
|
@ -91,7 +90,7 @@ bool convertEEprom(const QString & sourceEEprom, const QString & destinationEEpr
|
|||
if (!firmware.isValid())
|
||||
return false;
|
||||
|
||||
unsigned int version = firmware.getEEpromVersion();
|
||||
uint8_t version = firmware.getEEpromVersion();
|
||||
unsigned int variant = firmware.getEEpromVariant();
|
||||
|
||||
QFile sourceFile(sourceEEprom);
|
||||
|
@ -108,8 +107,7 @@ bool convertEEprom(const QString & sourceEEprom, const QString & destinationEEpr
|
|||
|
||||
QSharedPointer<RadioData> radioData = QSharedPointer<RadioData>(new RadioData());
|
||||
std::bitset<NUM_ERRORS> errors((unsigned long long)LoadEeprom(*radioData, (uint8_t *)eeprom.data(), eeprom_size));
|
||||
if (!errors.test(ALL_OK)
|
||||
|| !currentFirmware->saveEEPROM((uint8_t *)eeprom.data(), *radioData, variant, version)) {
|
||||
if (!errors.test(ALL_OK) || !currentFirmware->saveEEPROM((uint8_t *)eeprom.data(), *radioData, version, variant)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ bool XmlInterface::loadxml(RadioData &radioData, QDomDocument &doc)
|
|||
return false;
|
||||
}
|
||||
|
||||
void saveGeneralSettings(GeneralSettings & settings, global_settings & gs)
|
||||
void saveRadioSettings(GeneralSettings & settings, global_settings & gs)
|
||||
{
|
||||
Calibration rudderCalib(settings.calibMid[0], settings.calibSpanNeg[0], settings.calibSpanPos[0]);
|
||||
Calibration throttleCalib(settings.calibMid[1], settings.calibSpanNeg[1], settings.calibSpanPos[1]);
|
||||
|
@ -189,7 +189,7 @@ bool XmlInterface::save(RadioData &radioData)
|
|||
|
||||
// the general settings
|
||||
global_settings gs;
|
||||
saveGeneralSettings(settings, gs);
|
||||
saveRadioSettings(settings, gs);
|
||||
r.global_settings(gs);
|
||||
|
||||
// the models
|
||||
|
|
|
@ -218,7 +218,7 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
|||
|
||||
// For conversions
|
||||
#if defined(CPUARM)
|
||||
void loadGeneralSettings();
|
||||
void loadRadioSettingsSettings();
|
||||
void loadModel(int index, bool alarms=true);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -136,11 +136,11 @@ const char * loadModel(const char * filename, bool alarms)
|
|||
return error;
|
||||
}
|
||||
|
||||
const char * loadGeneralSettings()
|
||||
const char * loadRadioSettingsSettings()
|
||||
{
|
||||
const char * error = loadFile(RADIO_SETTINGS_PATH, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral));
|
||||
if (error) {
|
||||
TRACE("loadGeneralSettings error=%s", error);
|
||||
TRACE("loadRadioSettingsSettings error=%s", error);
|
||||
}
|
||||
// TODO this is temporary, we only have one model for now
|
||||
return error;
|
||||
|
@ -176,7 +176,7 @@ void storageReadAll()
|
|||
{
|
||||
TRACE("storageReadAll");
|
||||
|
||||
if (loadGeneralSettings() != NULL) {
|
||||
if (loadRadioSettingsSettings() != NULL) {
|
||||
storageEraseAll(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue