diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-06 09:17:32 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-06 09:18:23 +0200 |
commit | 84d4f021259e589498229b65dd89cf4948022bd6 (patch) | |
tree | 4589a46a9229b25c6b3aa07d4b2cea62fa382ef3 | |
parent | 5d3572e15b063ccdf2fc5adde8fa9f2d4d3553be (diff) |
tracker/hatire: add debug logging variance
-rwxr-xr-x | tracker-hatire/thread.cpp | 15 | ||||
-rwxr-xr-x | tracker-hatire/thread.hpp | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index ace4198c..e0bd445f 100755 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -294,9 +294,6 @@ void hatire_thread::serial_info_impl() void hatire_thread::on_serial_read() { - constexpr int hz = 90; - constexpr int ms = 1000/hz; - { QMutexLocker lck(&data_mtx); #ifndef HATIRE_DEBUG_LOGFILE @@ -311,8 +308,20 @@ void hatire_thread::on_serial_read() } #endif } + + stat.input(timer.elapsed_ms()); + timer.start(); + + if (throttle_timer.elapsed_ms() >= 1000) + { + throttle_timer.start(); + qDebug() << "stat:" << "avg" << stat.avg() << "stddev" << stat.stddev(); + } + // qt can fire QSerialPort::readyRead() needlessly, causing a busy loop. // see https://github.com/opentrack/opentrack/issues/327#issuecomment-207941003 + constexpr int hz = 90; + constexpr int ms = 1000/hz; portable::sleep(ms); } diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp index f36d114e..44866e51 100755 --- a/tracker-hatire/thread.hpp +++ b/tracker-hatire/thread.hpp @@ -8,6 +8,9 @@ #include <QFile> #include <QCoreApplication> +#include "opentrack/variance.hpp" +#include "opentrack-compat/timer.hpp" + enum results { result_ok, @@ -100,6 +103,8 @@ class hatire_thread : public QThread QByteArray data_read; serial_t com_port; thread_settings s; + variance stat; + Timer timer, throttle_timer; void run() override; |