Directories FatFS / CoOS / STM32 libs moved to thirdparty
This commit is contained in:
@@ -3,6 +3,7 @@ set(simulation_SRCS
|
||||
telemetrysimu.cpp
|
||||
trainersimu.cpp
|
||||
debugoutput.cpp
|
||||
simulatorinterface.cpp
|
||||
)
|
||||
|
||||
set(simulation_UIS
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
int SimulatorDialog::screenshotIdx = 0;
|
||||
SimulatorDialog * traceCallbackInstance = 0;
|
||||
|
||||
void traceCb(const char * text) {
|
||||
void traceCb(const char * text)
|
||||
{
|
||||
// divert C callback into simulator instance
|
||||
if (traceCallbackInstance) {
|
||||
traceCallbackInstance->traceCallback(text);
|
||||
traceCallbackInstance->traceCallback(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +47,13 @@ void SimulatorDialog::updateDebugOutput()
|
||||
traceMutex.unlock();
|
||||
}
|
||||
|
||||
SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
||||
SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags):
|
||||
QDialog(parent),
|
||||
flags(flags),
|
||||
dialP_4(NULL),
|
||||
timer(NULL),
|
||||
lightOn(false),
|
||||
simulator(NULL),
|
||||
simulator(simulator),
|
||||
lastPhase(-1),
|
||||
beepVal(0),
|
||||
TelemetrySimu(0),
|
||||
@@ -72,8 +73,8 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
||||
|
||||
uint32_t SimulatorDialog9X::switchstatus = 0;
|
||||
|
||||
SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
|
||||
SimulatorDialog(parent, flags),
|
||||
SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags):
|
||||
SimulatorDialog(parent, simulator, flags),
|
||||
ui(new Ui::SimulatorDialog9X),
|
||||
beepShow(0)
|
||||
{
|
||||
@@ -149,8 +150,8 @@ SimulatorDialog9X::~SimulatorDialog9X()
|
||||
|
||||
uint32_t SimulatorDialogTaranis::switchstatus = 0;
|
||||
|
||||
SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int flags):
|
||||
SimulatorDialog(parent, flags),
|
||||
SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags):
|
||||
SimulatorDialog(parent, simulator, flags),
|
||||
ui(new Ui::SimulatorDialogTaranis)
|
||||
{
|
||||
lcdWidth = 212;
|
||||
@@ -435,7 +436,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||
windowName = tr("Simulating Radio (%1)").arg(GetCurrentFirmware()->getName());
|
||||
setWindowTitle(windowName);
|
||||
|
||||
simulator = GetCurrentFirmware()->getSimulator();
|
||||
simulator->setSdPath(g.profile[g.id()].sdPath());
|
||||
lcd->setData(simulator->getLcd(), lcdWidth, 64, lcdDepth);
|
||||
|
||||
if (flags & SIMULATOR_FLAGS_STICK_MODE_LEFT) {
|
||||
@@ -449,7 +450,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||
|
||||
setTrims();
|
||||
|
||||
int outputs = std::min(32,GetCurrentFirmware()->getCapability(Outputs));
|
||||
int outputs = std::min(32, GetCurrentFirmware()->getCapability(Outputs));
|
||||
if (outputs <= 16) {
|
||||
// hide second Outputs tab
|
||||
tabWidget->removeTab(tabWidget->indexOf(ui->outputs2));
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "modeledit/node.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "telemetrysimu.h"
|
||||
#include "trainersimu.h"
|
||||
#include "debugoutput.h"
|
||||
@@ -36,7 +35,7 @@ class SimulatorDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog(QWidget * parent = NULL, unsigned int flags=0);
|
||||
explicit SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog();
|
||||
|
||||
void start(const char * filename);
|
||||
@@ -87,9 +86,7 @@ class SimulatorDialog : public QDialog
|
||||
virtual void getValues() = 0;
|
||||
void setValues();
|
||||
void centerSticks();
|
||||
// void timerTick();
|
||||
|
||||
bool keyState(EnumKeys key);
|
||||
int getValue(qint8 i);
|
||||
bool getSwitch(int swtch, bool nc, qint8 level=0);
|
||||
void setTrims();
|
||||
@@ -153,7 +150,7 @@ class SimulatorDialog9X: public SimulatorDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog9X(QWidget * parent = NULL, unsigned int flags=0);
|
||||
explicit SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog9X();
|
||||
|
||||
protected:
|
||||
@@ -178,7 +175,7 @@ class SimulatorDialogTaranis: public SimulatorDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogTaranis(QWidget * parent = NULL, unsigned int flags=0);
|
||||
explicit SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogTaranis();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -58,7 +58,8 @@ if (inputs.rotenc) simuSetKey(KEY_ENTER, true);
|
||||
#ifdef GETVALUES_IMPORT
|
||||
#undef GETVALUES_IMPORT
|
||||
memset(outputs.chans, 0, sizeof(outputs.chans));
|
||||
memcpy(outputs.chans, g_chans512, sizeof(g_chans512));
|
||||
for (unsigned int i=0; i<DIM(g_chans512); i++)
|
||||
outputs.chans[i] = g_chans512[i];
|
||||
for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
|
||||
#if defined(BOLD_FONT)
|
||||
outputs.vsw[i] = getSwitch(SWSRC_SW1+i);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#include "simulatorinterface.h"
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QLibrary>
|
||||
#include <QMap>
|
||||
#include <QMessageBox>
|
||||
|
||||
QMap<QString, SimulatorFactory *> registered_simulators;
|
||||
|
||||
void registerSimulatorFactory(SimulatorFactory *factory)
|
||||
{
|
||||
qDebug() << "registering" << factory->name() << "simulator";
|
||||
registered_simulators[factory->name()] = factory;
|
||||
}
|
||||
|
||||
void registerSimulator(const QString &filename)
|
||||
{
|
||||
QLibrary lib(filename);
|
||||
typedef SimulatorFactory * (*RegisterSimulator)();
|
||||
RegisterSimulator registerSimulator = (RegisterSimulator)lib.resolve("registerSimu");
|
||||
if (registerSimulator) {
|
||||
SimulatorFactory *factory = registerSimulator();
|
||||
registerSimulatorFactory(factory);
|
||||
}
|
||||
else {
|
||||
qWarning() << "Library error" << filename << lib.errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void registerSimulators()
|
||||
{
|
||||
QDir dir(".");
|
||||
QStringList filters;
|
||||
#if !defined __GNUC__
|
||||
filters << "*-simulator.dll";
|
||||
#else
|
||||
filters << "*-simulator.so";
|
||||
#endif
|
||||
foreach(QString filename, dir.entryList(filters, QDir::Files)) {
|
||||
registerSimulator(filename);
|
||||
}
|
||||
}
|
||||
|
||||
SimulatorFactory *getSimulatorFactory(const QString &name)
|
||||
{
|
||||
QString simuName = name;
|
||||
while(1) {
|
||||
qDebug() << "searching" << simuName << "simulator";
|
||||
if (registered_simulators.contains(simuName)) {
|
||||
return registered_simulators[simuName];
|
||||
}
|
||||
else {
|
||||
int pos = simuName.lastIndexOf('-');
|
||||
if (pos <= 0)
|
||||
break;
|
||||
simuName = simuName.mid(0, pos);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,23 @@
|
||||
#ifndef simulator_interface_h
|
||||
#define simulator_interface_h
|
||||
|
||||
#include "eeprominterface.h"
|
||||
#include "constants.h"
|
||||
#include <inttypes.h>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QMap>
|
||||
#include <algorithm>
|
||||
|
||||
struct TxInputs {
|
||||
#if __GNUC__
|
||||
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
||||
#else
|
||||
#include "../targets/windows/winbuild.h"
|
||||
#endif
|
||||
|
||||
template<class t> t LIMIT(t mi, t x, t ma) { return std::min(std::max(mi, x), ma); }
|
||||
|
||||
struct TxInputs
|
||||
{
|
||||
int sticks[NUM_STICKS]; /* lh lv rv rh */
|
||||
int pots[C9X_NUM_POTS];
|
||||
int switches[C9X_NUM_SWITCHES];
|
||||
@@ -28,33 +42,34 @@ struct TxInputs {
|
||||
bool trims[8];
|
||||
};
|
||||
|
||||
class TxOutputs {
|
||||
class TxOutputs
|
||||
{
|
||||
public:
|
||||
TxOutputs() {
|
||||
memset(this, 0, sizeof(TxOutputs));
|
||||
}
|
||||
|
||||
int16_t chans[C9X_NUM_CHNOUT];
|
||||
TxOutputs() { memset(this, 0, sizeof(TxOutputs)); }
|
||||
int chans[C9X_NUM_CHNOUT];
|
||||
bool vsw[C9X_NUM_CSW];
|
||||
int16_t gvars[C9X_MAX_FLIGHT_MODES][C9X_MAX_GVARS];
|
||||
int gvars[C9X_MAX_FLIGHT_MODES][C9X_MAX_GVARS];
|
||||
unsigned int beep;
|
||||
// uint8_t phase;
|
||||
};
|
||||
|
||||
struct Trims {
|
||||
int16_t values[NUM_STICKS]; /* lh lv rv rh */
|
||||
bool extended;
|
||||
struct Trims
|
||||
{
|
||||
int values[NUM_STICKS]; /* lh lv rv rh */
|
||||
bool extended;
|
||||
};
|
||||
|
||||
class SimulatorInterface {
|
||||
|
||||
class SimulatorInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~SimulatorInterface() {};
|
||||
|
||||
virtual void start(QByteArray & eeprom, bool tests=true) = 0;
|
||||
virtual void setSdPath(const QString &sdPath) { };
|
||||
|
||||
virtual void start(const char * filename, bool tests=true) = 0;
|
||||
virtual void start(QByteArray &eeprom, bool tests=true) = 0;
|
||||
|
||||
virtual void start(const char *filename, bool tests=true) = 0;
|
||||
|
||||
virtual void stop() = 0;
|
||||
|
||||
@@ -62,7 +77,7 @@ class SimulatorInterface {
|
||||
|
||||
virtual uint8_t * getLcd() = 0;
|
||||
|
||||
virtual bool lcdChanged(bool & lightEnable) = 0;
|
||||
virtual bool lcdChanged(bool &lightEnable) = 0;
|
||||
|
||||
virtual void setValues(TxInputs &inputs) = 0;
|
||||
|
||||
@@ -70,13 +85,13 @@ class SimulatorInterface {
|
||||
|
||||
virtual void setTrim(unsigned int idx, int value) = 0;
|
||||
|
||||
virtual void getTrims(Trims & trims) = 0;
|
||||
virtual void getTrims(Trims &trims) = 0;
|
||||
|
||||
virtual unsigned int getPhase() = 0;
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase) = 0;
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) = 0;
|
||||
virtual void wheelEvent(int steps) { };
|
||||
|
||||
virtual const char * getError() = 0;
|
||||
|
||||
@@ -87,4 +102,21 @@ class SimulatorInterface {
|
||||
virtual void installTraceHook(void (*callback)(const char *)) = 0;
|
||||
};
|
||||
|
||||
class SimulatorFactory {
|
||||
|
||||
public:
|
||||
|
||||
virtual ~SimulatorFactory() { }
|
||||
|
||||
virtual QString name() = 0;
|
||||
|
||||
virtual BoardEnum type() = 0;
|
||||
|
||||
virtual SimulatorInterface *create() = 0;
|
||||
};
|
||||
|
||||
void registerSimulators();
|
||||
SimulatorFactory *getSimulatorFactory(const QString &name);
|
||||
extern QMap<QString, SimulatorFactory *> registered_simulators;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include "telemetrysimu.h"
|
||||
#include "ui_telemetrysimu.h"
|
||||
#include "simulatorinterface.h"
|
||||
#include "radio/src/telemetry/frsky.h"
|
||||
|
||||
TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * simulator):
|
||||
@@ -90,4 +91,4 @@ void TelemetrySimulator::generateTelemetryFrame()
|
||||
return;
|
||||
}
|
||||
simulator->sendTelemetry(buffer, 9);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user