diff options
-rwxr-xr-x[-rw-r--r--] | tracker-hatire/ftnoir_hatcontrols.ui | 304 | ||||
-rwxr-xr-x | tracker-hatire/ftnoir_tracker_hat_dialog.cpp | 2 | ||||
-rwxr-xr-x | tracker-hatire/ftnoir_tracker_hat_settings.h | 3 | ||||
-rwxr-xr-x | tracker-hatire/thread.cpp | 13 |
4 files changed, 142 insertions, 180 deletions
diff --git a/tracker-hatire/ftnoir_hatcontrols.ui b/tracker-hatire/ftnoir_hatcontrols.ui index 2d347f08..3ff54618 100644..100755 --- a/tracker-hatire/ftnoir_hatcontrols.ui +++ b/tracker-hatire/ftnoir_hatcontrols.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>370</width> - <height>740</height> + <width>341</width> + <height>525</height> </rect> </property> <property name="minimumSize"> @@ -42,60 +42,16 @@ <bool>false</bool> </property> <layout class="QGridLayout" name="gridLayout_7"> - <item row="1" column="2"> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="btnOK"> + <item row="0" column="0" colspan="2"> + <widget class="QTabWidget" name="tabWidget"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="3"> - <widget class="QTabWidget" name="tabWidget"> - <property name="minimumSize"> - <size> <width>0</width> <height>0</height> </size> @@ -114,6 +70,15 @@ <string>General</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>4</number> + </property> + <property name="rightMargin"> + <number>4</number> + </property> <item> <widget class="QGroupBox" name="groupBox_2"> <property name="title"> @@ -126,6 +91,31 @@ <property name="spacing"> <number>4</number> </property> + <item row="0" column="1"> + <widget class="QComboBox" name="cbSerialPort"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>65535</width> + <height>16777215</height> + </size> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + <property name="modelColumn"> + <number>0</number> + </property> + </widget> + </item> <item row="0" column="0"> <widget class="QLabel" name="label_5"> <property name="sizePolicy"> @@ -145,28 +135,29 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QComboBox" name="cbSerialPort"> + <item row="1" column="1"> + <widget class="QCheckBox" name="serial_bug_workaround"> + <property name="text"> + <string>Buggy serial port uses too much CPU</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_6"> <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="maximumSize"> <size> - <width>65535</width> + <width>65536</width> <height>16777215</height> </size> </property> - <property name="editable"> - <bool>false</bool> - </property> - <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToMinimumContentsLength</enum> - </property> - <property name="modelColumn"> - <number>0</number> + <property name="text"> + <string>Workaround</string> </property> </widget> </item> @@ -190,22 +181,6 @@ </widget> </item> <item> - <widget class="QPushButton" name="btnCenter"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>20</height> - </size> - </property> - <property name="text"> - <string>Center</string> - </property> - </widget> - </item> - <item> <widget class="QPushButton" name="btnReset"> <property name="enabled"> <bool>false</bool> @@ -852,13 +827,6 @@ <string>Arduino Commands</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QLabel" name="lab_cmd_init_2"> - <property name="text"> - <string>Delay Init</string> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="lab_cmd_init"> <property name="text"> @@ -866,20 +834,6 @@ </property> </widget> </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="le_cmd_init"> - <property name="toolTip"> - <string>Command for Initialising Arduino</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="lab_cmd_init_3"> - <property name="text"> - <string>Delay Start</string> - </property> - </widget> - </item> <item row="3" column="0"> <widget class="QLabel" name="lab_cmd_start"> <property name="text"> @@ -894,27 +848,24 @@ </property> </widget> </item> - <item row="4" column="1"> - <widget class="QLabel" name="lab_cmd_init_4"> - <property name="text"> - <string>Delay Sequence</string> + <item row="1" column="1"> + <widget class="QLineEdit" name="le_cmd_init"> + <property name="toolTip"> + <string>Command for Initialising Arduino</string> </property> </widget> </item> - <item row="4" column="2"> - <widget class="QSpinBox" name="spb_AfterStart"> + <item row="5" column="1"> + <widget class="QLineEdit" name="le_cmd_stop"> <property name="toolTip"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Delay after Start Command in ms</span></p></body></html></string> - </property> - <property name="maximum"> - <number>5000</number> + <string>Command for Stop send sequence</string> </property> - <property name="singleStep"> - <number>50</number> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="lab_cmd_center"> + <property name="text"> + <string>Center:</string> </property> </widget> </item> @@ -925,17 +876,10 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="le_cmd_stop"> - <property name="toolTip"> - <string>Command for Stop send sequence</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="lab_cmd_center"> + <item row="8" column="0"> + <widget class="QLabel" name="lab_cmd_reset"> <property name="text"> - <string>Center:</string> + <string>Reset:</string> </property> </widget> </item> @@ -946,6 +890,13 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> + <item row="8" column="1"> + <widget class="QLineEdit" name="le_cmd_reset"> + <property name="toolTip"> + <string>Command for Reset Arduino</string> + </property> + </widget> + </item> <item row="7" column="0"> <widget class="QLabel" name="lab_cmd_zero"> <property name="text"> @@ -960,20 +911,6 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="8" column="0"> - <widget class="QLabel" name="lab_cmd_reset"> - <property name="text"> - <string>Reset:</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="QLineEdit" name="le_cmd_reset"> - <property name="toolTip"> - <string>Command for Reset Arduino</string> - </property> - </widget> - </item> <item row="8" column="2"> <widget class="QCheckBox" name="cb_Endian"> <property name="toolTip"> @@ -989,7 +926,26 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="0" column="2"> + <item row="7" column="2"> + <widget class="QSpinBox" name="spb_Fps"> + <property name="maximumSize"> + <size> + <width>51</width> + <height>19</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Indicate at OpenTrack speed sketch FPS to adjust CPU </p></body></html></string> + </property> + <property name="minimum"> + <number>10</number> + </property> + <property name="maximum"> + <number>200</number> + </property> + </widget> + </item> + <item row="1" column="2"> <widget class="QSpinBox" name="spb_BeforeInit"> <property name="maximumSize"> <size> @@ -1012,7 +968,7 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="2" column="2"> + <item row="3" column="2"> <widget class="QSpinBox" name="spb_BeforeStart"> <property name="toolTip"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -1029,22 +985,40 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="7" column="2"> - <widget class="QSpinBox" name="spb_Fps"> - <property name="maximumSize"> - <size> - <width>51</width> - <height>19</height> - </size> + <item row="0" column="2"> + <widget class="QLabel" name="label_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="toolTip"> - <string><html><head/><body><p>Indicate at OpenTrack speed sketch FPS to adjust CPU </p></body></html></string> + <property name="text"> + <string>Delay</string> </property> - <property name="minimum"> - <number>10</number> + </widget> + </item> + <item row="4" column="2"> + <widget class="QSpinBox" name="spb_AfterStart"> + <property name="toolTip"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Delay after Start Command in ms</span></p></body></html></string> </property> <property name="maximum"> - <number>200</number> + <number>5000</number> + </property> + <property name="singleStep"> + <number>50</number> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="lab_cmd_init_4"> + <property name="text"> + <string>Delay after startup</string> </property> </widget> </item> @@ -1172,34 +1146,18 @@ p, li { white-space: pre-wrap; } </widget> </widget> </item> - <item row="1" column="1"> - <widget class="QPushButton" name="btnSave"> - <property name="minimumSize"> - <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>25</height> - </size> - </property> - <property name="text"> - <string>Save</string> + <item row="1" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> </layout> </widget> <tabstops> - <tabstop>btnOK</tabstop> - <tabstop>btnSave</tabstop> - <tabstop>btnCancel</tabstop> <tabstop>cbSerialPort</tabstop> <tabstop>btnZero</tabstop> - <tabstop>btnCenter</tabstop> <tabstop>btnReset</tabstop> <tabstop>chkEnableYaw</tabstop> <tabstop>cb_yaw</tabstop> @@ -1219,9 +1177,7 @@ p, li { white-space: pre-wrap; } <tabstop>chkEnableZ</tabstop> <tabstop>cb_z</tabstop> <tabstop>chkInvertZ</tabstop> - <tabstop>spb_BeforeInit</tabstop> <tabstop>le_cmd_init</tabstop> - <tabstop>spb_BeforeStart</tabstop> <tabstop>le_cmd_start</tabstop> <tabstop>spb_AfterStart</tabstop> <tabstop>le_cmd_stop</tabstop> diff --git a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp index 60ddd14a..734619c9 100755 --- a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp +++ b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp @@ -98,6 +98,8 @@ TrackerControls::TrackerControls() : theTracker(nullptr), timer(this) tie_setting(s.pParity, ui.QCB_Serial_parity); tie_setting(s.pStopBits, ui.QCB_Serial_stopBits); + tie_setting(s.serial_bug_workaround, ui.serial_bug_workaround); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); diff --git a/tracker-hatire/ftnoir_tracker_hat_settings.h b/tracker-hatire/ftnoir_tracker_hat_settings.h index 92dacd42..53ab8870 100755 --- a/tracker-hatire/ftnoir_tracker_hat_settings.h +++ b/tracker-hatire/ftnoir_tracker_hat_settings.h @@ -22,7 +22,7 @@ struct TrackerSettings : opts value<int> DelayInit, DelayStart, DelaySeq; - value<bool> BigEndian, EnableLogging; + value<bool> BigEndian, EnableLogging, serial_bug_workaround; value<QString> QSerialPortName; @@ -63,6 +63,7 @@ struct TrackerSettings : opts DelaySeq(b, "after-start-delay", 0), BigEndian(b, "is-big-endian", false), EnableLogging(b, "enable-logging", false), + serial_bug_workaround(b, "serial-bug-workaround", false), QSerialPortName(b, "serial-port-name", ""), pBaudRate(b, "baud-rate", QSerialPort::Baud115200), pDataBits(b, "data-bits", QSerialPort::Data8), diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index 238c5fdd..d512e463 100755 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -309,11 +309,14 @@ void hatire_thread::on_serial_read() 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); + if (s.serial_bug_workaround) + { + // 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); + } } QByteArray& hatire_thread::send_data_read_nolock() |