1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +03:00

Merge pull request #703 from opentx/bsongis/standalone_simu

Bsongis/standalone simu
This commit is contained in:
Kjell Kernen 2014-02-20 21:18:14 +01:00
commit de3e0e802f
55 changed files with 4189 additions and 9554 deletions

View file

@ -1,5 +1,6 @@
#include <QtGui>
#include "helpers.h"
#include "simulatordialog.h"
QString getPhaseName(int val, char * phasename)
{
@ -635,24 +636,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
b->setMaxVisibleItems(10);
}
float ValToTim(int value)
{
return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0);
}
int TimToVal(float value)
{
int temp;
if (value>60) {
temp=136+round((value-60));
} else if (value>2) {
temp=20+round((value-2.0)*2.0);
} else {
temp=round(value*10.0);
}
return (temp-129);
}
void populateCSWCB(QComboBox *b, int value)
{
int order[] = {
@ -694,27 +677,6 @@ void populateCSWCB(QComboBox *b, int value)
b->setMaxVisibleItems(10);
}
QString getSignedStr(int value)
{
return value > 0 ? QString("+%1").arg(value) : QString("%1").arg(value);
}
QString getGVarString(int16_t val, bool sign)
{
if (val >= -10000 && val <= 10000) {
if (sign)
return QString("%1%").arg(getSignedStr(val));
else
return QString("%1%").arg(val);
}
else {
if (val<0)
return QObject::tr("-GV%1").arg(-val-10000);
else
return QObject::tr("GV%1").arg(val-10000);
}
}
QString image2qstring(QImage image)
{
if (image.isNull())
@ -945,3 +907,34 @@ CompanionIcon::CompanionIcon(QString baseimage)
addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48));
}
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
{
if (GetEepromInterface()->getSimulator()) {
RadioData * simuData = new RadioData(radioData);
unsigned int flags = 0;
if (modelIdx >= 0) {
flags |= SIMULATOR_FLAGS_NOTX;
simuData->generalSettings.currModel = modelIdx;
}
if (radioData.generalSettings.stickMode & 1) {
flags |= SIMULATOR_FLAGS_STICK_MODE_LEFT;
}
BoardEnum board = GetEepromInterface()->getBoard();
SimulatorDialog * sd;
if (IS_TARANIS(board))
sd = new SimulatorDialogTaranis(parent, flags);
else
sd = new SimulatorDialog9X(parent, flags);
QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0);
GetEepromInterface()->save((uint8_t *)eeprom.data(), *simuData, GetEepromInterface()->getCapability(SimulatorVariant));
delete simuData;
sd->start(eeprom);
sd->exec();
delete sd;
}
else {
QMessageBox::warning(NULL,
QObject::tr("Warning"),
QObject::tr("Simulator for this firmware is not yet available"));
}
}