Minor misc. fixes (#4729)

* [Simulator] Remove extraneous format value in microsTimer; Better way to delete SimulatorStartupDialog (in case no event loop starts).

* [Simulator] No helpers dependency for SimulatorStartupDialog.

* [simpgmspace] Rename micros timer function and make externally available.

* [Companion] Fix possible uninitialized value in TreeModel (compiler warning).

* [multi_arm] Fix minor compiler warning (MSVC: "unsafe mix of type 'uint8_t' and type 'bool' in operation").

* [lua] Fix compiler warning ("'data' may be used uninitialized in this function").

* [OpenTxSimulator] Fix analogs array range.

* [Simulator] Auto-start simulator when SimulatorMainWindow is first shown (vs. before it was shown).

* [Simulator] DebugOutput: prevent possible mutex deadlock on buffer overflow (force queued connection for Qt < 5.3).

* [Companion] Display calibration data for Horus joysticks (MOUSE1/MOUSE2)
This commit is contained in:
Max Paperno
2017-04-01 08:13:24 +02:00
committed by Bertrand Songis
parent 9c7c8244f4
commit 5dabe53af4
14 changed files with 35 additions and 27 deletions
+1
View File
@@ -22,6 +22,7 @@
<file>images/simulator/icons/svg/fixed_x-on.svg</file>
<file>images/simulator/icons/svg/fixed_y.svg</file>
<file>images/simulator/icons/svg/fixed_y-on.svg</file>
<file>images/simulator/icons/svg/folder_open.svg</file>
<file>images/simulator/icons/svg/hold_x.svg</file>
<file>images/simulator/icons/svg/hold_x-on.svg</file>
<file>images/simulator/icons/svg/hold_y.svg</file>
+3 -3
View File
@@ -41,10 +41,10 @@ CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSe
tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
tableWidget->setStyleSheet("QTableWidget {background-color: transparent;}");
QStringList headerLabels;
headerLabels << QObject::tr("Negative span") << QObject::tr("Mid value") << QObject::tr("Positive span");
headerLabels << QObject::tr("Negative span") << QObject::tr("Mid value") << QObject::tr("Positive span");
tableWidget->setHorizontalHeaderLabels(headerLabels);
int rows = CPN_MAX_STICKS + getBoardCapability(getCurrentBoard(), Board::Pots) + getBoardCapability(getCurrentBoard(), Board::Sliders);
int rows = CPN_MAX_STICKS + getBoardCapability(getCurrentBoard(), Board::Pots) + getBoardCapability(getCurrentBoard(), Board::Sliders) + getBoardCapability(getCurrentBoard(), Board::MouseAnalogs);
tableWidget->setRowCount(rows);
for(int i = 0; i < rows; ++i) {
@@ -80,7 +80,7 @@ void CalibrationPanel::onCellChanged(int value)
emit modified();
}
}
int CalibrationPanel::getCalibrationValue(int row, int column)
{
switch(column) {
-1
View File
@@ -762,7 +762,6 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
dialog->deleteLater();
}
else if (dialog->setRadioData(simuData)) {
dialog->start();
dialog->show();
}
else {
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.2" width="24" height="24" viewBox="0 0 24 24" id="svg2">
<defs id="defs8" />
<path d="M 22.3,8 H 19.9 C 19.5,6.8 18.4,6 17.1,6 h -6 c 0,-1.1 -0.9,-2 -2,-2 H 5 C 3.3,4 2,5.3 2,7 v 10 c 0,1.7 1.3,3 3,3 h 12 c 1.7,0 3.4,-1.3 3.8,-3 L 23,9 C 23.1,8.4 22.8,8 22.3,8 z M 4,9 V 7 C 4,6.4 4.4,6 5,6 h 4 c 0,1.1 0.9,2 2,2 h 6 c 0.6,0 1,0.4 1,1 H 6.9 C 6.3,9 5.8,9.4 5.6,10 L 4,16.3 V 9 z m 14.9,7.5 C 18.7,17.3 17.8,18 17,18 H 5 C 5,18 4.6,17.8 4.8,17.2 l 1.9,-7 C 6.7,10.1 6.9,10 7,10 h 13.7 l -1.8,6.5 z" id="path4" />
</svg>

After

Width:  |  Height:  |  Size: 783 B

+2 -2
View File
@@ -265,7 +265,7 @@ void TreeModel::refresh()
for (unsigned i=0; i<radioData->models.size(); i++) {
ModelData & model = radioData->models[i];
int currentColumn = 0;
TreeItem * current;
TreeItem * current = NULL;
if (IS_HORUS(board)) {
if (!model.isEmpty()) {
TreeItem * categoryItem;
@@ -290,7 +290,7 @@ void TreeModel::refresh()
current->setData(currentColumn++, QString().sprintf("%02d", i + 1));
}
if (!model.isEmpty()) {
if (!model.isEmpty() && current) {
QString modelName;
if (strlen(model.name) > 0)
modelName = model.name;
+2 -2
View File
@@ -87,8 +87,8 @@ DebugOutput::DebugOutput(QWidget * parent, SimulatorInterface *simulator):
m_dataBufferDevice->setInputBufferMaxSize(DEBUG_OUTPUT_WIDGET_INP_BUFF_SIZE);
m_dataBufferDevice->open(QIODevice::ReadWrite | QIODevice::Text);
connect(m_dataBufferDevice, &FilteredTextBuffer::readyRead, this, &DebugOutput::processBytesReceived);
connect(m_dataBufferDevice, &FilteredTextBuffer::bufferOverflow, this, &DebugOutput::onDataBufferOverflow);
connect(m_dataBufferDevice, &FilteredTextBuffer::readyRead, this, &DebugOutput::processBytesReceived, Qt::QueuedConnection);
connect(m_dataBufferDevice, &FilteredTextBuffer::bufferOverflow, this, &DebugOutput::onDataBufferOverflow, Qt::QueuedConnection);
connect(this, &DebugOutput::filterChanged, m_dataBufferDevice, &FilteredTextBuffer::setLineFilter);
connect(this, &DebugOutput::filterEnabledChanged, m_dataBufferDevice, &FilteredTextBuffer::setLineFilterEnabled);
connect(this, &DebugOutput::filterExprChanged, m_dataBufferDevice, &FilteredTextBuffer::setLineFilterExpr);
@@ -168,13 +168,14 @@ void SimulatorMainWindow::closeEvent(QCloseEvent *)
void SimulatorMainWindow::show()
{
QMainWindow::show();
#ifdef Q_OS_LINUX
// for whatever reason, w/out this workaround any floating docks may appear and get "stuck" behind other windows, eg. Terminal or Companion.
if (m_firstShow) {
restoreUiState();
m_firstShow = false;
#ifdef Q_OS_LINUX
// for whatever reason, w/out this workaround any floating docks may appear and get "stuck" behind other windows, eg. Terminal or Companion.
restoreUiState();
#endif
start();
}
#endif
}
void SimulatorMainWindow::changeEvent(QEvent *e)
@@ -24,7 +24,6 @@
#include "appdata.h"
#include "constants.h"
#include "simulatorinterface.h"
#include "helpers.h"
#include <QFileDialog>
@@ -52,7 +51,7 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
ui->optGrp_dataSource->setId(ui->optFolder, SimulatorOptions::START_WITH_FOLDER);
ui->optGrp_dataSource->setId(ui->optSdPath, SimulatorOptions::START_WITH_SDPATH);
CompanionIcon icon("open.png");
SimulatorIcon icon("folder_open");
ui->btnSelectDataFile->setIcon(icon);
ui->btnSelectDataFolder->setIcon(icon);
ui->btnSelectSdPath->setIcon(icon);
+1 -2
View File
@@ -185,7 +185,7 @@ int main(int argc, char *argv[])
if (!cliOptsFound || profileId == -1 || simOptions.firmwareId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty())) {
SimulatorStartupDialog * dlg = new SimulatorStartupDialog(&simOptions, &profileId);
int ret = dlg->exec();
dlg->deleteLater();
delete dlg;
if (ret != QDialog::Accepted) {
return finish(0);
}
@@ -219,7 +219,6 @@ int main(int argc, char *argv[])
showMessage(resultMsg, QMessageBox::Critical);
}
else if (mainWindow->setOptions(simOptions, true)) {
mainWindow->start();
mainWindow->show();
result = app.exec();
if (!result) {
+1 -1
View File
@@ -408,7 +408,7 @@ static int luaCrossfireTelemetryPop(lua_State * L)
}
}
uint8_t length, data;
uint8_t length = 0, data = 0;
if (luaInputTelemetryFifo->probe(length) && luaInputTelemetryFifo->size() >= uint32_t(length)) {
// length value includes the length field
luaInputTelemetryFifo->pop(length);
+1 -1
View File
@@ -74,7 +74,7 @@ static void sendByteMulti(uint8_t b) //max 11 changes 0 10 10 10 10 P 1
uint8_t len = BITLEN_MULTI; //max val: 10*20 < 256
for (uint8_t i=0; i<=9; i++) { //8Bits + 1Parity + Stop=1
bool nlev = b & 1; //lsb first
parity = parity ^ nlev;
parity = parity ^ (uint8_t)nlev;
if (lev == nlev) {
len += BITLEN_MULTI;
}
+1 -1
View File
@@ -18,7 +18,7 @@
#include "opentx.h"
#include "simulcd.h"
int16_t g_anas[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
int16_t g_anas[Analogs::NUM_ANALOGS];
uint16_t anaIn(uint8_t chan)
{
+5 -5
View File
@@ -81,7 +81,7 @@ void toplcdOff()
{
}
U64 microsTimer(void)
uint64_t simuTimerMicros(void)
{
#if SIMPGMSPC_USE_QT
@@ -104,7 +104,7 @@ U64 microsTimer(void)
freqScale = 1e6 / frequency.QuadPart;
// init timer
QueryPerformanceCounter(&firstTick);
TRACE_SIMPGMSPACE("microsTimer() init: first tick = %llu @ %llu Hz: %g", firstTick.QuadPart, frequency.QuadPart);
TRACE_SIMPGMSPACE("microsTimer() init: first tick = %llu @ %llu Hz", firstTick.QuadPart, frequency.QuadPart);
}
// read the timer
QueryPerformanceCounter(&newTick);
@@ -121,18 +121,18 @@ U64 microsTimer(void)
uint16_t getTmr16KHz()
{
return microsTimer() * 2 / 125;
return simuTimerMicros() * 2 / 125;
}
uint16_t getTmr2MHz()
{
return microsTimer() * 2;
return simuTimerMicros() * 2;
}
// return 2ms resolution to match CoOS settings
U64 CoGetOSTime(void)
{
return microsTimer() / 2000;
return simuTimerMicros() / 2000;
}
void simuInit()
+5 -3
View File
@@ -356,15 +356,16 @@ extern char * main_thread_error;
#define SIMU_SLEEP(x) do { if (!main_thread_running) return; sleep(x/*ms*/); } while (0)
#define SIMU_SLEEP_NORET(x) do { sleep(x/*ms*/); } while (0)
uint64_t simuTimerMicros(void);
void simuInit();
void StartSimu(bool tests=true, const char * sdPath = 0, const char * settingsPath = 0);
void StopSimu();
void simuSetKey(uint8_t key, bool state);
void simuSetTrim(uint8_t trim, bool state);
void simuSetSwitch(uint8_t swtch, int8_t state);
void StartSimu(bool tests=true, const char * sdPath = 0, const char * settingsPath = 0);
void StopSimu();
void StartEepromThread(const char *filename="eeprom.bin");
void StopEepromThread();
#if defined(SIMU_AUDIO) && defined(CPUARM)
@@ -419,6 +420,7 @@ OS_TID CoCreateTask(FUNCPtr task, void *argv, uint32_t parameter, void * stk, ui
#define CoTickDelay(x) sleep(2*(x))
#define CoCreateFlag(...) 0
U64 CoGetOSTime(void);
#define UART_Stop(...)
#define UART3_Stop(...)
#define USART_GetITStatus(...) 0