mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
Fixes #1042
This commit is contained in:
parent
cfd4aa73a0
commit
533000ddcd
17 changed files with 70 additions and 2 deletions
|
@ -48,6 +48,8 @@ class Er9xSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase() { return 0; }
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase) { return 0; }
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) { }
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -48,6 +48,8 @@ class Ersky9xSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase() { return 0; }
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase) { return 0; }
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) { }
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -200,6 +200,13 @@ unsigned int Open9xGruvin9xSimulator::getPhase()
|
|||
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()
|
||||
{
|
||||
#define GETERROR_IMPORT
|
||||
|
|
|
@ -50,6 +50,8 @@ class Open9xGruvin9xSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase();
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase);
|
||||
|
||||
virtual void wheelEvent(uint8_t steps);
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -191,6 +191,13 @@ unsigned int Open9xM128Simulator::getPhase()
|
|||
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()
|
||||
{
|
||||
#define GETERROR_IMPORT
|
||||
|
|
|
@ -50,6 +50,8 @@ class Open9xM128Simulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase();
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase);
|
||||
|
||||
virtual void wheelEvent(uint8_t steps);
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -233,6 +233,13 @@ unsigned int Open9xSky9xSimulator::getPhase()
|
|||
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()
|
||||
{
|
||||
#define GETERROR_IMPORT
|
||||
|
|
|
@ -50,6 +50,8 @@ class Open9xSky9xSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase();
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase);
|
||||
|
||||
virtual void wheelEvent(uint8_t steps);
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -273,6 +273,13 @@ unsigned int OpentxTaranisSimulator::getPhase()
|
|||
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()
|
||||
{
|
||||
#define GETERROR_IMPORT
|
||||
|
|
|
@ -50,6 +50,8 @@ class OpentxTaranisSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase();
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase);
|
||||
|
||||
virtual void wheelEvent(uint8_t steps);
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -197,6 +197,13 @@ unsigned int Open9xSimulator::getPhase()
|
|||
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()
|
||||
{
|
||||
#define GETERROR_IMPORT
|
||||
|
|
|
@ -49,6 +49,8 @@ class Open9xSimulator : public SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase();
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase);
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) { }
|
||||
|
||||
virtual const char * getError();
|
||||
|
|
|
@ -18,6 +18,7 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
|||
lightOn(false),
|
||||
txInterface(NULL),
|
||||
simulator(NULL),
|
||||
lastPhase(-1),
|
||||
beepVal(0),
|
||||
buttonPressed(0),
|
||||
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)) {
|
||||
|
||||
setValues();
|
||||
|
@ -517,6 +531,7 @@ void SimulatorDialog::centerSticks()
|
|||
|
||||
void SimulatorDialog::start(QByteArray & eeprom)
|
||||
{
|
||||
lastPhase = -1;
|
||||
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
|
||||
getValues();
|
||||
setupTimer();
|
||||
|
@ -524,6 +539,7 @@ void SimulatorDialog::start(QByteArray & eeprom)
|
|||
|
||||
void SimulatorDialog::start(const char * filename)
|
||||
{
|
||||
lastPhase = -1;
|
||||
simulator->start(filename);
|
||||
getValues();
|
||||
setupTimer();
|
||||
|
|
|
@ -73,6 +73,7 @@ class SimulatorDialog : public QDialog
|
|||
|
||||
EEPROMInterface *txInterface;
|
||||
SimulatorInterface *simulator;
|
||||
unsigned int lastPhase;
|
||||
|
||||
void setupSticks();
|
||||
void setupTimer();
|
||||
|
|
|
@ -72,6 +72,8 @@ class SimulatorInterface {
|
|||
|
||||
virtual unsigned int getPhase() = 0;
|
||||
|
||||
virtual const char * getPhaseName(unsigned int phase) = 0;
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) = 0;
|
||||
|
||||
virtual const char * getError() = 0;
|
||||
|
|
|
@ -204,7 +204,7 @@ char idx2char(int8_t idx)
|
|||
return ' ';
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
#if defined(CPUARM) || defined(SIMU)
|
||||
int8_t char2idx(char c)
|
||||
{
|
||||
if (c == '_') return 37;
|
||||
|
|
|
@ -591,7 +591,7 @@ extern uint8_t pxxFlag[NUM_MODULES];
|
|||
#define ZCHAR_MAX (LEN_STD_CHARS + LEN_SPECIAL_CHARS)
|
||||
|
||||
char idx2char(int8_t idx);
|
||||
#if defined(CPUARM)
|
||||
#if defined(CPUARM) || defined(SIMU)
|
||||
int8_t char2idx(char c);
|
||||
void str2zchar(char *dest, const char *src, int size);
|
||||
void zchar2str(char *dest, const char *src, int size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue