summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-09 16:21:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-09 16:21:32 +0200
commitfd0ad89c7c6f61aa14d6e908e9217121f4afa5c6 (patch)
tree5274ef7761b249c5ee48a823a48b2c744c4df593
parente6fb571266c22f120c0111731da1f2e6bf4d812d (diff)
tracker/hatire: move to opentrack settings API
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat.cpp71
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat.h30
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat_dialog.cpp270
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat_dialog.h50
-rwxr-xr-xtracker-hatire/ftnoir_tracker_hat_settings.cpp134
-rwxr-xr-x[-rw-r--r--]tracker-hatire/ftnoir_tracker_hat_settings.h109
-rwxr-xr-xtracker-hatire/thread.cpp47
-rwxr-xr-xtracker-hatire/thread.hpp54
8 files changed, 164 insertions, 601 deletions
diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp
index 2dc35b3b..b3b9c433 100755
--- a/tracker-hatire/ftnoir_tracker_hat.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat.cpp
@@ -25,8 +25,6 @@ hatire::hatire()
Begin.append((char) 0xAA);
End.append((char) 0x55);
End.append((char) 0x55);
-
- settings.load_ini();
}
hatire::~hatire()
@@ -36,7 +34,7 @@ hatire::~hatire()
//send RESET to Arduino
void hatire::reset()
{
- t.sendcmd(ts.sCmdReset);
+ t.sendcmd_str(s.CmdReset);
}
// return FPS
@@ -49,8 +47,6 @@ void hatire::start_tracker(QFrame*)
{
CptError=0;
frame_cnt=0;
- settings.load_ini();
- applysettings(settings);
t.Log("Starting Tracker");
serial_result ret = t.init_serial_port();
@@ -67,7 +63,7 @@ void hatire::start_tracker(QFrame*)
break;
}
- t.start(ts);
+ t.start();
}
void hatire::serial_info()
@@ -99,7 +95,7 @@ void hatire::data(double *data)
{
QDataStream stream(&data_read, QIODevice::ReadOnly);
- if (ts.bBigEndian)
+ if (s.BigEndian)
stream.setByteOrder(QDataStream::BigEndian);
else
stream.setByteOrder(QDataStream::LittleEndian);
@@ -159,12 +155,12 @@ void hatire::data(double *data)
double& place;
} spec[] =
{
- { bEnableX, bInvertX, HAT.Trans[iXAxis], data[TX] },
- { bEnableY, bInvertY, HAT.Trans[iYAxis], data[TY] },
- { bEnableZ, bInvertZ, HAT.Trans[iZAxis], data[TZ] },
- { bEnableYaw, bInvertYaw, HAT.Rot[iYawAxis], data[Yaw] },
- { bEnablePitch, bInvertPitch, HAT.Rot[iPitchAxis], data[Pitch] },
- { bEnableRoll, bInvertRoll, HAT.Rot[iRollAxis], data[Roll] },
+ { s.EnableX, s.InvertX, HAT.Trans[s.XAxis], data[TX] },
+ { s.EnableY, s.InvertY, HAT.Trans[s.YAxis], data[TY] },
+ { s.EnableZ, s.InvertZ, HAT.Trans[s.ZAxis], data[TZ] },
+ { s.EnableYaw, s.InvertYaw, HAT.Rot[s.YawAxis], data[Yaw] },
+ { s.EnablePitch, s.InvertPitch, HAT.Rot[s.PitchAxis], data[Pitch] },
+ { s.EnableRoll, s.InvertRoll, HAT.Rot[s.RollAxis], data[Roll] },
};
for (unsigned i = 0; i < sizeof(spec) / sizeof(*spec); i++)
@@ -178,55 +174,6 @@ void hatire::data(double *data)
//data->y=CptError;
}
-//
-// Apply modification Settings
-//
-void hatire::applysettings(const TrackerSettings& settings)
-{
- ts.sSerialPortName = settings.SerialPortName;
-
- bEnableRoll = settings.EnableRoll;
- bEnablePitch = settings.EnablePitch;
- bEnableYaw = settings.EnableYaw;
- bEnableX = settings.EnableX;
- bEnableY = settings.EnableY;
- bEnableZ = settings.EnableZ;
-
- bInvertRoll = settings.InvertRoll;
- bInvertPitch = settings.InvertPitch;
- bInvertYaw = settings.InvertYaw;
- bInvertX = settings.InvertX;
- bInvertY = settings.InvertY;
- bInvertZ = settings.InvertZ;
- ts.bEnableLogging = settings.EnableLogging;
-
- iRollAxis= settings.RollAxis;
- iPitchAxis= settings.PitchAxis;
- iYawAxis= settings.YawAxis;
- iXAxis= settings.XAxis;
- iYAxis= settings.YAxis;
- iZAxis= settings.ZAxis;
-
- ts.iBaudRate=settings.pBaudRate;
- ts.iDataBits=settings.pDataBits;
- ts.iParity=settings.pParity;
- ts.iStopBits=settings.pStopBits;
- ts.iFlowControl=settings.pFlowControl;
-
- ts.sCmdStart= settings.CmdStart.toLatin1();
- ts.sCmdStop= settings.CmdStop.toLatin1();
- ts.sCmdInit= settings.CmdInit.toLatin1();
- ts.sCmdReset= settings.CmdReset.toLatin1();
- ts.sCmdCenter= settings.CmdCenter.toLatin1();
- ts.sCmdZero= settings.CmdZero.toLatin1();
- ts.iDelayInit=settings.DelayInit;
- ts.iDelayStart=settings.DelayStart;
- ts.iDelaySeq=settings.DelaySeq;
- ts.bBigEndian=settings.BigEndian;
-
- t.update_serial_settings(ts);
-}
-
#include "ftnoir_tracker_hat_dialog.h"
OPENTRACK_DECLARE_TRACKER(hatire, TrackerControls, TrackerDll)
diff --git a/tracker-hatire/ftnoir_tracker_hat.h b/tracker-hatire/ftnoir_tracker_hat.h
index e951c69f..36d56594 100755
--- a/tracker-hatire/ftnoir_tracker_hat.h
+++ b/tracker-hatire/ftnoir_tracker_hat.h
@@ -27,48 +27,26 @@ public:
void start_tracker(QFrame*);
void data(double *data);
//void center();
- void applysettings(const TrackerSettings& settings);
//bool notifyZeroed();
void reset();
void get_info( int *tps );
void serial_info();
void send_serial_command(const QByteArray& x);
+ hatire_thread t;
private:
TArduinoData ArduinoData, HAT;
QByteArray Begin;
QByteArray End;
- hatire_thread t;
- thread_settings ts;
-
// XXX move to settings api -sh 20160410
- TrackerSettings settings;
+ TrackerSettings s;
int frame_cnt;
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
- bool bInvertRoll;
- bool bInvertPitch;
- bool bInvertYaw;
- bool bInvertX;
- bool bInvertY;
- bool bInvertZ;
-
- int iRollAxis;
- int iPitchAxis;
- int iYawAxis;
- int iXAxis;
- int iYAxis;
- int iZAxis;
-
volatile int CptError;
+
+ static inline QByteArray to_latin1(const QString& str) { return str.toLatin1(); }
};
class TrackerDll : public Metadata
diff --git a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
index 6bec65ce..60ddd14a 100755
--- a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
@@ -13,35 +13,18 @@
#include <QScrollBar>
-TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this)
+TrackerControls::TrackerControls() : theTracker(nullptr), timer(this)
{
- // TODO move to settings api -sh 20160504
-
- ui.setupUi( this );
- settings.load_ini();
+ ui.setupUi(this);
ui.label_version->setText(VER_FILEVERSION_STR);
// make SerialPort list
ui.cbSerialPort->clear();
- foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) {
- ui.cbSerialPort->addItem(PortInfo.portName());
+ for (const QSerialPortInfo& port_info : QSerialPortInfo::availablePorts() ) {
+ ui.cbSerialPort->addItem(port_info.portName());
}
- // Stop if no SerialPort dispo
- if (ui.cbSerialPort->count()<1) {
- QMessageBox::critical(this,"Error", "No SerialPort avaible");
- } else {
-
- int indxport =ui.cbSerialPort->findText(settings.SerialPortName,Qt::MatchExactly );
- if (indxport!=-1) {
- ui.cbSerialPort->setCurrentIndex(indxport);
- } else {
- if (settings.SerialPortName != "")
- QMessageBox::warning(this,"Error", "Selected SerialPort modified");
- ui.cbSerialPort-> setCurrentIndex(indxport);
- }
- }
// Serial config
ui.QCB_Serial_baudRate->clear();
ui.QCB_Serial_baudRate->addItem(QLatin1String("9600"),QSerialPort::Baud9600);
@@ -49,14 +32,12 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
ui.QCB_Serial_baudRate->addItem(QLatin1String("38400"),QSerialPort::Baud38400);
ui.QCB_Serial_baudRate->addItem(QLatin1String("57600"),QSerialPort:: Baud57600);
ui.QCB_Serial_baudRate->addItem(QLatin1String("115200"),QSerialPort::Baud115200);
- ui.QCB_Serial_baudRate->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate));
ui.QCB_Serial_dataBits->clear();
ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5);
ui.QCB_Serial_dataBits->addItem(QLatin1String("6"), QSerialPort::Data6);
ui.QCB_Serial_dataBits->addItem(QLatin1String("7"), QSerialPort::Data7);
ui.QCB_Serial_dataBits->addItem(QLatin1String("8"), QSerialPort::Data8);
- ui.QCB_Serial_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits));
ui.QCB_Serial_parity->clear();
ui.QCB_Serial_parity->addItem(QLatin1String("None"), QSerialPort::NoParity);
@@ -64,108 +45,61 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
ui.QCB_Serial_parity->addItem(QLatin1String("Odd"), QSerialPort::OddParity);
ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity);
ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity);
- ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity));
ui.QCB_Serial_stopBits->clear();
ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop);
ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop);
ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop);
- ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits));
-
ui.QCB_Serial_flowControl->clear();
ui.QCB_Serial_flowControl->addItem(QLatin1String("None"), QSerialPort::NoFlowControl);
ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl);
ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl);
- ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl));
-
-
- ui.chkEnableRoll->setChecked(settings.EnableRoll);
- ui.chkEnablePitch->setChecked(settings.EnablePitch);
- ui.chkEnableYaw->setChecked(settings.EnableYaw);
- ui.chkEnableX->setChecked(settings.EnableX);
- ui.chkEnableY->setChecked(settings.EnableY);
- ui.chkEnableZ->setChecked(settings.EnableZ);
-
- ui.chkInvertRoll->setChecked(settings.InvertRoll);
- ui.chkInvertPitch->setChecked(settings.InvertPitch);
- ui.chkInvertYaw->setChecked(settings.InvertYaw);
- ui.chkInvertX->setChecked(settings.InvertX);
- ui.chkInvertY->setChecked(settings.InvertY);
- ui.chkInvertZ->setChecked(settings.InvertZ);
-
- ui.chkEnableLogging->setChecked(settings.EnableLogging);
-
-
- ui.cb_roll->setCurrentIndex(settings.RollAxis);
- ui.cb_pitch->setCurrentIndex(settings.PitchAxis);
- ui.cb_yaw->setCurrentIndex(settings.YawAxis);
- ui.cb_x->setCurrentIndex(settings.XAxis);
- ui.cb_y->setCurrentIndex(settings.YAxis);
- ui.cb_z->setCurrentIndex(settings.ZAxis);
-
- ui.le_cmd_start->setText(settings.CmdStart);
- ui.le_cmd_stop->setText(settings.CmdStop);
- ui.le_cmd_init->setText(settings.CmdInit);
- ui.le_cmd_reset->setText(settings.CmdReset);
- ui.le_cmd_center->setText(settings.CmdCenter);
- ui.le_cmd_zero->setText(settings.CmdZero);
-
- ui.spb_BeforeInit->setValue(settings.DelayInit);
- ui.spb_BeforeStart->setValue(settings.DelayStart);
- ui.spb_AfterStart->setValue(settings.DelaySeq);
-
- ui.cb_Endian->setChecked(settings.BigEndian);
-
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave()));
-
-
- connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) );
-
- connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
- connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) );
- connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) );
- connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) );
- connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) );
- connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) );
-
- connect( ui.chkInvertRoll,SIGNAL(toggled(bool)), this,SLOT(set_inv_roll(bool)) );
- connect( ui.chkInvertPitch,SIGNAL(toggled(bool)), this,SLOT(set_inv_pitch(bool)) );
- connect( ui.chkInvertYaw,SIGNAL(toggled(bool)), this,SLOT(set_inv_yaw(bool)) );
- connect( ui.chkInvertX,SIGNAL(toggled(bool)), this,SLOT(set_inv_x(bool)) );
- connect( ui.chkInvertY,SIGNAL(toggled(bool)), this,SLOT(set_inv_y(bool)) );
- connect( ui.chkInvertZ,SIGNAL(toggled(bool)), this,SLOT(set_inv_z(bool)) );
- connect( ui.chkEnableLogging,SIGNAL(toggled(bool)), this,SLOT(set_diag_logging(bool)) );
-
- connect(ui.cb_roll, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_roll(int)));
- connect(ui.cb_pitch, SIGNAL(currentIndexChanged(int)),this,SLOT(set_rot_pitch(int)));
- connect(ui.cb_yaw, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_yaw(int)));
- connect(ui.cb_x, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_x(int)));
- connect(ui.cb_y, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_y(int)));
- connect(ui.cb_z, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_z(int)));
-
- connect(ui.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString)));
- connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString)));
- connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString)));
- connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString)));
- connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString)));
- connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString)));
-
- connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int)));
- connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int)));
- connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int)));
-
- connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) );
-
-
- connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) );
- connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) );
- connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) );
- connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) );
- connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) );
+
+ tie_setting(s.EnableYaw, ui.chkEnableYaw);
+ tie_setting(s.EnablePitch, ui.chkEnablePitch);
+ tie_setting(s.EnableRoll, ui.chkEnableRoll);
+ tie_setting(s.EnableX, ui.chkEnableX);
+ tie_setting(s.EnableY, ui.chkEnableY);
+ tie_setting(s.EnableZ, ui.chkEnableZ);
+
+ tie_setting(s.InvertYaw, ui.chkInvertYaw);
+ tie_setting(s.InvertPitch, ui.chkInvertPitch);
+ tie_setting(s.InvertRoll, ui.chkInvertRoll);
+ tie_setting(s.InvertX, ui.chkInvertX);
+ tie_setting(s.InvertY, ui.chkInvertY);
+ tie_setting(s.InvertZ, ui.chkInvertZ);
+
+ tie_setting(s.EnableLogging, ui.chkEnableLogging);
+
+ tie_setting(s.YawAxis, ui.cb_yaw);
+ tie_setting(s.PitchAxis, ui.cb_pitch);
+ tie_setting(s.RollAxis, ui.cb_roll);
+ tie_setting(s.XAxis, ui.cb_x);
+ tie_setting(s.YAxis, ui.cb_y);
+ tie_setting(s.ZAxis, ui.cb_z);
+
+ tie_setting(s.CmdStart, ui.le_cmd_start);
+ tie_setting(s.CmdStop, ui.le_cmd_stop);
+ tie_setting(s.CmdInit, ui.le_cmd_init);
+ tie_setting(s.CmdReset, ui.le_cmd_reset);
+ tie_setting(s.CmdCenter, ui.le_cmd_center);
+ tie_setting(s.CmdZero, ui.le_cmd_zero);
+
+ tie_setting(s.DelayInit, ui.spb_BeforeInit);
+ tie_setting(s.DelayStart, ui.spb_BeforeStart);
+ tie_setting(s.DelaySeq, ui.spb_AfterStart);
+
+ tie_setting(s.BigEndian, ui.cb_Endian);
+
+ tie_setting(s.pBaudRate, ui.QCB_Serial_baudRate);
+ tie_setting(s.pDataBits, ui.QCB_Serial_dataBits);
+ tie_setting(s.pFlowControl, ui.QCB_Serial_flowControl);
+ tie_setting(s.pParity, ui.QCB_Serial_parity);
+ tie_setting(s.pStopBits, ui.QCB_Serial_stopBits);
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset()));
//connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter()));
@@ -180,16 +114,11 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
//connect(ui.lineSend,SIGNAL(keyPressEvent),this,SLOT(on_lineSend_returnPressed()) );
}
-//
-// Destructor for server-dialog
-//
TrackerControls::~TrackerControls() {
}
-//
-// Initialize tracker-client-dialog
-//
-void TrackerControls::Initialize(QWidget *parent) {
+void TrackerControls::Initialize(QWidget *parent)
+{
QPoint offsetpos(100, 100);
if (parent) {
this->move(parent->pos() + offsetpos);
@@ -198,15 +127,6 @@ void TrackerControls::Initialize(QWidget *parent) {
}
//
-// Apply online settings to tracker
-//
-void TrackerControls::settings_changed()
-{
- settingsDirty = true;
- if (theTracker) theTracker->applysettings(settings);
-}
-
-//
// Zero asked to ARDUINO
//
void TrackerControls::doZero() {
@@ -260,7 +180,6 @@ void TrackerControls::poll_tracker_info()
ui.lab_vtps->setText(QString::number(frame_cnt*(1000/last_time.elapsed())));
last_time.restart();
}
-
}
void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
@@ -272,104 +191,41 @@ void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
bar->setValue(bar->maximum());
}
-void TrackerControls::doSave() {
- settingsDirty=false;
- settings.save_ini();
-}
-
-//
-// OK clicked on server-dialog
-//
-void TrackerControls::doOK() {
- settingsDirty=false;
- settings.save_ini();
- this->close();
+void TrackerControls::doOK()
+{
+ s.b->save();
+ close();
}
-//
-// Cancel clicked on server-dialog
-//
-void TrackerControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
- switch (ret) {
- case QMessageBox::Save:
- settings.save_ini();
- close();
- break;
- case QMessageBox::Discard:
- close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- close();
- }
+void TrackerControls::doCancel()
+{
+ s.b->reload();
+ close();
}
-#ifdef OPENTRACK_API
void TrackerControls::register_tracker(ITracker *tracker)
-#else
-void TrackerControls::registerTracker(ITracker *tracker)
-#endif
{
theTracker = static_cast<hatire*>(tracker);
- connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray)));
-
- if (isVisible() && settingsDirty) theTracker->applysettings(settings);
+ connect(&theTracker->t, SIGNAL(serial_debug_info(QByteArray)), this, SLOT(WriteMsgInfo(QByteArray)));
ui.cbSerialPort->setEnabled(false);
ui.btnZero->setEnabled(true);
- ui.btnCenter->setEnabled(true);
+ //ui.btnCenter->setEnabled(true);
ui.btnReset->setEnabled(true);
ui.pteINFO->clear();
ui.lab_vstatus->setText("HAT START");
last_time.start();
timer.start(250);
-
}
-#ifdef OPENTRACK_API
void TrackerControls::unregister_tracker()
-#else
-void TrackerControls::unRegisterTracker()
-#endif
{
timer.stop();
- theTracker=NULL;
+ theTracker = nullptr;
ui.cbSerialPort->setEnabled(true);
ui.btnZero->setEnabled(false);
- ui.btnCenter->setEnabled(false);
+ //ui.btnCenter->setEnabled(false);
ui.btnReset->setEnabled(false);
ui.lab_vstatus->setText("HAT STOPPED");
ui.lab_vtps->setText("");
}
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-#ifdef OPENTRACK_API
-#else
-#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
-{
- return new TrackerControls;
-}
-#endif
-
diff --git a/tracker-hatire/ftnoir_tracker_hat_dialog.h b/tracker-hatire/ftnoir_tracker_hat_dialog.h
index f1c16219..b93c4301 100755
--- a/tracker-hatire/ftnoir_tracker_hat_dialog.h
+++ b/tracker-hatire/ftnoir_tracker_hat_dialog.h
@@ -28,54 +28,8 @@ private:
public slots:
void WriteMsgInfo(const QByteArray &MsgInfo);
-protected slots:
- void set_mod_port(const QString & val) { settings.SerialPortName =val; settings_changed(); }
- void set_ena_roll(bool val) { settings.EnableRoll = val; settings_changed(); }
- void set_ena_pitch(bool val) { settings.EnablePitch = val; settings_changed(); }
- void set_ena_yaw(bool val) { settings.EnableYaw = val; settings_changed(); }
- void set_ena_x(bool val) { settings.EnableX = val; settings_changed(); }
- void set_ena_y(bool val) { settings.EnableY = val; settings_changed(); }
- void set_ena_z(bool val) { settings.EnableZ = val; settings_changed(); }
-
- void set_inv_roll(bool val) { settings.InvertRoll = val; settings_changed(); }
- void set_inv_pitch(bool val) { settings.InvertPitch = val; settings_changed(); }
- void set_inv_yaw(bool val) { settings.InvertYaw = val; settings_changed(); }
- void set_inv_x(bool val) { settings.InvertX = val; settings_changed(); }
- void set_inv_y(bool val) { settings.InvertY = val; settings_changed(); }
- void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); }
-
- void set_diag_logging(bool val) { settings.EnableLogging = val; settings_changed(); }
-
-
- void set_rot_roll(int val) { settings.RollAxis = val; settings_changed(); }
- void set_rot_pitch(int val) { settings.PitchAxis = val; settings_changed(); }
- void set_rot_yaw(int val) { settings.YawAxis = val; settings_changed(); }
- void set_acc_x(int val) { settings.XAxis = val; settings_changed(); }
- void set_acc_y(int val) { settings.YAxis = val; settings_changed(); }
- void set_acc_z(int val) { settings.ZAxis = val; settings_changed(); }
-
- void set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); }
- void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); }
- void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); }
- void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); }
- void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); }
- void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); }
-
- void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); }
- void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); }
- void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); }
-
- void set_endian(bool val) { settings.BigEndian = val; settings_changed(); }
-
- void set_mod_baud(int val) { settings.pBaudRate = static_cast<QSerialPort::BaudRate>(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_dataBits(int val) { settings.pDataBits = static_cast<QSerialPort::DataBits>(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_parity(int val) { settings.pParity = static_cast<QSerialPort::Parity>(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_stopBits(int val) { settings.pStopBits = static_cast<QSerialPort::StopBits>(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); }
- void set_mod_flowControl(int val) { settings.pFlowControl = static_cast<QSerialPort::FlowControl>(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); }
-
void doOK();
void doCancel();
- void doSave();
void doReset();
//void doCenter();
void doZero();
@@ -84,9 +38,7 @@ protected slots:
void doSerialInfo();
protected:
- bool settingsDirty;
- void settings_changed();
- TrackerSettings settings;
+ TrackerSettings s;
QTimer timer;
private slots:
diff --git a/tracker-hatire/ftnoir_tracker_hat_settings.cpp b/tracker-hatire/ftnoir_tracker_hat_settings.cpp
deleted file mode 100755
index 8da5c1c6..00000000
--- a/tracker-hatire/ftnoir_tracker_hat_settings.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Homepage http://facetracknoir.sourceforge.net/home/default.htm *
- * *
- * ISC License (ISC) *
- * *
- * Copyright (c) 2015, Wim Vriend *
- * *
- * Permission to use, copy, modify, and/or distribute this software for any *
- * purpose with or without fee is hereby granted, provided that the above *
- * copyright notice and this permission notice appear in all copies. *
- */
-#include <QCoreApplication>
-#include <QSettings>
-#include <QVariant>
-
-#include "ftnoir_tracker_hat_settings.h"
-#include "opentrack-compat/options.hpp"
-
-// XXX TODO move to opentrack settings api -sh 20160410
-
-void TrackerSettings::load_ini()
-{
- QString currentFile = options::group::ini_pathname();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "HAT" );
-
- SerialPortName=iniFile.value ( "PortName" ).toString();
-
- EnableRoll = iniFile.value( "EnableRoll", 1 ).toBool();
- EnablePitch = iniFile.value( "EnablePitch", 1 ).toBool();
- EnableYaw = iniFile.value( "EnableYaw", 1 ).toBool();
- EnableX = iniFile.value( "EnableX", 0 ).toBool();
- EnableY = iniFile.value( "EnableY", 0 ).toBool();
- EnableZ = iniFile.value( "EnableZ", 0 ).toBool();
- EnableLogging = iniFile.value( "EnableLogging", 0).toBool();
-
- InvertRoll = iniFile.value( "InvertRoll", 1 ).toBool();
- InvertPitch = iniFile.value( "InvertPitch", 1 ).toBool();
- InvertYaw = iniFile.value( "InvertYaw", 1 ).toBool();
- InvertX = iniFile.value( "InvertX", 0 ).toBool();
- InvertY = iniFile.value( "InvertY", 0 ).toBool();
- InvertZ = iniFile.value( "InvertZ", 0 ).toBool();
-
-
- RollAxis=iniFile.value("RollAxe",1).toInt();
- PitchAxis=iniFile.value("PitchAxe",2).toInt();
- YawAxis=iniFile.value("YawAxe",0).toInt();
- XAxis=iniFile.value("XAxe",1).toInt();
- YAxis=iniFile.value("YAxe",2).toInt();
- ZAxis=iniFile.value("ZAxe",0).toInt();
-
-
- CmdStart=iniFile.value ( "CmdStart").toString();
- CmdStop=iniFile.value ( "CmdStop" ).toString();
- CmdInit=iniFile.value ( "CmdInit" ).toString();
- CmdReset=iniFile.value ( "CmdReset" ).toString();
- CmdCenter=iniFile.value ( "CmdCenter" ).toString();
- CmdZero=iniFile.value ( "CmdZero" ).toString();
-
- DelayInit=iniFile.value("DelayInit",0).toInt();
- DelayStart=iniFile.value("DelayStart",0).toInt();
- DelaySeq=iniFile.value("DelaySeq",0).toInt();
-
- FPSArduino=iniFile.value("FPSArduino",30).toInt();
-
- BigEndian=iniFile.value("BigEndian",0).toBool();
-
-
- pBaudRate=static_cast<QSerialPort::BaudRate>(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt());
- pDataBits=static_cast<QSerialPort::DataBits>(iniFile.value("DataBits",QSerialPort::Data8).toInt());
- pParity=static_cast<QSerialPort::Parity>(iniFile.value("Parity",QSerialPort::NoParity).toInt());
- pStopBits=static_cast<QSerialPort::StopBits>(iniFile.value("StopBits",QSerialPort::OneStop).toInt());
- pFlowControl=static_cast<QSerialPort::FlowControl>(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt());
-
- iniFile.endGroup();
-}
-
-void TrackerSettings::save_ini() const
-{
-
- QString currentFile = options::group::ini_pathname();
-
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "HAT" );
-
- iniFile.setValue ( "PortName",SerialPortName );
-
- iniFile.setValue( "EnableRoll", EnableRoll );
- iniFile.setValue( "EnablePitch", EnablePitch );
- iniFile.setValue( "EnableYaw", EnableYaw );
- iniFile.setValue( "EnableX", EnableX );
- iniFile.setValue( "EnableY", EnableY );
- iniFile.setValue( "EnableZ", EnableZ );
- iniFile.setValue( "EnableLogging", EnableLogging );
-
- iniFile.setValue( "InvertRoll", InvertRoll );
- iniFile.setValue( "InvertPitch", InvertPitch );
- iniFile.setValue( "InvertYaw", InvertYaw );
- iniFile.setValue( "InvertX", InvertX );
- iniFile.setValue( "InvertY", InvertY );
- iniFile.setValue( "InvertZ", InvertZ );
-
- iniFile.setValue ( "RollAxe", RollAxis );
- iniFile.setValue ( "PitchAxe", PitchAxis );
- iniFile.setValue ( "YawAxe",YawAxis );
- iniFile.setValue ( "XAxe", XAxis );
- iniFile.setValue ( "YAxe", YAxis );
- iniFile.setValue ( "ZAxe", ZAxis );
-
- iniFile.setValue ( "CmdStart",CmdStart.toLatin1());
- iniFile.setValue ( "CmdStop",CmdStop.toLatin1());
- iniFile.setValue ( "CmdInit",CmdInit.toLatin1());
- iniFile.setValue ( "CmdReset",CmdReset.toLatin1());
- iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() );
- iniFile.setValue ( "CmdZero",CmdZero.toLatin1() );
-
- iniFile.setValue ( "DelayInit",DelayInit);
- iniFile.setValue ( "DelayStart",DelayStart);
- iniFile.setValue ( "DelaySeq",DelaySeq);
-
- iniFile.setValue ( "FPSArduino", FPSArduino );
-
- iniFile.setValue("BigEndian",BigEndian);
-
- iniFile.setValue("BaudRate",pBaudRate);
- iniFile.setValue("DataBits",pDataBits);
- iniFile.setValue("Parity",pParity);
- iniFile.setValue("StopBits",pStopBits);
- iniFile.setValue("FlowControl",pFlowControl);
-
-
- iniFile.endGroup();
-}
diff --git a/tracker-hatire/ftnoir_tracker_hat_settings.h b/tracker-hatire/ftnoir_tracker_hat_settings.h
index 06d54e34..92dacd42 100644..100755
--- a/tracker-hatire/ftnoir_tracker_hat_settings.h
+++ b/tracker-hatire/ftnoir_tracker_hat_settings.h
@@ -7,54 +7,67 @@
#pragma once
-#include <QtSerialPort/QSerialPort>
+#include <QSerialPort>
+#include "opentrack-compat/options.hpp"
-struct TrackerSettings
+using namespace options;
+
+struct TrackerSettings : opts
{
- void load_ini();
- void save_ini() const;
-
- bool EnableRoll;
- bool EnablePitch;
- bool EnableYaw;
- bool EnableX;
- bool EnableY;
- bool EnableZ;
-
- bool InvertRoll;
- bool InvertPitch;
- bool InvertYaw;
- bool InvertX;
- bool InvertY;
- bool InvertZ;
-
- int RollAxis;
- int PitchAxis;
- int YawAxis;
- int XAxis;
- int YAxis;
- int ZAxis;
-
- QString CmdStart;
- QString CmdStop;
- QString CmdInit;
- QString CmdReset;
- QString CmdCenter;
- QString CmdZero;
-
- int DelayInit;
- int DelayStart;
- int DelaySeq;
-
- bool BigEndian;
- bool EnableLogging;
-
- QString SerialPortName;
- QSerialPort::BaudRate pBaudRate;
- QSerialPort::DataBits pDataBits;
- QSerialPort::Parity pParity;
- QSerialPort::StopBits pStopBits;
- QSerialPort::FlowControl pFlowControl;
-
- int FPSArduino;
+ value<bool> EnableRoll, EnablePitch, EnableYaw, EnableX, EnableY, EnableZ;
+ value<bool> InvertRoll, InvertPitch, InvertYaw, InvertX, InvertY, InvertZ;
+ value<int> RollAxis, PitchAxis, YawAxis, XAxis, YAxis, ZAxis;
+
+ value<QString> CmdStart, CmdStop, CmdInit, CmdReset, CmdCenter, CmdZero;
+
+ value<int> DelayInit, DelayStart, DelaySeq;
+
+ value<bool> BigEndian, EnableLogging;
+
+ value<QString> QSerialPortName;
+
+ value<QSerialPort::BaudRate> pBaudRate;
+ value<QSerialPort::DataBits> pDataBits;
+ value<QSerialPort::Parity> pParity;
+ value<QSerialPort::StopBits> pStopBits;
+ value<QSerialPort::FlowControl> pFlowControl;
+
+ TrackerSettings() :
+ opts("hatire-tracker"),
+ EnableRoll(b, "enable-roll", true),
+ EnablePitch(b, "enable-pitch", true),
+ EnableYaw(b, "enable-yaw", true),
+ EnableX(b, "enable-x", false),
+ EnableY(b, "enable-y", false),
+ EnableZ(b, "enable-z", false),
+ InvertRoll(b, "invert-roll", false),
+ InvertPitch(b, "invert-pitch", false),
+ InvertYaw(b, "invert-yaw", false),
+ InvertX(b, "invert-x", false),
+ InvertY(b, "invert-y", false),
+ InvertZ(b, "invert-z", false),
+ RollAxis(b, "roll-axis", 1),
+ PitchAxis(b, "pitch-axis", 2),
+ YawAxis(b, "pitch-axis", 0),
+ XAxis(b, "x-axis", 0),
+ YAxis(b, "y-axis", 2),
+ ZAxis(b, "z-axis", 1),
+ CmdStart(b, "start-command", ""),
+ CmdStop(b, "stop-command", ""),
+ CmdInit(b, "init-command", ""),
+ CmdReset(b, "reset-command", ""),
+ CmdCenter(b, "center-command", ""),
+ CmdZero(b, "zero-command", ""),
+ DelayInit(b, "init-delay", 0),
+ DelayStart(b, "start-delay", 0),
+ DelaySeq(b, "after-start-delay", 0),
+ BigEndian(b, "is-big-endian", false),
+ EnableLogging(b, "enable-logging", false),
+ QSerialPortName(b, "serial-port-name", ""),
+ pBaudRate(b, "baud-rate", QSerialPort::Baud115200),
+ pDataBits(b, "data-bits", QSerialPort::Data8),
+ pParity(b, "parity", QSerialPort::NoParity),
+ pStopBits(b, "stop-bits", QSerialPort::OneStop),
+ pFlowControl(b, "flow-control", QSerialPort::HardwareControl)
+ {}
};
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp
index e4ce8044..238c5fdd 100755
--- a/tracker-hatire/thread.cpp
+++ b/tracker-hatire/thread.cpp
@@ -52,7 +52,7 @@ void hatire_thread::Log(const QString& message)
{
// Drop out immediately if logging is off. Yes, there is still some overhead because of passing strings around for no reason.
// that's unfortunate and I'll monitor the impact and see if it needs a more involved fix.
- if (!s.bEnableLogging) return;
+ if (!s.EnableLogging) return;
Diag flDiagnostics;
@@ -67,9 +67,8 @@ void hatire_thread::Log(const QString& message)
}
}
-void hatire_thread::start(const thread_settings& s_)
+void hatire_thread::start()
{
- s = s_;
com_port.moveToThread(this);
#ifdef HATIRE_DEBUG_LOGFILE
read_timer.moveToThread(this);
@@ -83,21 +82,15 @@ hatire_thread::~hatire_thread()
wait();
}
-thread_settings hatire_thread::serial_settings_impl()
-{
- return s;
-}
-
hatire_thread::hatire_thread()
{
data_read.reserve(65536);
connect(this, &QThread::finished, this, &hatire_thread::teardown_serial);
- connect(this, &hatire_thread::update_serial_settings, this, &hatire_thread::update_serial_settings_impl, Qt::QueuedConnection);
connect(this, &hatire_thread::init_serial_port, this, &hatire_thread::init_serial_port_impl, Qt::QueuedConnection);
connect(this, &hatire_thread::serial_info, this, &hatire_thread::serial_info_impl, Qt::QueuedConnection);
connect(this, &hatire_thread::sendcmd, this, &hatire_thread::sendcmd_impl, Qt::QueuedConnection);
- connect(this, &hatire_thread::serial_settings, this, &hatire_thread::serial_settings_impl, Qt::QueuedConnection);
+ connect(this, &hatire_thread::sendcmd_str, this, &hatire_thread::sendcmd_str_impl, Qt::QueuedConnection);
}
void hatire_thread::teardown_serial()
@@ -106,7 +99,7 @@ void hatire_thread::teardown_serial()
{
QByteArray msg;
Log("Tracker shut down");
- com_port.write(s.sCmdStop);
+ com_port.write(to_latin1(s.CmdStop));
if (!com_port.waitForBytesWritten(1000))
{
emit serial_debug_info("TimeOut in writing CMD");
@@ -115,7 +108,7 @@ void hatire_thread::teardown_serial()
{
msg.append("\r\n");
msg.append("SEND '");
- msg.append(s.sCmdStop);
+ msg.append(s.CmdStop);
msg.append("'\r\n");
}
emit serial_debug_info(msg);
@@ -139,25 +132,20 @@ void hatire_thread::run()
(void) exec();
}
-void hatire_thread::update_serial_settings_impl(const thread_settings &s_)
-{
- s = s_;
-}
-
serial_result hatire_thread::init_serial_port_impl()
{
#ifndef HATIRE_DEBUG_LOGFILE
- com_port.setPortName(s.sSerialPortName);
+ com_port.setPortName(s.QSerialPortName);
if (com_port.open(QIODevice::ReadWrite))
{
Log("Port Open");
if (
- com_port.setBaudRate((QSerialPort::BaudRate)s.iBaudRate)
- && com_port.setDataBits((QSerialPort::DataBits)s.iDataBits)
- && com_port.setParity((QSerialPort::Parity)s.iParity)
- && com_port.setStopBits((QSerialPort::StopBits)s.iStopBits)
- && com_port.setFlowControl((QSerialPort::FlowControl)s.iFlowControl)
+ com_port.setBaudRate((QSerialPort::BaudRate)s.pBaudRate)
+ && com_port.setDataBits((QSerialPort::DataBits)s.pDataBits)
+ && com_port.setParity((QSerialPort::Parity)s.pParity)
+ && com_port.setStopBits((QSerialPort::StopBits)s.pStopBits)
+ && com_port.setFlowControl((QSerialPort::FlowControl)s.pFlowControl)
&& com_port.clear(QSerialPort::AllDirections)
&& com_port.setDataErrorPolicy(QSerialPort::IgnorePolicy)
)
@@ -178,22 +166,25 @@ serial_result hatire_thread::init_serial_port_impl()
Log("Couldn't set RTS");
}
// Wait init arduino sequence
- for (int i = 1; i <=s.iDelayInit; i+=50) {
+ for (int i = 1; i <= s.DelayInit; i+=50)
+ {
if (com_port.waitForReadyRead(50)) break;
}
Log("Waiting on init");
qDebug() << QTime::currentTime() << " HAT send INIT ";
- sendcmd(s.sCmdInit);
+ sendcmd_str(s.CmdInit);
// Wait init MPU sequence
- for (int i = 1; i <=s.iDelayStart; i+=50) {
+ for (int i = 1; i <= s.DelayStart; i+=50)
+ {
if (com_port.waitForReadyRead(50)) break;
}
// Send START cmd to IMU
qDebug() << QTime::currentTime() << " HAT send START ";
- sendcmd(s.sCmdStart);
+ sendcmd_str(s.CmdStart);
// Wait start MPU sequence
- for (int i = 1; i <=s.iDelaySeq; i+=50) {
+ for (int i = 1; i <=s.DelaySeq; i+=50)
+ {
if (com_port.waitForReadyRead(50)) break;
}
Log("Port setup, waiting for HAT frames to process");
diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp
index 1a3f2b09..12d07f97 100755
--- a/tracker-hatire/thread.hpp
+++ b/tracker-hatire/thread.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "ftnoir_tracker_hat_settings.h"
+
#include <QSerialPort>
#include <QByteArray>
#include <QThread>
@@ -31,47 +33,6 @@ enum results
# define unused(t, i) t i
#endif
-struct thread_settings
-{
- QByteArray sCmdStart;
- QByteArray sCmdStop;
- QByteArray sCmdInit;
- QByteArray sCmdReset;
- QByteArray sCmdCenter;
- QByteArray sCmdZero;
-
- QString sSerialPortName;
- QSerialPort::BaudRate iBaudRate;
- QSerialPort::DataBits iDataBits;
- QSerialPort::Parity iParity;
- QSerialPort::StopBits iStopBits;
- QSerialPort::FlowControl iFlowControl;
-
- int iDelayInit;
- int iDelayStart;
- int iDelaySeq;
- bool bBigEndian;
- volatile bool bEnableLogging;
-
- thread_settings() :
- iBaudRate(QSerialPort::UnknownBaud),
- iDataBits(QSerialPort::UnknownDataBits),
- iParity(QSerialPort::UnknownParity),
- iStopBits(QSerialPort::UnknownStopBits),
- iFlowControl(QSerialPort::UnknownFlowControl),
- iDelayInit(0),
- iDelayStart(0),
- iDelaySeq(0),
- bBigEndian(false),
- bEnableLogging(false)
- {
- }
-};
-
-#include <QMetaType>
-
-Q_DECLARE_METATYPE(thread_settings)
-
struct serial_result
{
serial_result() : code(result_ok) {}
@@ -102,33 +63,32 @@ class hatire_thread : public QThread
QByteArray data_read;
serial_t com_port;
- thread_settings s;
+ TrackerSettings s;
variance stat;
Timer timer, throttle_timer;
void run() override;
+ static inline QByteArray to_latin1(const QString& str) { return str.toLatin1(); }
private slots:
void on_serial_read();
void teardown_serial();
void sendcmd_impl(unused(const QByteArray, &cmd));
+ void sendcmd_str_impl(const QString& str) { sendcmd(str.toLatin1()); }
void serial_info_impl();
serial_result init_serial_port_impl();
- void update_serial_settings_impl(const thread_settings& s);
- thread_settings serial_settings_impl();
signals:
void serial_debug_info(const QByteArray &MsgInfo);
void sendcmd(const QByteArray& cmd);
+ void sendcmd_str(const QString& cmd);
void serial_info();
serial_result init_serial_port();
- void update_serial_settings(const thread_settings& s);
- thread_settings serial_settings();
public:
- void start(const thread_settings &s_);
+ void start();
~hatire_thread() override;
hatire_thread();