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

[Simulator] Dyanamic Simulator virtual hardware generation and many other improvements (#4260)

* Move simulator widgets to subfolder (no code changes).

* [Simulator] Major Simulator re-structuring to reduce code redundancies and allow for fully dynamic simulated hardware setup:
    SimulatorDialog is no longer sub-classed by individual radio UIs, instead a new class is added which handles just the "skin," LCD, and navigation controls (also makes setting up new models much quicker);
    All radio switches/knobs/sliders are populated dynamically based on loaded hardware configuration data (eeprom/bin), including control types and names (in case of no hardware config data, reasonable "factory defaults" are loaded);
    Starting Horus sim with alternate path for RADIO and MODEL data folders is now supported (.otx file is WIP);
    6-way switch now works properly and various other inconsistencies addressed (eg. some Horus analogs were backwards).

* Add missing OpenTX headers to new files.

* [Simulator] Fix loading of Horus hardware settings from Companion simulation.

* Update Travis CI build environment to Qt 5.7.

* [Simulator] Fix 9X missing colored side LCD images, an #include fix, and some cleanup.

* [TravisCI] Set up for parallel Travis builds and use Qt5.7 (#4263)

* Fix starting Simulator with non-existing file/folder structure (now properly creates new ones as needed, including Horus directories with default radio/model);  Temporarily remove option for using .otx file with Horus (until that feature is added).

* Load correct simulator skin for X7 when launching from Companion.

* X7 hardware defaults changed to match production hardware

* Fix minor compiler warning in mdichild.cpp, and some cleanup in eeprominterface.cpp.

* [Simulator] Centralize radio UI flavor determination.

* [Simulator] Updates:
    Add X7 UI flavor;
    Centralize LCD settings;
    Simplify drawing curved UI widgets;
    LCD color can be changed for any 1/4-bit display radio;
    Slight change on default LCD "off" color;
    Refactor LcdWidget to not use globals.

* [Companion] X7 EEPROM import fix

+ cosmetics
+ compilation error fixed on Manjaro

* [Companion] 9XR-PRO EEPROM import fix

+ cosmetics
+ compilation error fixed on Manjaro

* Navigation fix
French translations

* [X7] Main view cosmetics

* Fix switch/ana custom name import

* [Simulator] Add white border above/below X7 bezel, and use white-colored padding on sides; Adjust X7 default LCD color.

* Does this work? (#4269)

Read an Horus SD card produces a temporary .otx file now

* Bsongis/companion warning before automatic conversions (#4271)

* Does this work?

* Warning before automatic conversions

* Force different file name after conversion (#4272)

* Force different file name after conversion

* More detailed instructions

* [Companion] Files automatically named during XXX => Horus conversions
This commit is contained in:
Max Paperno 2017-01-24 01:54:12 -05:00 committed by Bertrand Songis
parent b3f4870da7
commit 17a03e6c18
43 changed files with 3564 additions and 5937 deletions

View file

@ -202,7 +202,7 @@ void GVarGroup::valuesChanged()
weight = round(dsb->value()/step);
if (panel)
emit panel->modified();
}
}
@ -813,8 +813,6 @@ CompanionIcon::CompanionIcon(const QString &baseimage)
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
{
QString settingsPath;
Firmware * firmware = getCurrentFirmware();
SimulatorInterface * simulator = getCurrentSimulator();
if (simulator) {
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
@ -824,60 +822,31 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
#endif
Firmware * firmware = getCurrentFirmware();
RadioData * simuData = new RadioData(radioData);
BoardEnum board = getCurrentBoard();
QByteArray eeprom = QByteArray();
QString sdPath = g.profile[g.id()].sdPath();
QString settingsPath = "";
unsigned int flags = 0;
if (modelIdx >= 0) {
flags |= SIMULATOR_FLAGS_NOTX;
simuData->setCurrentModel(modelIdx);
}
if (radioData.generalSettings.stickMode & 1) {
flags |= SIMULATOR_FLAGS_STICK_MODE_LEFT;
}
BoardEnum board = getCurrentBoard();
SimulatorDialog * dialog;
if (board == BOARD_HORUS) {
dialog = new SimulatorDialogHorus(parent, simulator, flags);
if (IS_HORUS(board)) {
QTemporaryDir tmpDir(QDir::tempPath() + "/otx-XXXXXX");
settingsPath = tmpDir.path();
tmpDir.setAutoRemove(false);
SdcardFormat sdcard(settingsPath);
sdcard.write(*simuData);
qDebug() << "Starting Horus simulation with SD path" << g.profile[g.id()].sdPath() << "and models/settings path" << settingsPath;
simulator->setSdPath(g.profile[g.id()].sdPath(), settingsPath);
dialog->start(NULL);
}
else if (board == BOARD_FLAMENCO) {
dialog = new SimulatorDialogFlamenco(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData);
simulator->setSdPath(g.profile[g.id()].sdPath(), "");
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++) {
if (radioData.generalSettings.isPotAvailable(i)) {
flags |= (SIMULATOR_FLAGS_S1 << i);
if (radioData.generalSettings.potConfig[1] == GeneralSettings::POT_MULTIPOS_SWITCH ) {
flags |= (SIMULATOR_FLAGS_S1_MULTI << i);
}
}
}
dialog = new SimulatorDialogTaranis(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData);
qDebug() << "Starting Taranis simulation with SD path" << g.profile[g.id()].sdPath();
simulator->setSdPath(g.profile[g.id()].sdPath(), "");
dialog->start(eeprom);
}
else {
dialog = new SimulatorDialog9X(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData, 0, firmware->getCapability(SimulatorVariant));
simulator->setSdPath(g.profile[g.id()].sdPath(), ""); // does 9X need SD card path? I think not.
dialog->start(eeprom);
}
qDebug() << "Starting" << firmware->getName() << "simulation with SD path" << sdPath << "and models/settings path" << settingsPath;
SimulatorDialog * dialog = new SimulatorDialog(parent, simulator, flags);
dialog->setPaths(sdPath, settingsPath);
dialog->setRadioData(simuData);
dialog->start();
dialog->exec();
dialog->deleteLater();
if (!settingsPath.isEmpty()) {