diff options
Diffstat (limited to 'tracker-hatire')
-rw-r--r-- | tracker-hatire/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_hatcontrols.ui | 86 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_tracker_hat.cpp | 2 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_tracker_hat.h | 3 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_tracker_hat_dialog.cpp | 5 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_tracker_hat_settings.h | 3 | ||||
-rw-r--r-- | tracker-hatire/lang/nl_NL.ts | 4 | ||||
-rw-r--r-- | tracker-hatire/lang/ru_RU.ts | 4 | ||||
-rw-r--r-- | tracker-hatire/lang/stub.ts | 4 | ||||
-rw-r--r-- | tracker-hatire/lang/zh_CN.ts | 6 | ||||
-rw-r--r-- | tracker-hatire/thread.cpp | 17 | ||||
-rw-r--r-- | tracker-hatire/thread.hpp | 1 |
12 files changed, 93 insertions, 45 deletions
diff --git a/tracker-hatire/CMakeLists.txt b/tracker-hatire/CMakeLists.txt index a73a471c..01dd52b9 100644 --- a/tracker-hatire/CMakeLists.txt +++ b/tracker-hatire/CMakeLists.txt @@ -2,4 +2,7 @@ if(Qt5SerialPort_FOUND) otr_module(tracker-hatire) target_link_libraries(${self} ${Qt5SerialPort_LIBRARIES}) target_include_directories(${self} SYSTEM PUBLIC ${Qt5SerialPort_INCLUDE_DIRS}) + if (WIN32 OR APPLE) + otr_install_lib(Qt5::SerialPort .) + endif() endif() diff --git a/tracker-hatire/ftnoir_hatcontrols.ui b/tracker-hatire/ftnoir_hatcontrols.ui index aa84758b..758d8e51 100644 --- a/tracker-hatire/ftnoir_hatcontrols.ui +++ b/tracker-hatire/ftnoir_hatcontrols.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>389</width> - <height>488</height> + <height>497</height> </rect> </property> <property name="minimumSize"> @@ -103,7 +103,7 @@ <bool>false</bool> </property> <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToMinimumContentsLength</enum> + <enum>QComboBox::AdjustToContents</enum> </property> <property name="modelColumn"> <number>0</number> @@ -1136,16 +1136,6 @@ p, li { white-space: pre-wrap; } <string>Serial Parameters</string> </property> <layout class="QGridLayout" name="gridLayout_8"> - <item row="0" column="1"> - <widget class="QComboBox" name="QCB_Serial_baudRate"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> <item row="3" column="1"> <widget class="QComboBox" name="QCB_Serial_stopBits"> <property name="sizePolicy"> @@ -1163,6 +1153,13 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> + <item row="0" column="0"> + <widget class="QLabel" name="baudRateLabel"> + <property name="text"> + <string>BaudRate:</string> + </property> + </widget> + </item> <item row="2" column="1"> <widget class="QComboBox" name="QCB_Serial_parity"> <property name="sizePolicy"> @@ -1173,13 +1170,10 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="4" column="1"> - <widget class="QComboBox" name="QCB_Serial_flowControl"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="1" column="0"> + <widget class="QLabel" name="dataBitsLabel"> + <property name="text"> + <string>Data bits</string> </property> </widget> </item> @@ -1190,6 +1184,16 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> + <item row="0" column="1"> + <widget class="QComboBox" name="QCB_Serial_baudRate"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> <item row="2" column="0"> <widget class="QLabel" name="parityLabel"> <property name="text"> @@ -1197,15 +1201,18 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="baudRateLabel"> - <property name="text"> - <string>BaudRate:</string> + <item row="1" column="1"> + <widget class="QComboBox" name="QCB_Serial_dataBits"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QComboBox" name="QCB_Serial_dataBits"> + <item row="4" column="1"> + <widget class="QComboBox" name="QCB_Serial_flowControl"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -1214,10 +1221,23 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="dataBitsLabel"> + <item row="5" column="0"> + <widget class="QLabel" name="label_6"> <property name="text"> - <string>Data bits</string> + <string>DTR</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="QCB_Serial_dtr"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> </property> </widget> </item> @@ -1371,6 +1391,7 @@ p, li { white-space: pre-wrap; } </layout> </widget> <tabstops> + <tabstop>tabWidget</tabstop> <tabstop>cbSerialPort</tabstop> <tabstop>btnZero</tabstop> <tabstop>btnReset</tabstop> @@ -1393,24 +1414,27 @@ p, li { white-space: pre-wrap; } <tabstop>cb_z</tabstop> <tabstop>chkInvertZ</tabstop> <tabstop>le_cmd_init</tabstop> + <tabstop>spb_BeforeInit</tabstop> <tabstop>le_cmd_start</tabstop> + <tabstop>spb_BeforeStart</tabstop> <tabstop>spb_AfterStart</tabstop> <tabstop>le_cmd_stop</tabstop> <tabstop>le_cmd_center</tabstop> <tabstop>le_cmd_zero</tabstop> - <tabstop>le_cmd_reset</tabstop> <tabstop>spb_Fps</tabstop> + <tabstop>le_cmd_reset</tabstop> <tabstop>cb_Endian</tabstop> <tabstop>QCB_Serial_baudRate</tabstop> <tabstop>QCB_Serial_dataBits</tabstop> <tabstop>QCB_Serial_parity</tabstop> <tabstop>QCB_Serial_stopBits</tabstop> <tabstop>QCB_Serial_flowControl</tabstop> + <tabstop>QCB_Serial_dtr</tabstop> + <tabstop>btn_icone</tabstop> + <tabstop>chkEnableLogging</tabstop> <tabstop>lineSend</tabstop> <tabstop>btnSend</tabstop> <tabstop>pteINFO</tabstop> - <tabstop>tabWidget</tabstop> - <tabstop>btn_icone</tabstop> </tabstops> <resources> <include location="ftnoir_hat.qrc"/> diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp index b53a9213..9948c30e 100644 --- a/tracker-hatire/ftnoir_tracker_hat.cpp +++ b/tracker-hatire/ftnoir_tracker_hat.cpp @@ -122,7 +122,7 @@ void hatire::data(double *data) } for (unsigned k = 0; k < 3; k++) - HAT.Rot[k] = clamp(HAT.Rot[k], -180, 180); + HAT.Rot[k] = std::clamp(HAT.Rot[k], -180.f, 180.f); const struct { diff --git a/tracker-hatire/ftnoir_tracker_hat.h b/tracker-hatire/ftnoir_tracker_hat.h index b2300556..16e39c7d 100644 --- a/tracker-hatire/ftnoir_tracker_hat.h +++ b/tracker-hatire/ftnoir_tracker_hat.h @@ -32,6 +32,7 @@ public: void send_serial_command(const QByteArray& x); hatire_thread t; + private: TArduinoData ArduinoData {}, HAT {}; QByteArray Begin; @@ -42,8 +43,6 @@ private: int frame_cnt = 0; std::atomic<int> CptError { 0 }; - - static inline QByteArray to_latin1(const QString& str) { return str.toLatin1(); } }; class hatire_metadata : public Metadata diff --git a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp index 7cb25d18..7cede5ca 100644 --- a/tracker-hatire/ftnoir_tracker_hat_dialog.cpp +++ b/tracker-hatire/ftnoir_tracker_hat_dialog.cpp @@ -32,6 +32,10 @@ dialog_hatire::dialog_hatire() : theTracker(nullptr), timer(this) 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->addItem(QLatin1String("230400"),(QSerialPort::BaudRate)230400); + ui.QCB_Serial_baudRate->addItem(QLatin1String("250000"),(QSerialPort::BaudRate)250000); + ui.QCB_Serial_baudRate->addItem(QLatin1String("500000"),(QSerialPort::BaudRate)500000); + ui.QCB_Serial_baudRate->addItem(QLatin1String("1000000"),(QSerialPort::BaudRate)1000000); ui.QCB_Serial_dataBits->clear(); ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5); @@ -91,6 +95,7 @@ dialog_hatire::dialog_hatire() : theTracker(nullptr), timer(this) tie_setting(s.DelaySeq, ui.spb_AfterStart); tie_setting(s.BigEndian, ui.cb_Endian); + tie_setting(s.pDTR, ui.QCB_Serial_dtr); tie_setting(s.pBaudRate, ui.QCB_Serial_baudRate); tie_setting(s.pDataBits, ui.QCB_Serial_dataBits); diff --git a/tracker-hatire/ftnoir_tracker_hat_settings.h b/tracker-hatire/ftnoir_tracker_hat_settings.h index a41f906d..b17042c7 100644 --- 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, pDTR; 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), + pDTR(b, "data-terminal-ready", false), QSerialPortName(b, "serial-port-name", ""), pBaudRate(b, "baud-rate", QSerialPort::Baud115200), pDataBits(b, "data-bits", QSerialPort::Data8), diff --git a/tracker-hatire/lang/nl_NL.ts b/tracker-hatire/lang/nl_NL.ts index a1e613b0..af8cbd2c 100644 --- a/tracker-hatire/lang/nl_NL.ts +++ b/tracker-hatire/lang/nl_NL.ts @@ -269,6 +269,10 @@ p, li { white-space: pre-wrap; } <source>Enable logging to diagnostic file</source> <translation type="unfinished"></translation> </message> + <message> + <source>DTR</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>dialog_hatire</name> diff --git a/tracker-hatire/lang/ru_RU.ts b/tracker-hatire/lang/ru_RU.ts index f7f3024d..16052702 100644 --- a/tracker-hatire/lang/ru_RU.ts +++ b/tracker-hatire/lang/ru_RU.ts @@ -269,6 +269,10 @@ p, li { white-space: pre-wrap; } <source>Enable logging to diagnostic file</source> <translation type="unfinished"></translation> </message> + <message> + <source>DTR</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>dialog_hatire</name> diff --git a/tracker-hatire/lang/stub.ts b/tracker-hatire/lang/stub.ts index 0d22bf81..90c8e616 100644 --- a/tracker-hatire/lang/stub.ts +++ b/tracker-hatire/lang/stub.ts @@ -269,6 +269,10 @@ p, li { white-space: pre-wrap; } <source>Enable logging to diagnostic file</source> <translation type="unfinished"></translation> </message> + <message> + <source>DTR</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>dialog_hatire</name> diff --git a/tracker-hatire/lang/zh_CN.ts b/tracker-hatire/lang/zh_CN.ts index 0d22bf81..d80cfa28 100644 --- a/tracker-hatire/lang/zh_CN.ts +++ b/tracker-hatire/lang/zh_CN.ts @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1"> +<TS version="2.1" language="zh_CN"> <context> <name>UIHATControls</name> <message> @@ -269,6 +269,10 @@ p, li { white-space: pre-wrap; } <source>Enable logging to diagnostic file</source> <translation type="unfinished"></translation> </message> + <message> + <source>DTR</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>dialog_hatire</name> diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index 4938e77f..7d61a90a 100644 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -71,7 +71,7 @@ void hatire_thread::Log(const QString& message) { QTextStream out(&flDiagnostics); QString milliSeconds; - milliSeconds = QString("%1").arg(QTime::currentTime().msec(), 3, 10, QChar('0')); + milliSeconds = QStringLiteral("%1").arg(QTime::currentTime().msec(), 3, 10, QChar('0')); // We have a file out << QTime::currentTime().toString() << "." << milliSeconds << ": " << message << "\r\n"; flDiagnostics.close(); @@ -111,7 +111,7 @@ void hatire_thread::teardown_serial() { QByteArray msg; Log("Tracker shut down"); - com_port.write(to_latin1(s.CmdStop)); + com_port.write(s.CmdStop->toUtf8()); if (!com_port.waitForBytesWritten(1000)) { emit serial_debug_info("TimeOut in writing CMD"); @@ -120,7 +120,7 @@ void hatire_thread::teardown_serial() { msg.append("\r\n"); msg.append("SEND '"); - msg.append(s.CmdStop); + msg.append(s.CmdStop->toUtf8()); msg.append("'\r\n"); } emit serial_debug_info(msg); @@ -168,6 +168,7 @@ serial_result hatire_thread::init_serial_port_impl() && com_port.setParity((QSerialPort::Parity)s.pParity) && com_port.setStopBits((QSerialPort::StopBits)s.pStopBits) && com_port.setFlowControl((QSerialPort::FlowControl)s.pFlowControl) + && com_port.setDataTerminalReady(s.pDTR) && com_port.clear(QSerialPort::AllDirections) ) { @@ -200,7 +201,7 @@ serial_result hatire_thread::init_serial_port_impl() } Log(tr("Waiting on init")); qDebug() << QTime::currentTime() << " HAT send INIT "; - sendcmd_str(s.CmdInit); + emit sendcmd_str(s.CmdInit); // Wait init MPU sequence for (int i = 1; i <= s.DelayStart; i+=50) { @@ -208,7 +209,7 @@ serial_result hatire_thread::init_serial_port_impl() } // Send START cmd to IMU qDebug() << QTime::currentTime() << " HAT send START "; - sendcmd_str(s.CmdStart); + emit sendcmd_str(s.CmdStart); // Wait start MPU sequence for (int i = 1; i <=s.DelaySeq; i+=50) @@ -241,13 +242,13 @@ void hatire_thread::serial_info_impl() if (com_port.isOpen()) { msg.append("\r\n"); - msg.append(com_port.portName()); + msg.append(com_port.portName().toUtf8()); msg.append("\r\n"); msg.append("BAUDRATE :"); - msg.append(QString::number(com_port.baudRate())); + msg.append(QString::number(com_port.baudRate()).toLatin1()); msg.append("\r\n"); msg.append("DataBits :"); - msg.append(QString::number(com_port.dataBits())); + msg.append(QString::number(com_port.dataBits()).toLatin1()); msg.append("\r\n"); msg.append("Parity :"); diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp index 5cecbdce..f6bd8d49 100644 --- a/tracker-hatire/thread.hpp +++ b/tracker-hatire/thread.hpp @@ -50,7 +50,6 @@ class hatire_thread : public QThread char buf[1024]; void run() override; - static inline QByteArray to_latin1(const QString& str) { return str.toLatin1(); } void serial_debug_info_str(const QString& str); |