Fixes #1042
This commit is contained in:
@@ -48,6 +48,8 @@ class Er9xSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase() { return 0; }
|
virtual unsigned int getPhase() { return 0; }
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase) { return 0; }
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps) { }
|
virtual void wheelEvent(uint8_t steps) { }
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ class Ersky9xSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase() { return 0; }
|
virtual unsigned int getPhase() { return 0; }
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase) { return 0; }
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps) { }
|
virtual void wheelEvent(uint8_t steps) { }
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -200,6 +200,13 @@ unsigned int Open9xGruvin9xSimulator::getPhase()
|
|||||||
return getFlightPhase();
|
return getFlightPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * Open9xGruvin9xSimulator::getPhaseName(unsigned int phase)
|
||||||
|
{
|
||||||
|
static char buff[sizeof(g_model.phaseData[0].name)+1];
|
||||||
|
zchar2str(buff, g_model.phaseData[phase].name, sizeof(g_model.phaseData[0].name));
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
const char * Open9xGruvin9xSimulator::getError()
|
const char * Open9xGruvin9xSimulator::getError()
|
||||||
{
|
{
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class Open9xGruvin9xSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase();
|
virtual unsigned int getPhase();
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase);
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps);
|
virtual void wheelEvent(uint8_t steps);
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -191,6 +191,13 @@ unsigned int Open9xM128Simulator::getPhase()
|
|||||||
return getFlightPhase();
|
return getFlightPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * Open9xM128Simulator::getPhaseName(unsigned int phase)
|
||||||
|
{
|
||||||
|
static char buff[sizeof(g_model.phaseData[0].name)+1];
|
||||||
|
zchar2str(buff, g_model.phaseData[phase].name, sizeof(g_model.phaseData[0].name));
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
const char * Open9xM128Simulator::getError()
|
const char * Open9xM128Simulator::getError()
|
||||||
{
|
{
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class Open9xM128Simulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase();
|
virtual unsigned int getPhase();
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase);
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps);
|
virtual void wheelEvent(uint8_t steps);
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -233,6 +233,13 @@ unsigned int Open9xSky9xSimulator::getPhase()
|
|||||||
return getFlightPhase();
|
return getFlightPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * Open9xSky9xSimulator::getPhaseName(unsigned int phase)
|
||||||
|
{
|
||||||
|
static char buff[sizeof(g_model.phaseData[0].name)+1];
|
||||||
|
zchar2str(buff, g_model.phaseData[phase].name, sizeof(g_model.phaseData[0].name));
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
const char * Open9xSky9xSimulator::getError()
|
const char * Open9xSky9xSimulator::getError()
|
||||||
{
|
{
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class Open9xSky9xSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase();
|
virtual unsigned int getPhase();
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase);
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps);
|
virtual void wheelEvent(uint8_t steps);
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -273,6 +273,13 @@ unsigned int OpentxTaranisSimulator::getPhase()
|
|||||||
return getFlightPhase();
|
return getFlightPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * OpentxTaranisSimulator::getPhaseName(unsigned int phase)
|
||||||
|
{
|
||||||
|
static char buff[sizeof(g_model.phaseData[0].name)+1];
|
||||||
|
zchar2str(buff, g_model.phaseData[phase].name, sizeof(g_model.phaseData[0].name));
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
const char * OpentxTaranisSimulator::getError()
|
const char * OpentxTaranisSimulator::getError()
|
||||||
{
|
{
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class OpentxTaranisSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase();
|
virtual unsigned int getPhase();
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase);
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps);
|
virtual void wheelEvent(uint8_t steps);
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -197,6 +197,13 @@ unsigned int Open9xSimulator::getPhase()
|
|||||||
return getFlightPhase();
|
return getFlightPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * Open9xSimulator::getPhaseName(unsigned int phase)
|
||||||
|
{
|
||||||
|
static char buff[sizeof(g_model.phaseData[0].name)+1];
|
||||||
|
zchar2str(buff, g_model.phaseData[phase].name, sizeof(g_model.phaseData[0].name));
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
const char * Open9xSimulator::getError()
|
const char * Open9xSimulator::getError()
|
||||||
{
|
{
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ class Open9xSimulator : public SimulatorInterface {
|
|||||||
|
|
||||||
virtual unsigned int getPhase();
|
virtual unsigned int getPhase();
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase);
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps) { }
|
virtual void wheelEvent(uint8_t steps) { }
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
|||||||
lightOn(false),
|
lightOn(false),
|
||||||
txInterface(NULL),
|
txInterface(NULL),
|
||||||
simulator(NULL),
|
simulator(NULL),
|
||||||
|
lastPhase(-1),
|
||||||
beepVal(0),
|
beepVal(0),
|
||||||
buttonPressed(0),
|
buttonPressed(0),
|
||||||
trimPressed (TRIM_NONE),
|
trimPressed (TRIM_NONE),
|
||||||
@@ -489,6 +490,19 @@ void SimulatorDialog::onTimerEvent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//display current flight mode in window title
|
||||||
|
unsigned int currentPhase = simulator->getPhase();
|
||||||
|
if (currentPhase != lastPhase) {
|
||||||
|
lastPhase = currentPhase;
|
||||||
|
const char * phase_name = simulator->getPhaseName(currentPhase);
|
||||||
|
if ( phase_name && phase_name[0] ) {
|
||||||
|
setWindowTitle(windowName + QString(" [fm: %1]").arg(QString(phase_name)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setWindowTitle(windowName + QString(" [fm: %1]").arg(simulator->getPhase()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(lcd_counter++ % 5)) {
|
if (!(lcd_counter++ % 5)) {
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
@@ -517,6 +531,7 @@ void SimulatorDialog::centerSticks()
|
|||||||
|
|
||||||
void SimulatorDialog::start(QByteArray & eeprom)
|
void SimulatorDialog::start(QByteArray & eeprom)
|
||||||
{
|
{
|
||||||
|
lastPhase = -1;
|
||||||
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
|
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
|
||||||
getValues();
|
getValues();
|
||||||
setupTimer();
|
setupTimer();
|
||||||
@@ -524,6 +539,7 @@ void SimulatorDialog::start(QByteArray & eeprom)
|
|||||||
|
|
||||||
void SimulatorDialog::start(const char * filename)
|
void SimulatorDialog::start(const char * filename)
|
||||||
{
|
{
|
||||||
|
lastPhase = -1;
|
||||||
simulator->start(filename);
|
simulator->start(filename);
|
||||||
getValues();
|
getValues();
|
||||||
setupTimer();
|
setupTimer();
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ class SimulatorDialog : public QDialog
|
|||||||
|
|
||||||
EEPROMInterface *txInterface;
|
EEPROMInterface *txInterface;
|
||||||
SimulatorInterface *simulator;
|
SimulatorInterface *simulator;
|
||||||
|
unsigned int lastPhase;
|
||||||
|
|
||||||
void setupSticks();
|
void setupSticks();
|
||||||
void setupTimer();
|
void setupTimer();
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ class SimulatorInterface {
|
|||||||
virtual void getTrims(Trims & trims) = 0;
|
virtual void getTrims(Trims & trims) = 0;
|
||||||
|
|
||||||
virtual unsigned int getPhase() = 0;
|
virtual unsigned int getPhase() = 0;
|
||||||
|
|
||||||
|
virtual const char * getPhaseName(unsigned int phase) = 0;
|
||||||
|
|
||||||
virtual void wheelEvent(uint8_t steps) = 0;
|
virtual void wheelEvent(uint8_t steps) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ char idx2char(int8_t idx)
|
|||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) || defined(SIMU)
|
||||||
int8_t char2idx(char c)
|
int8_t char2idx(char c)
|
||||||
{
|
{
|
||||||
if (c == '_') return 37;
|
if (c == '_') return 37;
|
||||||
|
|||||||
+1
-1
@@ -591,7 +591,7 @@ extern uint8_t pxxFlag[NUM_MODULES];
|
|||||||
#define ZCHAR_MAX (LEN_STD_CHARS + LEN_SPECIAL_CHARS)
|
#define ZCHAR_MAX (LEN_STD_CHARS + LEN_SPECIAL_CHARS)
|
||||||
|
|
||||||
char idx2char(int8_t idx);
|
char idx2char(int8_t idx);
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) || defined(SIMU)
|
||||||
int8_t char2idx(char c);
|
int8_t char2idx(char c);
|
||||||
void str2zchar(char *dest, const char *src, int size);
|
void str2zchar(char *dest, const char *src, int size);
|
||||||
void zchar2str(char *dest, const char *src, int size);
|
void zchar2str(char *dest, const char *src, int size);
|
||||||
|
|||||||
Reference in New Issue
Block a user