summaryrefslogtreecommitdiffhomepage
path: root/tracker-hatire/thread.hpp
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 /tracker-hatire/thread.hpp
parente6fb571266c22f120c0111731da1f2e6bf4d812d (diff)
tracker/hatire: move to opentrack settings API
Diffstat (limited to 'tracker-hatire/thread.hpp')
-rwxr-xr-xtracker-hatire/thread.hpp54
1 files changed, 7 insertions, 47 deletions
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();