diff --git a/companion/src/firmwares/er9x/er9xsimulator.h b/companion/src/firmwares/er9x/er9xsimulator.h index e585fb7fa..52de60575 100644 --- a/companion/src/firmwares/er9x/er9xsimulator.h +++ b/companion/src/firmwares/er9x/er9xsimulator.h @@ -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(); diff --git a/companion/src/firmwares/ersky9x/ersky9xsimulator.h b/companion/src/firmwares/ersky9x/ersky9xsimulator.h index c3f4948ec..93eaae105 100644 --- a/companion/src/firmwares/ersky9x/ersky9xsimulator.h +++ b/companion/src/firmwares/ersky9x/ersky9xsimulator.h @@ -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(); diff --git a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp index aea3df1cb..de6feeb74 100644 --- a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp @@ -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 diff --git a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h index 163d1ec68..57a8ac646 100644 --- a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h +++ b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h @@ -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(); diff --git a/companion/src/firmwares/opentx/opentxM128simulator.cpp b/companion/src/firmwares/opentx/opentxM128simulator.cpp index e615d8d9c..5bb512116 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.cpp +++ b/companion/src/firmwares/opentx/opentxM128simulator.cpp @@ -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 diff --git a/companion/src/firmwares/opentx/opentxM128simulator.h b/companion/src/firmwares/opentx/opentxM128simulator.h index 1efd990af..25941eb6b 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.h +++ b/companion/src/firmwares/opentx/opentxM128simulator.h @@ -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(); diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp index 5e3e5d233..d7ca438a0 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp @@ -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 diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.h b/companion/src/firmwares/opentx/opentxSky9xsimulator.h index 46355a072..9af799f18 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.h +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.h @@ -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(); diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 52ada6c30..16c93b06c 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -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 diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.h b/companion/src/firmwares/opentx/opentxTaranisSimulator.h index be7350799..d5113db7a 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.h +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.h @@ -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(); diff --git a/companion/src/firmwares/opentx/opentxsimulator.cpp b/companion/src/firmwares/opentx/opentxsimulator.cpp index a21b90732..b9d487a96 100644 --- a/companion/src/firmwares/opentx/opentxsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxsimulator.cpp @@ -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 diff --git a/companion/src/firmwares/opentx/opentxsimulator.h b/companion/src/firmwares/opentx/opentxsimulator.h index c563b12d8..97342872f 100644 --- a/companion/src/firmwares/opentx/opentxsimulator.h +++ b/companion/src/firmwares/opentx/opentxsimulator.h @@ -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(); diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 761fc0c06..1f6f6dfe4 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -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(); diff --git a/companion/src/simulation/simulatordialog.h b/companion/src/simulation/simulatordialog.h index 0425c7361..42ee82cb3 100644 --- a/companion/src/simulation/simulatordialog.h +++ b/companion/src/simulation/simulatordialog.h @@ -73,6 +73,7 @@ class SimulatorDialog : public QDialog EEPROMInterface *txInterface; SimulatorInterface *simulator; + unsigned int lastPhase; void setupSticks(); void setupTimer(); diff --git a/companion/src/simulation/simulatorinterface.h b/companion/src/simulation/simulatorinterface.h index 65ee2792b..8316a1019 100644 --- a/companion/src/simulation/simulatorinterface.h +++ b/companion/src/simulation/simulatorinterface.h @@ -71,6 +71,8 @@ class SimulatorInterface { 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; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 2ff9554aa..b35a146b8 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -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; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 55ae36067..d334b7ec3 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -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);