summaryrefslogtreecommitdiffhomepage
path: root/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-04-29 11:30:37 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-04-29 11:30:37 +0200
commit38dd6e55d20adfd830d834c394fc6ce7373a4805 (patch)
tree0a94bf051ff0bc153abebaa74e474748c2d4d8a6 /tracker-hatire/ftnoir_tracker_hat_dialog.cpp
parent4db6f6334d13ed5e8696dfa0208b42b3e9a2352a (diff)
tracker/hatire: move io to a separate thread
We can't have async io on the main thread because QSerialPort's readyRead() signal can fire constantly, thus consuming all CPU time. We can't sleep in the main thread either as that blocks too many things. We can't ignore readyRead() invocations over a threshold as that'll make us lose some of data notifications. Refactor hatire to put IO on a thread. Since this is a separate Qt event loop, we may sleep in there. Further, add a debug mode reading data from a file, as if it came from a serial-attached device. Issue: #327
Diffstat (limited to 'tracker-hatire/ftnoir_tracker_hat_dialog.cpp')
-rw-r--r--tracker-hatire/ftnoir_tracker_hat_dialog.cpp41
1 files changed, 5 insertions, 36 deletions
diff --git a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
index 3ef1a764..4ef83fb5 100644
--- a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp
@@ -13,13 +13,6 @@
#include <QScrollBar>
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this)
{
@@ -180,7 +173,7 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) );
connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset()));
- connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter()));
+ //connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter()));
connect(ui.btnZero, SIGNAL(clicked()), this, SLOT(doZero()));
connect(ui.btnSend, SIGNAL(clicked()), this, SLOT(doSend()));
@@ -209,8 +202,6 @@ void TrackerControls::Initialize(QWidget *parent) {
show();
}
-
-
//
// Apply online settings to tracker
//
@@ -220,27 +211,13 @@ void TrackerControls::settings_changed()
if (theTracker) theTracker->applysettings(settings);
}
-
-//
-// Center asked to ARDUINO
-//
-void TrackerControls::doCenter() {
-#ifdef OPENTRACK_API
- if (theTracker) theTracker->center();
-#else
- if (theTracker) theTracker->notifyCenter();
-#endif
-}
-
-
//
// Zero asked to ARDUINO
//
void TrackerControls::doZero() {
- if (theTracker) theTracker->notifyZeroed();
+ //if (theTracker) theTracker->notifyZeroed();
}
-
//
// Reset asked to ARDUINO
//
@@ -253,32 +230,28 @@ void TrackerControls::doReset() {
// Serial Info debug
//
void TrackerControls::doSerialInfo() {
- if (theTracker) theTracker->SerialInfo();
+ if (theTracker) theTracker->serial_info();
}
-
//
// Send command to ARDUINO
//
void TrackerControls::doSend() {
if (theTracker) {
if (!ui.lineSend->text().isEmpty()) {
- theTracker->sendcmd(ui.lineSend->text().toLatin1());
+ theTracker->send_serial_command(ui.lineSend->text().toLatin1());
}
}
}
-
//
// Enter on lineSend for send to ARDUINO
//
void TrackerControls::on_lineSend_returnPressed()
{
this->doSend();
-
}
-
//
// Display FPS of Arduino.
//
@@ -295,7 +268,6 @@ void TrackerControls::poll_tracker_info()
}
-
void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
{
QApplication::beep();
@@ -305,14 +277,11 @@ void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
bar->setValue(bar->maximum());
}
-
-
void TrackerControls::doSave() {
settingsDirty=false;
settings.save_ini();
}
-
//
// OK clicked on server-dialog
//
@@ -358,7 +327,7 @@ void TrackerControls::register_tracker(ITracker *tracker)
void TrackerControls::registerTracker(ITracker *tracker)
#endif
{
- theTracker = static_cast<FTNoIR_Tracker*>(tracker);
+ theTracker = static_cast<hatire*>(tracker);
connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray)));
if (isVisible() && settingsDirty) theTracker->applysettings(settings);