mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-26 01:35:16 +03:00
This commit is contained in:
parent
99b9de271c
commit
979de6bfa2
2 changed files with 18 additions and 3 deletions
|
@ -813,6 +813,7 @@ CompanionIcon::CompanionIcon(const QString &baseimage)
|
||||||
|
|
||||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
{
|
{
|
||||||
|
QString settingsPath;
|
||||||
Firmware * firmware = GetCurrentFirmware();
|
Firmware * firmware = GetCurrentFirmware();
|
||||||
SimulatorInterface * simulator = GetCurrentFirmwareSimulator();
|
SimulatorInterface * simulator = GetCurrentFirmwareSimulator();
|
||||||
if (simulator) {
|
if (simulator) {
|
||||||
|
@ -837,14 +838,20 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
|
|
||||||
if (board == BOARD_HORUS && HORUS_READY_FOR_RELEASE()) {
|
if (board == BOARD_HORUS && HORUS_READY_FOR_RELEASE()) {
|
||||||
dialog = new SimulatorDialogHorus(parent, simulator, flags);
|
dialog = new SimulatorDialogHorus(parent, simulator, flags);
|
||||||
SdcardFormat sdcard(g.profile[g.id()].sdPath());
|
QTemporaryDir tmpDir(QDir::tempPath() + "/otx-XXXXXX");
|
||||||
|
settingsPath = tmpDir.path();
|
||||||
|
tmpDir.setAutoRemove(false);
|
||||||
|
SdcardFormat sdcard(settingsPath);
|
||||||
sdcard.write(*simuData);
|
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);
|
dialog->start(NULL);
|
||||||
}
|
}
|
||||||
else if (board == BOARD_FLAMENCO) {
|
else if (board == BOARD_FLAMENCO) {
|
||||||
dialog = new SimulatorDialogFlamenco(parent, simulator, flags);
|
dialog = new SimulatorDialogFlamenco(parent, simulator, flags);
|
||||||
QByteArray eeprom(getEEpromSize(board), 0);
|
QByteArray eeprom(getEEpromSize(board), 0);
|
||||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
|
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
|
||||||
|
simulator->setSdPath(g.profile[g.id()].sdPath(), "");
|
||||||
dialog->start(eeprom);
|
dialog->start(eeprom);
|
||||||
}
|
}
|
||||||
else if (board == BOARD_TARANIS_X9D || board == BOARD_TARANIS_X9DP || board == BOARD_TARANIS_X9E) {
|
else if (board == BOARD_TARANIS_X9D || board == BOARD_TARANIS_X9DP || board == BOARD_TARANIS_X9E) {
|
||||||
|
@ -859,17 +866,26 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
dialog = new SimulatorDialogTaranis(parent, simulator, flags);
|
dialog = new SimulatorDialogTaranis(parent, simulator, flags);
|
||||||
QByteArray eeprom(getEEpromSize(board), 0);
|
QByteArray eeprom(getEEpromSize(board), 0);
|
||||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
|
firmware->saveEEPROM((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);
|
dialog->start(eeprom);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dialog = new SimulatorDialog9X(parent, simulator, flags);
|
dialog = new SimulatorDialog9X(parent, simulator, flags);
|
||||||
QByteArray eeprom(getEEpromSize(board), 0);
|
QByteArray eeprom(getEEpromSize(board), 0);
|
||||||
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData, 0, firmware->getCapability(SimulatorVariant));
|
firmware->saveEEPROM((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);
|
dialog->start(eeprom);
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
|
if (!settingsPath.isEmpty()) {
|
||||||
|
// TODO either delete tmp directory and its contents OR use it to get back data from the simulation
|
||||||
|
qDebug() << "Simulation finished, deleting temporary settings directory" << settingsPath;
|
||||||
|
QDir tmp(settingsPath);
|
||||||
|
tmp.removeRecursively();
|
||||||
|
}
|
||||||
delete simuData;
|
delete simuData;
|
||||||
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
|
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
|
|
@ -78,7 +78,7 @@ SimulatorDialog::~SimulatorDialog()
|
||||||
delete simulator;
|
delete simulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorDialog::closeEvent (QCloseEvent *)
|
void SimulatorDialog::closeEvent(QCloseEvent *)
|
||||||
{
|
{
|
||||||
simulator->stop();
|
simulator->stop();
|
||||||
timer->stop();
|
timer->stop();
|
||||||
|
@ -596,7 +596,6 @@ void SimulatorDialog::startCommon()
|
||||||
lastPhase = -1;
|
lastPhase = -1;
|
||||||
numGvars = GetCurrentFirmware()->getCapability(Gvars);
|
numGvars = GetCurrentFirmware()->getCapability(Gvars);
|
||||||
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
|
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
|
||||||
simulator->setSdPath(g.profile[radioProfileId].sdPath());
|
|
||||||
simulator->setVolumeGain(g.profile[radioProfileId].volumeGain());
|
simulator->setVolumeGain(g.profile[radioProfileId].volumeGain());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue