mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
Ported from master to next:
#1489: TRACE() output intercepted and shown in Companion (shortcut F6) #1270: simple Trainer Simulator (shortcut F5) #1466: telemetry simulator (shorcut F5)
This commit is contained in:
parent
a2dc0040b0
commit
bb921a0a7f
39 changed files with 865 additions and 96 deletions
|
@ -54,6 +54,10 @@ class Er9xSimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Er9xInterface * er9xInterface;
|
Er9xInterface * er9xInterface;
|
||||||
|
|
|
@ -54,6 +54,10 @@ class Ersky9xSimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Ersky9xInterface * ersky9xInterface;
|
Ersky9xInterface * ersky9xInterface;
|
||||||
|
|
|
@ -56,6 +56,11 @@ class Open9xGruvin9xSimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *)) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,6 +56,11 @@ class OpenTxM128Simulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *)) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,6 +55,11 @@ class OpenTxM64Simulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *)) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace Open9xSky9x {
|
||||||
#include "radio/src/eeprom_raw.cpp"
|
#include "radio/src/eeprom_raw.cpp"
|
||||||
#include "radio/src/eeprom_conversions.cpp"
|
#include "radio/src/eeprom_conversions.cpp"
|
||||||
#include "radio/src/opentx.cpp"
|
#include "radio/src/opentx.cpp"
|
||||||
|
// #include "radio/src/debug.cpp" // only included once in Taranis simulator because functions are exported as C and don't support namespaces
|
||||||
#include "radio/src/main_arm.cpp"
|
#include "radio/src/main_arm.cpp"
|
||||||
#include "radio/src/strhelpers.cpp"
|
#include "radio/src/strhelpers.cpp"
|
||||||
#include "radio/src/switches.cpp"
|
#include "radio/src/switches.cpp"
|
||||||
|
@ -281,3 +282,13 @@ const char * Open9xSky9xSimulator::getError()
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
#include "simulatorimport.h"
|
#include "simulatorimport.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Open9xSky9xSimulator::setTrainerInput(unsigned int inputNumber, int16_t value)
|
||||||
|
{
|
||||||
|
#define SETTRAINER_IMPORT
|
||||||
|
#include "simulatorimport.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
void Open9xSky9xSimulator::installTraceHook(void (*callback)(const char *)) {
|
||||||
|
::traceCallback = callback;
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,11 @@ class Open9xSky9xSimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) {};
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value);
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -78,6 +78,7 @@ inline int geteepromsize() {
|
||||||
#include "radio/src/eeprom_conversions.cpp"
|
#include "radio/src/eeprom_conversions.cpp"
|
||||||
#include "radio/src/eeprom_rlc.cpp"
|
#include "radio/src/eeprom_rlc.cpp"
|
||||||
#include "radio/src/opentx.cpp"
|
#include "radio/src/opentx.cpp"
|
||||||
|
#include "radio/src/debug.cpp"
|
||||||
#include "radio/src/main_arm.cpp"
|
#include "radio/src/main_arm.cpp"
|
||||||
#include "radio/src/strhelpers.cpp"
|
#include "radio/src/strhelpers.cpp"
|
||||||
#include "radio/src/switches.cpp"
|
#include "radio/src/switches.cpp"
|
||||||
|
@ -321,3 +322,18 @@ const char * OpentxTaranisSimulator::getError()
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
#include "simulatorimport.h"
|
#include "simulatorimport.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisSimulator::sendTelemetry(uint8_t * data, unsigned int len)
|
||||||
|
{
|
||||||
|
processSportPacket(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisSimulator::setTrainerInput(unsigned int inputNumber, int16_t value)
|
||||||
|
{
|
||||||
|
#define SETTRAINER_IMPORT
|
||||||
|
#include "simulatorimport.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisSimulator::installTraceHook(void (*callback)(const char *)) {
|
||||||
|
::traceCallback = callback;
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,11 @@ class OpentxTaranisSimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len);
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value);
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,6 +79,7 @@ inline int geteepromsize() {
|
||||||
#include "radio/src/eeprom_conversions.cpp"
|
#include "radio/src/eeprom_conversions.cpp"
|
||||||
#include "radio/src/eeprom_rlc.cpp"
|
#include "radio/src/eeprom_rlc.cpp"
|
||||||
#include "radio/src/opentx.cpp"
|
#include "radio/src/opentx.cpp"
|
||||||
|
// #include "radio/src/debug.cpp" // only included once in Taranis simulator because functions are exported as C and don't support namespaces
|
||||||
#include "radio/src/main_arm.cpp"
|
#include "radio/src/main_arm.cpp"
|
||||||
#include "radio/src/strhelpers.cpp"
|
#include "radio/src/strhelpers.cpp"
|
||||||
#include "radio/src/switches.cpp"
|
#include "radio/src/switches.cpp"
|
||||||
|
@ -325,3 +326,18 @@ const char * OpentxTaranisX9ESimulator::getError()
|
||||||
#define GETERROR_IMPORT
|
#define GETERROR_IMPORT
|
||||||
#include "simulatorimport.h"
|
#include "simulatorimport.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisX9ESimulator::sendTelemetry(uint8_t * data, unsigned int len)
|
||||||
|
{
|
||||||
|
processSportPacket(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisX9ESimulator::setTrainerInput(unsigned int inputNumber, int16_t value)
|
||||||
|
{
|
||||||
|
#define SETTRAINER_IMPORT
|
||||||
|
#include "simulatorimport.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpentxTaranisX9ESimulator::installTraceHook(void (*callback)(const char *)) {
|
||||||
|
::traceCallback = callback;
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,11 @@ class OpentxTaranisX9ESimulator : public SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError();
|
virtual const char * getError();
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len);
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value);
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
set(simulation_SRCS
|
set(simulation_SRCS
|
||||||
simulatordialog.cpp
|
simulatordialog.cpp
|
||||||
|
telemetrysimu.cpp
|
||||||
|
trainersimu.cpp
|
||||||
|
debugoutput.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(simulation_UIS
|
set(simulation_UIS
|
||||||
simulatordialog-9x.ui
|
simulatordialog-9x.ui
|
||||||
simulatordialog-taranis.ui
|
simulatordialog-taranis.ui
|
||||||
|
telemetrysimu.ui
|
||||||
|
trainersimu.ui
|
||||||
|
debugoutput.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set(simulation_HDRS
|
set(simulation_HDRS
|
||||||
|
@ -14,6 +20,9 @@ set(simulation_HDRS
|
||||||
xcursorwidget.h
|
xcursorwidget.h
|
||||||
xmenuwidget.h
|
xmenuwidget.h
|
||||||
myslider.h
|
myslider.h
|
||||||
|
telemetrysimu.h
|
||||||
|
trainersimu.h
|
||||||
|
debugoutput.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SDL_FOUND)
|
if(SDL_FOUND)
|
||||||
|
|
45
companion/src/simulation/debugoutput.cpp
Normal file
45
companion/src/simulation/debugoutput.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include <QtGui>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "debugoutput.h"
|
||||||
|
#include "ui_debugoutput.h"
|
||||||
|
|
||||||
|
DebugOutput::DebugOutput(QWidget * parent):
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DebugOutput)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
QFont newFont("Courier", 13);
|
||||||
|
ui->Output->setFont(newFont);
|
||||||
|
ui->Output->setAttribute(Qt::WA_MacNormalSize);
|
||||||
|
#endif
|
||||||
|
#if defined WIN32 || !defined __GNUC__
|
||||||
|
QFont newFont("Courier", 9);
|
||||||
|
ui->Output->setFont(newFont);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugOutput::~DebugOutput()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugOutput::traceCallback(const QString & text)
|
||||||
|
{
|
||||||
|
// ui->Output->appendPlainText(text);
|
||||||
|
QTextCursor cursor(ui->Output->textCursor());
|
||||||
|
|
||||||
|
// is the scrollbar at the end?
|
||||||
|
bool atEnd = (ui->Output->verticalScrollBar()->value() == ui->Output->verticalScrollBar()->maximum());
|
||||||
|
|
||||||
|
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor, 1);
|
||||||
|
cursor.insertText(text);
|
||||||
|
|
||||||
|
if (atEnd) {
|
||||||
|
ui->Output->verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
32
companion/src/simulation/debugoutput.h
Normal file
32
companion/src/simulation/debugoutput.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef debugoutput_h
|
||||||
|
#define debugoutput_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "simulatorinterface.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DebugOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DebugOutput : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DebugOutput(QWidget * parent);
|
||||||
|
virtual ~DebugOutput();
|
||||||
|
void traceCallback(const QString & text);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DebugOutput * ui;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
50
companion/src/simulation/debugoutput.ui
Normal file
50
companion/src/simulation/debugoutput.ui
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DebugOutput</class>
|
||||||
|
<widget class="QDialog" name="DebugOutput">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>711</width>
|
||||||
|
<height>470</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Debug Output</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../companion.qrc">
|
||||||
|
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="Output">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Courier New</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../companion.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -9,6 +9,42 @@
|
||||||
#define RESX 1024
|
#define RESX 1024
|
||||||
|
|
||||||
int SimulatorDialog::screenshotIdx = 0;
|
int SimulatorDialog::screenshotIdx = 0;
|
||||||
|
SimulatorDialog * traceCallbackInstance = 0;
|
||||||
|
|
||||||
|
void traceCb(const char * text) {
|
||||||
|
// divert C callback into simulator instance
|
||||||
|
if (traceCallbackInstance) {
|
||||||
|
traceCallbackInstance->traceCallback(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorDialog::traceCallback(const char * text)
|
||||||
|
{
|
||||||
|
// this function is called from other threads
|
||||||
|
traceMutex.lock();
|
||||||
|
// limit the size of list
|
||||||
|
if (traceList.size() < 1000) {
|
||||||
|
traceList.append(QString(text));
|
||||||
|
}
|
||||||
|
traceMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorDialog::updateDebugOutput()
|
||||||
|
{
|
||||||
|
traceMutex.lock();
|
||||||
|
while (!traceList.isEmpty()) {
|
||||||
|
QString text = traceList.takeFirst();
|
||||||
|
traceBuffer.append(text);
|
||||||
|
// limit the size of traceBuffer
|
||||||
|
if (traceBuffer.size() > 10*1024) {
|
||||||
|
traceBuffer.remove(0, 1*1024);
|
||||||
|
}
|
||||||
|
if (DebugOut) {
|
||||||
|
DebugOut->traceCallback(QString(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traceMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -19,10 +55,19 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
||||||
simulator(NULL),
|
simulator(NULL),
|
||||||
lastPhase(-1),
|
lastPhase(-1),
|
||||||
beepVal(0),
|
beepVal(0),
|
||||||
|
TelemetrySimu(0),
|
||||||
|
TrainerSimu(0),
|
||||||
|
DebugOut(0),
|
||||||
buttonPressed(0),
|
buttonPressed(0),
|
||||||
trimPressed (TRIM_NONE),
|
trimPressed (TRIM_NONE),
|
||||||
middleButtonPressed(false)
|
middleButtonPressed(false)
|
||||||
{
|
{
|
||||||
|
//shorcut for telemetry simulator
|
||||||
|
// new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this, SLOT(openTelemetrySimulator()));
|
||||||
|
new QShortcut(QKeySequence(Qt::Key_F4), this, SLOT(openTelemetrySimulator()));
|
||||||
|
new QShortcut(QKeySequence(Qt::Key_F5), this, SLOT(openTrainerSimulator()));
|
||||||
|
new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(openDebugOutput()));
|
||||||
|
traceCallbackInstance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SimulatorDialog9X::switchstatus = 0;
|
uint32_t SimulatorDialog9X::switchstatus = 0;
|
||||||
|
@ -37,6 +82,9 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
|
||||||
|
|
||||||
initUi<Ui::SimulatorDialog9X>(ui);
|
initUi<Ui::SimulatorDialog9X>(ui);
|
||||||
|
|
||||||
|
// install simulator TRACE hook
|
||||||
|
simulator->installTraceHook(traceCb);
|
||||||
|
|
||||||
backLight = g.backLight();
|
backLight = g.backLight();
|
||||||
if (backLight > 4) backLight = 0;
|
if (backLight > 4) backLight = 0;
|
||||||
switch (backLight) {
|
switch (backLight) {
|
||||||
|
@ -109,6 +157,10 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int fl
|
||||||
lcdDepth = 4;
|
lcdDepth = 4;
|
||||||
|
|
||||||
initUi<Ui::SimulatorDialogTaranis>(ui);
|
initUi<Ui::SimulatorDialogTaranis>(ui);
|
||||||
|
|
||||||
|
// install simulator TRACE hook
|
||||||
|
simulator->installTraceHook(traceCb);
|
||||||
|
|
||||||
dialP_4 = ui->dialP_4;
|
dialP_4 = ui->dialP_4;
|
||||||
|
|
||||||
ui->lcd->setBackgroundColor(47, 123, 227);
|
ui->lcd->setBackgroundColor(47, 123, 227);
|
||||||
|
@ -154,6 +206,7 @@ SimulatorDialogTaranis::~SimulatorDialogTaranis()
|
||||||
|
|
||||||
SimulatorDialog::~SimulatorDialog()
|
SimulatorDialog::~SimulatorDialog()
|
||||||
{
|
{
|
||||||
|
traceCallbackInstance = 0;
|
||||||
delete timer;
|
delete timer;
|
||||||
delete simulator;
|
delete simulator;
|
||||||
}
|
}
|
||||||
|
@ -215,6 +268,28 @@ void SimulatorDialog::onTrimReleased()
|
||||||
trimPressed = TRIM_NONE;
|
trimPressed = TRIM_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimulatorDialog::openTelemetrySimulator()
|
||||||
|
{
|
||||||
|
TelemetrySimu = new TelemetrySimulator(this, simulator);
|
||||||
|
TelemetrySimu->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
TelemetrySimu->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorDialog::openTrainerSimulator()
|
||||||
|
{
|
||||||
|
TrainerSimu = new TrainerSimulator(this, simulator);
|
||||||
|
TrainerSimu->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
TrainerSimu->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorDialog::openDebugOutput()
|
||||||
|
{
|
||||||
|
DebugOut = new DebugOutput(this);
|
||||||
|
DebugOut->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
DebugOut->traceCallback(traceBuffer);
|
||||||
|
DebugOut->show();
|
||||||
|
}
|
||||||
|
|
||||||
void SimulatorDialog::keyPressEvent (QKeyEvent *event)
|
void SimulatorDialog::keyPressEvent (QKeyEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
@ -559,6 +634,8 @@ void SimulatorDialog::onTimerEvent()
|
||||||
QApplication::beep();
|
QApplication::beep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDebugOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorDialog::centerSticks()
|
void SimulatorDialog::centerSticks()
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "modeledit/node.h"
|
#include "modeledit/node.h"
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
#include "telemetrysimu.h"
|
||||||
|
#include "trainersimu.h"
|
||||||
|
#include "debugoutput.h"
|
||||||
|
|
||||||
#ifdef JOYSTICKS
|
#ifdef JOYSTICKS
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
|
@ -38,6 +41,7 @@ class SimulatorDialog : public QDialog
|
||||||
|
|
||||||
void start(const char * filename);
|
void start(const char * filename);
|
||||||
void start(QByteArray & eeprom);
|
void start(QByteArray & eeprom);
|
||||||
|
virtual void traceCallback(const char * text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <class T> void initUi(T * ui);
|
template <class T> void initUi(T * ui);
|
||||||
|
@ -95,6 +99,14 @@ class SimulatorDialog : public QDialog
|
||||||
|
|
||||||
int lcdWidth;
|
int lcdWidth;
|
||||||
int lcdDepth;
|
int lcdDepth;
|
||||||
|
TelemetrySimulator * TelemetrySimu;
|
||||||
|
TrainerSimulator * TrainerSimu;
|
||||||
|
DebugOutput * DebugOut;
|
||||||
|
|
||||||
|
QString traceBuffer;
|
||||||
|
QMutex traceMutex;
|
||||||
|
QList<QString> traceList;
|
||||||
|
void updateDebugOutput();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent *);
|
virtual void closeEvent(QCloseEvent *);
|
||||||
|
@ -125,6 +137,9 @@ class SimulatorDialog : public QDialog
|
||||||
void onTimerEvent();
|
void onTimerEvent();
|
||||||
void onTrimPressed();
|
void onTrimPressed();
|
||||||
void onTrimReleased();
|
void onTrimReleased();
|
||||||
|
void openTelemetrySimulator();
|
||||||
|
void openTrainerSimulator();
|
||||||
|
void openDebugOutput();
|
||||||
|
|
||||||
#ifdef JOYSTICKS
|
#ifdef JOYSTICKS
|
||||||
void onjoystickAxisValueChanged(int axis, int value);
|
void onjoystickAxisValueChanged(int axis, int value);
|
||||||
|
|
|
@ -101,4 +101,9 @@ return lcd_buf;
|
||||||
return main_thread_error;
|
return main_thread_error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SETTRAINER_IMPORT
|
||||||
|
#undef SETTRAINER_IMPORT
|
||||||
|
ppmInValid = 100;
|
||||||
|
g_ppmIns[inputNumber] = LIMIT<int16_t>(-512, value, 512);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,11 @@ class SimulatorInterface {
|
||||||
|
|
||||||
virtual const char * getError() = 0;
|
virtual const char * getError() = 0;
|
||||||
|
|
||||||
|
virtual void sendTelemetry(uint8_t * data, unsigned int len) = 0;
|
||||||
|
|
||||||
|
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) = 0;
|
||||||
|
|
||||||
|
virtual void installTraceHook(void (*callback)(const char *)) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
85
companion/src/simulation/telemetrysimu.cpp
Normal file
85
companion/src/simulation/telemetrysimu.cpp
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "telemetrysimu.h"
|
||||||
|
#include "ui_telemetrysimu.h"
|
||||||
|
#include "radio/src/telemetry/frsky.h"
|
||||||
|
|
||||||
|
TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * simulator):
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TelemetrySimulator),
|
||||||
|
simulator(simulator)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timer = new QTimer(this);
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
||||||
|
timer->start(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
TelemetrySimulator::~TelemetrySimulator()
|
||||||
|
{
|
||||||
|
timer->stop();
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetrySimulator::onTimerEvent()
|
||||||
|
{
|
||||||
|
if (ui->Simulate->isChecked()) {
|
||||||
|
generateTelemetryFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSportPacketCrc(uint8_t * packet)
|
||||||
|
{
|
||||||
|
short crc = 0;
|
||||||
|
for (int i=1; i<FRSKY_SPORT_PACKET_SIZE-1; i++) {
|
||||||
|
crc += packet[i]; //0-1FF
|
||||||
|
crc += crc >> 8; //0-100
|
||||||
|
crc &= 0x00ff;
|
||||||
|
crc += crc >> 8; //0-0FF
|
||||||
|
crc &= 0x00ff;
|
||||||
|
}
|
||||||
|
packet[FRSKY_SPORT_PACKET_SIZE-1] = 0xFF - (crc & 0x00ff);
|
||||||
|
//TRACE("crc set: %x", packet[FRSKY_SPORT_PACKET_SIZE-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void generateSportPacket(uint8_t * packet, uint8_t dataId, uint8_t prim, uint16_t appId, uint32_t data)
|
||||||
|
{
|
||||||
|
packet[0] = dataId;
|
||||||
|
packet[1] = prim;
|
||||||
|
*((uint16_t *)(packet+2)) = appId;
|
||||||
|
*((int32_t *)(packet+4)) = data;
|
||||||
|
setSportPacketCrc(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetrySimulator::generateTelemetryFrame()
|
||||||
|
{
|
||||||
|
static int item = 0;
|
||||||
|
uint8_t buffer[FRSKY_SPORT_PACKET_SIZE];
|
||||||
|
|
||||||
|
switch(item++) {
|
||||||
|
case 0:
|
||||||
|
generateSportPacket(buffer, 1, DATA_FRAME, RSSI_ID, LIMIT<uint32_t>(0, ui->Rssi->text().toInt(), 0xFF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
generateSportPacket(buffer, 1, DATA_FRAME, XJT_VERSION_ID, 11);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
generateSportPacket(buffer, 1, DATA_FRAME, SWR_ID, LIMIT<uint32_t>(0, ui->Swr->text().toInt(), 0xFF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
generateSportPacket(buffer, 1, DATA_FRAME, ADC1_ID, LIMIT<uint32_t>(0, ui->A1->text().toInt(), 0xFF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
generateSportPacket(buffer, 1, DATA_FRAME, ADC2_ID, LIMIT<uint32_t>(0, ui->A2->text().toInt(), 0xFF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
item = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
simulator->sendTelemetry(buffer, 9);
|
||||||
|
}
|
38
companion/src/simulation/telemetrysimu.h
Normal file
38
companion/src/simulation/telemetrysimu.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef telemetrysimu_h
|
||||||
|
#define telemetrysimu_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTimer>
|
||||||
|
#include "simulatorinterface.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TelemetrySimulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TelemetrySimulator : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TelemetrySimulator(QWidget * parent, SimulatorInterface * simulator);
|
||||||
|
virtual ~TelemetrySimulator();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TelemetrySimulator * ui;
|
||||||
|
QTimer * timer;
|
||||||
|
SimulatorInterface *simulator;
|
||||||
|
|
||||||
|
void generateTelemetryFrame();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTimerEvent();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
72
companion/src/simulation/telemetrysimu.ui
Normal file
72
companion/src/simulation/telemetrysimu.ui
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TelemetrySimulator</class>
|
||||||
|
<widget class="QDialog" name="TelemetrySimulator">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>184</width>
|
||||||
|
<height>165</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Telemetry Simulator</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QLineEdit" name="Swr"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="3">
|
||||||
|
<widget class="QLineEdit" name="A1"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>RSSI</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QLineEdit" name="Rssi"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>A1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>SWR</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QCheckBox" name="Simulate">
|
||||||
|
<property name="text">
|
||||||
|
<string>simulate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>A2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="3">
|
||||||
|
<widget class="QLineEdit" name="A2"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
113
companion/src/simulation/trainersimu.cpp
Normal file
113
companion/src/simulation/trainersimu.cpp
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "trainersimu.h"
|
||||||
|
#include "ui_trainersimu.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
#define GBALL_SIZE 20
|
||||||
|
#define RESX 512
|
||||||
|
|
||||||
|
TrainerSimulator::TrainerSimulator(QWidget * parent, SimulatorInterface * simulator):
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TrainerSimulator),
|
||||||
|
simulator(simulator)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
leftStick = ui->leftStick;
|
||||||
|
rightStick = ui->rightStick;
|
||||||
|
|
||||||
|
setupSticks();
|
||||||
|
|
||||||
|
// resize(0, 0); // to force min height, min width
|
||||||
|
setFixedSize(width(), height());
|
||||||
|
|
||||||
|
timer = new QTimer(this);
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
||||||
|
timer->start(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
TrainerSimulator::~TrainerSimulator()
|
||||||
|
{
|
||||||
|
timer->stop();
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrainerSimulator::centerSticks()
|
||||||
|
{
|
||||||
|
if (leftStick->scene())
|
||||||
|
nodeLeft->stepToCenter();
|
||||||
|
|
||||||
|
if (rightStick->scene())
|
||||||
|
nodeRight->stepToCenter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrainerSimulator::setupSticks()
|
||||||
|
{
|
||||||
|
QGraphicsScene *leftScene = new QGraphicsScene(leftStick);
|
||||||
|
leftScene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
|
leftStick->setScene(leftScene);
|
||||||
|
|
||||||
|
// leftStick->scene()->addLine(0,10,20,30);
|
||||||
|
|
||||||
|
QGraphicsScene *rightScene = new QGraphicsScene(rightStick);
|
||||||
|
rightScene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
|
rightStick->setScene(rightScene);
|
||||||
|
|
||||||
|
// rightStick->scene()->addLine(0,10,20,30);
|
||||||
|
|
||||||
|
nodeLeft = new Node();
|
||||||
|
nodeLeft->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
|
||||||
|
nodeLeft->setBallSize(GBALL_SIZE);
|
||||||
|
leftScene->addItem(nodeLeft);
|
||||||
|
|
||||||
|
nodeRight = new Node();
|
||||||
|
nodeRight->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
|
||||||
|
nodeRight->setBallSize(GBALL_SIZE);
|
||||||
|
rightScene->addItem(nodeRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrainerSimulator::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
if (leftStick->scene()) {
|
||||||
|
QRect qr = leftStick->contentsRect();
|
||||||
|
qreal w = (qreal)qr.width() - GBALL_SIZE;
|
||||||
|
qreal h = (qreal)qr.height() - GBALL_SIZE;
|
||||||
|
qreal cx = (qreal)qr.width()/2;
|
||||||
|
qreal cy = (qreal)qr.height()/2;
|
||||||
|
leftStick->scene()->setSceneRect(-cx,-cy,w,h);
|
||||||
|
|
||||||
|
QPointF p = nodeLeft->pos();
|
||||||
|
p.setX(qMin(cx, qMax(p.x(), -cx)));
|
||||||
|
p.setY(qMin(cy, qMax(p.y(), -cy)));
|
||||||
|
nodeLeft->setPos(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightStick->scene()) {
|
||||||
|
QRect qr = rightStick->contentsRect();
|
||||||
|
qreal w = (qreal)qr.width() - GBALL_SIZE;
|
||||||
|
qreal h = (qreal)qr.height() - GBALL_SIZE;
|
||||||
|
qreal cx = (qreal)qr.width()/2;
|
||||||
|
qreal cy = (qreal)qr.height()/2;
|
||||||
|
rightStick->scene()->setSceneRect(-cx,-cy,w,h);
|
||||||
|
|
||||||
|
QPointF p = nodeRight->pos();
|
||||||
|
p.setX(qMin(cx, qMax(p.x(), -cx)));
|
||||||
|
p.setY(qMin(cy, qMax(p.y(), -cy)));
|
||||||
|
nodeRight->setPos(p);
|
||||||
|
}
|
||||||
|
QDialog::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TrainerSimulator::onTimerEvent()
|
||||||
|
{
|
||||||
|
centerSticks();
|
||||||
|
setTrainerInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrainerSimulator::setTrainerInputs()
|
||||||
|
{
|
||||||
|
simulator->setTrainerInput(0, int( 512* nodeLeft->getX())); // LEFT HORZ
|
||||||
|
simulator->setTrainerInput(1, int(-512* nodeLeft->getY())); // LEFT VERT
|
||||||
|
simulator->setTrainerInput(2, int(-512*nodeRight->getY())); // RGHT VERT
|
||||||
|
simulator->setTrainerInput(3, int( 512*nodeRight->getX())); // RGHT HORZ
|
||||||
|
}
|
46
companion/src/simulation/trainersimu.h
Normal file
46
companion/src/simulation/trainersimu.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef trainersimu_h
|
||||||
|
#define trainersimu_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTimer>
|
||||||
|
#include "modeledit/node.h"
|
||||||
|
#include "simulatorinterface.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TrainerSimulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TrainerSimulator : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TrainerSimulator(QWidget * parent, SimulatorInterface * simulator);
|
||||||
|
virtual ~TrainerSimulator();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TrainerSimulator * ui;
|
||||||
|
QTimer * timer;
|
||||||
|
SimulatorInterface *simulator;
|
||||||
|
|
||||||
|
QGraphicsView * leftStick, * rightStick;
|
||||||
|
Node *nodeLeft;
|
||||||
|
Node *nodeRight;
|
||||||
|
|
||||||
|
void centerSticks();
|
||||||
|
void setupSticks();
|
||||||
|
void resizeEvent(QResizeEvent *event = 0);
|
||||||
|
void setTrainerInputs();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTimerEvent();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
95
companion/src/simulation/trainersimu.ui
Normal file
95
companion/src/simulation/trainersimu.ui
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TrainerSimulator</class>
|
||||||
|
<widget class="QDialog" name="TrainerSimulator">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>566</width>
|
||||||
|
<height>268</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Trainer simulator</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>563</width>
|
||||||
|
<height>267</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::Panel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>17</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QGraphicsView" name="rightStick">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>245</width>
|
||||||
|
<height>245</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGraphicsView" name="leftStick">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>245</width>
|
||||||
|
<height>245</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -389,6 +389,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR))
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||||
LCDSRC = lcd_common.cpp lcd_default.cpp
|
LCDSRC = lcd_common.cpp lcd_default.cpp
|
||||||
PULSESSRC = pulses/pulses_avr.cpp
|
PULSESSRC = pulses/pulses_avr.cpp
|
||||||
|
CPPSRC += debug.cpp
|
||||||
|
|
||||||
ifeq ($(PCB), 9XR)
|
ifeq ($(PCB), 9XR)
|
||||||
FLAVOUR = 9xr
|
FLAVOUR = 9xr
|
||||||
|
@ -456,6 +457,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||||
LCDSRC = lcd_common.cpp lcd_default.cpp
|
LCDSRC = lcd_common.cpp lcd_default.cpp
|
||||||
PULSESSRC = pulses/pulses_avr.cpp
|
PULSESSRC = pulses/pulses_avr.cpp
|
||||||
|
CPPSRC += debug.cpp
|
||||||
|
|
||||||
ifeq ($(PCB), 9XR128)
|
ifeq ($(PCB), 9XR128)
|
||||||
FLAVOUR = 9xr128
|
FLAVOUR = 9xr128
|
||||||
|
@ -519,6 +521,7 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561))
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||||
LCDSRC = lcd_common.cpp lcd_default.cpp
|
LCDSRC = lcd_common.cpp lcd_default.cpp
|
||||||
PULSESSRC = pulses/pulses_avr.cpp
|
PULSESSRC = pulses/pulses_avr.cpp
|
||||||
|
CPPSRC += debug.cpp
|
||||||
|
|
||||||
ifeq ($(PCB), 9XR2561)
|
ifeq ($(PCB), 9XR2561)
|
||||||
FLAVOUR = 9xr2561
|
FLAVOUR = 9xr2561
|
||||||
|
@ -584,7 +587,7 @@ ifeq ($(PCB), GRUVIN9X)
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||||
LCDSRC = lcd_common.cpp lcd_default.cpp
|
LCDSRC = lcd_common.cpp lcd_default.cpp
|
||||||
PULSESSRC = pulses/pulses_avr.cpp
|
PULSESSRC = pulses/pulses_avr.cpp
|
||||||
CPPSRC += audio_avr.cpp haptic.cpp
|
CPPSRC += audio_avr.cpp haptic.cpp debug.cpp
|
||||||
|
|
||||||
ifeq ($(SDCARD), YES)
|
ifeq ($(SDCARD), YES)
|
||||||
CPPDEFS += -DRTCLOCK
|
CPPDEFS += -DRTCLOCK
|
||||||
|
@ -626,7 +629,7 @@ ifeq ($(PCB), MEGA2560)
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||||
LCDSRC = lcd_common.cpp lcd_default.cpp
|
LCDSRC = lcd_common.cpp lcd_default.cpp
|
||||||
PULSESSRC = pulses/pulses_avr.cpp
|
PULSESSRC = pulses/pulses_avr.cpp
|
||||||
CPPSRC += audio_avr.cpp
|
CPPSRC += audio_avr.cpp debug.cpp
|
||||||
|
|
||||||
ifeq ($(PCBREV), ST7565P)
|
ifeq ($(PCBREV), ST7565P)
|
||||||
EXTRABOARDSRC = targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp
|
EXTRABOARDSRC = targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp
|
||||||
|
@ -711,7 +714,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
||||||
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp pulses/dsm2_arm.cpp
|
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp pulses/dsm2_arm.cpp
|
||||||
CPPSRC += tasks_arm.cpp audio_arm.cpp haptic.cpp gui/view_about.cpp gui/view_text.cpp telemetry/telemetry.cpp
|
CPPSRC += tasks_arm.cpp audio_arm.cpp haptic.cpp gui/view_about.cpp gui/view_text.cpp telemetry/telemetry.cpp
|
||||||
CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/second_serial_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp
|
CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/second_serial_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp
|
||||||
CPPSRC += loadboot.cpp
|
CPPSRC += loadboot.cpp debug.cpp
|
||||||
ifeq ($(SDCARD), YES)
|
ifeq ($(SDCARD), YES)
|
||||||
CPPDEFS += -DVOICE
|
CPPDEFS += -DVOICE
|
||||||
INCDIRS += FatFs FatFs/option
|
INCDIRS += FatFs FatFs/option
|
||||||
|
@ -731,7 +734,6 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
||||||
CPPSRC += targets/sky9x/bluetooth.cpp
|
CPPSRC += targets/sky9x/bluetooth.cpp
|
||||||
endif
|
endif
|
||||||
ifeq ($(DEBUG), YES)
|
ifeq ($(DEBUG), YES)
|
||||||
CPPSRC += debug.cpp
|
|
||||||
SRC += targets/sky9x/syscalls.c
|
SRC += targets/sky9x/syscalls.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -814,7 +816,7 @@ ifeq ($(PCB), TARANIS)
|
||||||
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp
|
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp
|
||||||
CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp
|
CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp
|
||||||
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/telemetry_driver.cpp
|
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/telemetry_driver.cpp
|
||||||
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp loadboot.cpp
|
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp loadboot.cpp debug.cpp
|
||||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
|
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
|
||||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||||
|
@ -879,9 +881,6 @@ ifeq ($(PCB), TARANIS)
|
||||||
CPPDEFS += -DRTCLOCK
|
CPPDEFS += -DRTCLOCK
|
||||||
CPPSRC += rtc.cpp targets/taranis/rtc_driver.cpp
|
CPPSRC += rtc.cpp targets/taranis/rtc_driver.cpp
|
||||||
endif
|
endif
|
||||||
ifeq ($(DEBUG), YES)
|
|
||||||
CPPSRC += debug.cpp
|
|
||||||
endif
|
|
||||||
ifeq ($(DSM2), PPM)
|
ifeq ($(DSM2), PPM)
|
||||||
CPPSRC += pulses/dsm2_arm.cpp
|
CPPSRC += pulses/dsm2_arm.cpp
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -407,7 +407,7 @@ bool isAudioFileReferenced(uint32_t i, char * filename)
|
||||||
uint8_t event = i & 0xFF;
|
uint8_t event = i & 0xFF;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("isAudioFileReferenced(%08x)\n", i); fflush(stdout);
|
TRACE("isAudioFileReferenced(%08x)", i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (category == SYSTEM_AUDIO_CATEGORY) {
|
if (category == SYSTEM_AUDIO_CATEGORY) {
|
||||||
|
@ -846,7 +846,7 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
|
||||||
void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
||||||
{
|
{
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
printf("playFile(\"%s\", flags=%x, id=%d)\n", filename, flags, id);
|
TRACE("playFile(\"%s\", flags=%x, id=%d)", filename, flags, id);
|
||||||
if (strlen(filename) > AUDIO_FILENAME_MAXLEN) {
|
if (strlen(filename) > AUDIO_FILENAME_MAXLEN) {
|
||||||
TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN);
|
TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN);
|
||||||
}
|
}
|
||||||
|
@ -893,7 +893,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
||||||
void AudioQueue::stopPlay(uint8_t id)
|
void AudioQueue::stopPlay(uint8_t id)
|
||||||
{
|
{
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
printf("stopPlay(id=%d)\n", id); fflush(stdout);
|
TRACE("stopPlay(id=%d)", id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For the moment it's only needed to stop the background music
|
// For the moment it's only needed to stop the background music
|
||||||
|
|
|
@ -34,28 +34,44 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../opentx.h"
|
#include "opentx.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if !defined(SIMU) && defined(DEBUG)
|
#if (defined(DEBUG) && defined(CPUARM)) || defined(SIMU)
|
||||||
|
|
||||||
Fifo<512> debugRxFifo;
|
#if defined(SIMU)
|
||||||
|
traceCallbackFunc traceCallback = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
#define PRINTF_BUFFER_SIZE 1024
|
||||||
|
#else
|
||||||
|
#define PRINTF_BUFFER_SIZE 256
|
||||||
|
#endif
|
||||||
|
|
||||||
// Outputs a string to the UART
|
// Outputs a string to the UART
|
||||||
void debugPuts(const char *format, ...)
|
void debugPuts(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
char tmp[256];
|
char tmp[PRINTF_BUFFER_SIZE];
|
||||||
|
|
||||||
va_start(arglist, format);
|
va_start(arglist, format);
|
||||||
vsnprintf(tmp, 256, format, arglist);
|
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
fputs(tmp, stdout);
|
||||||
|
fflush(stdout);
|
||||||
|
if (traceCallback) {
|
||||||
|
traceCallback(tmp);
|
||||||
|
}
|
||||||
|
#else
|
||||||
const char *t = tmp;
|
const char *t = tmp;
|
||||||
while (*t) {
|
while (*t) {
|
||||||
debugPutc(*t++);
|
debugPutc(*t++);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump(unsigned char *data, unsigned int size)
|
void dump(unsigned char *data, unsigned int size)
|
||||||
|
@ -73,9 +89,13 @@ void dump(unsigned char *data, unsigned int size)
|
||||||
debugPuts("\n\r");
|
debugPuts("\n\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(SIMU)
|
||||||
|
|
||||||
uint32_t Mem_address ;
|
uint32_t Mem_address ;
|
||||||
uint32_t Next_mem_address ;
|
uint32_t Next_mem_address ;
|
||||||
uint32_t Memaddmode ;
|
uint32_t Memaddmode ;
|
||||||
|
Fifo<512> debugRxFifo;
|
||||||
|
|
||||||
void crlf()
|
void crlf()
|
||||||
{
|
{
|
||||||
|
@ -86,55 +106,55 @@ void crlf()
|
||||||
// Send a single 4 bit value to the RS232 port as a hex digit
|
// Send a single 4 bit value to the RS232 port as a hex digit
|
||||||
void hex_digit_send( unsigned char c )
|
void hex_digit_send( unsigned char c )
|
||||||
{
|
{
|
||||||
c &= 0x0F ;
|
c &= 0x0F ;
|
||||||
if ( c > 9 )
|
if ( c > 9 )
|
||||||
{
|
{
|
||||||
c += 7 ;
|
c += 7 ;
|
||||||
}
|
}
|
||||||
c += '0' ;
|
c += '0' ;
|
||||||
debugPutc( c ) ;
|
debugPutc( c ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the 8 bit value to the RS232 port as 2 hex digits
|
// Send the 8 bit value to the RS232 port as 2 hex digits
|
||||||
void p2hex( unsigned char c )
|
void p2hex( unsigned char c )
|
||||||
{
|
{
|
||||||
// asm("swap %c") ;
|
// asm("swap %c") ;
|
||||||
hex_digit_send( c >> 4 ) ;
|
hex_digit_send( c >> 4 ) ;
|
||||||
// asm("swap %c") ;
|
// asm("swap %c") ;
|
||||||
hex_digit_send( c ) ;
|
hex_digit_send( c ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the 16 bit value to the RS232 port as 4 hex digits
|
// Send the 16 bit value to the RS232 port as 4 hex digits
|
||||||
void p4hex( uint16_t value )
|
void p4hex( uint16_t value )
|
||||||
{
|
{
|
||||||
p2hex( value >> 8 ) ;
|
p2hex( value >> 8 ) ;
|
||||||
p2hex( value ) ;
|
p2hex( value ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the 32 bit value to the RS232 port as 8 hex digits
|
// Send the 32 bit value to the RS232 port as 8 hex digits
|
||||||
void p8hex( uint32_t value )
|
void p8hex( uint32_t value )
|
||||||
{
|
{
|
||||||
p4hex( value >> 16 ) ;
|
p4hex( value >> 16 ) ;
|
||||||
p4hex( value ) ;
|
p4hex( value ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dispw_256( register uint32_t address, register uint32_t lines )
|
static void dispw_256( register uint32_t address, register uint32_t lines )
|
||||||
{
|
{
|
||||||
register uint32_t i ;
|
register uint32_t i ;
|
||||||
register uint32_t j ;
|
register uint32_t j ;
|
||||||
address &= 0xFFFFFFFC ;
|
address &= 0xFFFFFFFC ;
|
||||||
for ( i = 0 ; i < lines ; i += 1 )
|
for ( i = 0 ; i < lines ; i += 1 )
|
||||||
{
|
{
|
||||||
p8hex( address ) ;
|
p8hex( address ) ;
|
||||||
for ( j = 0 ; j < 4 ; j += 1 )
|
for ( j = 0 ; j < 4 ; j += 1 )
|
||||||
{
|
{
|
||||||
debugPutc(' ') ;
|
debugPutc(' ') ;
|
||||||
p8hex( *( (uint32_t *)address ) ) ;
|
p8hex( *( (uint32_t *)address ) ) ;
|
||||||
address += 4 ;
|
address += 4 ;
|
||||||
}
|
}
|
||||||
crlf() ;
|
crlf() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern Fifo<512> uart3TxFifo;
|
extern Fifo<512> uart3TxFifo;
|
||||||
|
@ -221,7 +241,8 @@ void debugTask(void* pdata)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // #if !defined(SIMU)
|
||||||
|
#endif // #if (defined(DEBUG) && defined(CPUARM)) || defined(SIMU)
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG_TRACE_BUFFER)
|
#if defined(DEBUG_TRACE_BUFFER)
|
||||||
|
|
|
@ -40,44 +40,17 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if (defined(DEBUG) && defined(CPUARM)) || defined(SIMU)
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define TRACE(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_DEBUG(...) do { printf("-D- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_DEBUG_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_INFO(...) do { printf("-I- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_INFO_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_WARNING(...) do { printf("-W- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_WARNING_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define TRACE_ERROR(...) do { printf("-E- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
||||||
#define FLUSH()
|
|
||||||
|
|
||||||
inline void dump(void * data, unsigned int size)
|
|
||||||
{
|
|
||||||
unsigned char *uchar_data = (unsigned char *)data;
|
|
||||||
|
|
||||||
printf("DUMP %d bytes ...\n\r", size);
|
|
||||||
unsigned int i = 0, j=0;
|
|
||||||
while (i*32+j < size) {
|
|
||||||
printf("%.2X ", uchar_data[i*32+j]);
|
|
||||||
j++;
|
|
||||||
if (j==32) {
|
|
||||||
i++; j=0;
|
|
||||||
printf("\n\r");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n\r");
|
|
||||||
}
|
|
||||||
#define DUMP(data, size) dump(data, size)
|
|
||||||
|
|
||||||
#elif defined(DEBUG) && defined(CPUARM)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
typedef void (*traceCallbackFunc)(const char * text);
|
||||||
|
extern traceCallbackFunc traceCallback;
|
||||||
|
#endif
|
||||||
|
|
||||||
void debugPuts(const char *string, ...);
|
void debugPuts(const char *string, ...);
|
||||||
void dump(unsigned char *data, unsigned int size);
|
void dump(unsigned char *data, unsigned int size);
|
||||||
void debugFlush();
|
void debugFlush();
|
||||||
|
@ -95,8 +68,13 @@ void debugFlush();
|
||||||
#define TRACE_WARNING(...) debugPuts("-W- " __VA_ARGS__)
|
#define TRACE_WARNING(...) debugPuts("-W- " __VA_ARGS__)
|
||||||
#define TRACE_WARNING_WP(...) debugPuts(__VA_ARGS__)
|
#define TRACE_WARNING_WP(...) debugPuts(__VA_ARGS__)
|
||||||
#define TRACE_ERROR(...) debugPuts("-E- " __VA_ARGS__)
|
#define TRACE_ERROR(...) debugPuts("-E- " __VA_ARGS__)
|
||||||
|
|
||||||
|
#if !defined(SIMU)
|
||||||
#define FLUSH() debugFlush();
|
#define FLUSH() debugFlush();
|
||||||
void debugTask(void* pdata);
|
void debugTask(void* pdata);
|
||||||
|
#else
|
||||||
|
#define FLUSH()
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -293,12 +293,10 @@ inline bool EeFsOpen()
|
||||||
|
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
if (eeFs.version != EEFS_VERS) {
|
if (eeFs.version != EEFS_VERS) {
|
||||||
printf("bad eeFs.version (%d instead of %d)\n", eeFs.version, EEFS_VERS);
|
TRACE("bad eeFs.version (%d instead of %d)", eeFs.version, EEFS_VERS);
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
if (eeFs.mySize != sizeof(eeFs)) {
|
if (eeFs.mySize != sizeof(eeFs)) {
|
||||||
printf("bad eeFs.mySize (%d instead of %d)\n", (int)eeFs.mySize, (int)sizeof(eeFs));
|
TRACE("bad eeFs.mySize (%d instead of %d)", (int)eeFs.mySize, (int)sizeof(eeFs));
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -605,7 +603,7 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
||||||
strcpy_P(&buf[len], STR_MODELS_EXT);
|
strcpy_P(&buf[len], STR_MODELS_EXT);
|
||||||
|
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
printf("SD-card backup filename=%s\n", buf); fflush(stdout);
|
TRACE("SD-card backup filename=%s", buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = f_open(&g_oLogFile, buf, FA_CREATE_ALWAYS | FA_WRITE);
|
result = f_open(&g_oLogFile, buf, FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
|
|
|
@ -116,7 +116,7 @@ void perMain()
|
||||||
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on
|
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on
|
||||||
checkBacklight();
|
checkBacklight();
|
||||||
|
|
||||||
#if (defined(FRSKY) || defined(MAVLINK))
|
#if defined(FRSKY) || defined(MAVLINK) || defined(SIMU)
|
||||||
telemetryWakeup();
|
telemetryWakeup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ void getGpsPilotPosition()
|
||||||
uint32_t angle2 = (lat*lat) / 10000;
|
uint32_t angle2 = (lat*lat) / 10000;
|
||||||
uint32_t angle4 = angle2 * angle2;
|
uint32_t angle4 = angle2 * angle2;
|
||||||
frskyData.hub.distFromEarthAxis = 139*(((uint32_t)10000000-((angle2*(uint32_t)123370)/81)+(angle4/25))/12500);
|
frskyData.hub.distFromEarthAxis = 139*(((uint32_t)10000000-((angle2*(uint32_t)123370)/81)+(angle4/25))/12500);
|
||||||
// printf("frskyData.hub.distFromEarthAxis=%d\n", frskyData.hub.distFromEarthAxis); fflush(stdout);
|
// TRACE("frskyData.hub.distFromEarthAxis=%d", frskyData.hub.distFromEarthAxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getGpsDistance()
|
void getGpsDistance()
|
||||||
|
|
|
@ -159,7 +159,7 @@ void simuSetKey(uint8_t key, bool state)
|
||||||
|
|
||||||
void simuSetTrim(uint8_t trim, bool state)
|
void simuSetTrim(uint8_t trim, bool state)
|
||||||
{
|
{
|
||||||
// printf("trim=%d state=%d\n", trim, state); fflush(stdout);
|
// TRACE("trim=%d state=%d", trim, state);
|
||||||
|
|
||||||
switch (trim) {
|
switch (trim) {
|
||||||
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
||||||
|
@ -176,7 +176,7 @@ void simuSetTrim(uint8_t trim, bool state)
|
||||||
// TODO use a better numbering to allow google tests to work on Taranis
|
// TODO use a better numbering to allow google tests to work on Taranis
|
||||||
void simuSetSwitch(uint8_t swtch, int8_t state)
|
void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||||
{
|
{
|
||||||
// printf("swtch=%d state=%d\n", swtch, state); fflush(stdout);
|
// TRACE("swtch=%d state=%d", swtch, state);
|
||||||
switch (swtch) {
|
switch (swtch) {
|
||||||
#if defined(PCBTARANIS) && defined(REV9E)
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H)
|
SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H)
|
||||||
|
@ -443,7 +443,7 @@ void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t si
|
||||||
assert(size);
|
assert(size);
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
// printf("EEPROM read (pos=%d, size=%d)\n", pointer_eeprom, size); fflush(stdout);
|
// TRACE("EEPROM read (pos=%d, size=%d)", pointer_eeprom, size);
|
||||||
if (fseek(fp, (long)pointer_eeprom, SEEK_SET)==-1) perror("error in fseek");
|
if (fseek(fp, (long)pointer_eeprom, SEEK_SET)==-1) perror("error in fseek");
|
||||||
if (fread(pointer_ram, size, 1, fp) <= 0) perror("error in fread");
|
if (fread(pointer_ram, size, 1, fp) <= 0) perror("error in fread");
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t si
|
||||||
assert(size);
|
assert(size);
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
// printf("EEPROM write (pos=%d, size=%d)\n", pointer_eeprom, size); fflush(stdout);
|
// TRACE("EEPROM write (pos=%d, size=%d)", pointer_eeprom, size);
|
||||||
if (fseek(fp, (long)pointer_eeprom, SEEK_SET)==-1) perror("error in fseek");
|
if (fseek(fp, (long)pointer_eeprom, SEEK_SET)==-1) perror("error in fseek");
|
||||||
if (fwrite(pointer_ram, size, 1, fp) <= 0) perror("error in fwrite");
|
if (fwrite(pointer_ram, size, 1, fp) <= 0) perror("error in fwrite");
|
||||||
}
|
}
|
||||||
|
@ -623,7 +623,7 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil)
|
||||||
|
|
||||||
FRESULT f_mkfs (const TCHAR *path, BYTE, UINT)
|
FRESULT f_mkfs (const TCHAR *path, BYTE, UINT)
|
||||||
{
|
{
|
||||||
printf("Format SD...\n"); fflush(stdout);
|
TRACE("Format SD...");
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ uint32_t readKeys()
|
||||||
result |= 0x02 << KEY_MENU;
|
result |= 0x02 << KEY_MENU;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// printf("readKeys(): %x => %x\n", x, result); fflush(stdout);
|
// TRACE("readKeys(): %x => %x", x, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,8 +181,10 @@ uint32_t telemetryTransmitPending()
|
||||||
|
|
||||||
void telemetryPortInit(uint32_t baudrate)
|
void telemetryPortInit(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
|
#if !defined(SIMU)
|
||||||
UART2_Configure(baudrate, Master_frequency);
|
UART2_Configure(baudrate, Master_frequency);
|
||||||
startPdcUsartReceive();
|
startPdcUsartReceive();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size)
|
void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size)
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct t_voice Voice ;
|
||||||
void pushPrompt(uint16_t value)
|
void pushPrompt(uint16_t value)
|
||||||
{
|
{
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
printf("playFile(\"%04d.ad4\")\n", value); fflush(stdout);
|
TRACE("playFile(\"%04d.ad4\")", value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct t_voice *vptr;
|
struct t_voice *vptr;
|
||||||
|
|
|
@ -72,7 +72,7 @@ uint32_t readKeys()
|
||||||
if (d & PIN_BUTTON_EXIT)
|
if (d & PIN_BUTTON_EXIT)
|
||||||
result |= 0x02 << KEY_EXIT;
|
result |= 0x02 << KEY_EXIT;
|
||||||
|
|
||||||
// printf("readKeys(): %x %x => %x\n", d, e, result); fflush(stdout);
|
// TRACE("readKeys(): %x %x => %x", d, e, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ uint32_t readTrims()
|
||||||
if (~c & PIN_TRIM_RH_R)
|
if (~c & PIN_TRIM_RH_R)
|
||||||
result |= 0x80; // RH_R
|
result |= 0x80; // RH_R
|
||||||
|
|
||||||
// printf("readTrims(): %x %x => %x\n", c, e, result); fflush(stdout);
|
// TRACE("readTrims(): %x %x => %x", c, e, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ void mixerTask(void * pdata)
|
||||||
doMixerCalculations();
|
doMixerCalculations();
|
||||||
CoLeaveMutexSection(mixerMutex);
|
CoLeaveMutexSection(mixerMutex);
|
||||||
|
|
||||||
#if defined(FRSKY) || defined(MAVLINK)
|
#if defined(FRSKY) || defined(MAVLINK) || defined(SIMU)
|
||||||
telemetryWakeup();
|
telemetryWakeup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ bool checkSportPacket(uint8_t *packet)
|
||||||
crc += crc >> 8; // 0-1FF
|
crc += crc >> 8; // 0-1FF
|
||||||
crc &= 0x00ff; // 0-FF
|
crc &= 0x00ff; // 0-FF
|
||||||
}
|
}
|
||||||
|
// TRACE("crc: 0x%02x", crc);
|
||||||
return (crc == 0x00ff);
|
return (crc == 0x00ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +104,8 @@ void processSportPacket(uint8_t *packet)
|
||||||
uint16_t appId = *((uint16_t *)(packet+2));
|
uint16_t appId = *((uint16_t *)(packet+2));
|
||||||
|
|
||||||
if (!checkSportPacket(packet)) {
|
if (!checkSportPacket(packet)) {
|
||||||
|
TRACE("processSportPacket(): checksumm error ");
|
||||||
|
DUMP(packet, FRSKY_SPORT_PACKET_SIZE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue