summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hatire
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-11-27 19:52:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2013-11-27 19:52:03 +0100
commit9990b05efb6fcd806ec5d996310f4a945a0b0fac (patch)
treecdfbacdd3b535ca594521265afaa4a1184c25201 /ftnoir_tracker_hatire
parent21dbb51ed05bffa69f036c6b82842aa0069b624f (diff)
merge in the right hatire branch this time!
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Diffstat (limited to 'ftnoir_tracker_hatire')
-rw-r--r--ftnoir_tracker_hatire/ftnoir_arduino_type.h22
-rw-r--r--ftnoir_tracker_hatire/ftnoir_hatcontrols.ui985
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp622
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat.h122
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp260
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h56
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp59
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp99
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h43
9 files changed, 1646 insertions, 622 deletions
diff --git a/ftnoir_tracker_hatire/ftnoir_arduino_type.h b/ftnoir_tracker_hatire/ftnoir_arduino_type.h
index 7f550579..bd5c4246 100644
--- a/ftnoir_tracker_hatire/ftnoir_arduino_type.h
+++ b/ftnoir_tracker_hatire/ftnoir_arduino_type.h
@@ -1,30 +1,30 @@
#ifndef FTNOIR_TARDUINO_TYPE_H
#define FTNOIR_TARDUINO_TYPE_H
-#include <QtGlobal>
-
-// Arduino frame structure
+// Arduino trame structure
#pragma pack(push,2)
struct TArduinoData
{
quint16 Begin; // Header trame 0xAAAA;
- quint16 Code; // 0->999 Num Frame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error
- float Gyro[3];
- float Acc[3];
- quint16 End; // End frame 0x5555;
+ quint16 Code; // 0->999 Num Trame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error
+ float Rot[3];
+ float Trans[3];
+ quint16 End; // End trame 0x5555;
} ;
#pragma pack(pop)
+
inline QDataStream & operator >> ( QDataStream& in, TArduinoData& out )
{
- in.setByteOrder(QDataStream::LittleEndian );
in.setFloatingPointPrecision(QDataStream::SinglePrecision );
- in >> out.Begin >> out.Code
- >> out.Gyro[0] >> out.Gyro[1] >> out.Gyro[2]
- >> out.Acc[0] >> out.Acc[1] >> out.Acc[2]
+ in >> out.Begin >> out.Code
+ >> out.Rot[0] >> out.Rot[1] >> out.Rot[2]
+ >> out.Trans[0] >> out.Trans[1] >> out.Trans[2]
>> out.End;
return in;
}
+
+
#endif
diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
index 97db404f..4446ca85 100644
--- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
+++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
@@ -6,20 +6,20 @@
<rect>
<x>0</x>
<y>0</y>
- <width>370</width>
- <height>520</height>
+ <width>307</width>
+ <height>509</height>
</rect>
</property>
<property name="minimumSize">
<size>
- <width>370</width>
- <height>520</height>
+ <width>0</width>
+ <height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
- <width>370</width>
- <height>520</height>
+ <width>65536</width>
+ <height>65536</height>
</size>
</property>
<property name="contextMenuPolicy">
@@ -30,7 +30,7 @@
</property>
<property name="windowIcon">
<iconset>
- <normaloff>images/hat.png</normaloff>images/hat.png</iconset>
+ <normaloff>:/images/hat.ico</normaloff>:/images/hat.ico</iconset>
</property>
<property name="windowOpacity">
<double>1.000000000000000</double>
@@ -41,69 +41,111 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
- <layout class="QGridLayout" name="gridLayout_5">
+ <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">
+ <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>OK</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
<size>
- <width>360</width>
- <height>470</height>
+ <width>0</width>
+ <height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
- <width>360</width>
- <height>470</height>
+ <width>65535</width>
+ <height>65535</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
- <property name="usesScrollButtons">
- <bool>true</bool>
- </property>
<widget class="QWidget" name="tab_config">
- <attribute name="icon">
- <iconset>
- <normaloff>:/images/hat.png</normaloff>:/images/hat.png</iconset>
- </attribute>
<attribute name="title">
<string>General</string>
</attribute>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QGroupBox" name="groupBox">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string/>
</property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="2" column="0">
- <widget class="QPushButton" name="btnCenter">
- <property name="minimumSize">
- <size>
- <width>80</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>Center</string>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QPushButton" name="btnReset">
- <property name="minimumSize">
+ <property name="maximumSize">
<size>
- <width>80</width>
- <height>20</height>
+ <width>65536</width>
+ <height>16777215</height>
</size>
</property>
<property name="text">
- <string>Reset</string>
+ <string>Serial port</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
<widget class="QComboBox" name="cbSerialPort">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -113,7 +155,7 @@
</property>
<property name="maximumSize">
<size>
- <width>100</width>
+ <width>65535</width>
<height>16777215</height>
</size>
</property>
@@ -128,20 +170,49 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_info">
- <property name="text">
- <string>Arduino serial port</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
- <item row="1" column="0">
+ <item>
+ <widget class="QPushButton" name="btnZero">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Zero</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnCenter">
+ <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="minimumSize">
+ <size>
+ <width>80</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBox_3">
<property name="minimumSize">
<size>
@@ -150,77 +221,36 @@
</size>
</property>
<property name="title">
- <string>Axis selection</string>
+ <string>Axis Configuration</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="6" column="2">
- <widget class="QCheckBox" name="chkEnableZ">
- <property name="maximumSize">
- <size>
- <width>20</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Enable Axis</string>
- </property>
- <property name="layoutDirection">
- <enum>Qt::LeftToRight</enum>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="4">
- <widget class="QCheckBox" name="chkInvertX">
- <property name="maximumSize">
- <size>
- <width>20</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Invert Axis</string>
- </property>
- <property name="layoutDirection">
- <enum>Qt::LeftToRight</enum>
- </property>
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="3">
- <widget class="QComboBox" name="cb_x">
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="2" column="2">
+ <widget class="QComboBox" name="cb_pitch">
<property name="toolTip">
<string>Associate Axis</string>
</property>
<item>
<property name="text">
- <string>X</string>
+ <string>RotX</string>
</property>
</item>
<item>
<property name="text">
- <string>Y</string>
+ <string>RotY</string>
</property>
</item>
<item>
<property name="text">
- <string>Z</string>
+ <string>RotZ</string>
</property>
</item>
</widget>
</item>
- <item row="4" column="2">
- <widget class="QCheckBox" name="chkEnableX">
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="chkEnableYaw">
<property name="maximumSize">
<size>
<width>20</width>
@@ -238,29 +268,8 @@
</property>
</widget>
</item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_x">
- <property name="text">
- <string>X</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_pitch">
- <property name="text">
- <string>Pitch</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_z">
- <property name="text">
- <string>Z</string>
- </property>
- </widget>
- </item>
- <item row="6" column="4">
- <widget class="QCheckBox" name="chkInvertZ">
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="chkEnableX">
<property name="maximumSize">
<size>
<width>20</width>
@@ -268,42 +277,31 @@
</size>
</property>
<property name="toolTip">
- <string>Invert Axis</string>
+ <string>Enable Axis</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
- <property name="styleSheet">
- <string notr="true"/>
- </property>
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="3" column="3">
- <widget class="QComboBox" name="cb_yaw">
- <property name="toolTip">
- <string>Associate Axis</string>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_pitch">
+ <property name="text">
+ <string>Pitch:</string>
</property>
- <item>
- <property name="text">
- <string>Yaw</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Pitch</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Roll</string>
- </property>
- </item>
</widget>
</item>
- <item row="2" column="2">
+ <item row="0" column="1">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Enable</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
<widget class="QCheckBox" name="chkEnablePitch">
<property name="maximumSize">
<size>
@@ -322,30 +320,29 @@
</property>
</widget>
</item>
- <item row="6" column="3">
- <widget class="QComboBox" name="cb_z">
- <property name="toolTip">
- <string>Associate Axis</string>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_yaw">
+ <property name="text">
+ <string>Yaw:</string>
</property>
- <item>
- <property name="text">
- <string>X</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Y</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Z</string>
- </property>
- </item>
</widget>
</item>
- <item row="3" column="4">
- <widget class="QCheckBox" name="chkInvertYaw">
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_y">
+ <property name="text">
+ <string>Y:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QCheckBox" name="chkInvertRoll">
<property name="maximumSize">
<size>
<width>20</width>
@@ -366,8 +363,15 @@
</property>
</widget>
</item>
- <item row="5" column="2">
- <widget class="QCheckBox" name="chkEnableY">
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_x">
+ <property name="text">
+ <string>X:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QCheckBox" name="chkInvertY">
<property name="maximumSize">
<size>
<width>20</width>
@@ -375,18 +379,21 @@
</size>
</property>
<property name="toolTip">
- <string>Enable Axis</string>
+ <string>Invert Axis</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="2" column="4">
- <widget class="QCheckBox" name="chkInvertPitch">
+ <item row="6" column="3">
+ <widget class="QCheckBox" name="chkInvertZ">
<property name="maximumSize">
<size>
<width>20</width>
@@ -407,30 +414,30 @@
</property>
</widget>
</item>
- <item row="1" column="3">
- <widget class="QComboBox" name="cb_roll">
+ <item row="6" column="2">
+ <widget class="QComboBox" name="cb_z">
<property name="toolTip">
<string>Associate Axis</string>
</property>
<item>
<property name="text">
- <string>Yaw</string>
+ <string>X</string>
</property>
</item>
<item>
<property name="text">
- <string>Pitch</string>
+ <string>Y</string>
</property>
</item>
<item>
<property name="text">
- <string>Roll</string>
+ <string>Z</string>
</property>
</item>
</widget>
</item>
- <item row="3" column="2">
- <widget class="QCheckBox" name="chkEnableYaw">
+ <item row="6" column="1">
+ <widget class="QCheckBox" name="chkEnableZ">
<property name="maximumSize">
<size>
<width>20</width>
@@ -448,29 +455,37 @@
</property>
</widget>
</item>
- <item row="0" column="3">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Input</string>
- </property>
- </widget>
- </item>
- <item row="0" column="4">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Invert</string>
+ <item row="5" column="2">
+ <widget class="QComboBox" name="cb_y">
+ <property name="toolTip">
+ <string>Associate Axis</string>
</property>
+ <item>
+ <property name="text">
+ <string>X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Z</string>
+ </property>
+ </item>
</widget>
</item>
<item row="3" column="0">
- <widget class="QLabel" name="label_yaw">
+ <widget class="QLabel" name="label_roll">
<property name="text">
- <string>Yaw</string>
+ <string>Roll:</string>
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QCheckBox" name="chkEnableRoll">
+ <item row="4" column="3">
+ <widget class="QCheckBox" name="chkInvertX">
<property name="maximumSize">
<size>
<width>20</width>
@@ -478,7 +493,7 @@
</size>
</property>
<property name="toolTip">
- <string>Enable Axis</string>
+ <string>Invert Axis</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -491,8 +506,8 @@
</property>
</widget>
</item>
- <item row="5" column="3">
- <widget class="QComboBox" name="cb_y">
+ <item row="4" column="2">
+ <widget class="QComboBox" name="cb_x">
<property name="toolTip">
<string>Associate Axis</string>
</property>
@@ -514,29 +529,58 @@
</widget>
</item>
<item row="2" column="3">
- <widget class="QComboBox" name="cb_pitch">
+ <widget class="QCheckBox" name="chkInvertPitch">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Invert Axis</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_z">
+ <property name="text">
+ <string>Z:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QComboBox" name="cb_roll">
<property name="toolTip">
<string>Associate Axis</string>
</property>
<item>
<property name="text">
- <string>Yaw</string>
+ <string>RotX</string>
</property>
</item>
<item>
<property name="text">
- <string>Pitch</string>
+ <string>RotY</string>
</property>
</item>
<item>
<property name="text">
- <string>Roll</string>
+ <string>RotZ</string>
</property>
</item>
</widget>
</item>
- <item row="1" column="4">
- <widget class="QCheckBox" name="chkInvertRoll">
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="chkEnableRoll">
<property name="maximumSize">
<size>
<width>20</width>
@@ -544,7 +588,7 @@
</size>
</property>
<property name="toolTip">
- <string>Invert Axis</string>
+ <string>Enable Axis</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -557,15 +601,27 @@
</property>
</widget>
</item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_y">
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="chkEnableY">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Enable Axis</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
<property name="text">
- <string>Y</string>
+ <string/>
</property>
</widget>
</item>
- <item row="5" column="4">
- <widget class="QCheckBox" name="chkInvertY">
+ <item row="1" column="3">
+ <widget class="QCheckBox" name="chkInvertYaw">
<property name="maximumSize">
<size>
<width>20</width>
@@ -586,48 +642,65 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_roll">
- <property name="text">
- <string>Roll</string>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="cb_yaw">
+ <property name="toolTip">
+ <string>Associate Axis</string>
</property>
+ <item>
+ <property name="text">
+ <string>RotX</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RotY</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RotZ</string>
+ </property>
+ </item>
</widget>
</item>
<item row="0" column="2">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Enable</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
+ <widget class="QLabel" name="label_2">
<property name="text">
- <string>Output</string>
+ <string>Axis</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
- <item row="2" column="0">
+ <item>
<widget class="QGroupBox" name="groupBox_status">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title">
- <string>Information</string>
+ <string>Status</string>
</property>
- <layout class="QGridLayout" name="gridLayout">
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="lab_tps">
<property name="minimumSize">
<size>
<width>31</width>
- <height>0</height>
+ <height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
- <height>13</height>
+ <height>20</height>
</size>
</property>
<property name="toolTip">
@@ -638,37 +711,56 @@
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="lab_vstatus">
+ <item row="0" column="1">
+ <widget class="QLabel" name="lab_vtps">
<property name="minimumSize">
<size>
- <width>170</width>
- <height>0</height>
+ <width>31</width>
+ <height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
- <height>16777215</height>
+ <height>20</height>
</size>
</property>
<property name="text">
- <string/>
+ <string>00</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="lab_vtps">
+ <item row="1" column="0">
+ <widget class="QLabel" name="lab_status">
<property name="minimumSize">
<size>
- <width>31</width>
- <height>0</height>
+ <width>0</width>
+ <height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
- <height>13</height>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Info :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="lab_vstatus">
+ <property name="minimumSize">
+ <size>
+ <width>170</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>20</height>
</size>
</property>
<property name="text">
@@ -676,16 +768,255 @@
</property>
</widget>
</item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_cmds">
+ <attribute name="title">
+ <string>Command</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="parametersBox">
+ <property name="title">
+ <string>Serial Parameters</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
- <widget class="QLabel" name="lab_status">
+ <widget class="QLabel" name="dataBitsLabel">
+ <property name="text">
+ <string>Data bits:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="QCB_Serial_dataBits"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="baudRateLabel">
+ <property name="text">
+ <string>BaudRate:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="QCB_Serial_baudRate"/>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="QCB_Serial_stopBits"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="flowControlLabel">
+ <property name="text">
+ <string>Flow control:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="QCB_Serial_flowControl"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="parityLabel">
+ <property name="text">
+ <string>Parity:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="QCB_Serial_parity"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="stopBitsLabel">
+ <property name="text">
+ <string>Stop bits:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <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">
+ <string>Init</string>
+ </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">
+ <string>Start:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="le_cmd_start">
+ <property name="toolTip">
+ <string>Command for Start send sequence</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="lab_cmd_init_4">
+ <property name="text">
+ <string>Delay Sequence</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="spb_AfterStart">
+ <property name="toolTip">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Delay after Start Command in ms&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>50</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="lab_cmd_stop">
+ <property name="text">
+ <string>Stop:</string>
+ </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">
+ <property name="text">
+ <string>Center:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLineEdit" name="le_cmd_center">
+ <property name="toolTip">
+ <string>Command for Center Gyro arduino</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="lab_cmd_zero">
+ <property name="text">
+ <string>Zero:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QLineEdit" name="le_cmd_zero">
+ <property name="toolTip">
+ <string>Command for Center Gyro arduino</string>
+ </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">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Little or Big Endian for &lt;span style=&quot; font-family:'Arial,Geneva,Helvetica,sans-serif'; font-size:medium; color:#000000;&quot;&gt;the serialization of byte order&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Arial,Geneva,Helvetica,sans-serif'; font-size:medium; color:#000000;&quot;&gt;Arduino is LittleEndian ( unchecked)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Endian</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="spb_BeforeStart">
+ <property name="toolTip">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Delay after Init command in ms&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>50</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="spb_BeforeInit">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
- <property name="text">
- <string>Status :</string>
+ <property name="toolTip">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Delay before Init command in ms&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>50</number>
</property>
</widget>
</item>
@@ -698,50 +1029,97 @@
<attribute name="title">
<string>About</string>
</attribute>
- <layout class="QFormLayout" name="formLayout">
+ <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
- <widget class="QLabel" name="label_10">
+ <widget class="QLabel" name="label_info_2">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;FTNoIR HAT Plugin&lt;br /&gt;Version 1.0&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;by FuraX49&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://hatire.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;FTNoIR HAT Plugin&lt;br /&gt;by FuraX49&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://hatire.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="label_35">
+ <item row="0" column="1" rowspan="2" colspan="2">
+ <widget class="QPushButton" name="btn_icone">
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
<property name="text">
<string/>
</property>
- <property name="pixmap">
- <pixmap resource="ftnoir_hat.qrc">:/images/hat_logo.png</pixmap>
+ <property name="icon">
+ <iconset>
+ <normalon>:/images/hat_logo.png</normalon>
+ </iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>128</width>
+ <height>128</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_version">
+ <property name="font">
+ <font>
+ <family>Arial Black</family>
+ <pointsize>10</pointsize>
+ <weight>75</weight>
+ <italic>true</italic>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Version 1.0.0</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="lineSend"/>
</item>
- <item row="4" column="0" colspan="2">
+ <item row="2" column="2">
+ <widget class="QPushButton" name="btnSend">
+ <property name="text">
+ <string>Send</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="3">
<widget class="QPlainTextEdit" name="pteINFO">
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
+ <property name="plainText">
+ <string notr="true"/>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
<property name="maximumBlockCount">
<number>800</number>
</property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QPushButton" name="btnSend">
- <property name="text">
- <string>Send</string>
+ <property name="backgroundVisible">
+ <bool>false</bool>
</property>
</widget>
</item>
@@ -749,31 +1127,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QPushButton" name="btnOK">
- <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>OK</string>
- </property>
- </widget>
- </item>
<item row="1" column="1">
<widget class="QPushButton" name="btnSave">
<property name="minimumSize">
@@ -793,39 +1146,41 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
- <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>
</layout>
</widget>
<tabstops>
+ <tabstop>btnOK</tabstop>
+ <tabstop>btnSave</tabstop>
<tabstop>btnCancel</tabstop>
+ <tabstop>chkEnableYaw</tabstop>
+ <tabstop>cb_yaw</tabstop>
+ <tabstop>chkInvertYaw</tabstop>
+ <tabstop>chkEnablePitch</tabstop>
+ <tabstop>cb_pitch</tabstop>
+ <tabstop>chkInvertPitch</tabstop>
+ <tabstop>chkEnableRoll</tabstop>
+ <tabstop>cb_roll</tabstop>
+ <tabstop>chkInvertRoll</tabstop>
+ <tabstop>chkEnableX</tabstop>
+ <tabstop>cb_x</tabstop>
+ <tabstop>chkInvertX</tabstop>
+ <tabstop>chkEnableY</tabstop>
+ <tabstop>cb_y</tabstop>
+ <tabstop>chkInvertY</tabstop>
+ <tabstop>chkEnableZ</tabstop>
+ <tabstop>cb_z</tabstop>
+ <tabstop>chkInvertZ</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>lineSend</tabstop>
+ <tabstop>btnSend</tabstop>
+ <tabstop>pteINFO</tabstop>
+ <tabstop>tabWidget</tabstop>
</tabstops>
- <resources>
- <include location="ftnoir_hat.qrc"/>
- </resources>
+ <resources/>
<connections/>
<slots>
<slot>startEngineClicked()</slot>
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
index fbe97854..b933dd14 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
@@ -1,217 +1,501 @@
/********************************************************************************
- * Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
- * Homepage: http://hatire.sourceforge.net *
- * *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU General Public License as published by the *
- * Free Software Foundation; either version 3 of the License, or (at your *
- * option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
- * more details. *
- * *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, see <http://www.gnu.org/licenses/>. *
- * *
- ********************************************************************************/
-
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
+* *
+* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
+* Homepage: http://hatire.sourceforge.net *
+* *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
#include "ftnoir_tracker_hat.h"
-#include "facetracknoir/global-settings.h"
-#include <QMessageBox>
-#include <QDebug>
-FTNoIR_Tracker::FTNoIR_Tracker() :
- SerialPort(nullptr),
- stop(false)
+FTNoIR_Tracker::FTNoIR_Tracker()
{
- TrackerSettings settings;
- settings.load_ini();
- applysettings(settings);
-
- //ListErrInf = new QList<QString>();
-
- datagram.reserve(30);
- qDebug() << "FTNoIR_Tracker::Initialize() Open SerialPort";
- SerialPort = new QSerialPort(sSerialPortName);
- if (SerialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered ) == true) {
- SerialPort->flush();
- SerialPort->setBaudRate(115200);
- SerialPort->setParity(QSerialPort::NoParity);
- SerialPort->setDataBits(QSerialPort::Data8);
- SerialPort->setStopBits(QSerialPort::OneStop);
- SerialPort->setFlowControl(QSerialPort::NoFlowControl);
- //SerialPort->setTimeout(waitTimeout);
- //SerialPort->setQueryMode(QextSerialPort::EventDriven); //Polling
- SerialPort->putChar('S');
- }
- else {
- QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open SerialPort",QMessageBox::Ok,QMessageBox::NoButton);
- delete SerialPort;
- SerialPort = NULL;
- }
+ ComPort = NULL;
+
+ HAT.Rot[0]=0;
+ HAT.Rot[1]=0;
+ HAT.Rot[2]=0;
+ HAT.Trans[0]=0;
+ HAT.Trans[1]=0;
+ HAT.Trans[2]=0;
+
+
+ // prepare & reserve QByteArray
+ dataRead.resize(4096);
+ dataRead.clear();
+ Begin.append((char) 0xAA);
+ Begin.append((char) 0xAA);
+ End.append((char) 0x55);
+ End.append((char) 0x55);
+
+ settings.load_ini();
}
FTNoIR_Tracker::~FTNoIR_Tracker()
{
- stop = true;
- wait();
- if (SerialPort!=NULL) {
- if (SerialPort->isOpen() ) {
- SerialPort->putChar('s'); //Send STOP to Arduino
- SerialPort->close();
- }
- delete SerialPort;
- SerialPort=NULL;
- }
-
+ if (ComPort!=NULL) {
+ if (ComPort->isOpen() ) {
+ ComPort->close();
+ }
+ delete ComPort;
+ ComPort=NULL;
+ }
}
//send CENTER to Arduino
void FTNoIR_Tracker::notifyCenter() {
- if (SerialPort!=NULL) {
- if (SerialPort->isOpen() ) {
- SerialPort->putChar('C');
- }
- }
+ sendcmd(sCmdCenter);
}
+//send ZERO to Arduino
+bool FTNoIR_Tracker::notifyZeroed() {
+ sendcmd(sCmdZero);
+ return true;
+}
-//send CENTER to Arduino
-void FTNoIR_Tracker::center() {
- if (SerialPort!=NULL) {
- if (SerialPort->isOpen() ) {
- SerialPort->putChar('C');
- }
- }
-}
//send RESET to Arduino
void FTNoIR_Tracker::reset() {
- if (SerialPort!=NULL) {
- if (SerialPort->isOpen() ) {
- SerialPort->putChar('R');
- }
- }
+ sendcmd(sCmdReset);
+}
+
+
+// Info SerialPort
+void FTNoIR_Tracker::SerialInfo() {
+ QByteArray Msg;
+ if (ComPort!=NULL) {
+ if (ComPort->isOpen() ) {
+ Msg.append("\r\n");
+ Msg.append(ComPort->portName());
+ Msg.append("\r\n");
+ Msg.append("BAUDRATE :");
+ Msg.append(QString::number(ComPort->baudRate()));
+ Msg.append("\r\n");
+ Msg.append("DataBits :");
+ Msg.append(QString::number(ComPort->dataBits()));
+ Msg.append("\r\n");
+ Msg.append("Parity :");
+ switch (ComPort->parity()) {
+ case 0: Msg.append("No parity");
+ break;
+ case 2: Msg.append("Even parity");
+ break;
+ case 3: Msg.append("Odd parity");
+ break;
+ case 4: Msg.append("Space parity");
+ break;
+ case 5: Msg.append("Mark parity");
+ break;
+ default: Msg.append("Unknown parity");
+ break;
+ }
+ Msg.append("\r\n");
+ Msg.append("Stop Bits :");
+ switch (ComPort->stopBits()) {
+ Msg.append(QString::number(ComPort->stopBits()));
+ case 1: Msg.append("1 stop bit.");
+ break;
+ case 2: Msg.append("2 stop bits.");
+ break;
+ case 3: Msg.append("1.5 stop bits.");
+ break;
+ default: Msg.append("Unknown number of stop bit.");
+ break;
+ }
+ Msg.append("\r\n");
+ Msg.append("Flow Control :");
+ switch (ComPort->flowControl()) {
+ case 0: Msg.append("No flow control");
+ break;
+ case 1: Msg.append("Hardware flow control (RTS/CTS)");
+ break;
+ case 2: Msg.append("Software flow control (XON/XOFF)");
+ break;
+ default: Msg.append("Unknown flow control");
+ break;
+ }
+ emit sendMsgInfo(Msg);
+
+ }
+ }
}
+
//send command to Arduino
-void FTNoIR_Tracker::sendcmd(QString* cmd) {
- QMutexLocker locker(&lock);
- QByteArray bytes;
- if (SerialPort!=NULL) {
- if (SerialPort->isOpen() ) {
- bytes.append(cmd->toLatin1());
- SerialPort->write(bytes);
- }
- }
-}
-
-// return FPS and last status
-void FTNoIR_Tracker::get_info(QString*, int* tps ){
- QMutexLocker locker(&lock);
- *tps=HAT.Code;
-#if 0
- if (ListErrInf->size()>0) {
- *info=ListErrInf->takeFirst();
- } else {
- *info= QString();
- }
-#endif
+void FTNoIR_Tracker::sendcmd(const QByteArray &cmd) {
+ QByteArray Msg;
+ if (cmd.length()>0) {
+ if (ComPort->isOpen() )
+ {
+ ComPort->write(cmd);
+ if (!ComPort->waitForBytesWritten(1000)) {
+ emit sendMsgInfo("TimeOut in writing CMD");
+ } else {
+ Msg.append("\r\n");
+ Msg.append("SEND '");
+ Msg.append(cmd);
+ Msg.append("'\r\n");
+ }
+ if ( !ComPort->waitForReadyRead(1000)) {
+ emit sendMsgInfo("TimeOut in response to CMD") ;
+ } else {
+ emit sendMsgInfo(Msg);
+ }
+ } else {
+ emit sendMsgInfo("ComPort not open") ;
+ }
+ }
}
-/** QThread run @override **/
-void FTNoIR_Tracker::run() {
- if (!SerialPort)
- return;
- while (!stop)
- {
- if (SerialPort->bytesAvailable()>=30)
- {
- QMutexLocker locker(&lock);
- datagram.clear();
- datagram=SerialPort->read(30);
- QDataStream datastream(datagram);
- datastream >> ArduinoData;
- if (ArduinoData.Begin==0xAAAA && ArduinoData.End==0x5555 )
- {
- if (ArduinoData.Code <= 1000)
- {
- HAT=ArduinoData;
- }
- } else {
- SerialPort->read(1);
- }
- }
- msleep(10);
- }
-}
-
-void FTNoIR_Tracker::StartTracker( QFrame* )
+// return FPS
+void FTNoIR_Tracker::get_info( int *tps ){
+ *tps=frame_cnt;
+ frame_cnt=0;
+}
+
+void FTNoIR_Tracker::SerialRead()
{
- start( QThread::TimeCriticalPriority );
- return;
+ QMutexLocker lck(&mutex);
+ dataRead+=ComPort->readAll();
}
-bool FTNoIR_Tracker::GiveHeadPoseData(double* data)
+#ifndef OPENTRACK_API
+void FTNoIR_Tracker::Initialize( QFrame *videoframe )
{
- QMutexLocker locker(&lock);
+ CptError=0;
+ dataRead.clear();
+ frame_cnt=0;
+
+ settings.load_ini();
+ applysettings(settings);
+ ComPort = new QSerialPort(this);
+ ComPort->setPortName(sSerialPortName);
+ if (ComPort->open(QIODevice::ReadWrite ) == true) {
+ connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead()));
+ if (
+ ComPort->setBaudRate((QSerialPort::BaudRate)iBaudRate)
+ && ComPort->setDataBits((QSerialPort::DataBits)iDataBits)
+ && ComPort->setParity((QSerialPort::Parity)iParity)
+ && ComPort->setStopBits((QSerialPort::StopBits)iStopBits)
+ && ComPort->setFlowControl((QSerialPort::FlowControl)iFlowControl)
+ && ComPort->clear(QSerialPort::AllDirections)
+ && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy)
+ ) {
+ // Wait init arduino sequence
+ for (int i = 1; i <=iDelayInit; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+ sendcmd(sCmdInit);
+ // Wait init MPU sequence
+ for (int i = 1; i <=iDelayStart; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+
+ } else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton);
+ }
+ }
+ else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton);
+ delete ComPort;
+ ComPort = NULL;
+ }
+ return;
+}
- const bool inversions[] = {
- bInvertX, bInvertY, bInvertZ, bInvertYaw, bInvertPitch, bInvertRoll
- };
- const bool enablement[] = {
- bEnableX, bEnableY, bEnableZ, bEnableYaw, bEnablePitch, bEnableRoll
- };
- const int axes[] = {
- iXAxis, iYAxis, iZAxis, iYawAxis, iPitchAxis, iRollAxis
- };
+void FTNoIR_Tracker::StartTracker(HWND parent_window)
+{
+ // Send START cmd to IMU
+ sendcmd(sCmdStart);
+ // Wait start MPU sequence
+ for (int i = 1; i <=iDelaySeq; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+ return;
+}
- for (int i = 0; i < 6; i++)
- {
- if (enablement[i])
- data[i] = HAT.Gyro[axes[i]] * (inversions[i] ? -1 : 1);
- }
- return true;
+void FTNoIR_Tracker::StopTracker( bool exit )
+{
+ QByteArray Msg;
+ if (sCmdStop.length()>0) {
+ if (ComPort->isOpen() )
+ {
+ ComPort->write(sCmdStop);
+ if (!ComPort->waitForBytesWritten(1000)) {
+ emit sendMsgInfo("TimeOut in writing CMD");
+ } else {
+ Msg.append("\r\n");
+ Msg.append("SEND '");
+ Msg.append(sCmdStop);
+ Msg.append("'\r\n");
+ }
+ emit sendMsgInfo(Msg);
+ }
+ }
+ // OK, the thread is not stopped, doing this. That might be dangerous anyway...
+ //
+ if (exit || !exit) return;
+ return;
}
+#else
+void FTNoIR_Tracker::StartTracker(QFrame*)
+{
+ CptError=0;
+ dataRead.clear();
+ frame_cnt=0;
+
+ settings.load_ini();
+ applysettings(settings);
+ ComPort = new QSerialPort(this);
+ ComPort->setPortName(sSerialPortName);
+ if (ComPort->open(QIODevice::ReadWrite ) == true) {
+ connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead()));
+ if (
+ ComPort->setBaudRate((QSerialPort::BaudRate)iBaudRate)
+ && ComPort->setDataBits((QSerialPort::DataBits)iDataBits)
+ && ComPort->setParity((QSerialPort::Parity)iParity)
+ && ComPort->setStopBits((QSerialPort::StopBits)iStopBits)
+ && ComPort->setFlowControl((QSerialPort::FlowControl)iFlowControl)
+ && ComPort->clear(QSerialPort::AllDirections)
+ && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy)
+ ) {
+ // Wait init arduino sequence
+ for (int i = 1; i <=iDelayInit; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+ sendcmd(sCmdInit);
+ // Wait init MPU sequence
+ for (int i = 1; i <=iDelayStart; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+ // Send START cmd to IMU
+ sendcmd(sCmdStart);
+
+ // Wait start MPU sequence
+ for (int i = 1; i <=iDelaySeq; i+=50) {
+ if (ComPort->waitForReadyRead(50)) break;
+ }
+ } else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton);
+ }
+ }
+ else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton);
+ delete ComPort;
+ ComPort = NULL;
+ }
+ return;
+
+}
+#endif
+
+
+//
+// Return 6DOF info
+//
+#ifdef OPENTRACK_API
+#define THeadPoseData double
+#endif
+
+bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data)
+{
+ QMutexLocker lck(&mutex);
+ while (dataRead.length()>=30) {
+ if ((dataRead.startsWith(Begin) && ( dataRead.mid(28,2)==End )) ) { // .Begin==0xAAAA .End==0x5555
+ QDataStream datastream(dataRead.left(30));
+ if (bBigEndian) datastream.setByteOrder(QDataStream::BigEndian );
+ else datastream.setByteOrder(QDataStream::LittleEndian );
+ datastream>>ArduinoData;
+ frame_cnt++;
+ if (ArduinoData.Code <= 1000) {
+ HAT=ArduinoData;
+ } else {
+ emit sendMsgInfo(dataRead.mid(4,24)) ;
+ }
+ dataRead.remove(0,30);
+ } else {
+ // resynchro trame
+ int index = dataRead.indexOf(Begin);
+ if (index==-1) {
+ index=dataRead.length();
+ }
+ emit sendMsgInfo(dataRead.mid(0,index)) ;
+ dataRead.remove(0,index);
+ CptError++;
+ }
+ }
+
+ if (CptError>50) {
+ emit sendMsgInfo("Can't find HAT frame") ;
+ CptError=0;
+ return false;
+ }
+#ifdef OPENTRACK_API
+ data[frame_cnt] = (long) HAT.Code;
+
+ if (bEnableYaw) {
+ if (bInvertYaw ) data[Yaw] = (double) HAT.Rot[iYawAxe] * -1.0f;
+ else data[Yaw] = (double) HAT.Rot[iYawAxe];
+ }
+
+ if (bEnablePitch) {
+ if (bInvertPitch) data[Pitch] = (double) HAT.Rot[iPitchAxe] * -1.0f;
+ else data[Pitch] = (double) HAT.Rot[iPitchAxe];
+ }
+
+ if (bEnableRoll) {
+ if (bInvertRoll) data[Roll] = (double) HAT.Rot[iRollAxe] * -1.0f;
+ else data[Roll] = (double) HAT.Rot[iRollAxe];
+ }
+
+ if (bEnableX) {
+ if (bInvertX) data[TX] =(double) HAT.Trans[iXAxe]* -1.0f;
+ else data[TX] = HAT.Trans[iXAxe];
+ }
+
+ if (bEnableY) {
+ if (bInvertY) data[TY] =(double) HAT.Trans[iYAxe]* -1.0f;
+ else data[TY] = HAT.Trans[iYAxe];
+ }
+
+ if (bEnableZ) {
+ if (bInvertZ) data[TZ] = HAT.Trans[iZAxe]* -1.0f;
+ else data[TZ] = HAT.Trans[iZAxe];
+ }
+#else
+ data->frame_number = (long) HAT.Code;
+
+ if (bEnableYaw) {
+ if (bInvertYaw ) data->yaw = (double) HAT.Rot[iYawAxe] * -1.0f;
+ else data->yaw = (double) HAT.Rot[iYawAxe];
+ }
+
+ if (bEnablePitch) {
+ if (bInvertPitch)data->pitch = (double) HAT.Rot[iPitchAxe] * -1.0f;
+ else data->pitch = (double) HAT.Rot[iPitchAxe];
+ }
+
+ if (bEnableRoll) {
+ if (bInvertRoll) data->roll = (double) HAT.Rot[iRollAxe] * -1.0f;
+ else data->roll = (double) HAT.Rot[iRollAxe];
+ }
+
+ if (bEnableX) {
+ if (bInvertX) data->x = (double) HAT.Trans[iXAxe]* -1.0f;
+ else data->x = (double) HAT.Trans[iXAxe];
+ }
+
+ if (bEnableY) {
+ if (bInvertY) data->y = (double) HAT.Trans[iYAxe]* -1.0f;
+ else data->y = (double) HAT.Trans[iYAxe];
+ }
+
+ if (bEnableZ) {
+ if (bInvertZ) data->z = (double) HAT.Trans[iZAxe]* -1.0f;
+ else data->z = (double) HAT.Trans[iZAxe];
+ }
+#endif
+
+ // For debug
+ //data->x=dataRead.length();
+ //data->y=CptError;
+
+ return true;
+
+}
+
+
+
+//
+// Apply modification Settings
+//
void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){
- qDebug()<<"Tracker:: Applying settings";
+ QMutexLocker lck(&mutex);
+ sSerialPortName= settings.SerialPortName;
+
+ bEnableRoll = settings.EnableRoll;
+ bEnablePitch = settings.EnablePitch;
+ bEnableYaw = settings.EnableYaw;
+ bEnableX = settings.EnableX;
+ bEnableY = settings.EnableY;
+ bEnableZ = settings.EnableZ;
- QMutexLocker locker(&lock);
- sSerialPortName= settings.SerialPortName;
+ bInvertRoll = settings.InvertRoll;
+ bInvertPitch = settings.InvertPitch;
+ bInvertYaw = settings.InvertYaw;
+ bInvertX = settings.InvertX;
+ bInvertY = settings.InvertY;
+ bInvertZ = settings.InvertZ;
- bEnableRoll = settings.EnableRoll;
- bEnablePitch = settings.EnablePitch;
- bEnableYaw = settings.EnableYaw;
- bEnableX = settings.EnableX;
- bEnableY = settings.EnableY;
- bEnableZ = settings.EnableZ;
+ iRollAxe= settings.RollAxe;
+ iPitchAxe= settings.PitchAxe;
+ iYawAxe= settings.YawAxe;
+ iXAxe= settings.XAxe;
+ iYAxe= settings.YAxe;
+ iZAxe= settings.ZAxe;
- bInvertRoll = settings.InvertRoll;
- bInvertPitch = settings.InvertPitch;
- bInvertYaw = settings.InvertYaw;
- bInvertX = settings.InvertX;
- bInvertY = settings.InvertY;
- bInvertZ = settings.InvertZ;
+ iBaudRate=settings.pBaudRate;
+ iDataBits=settings.pDataBits;
+ iParity=settings.pParity;
+ iStopBits=settings.pStopBits;
+ iFlowControl=settings.pFlowControl;
+ sCmdStart= settings.CmdStart.toLatin1();
+ sCmdStop= settings.CmdStop.toLatin1();
+ sCmdInit= settings.CmdInit.toLatin1();
+ sCmdReset= settings.CmdReset.toLatin1();
+ sCmdCenter= settings.CmdCenter.toLatin1();
+ sCmdZero= settings.CmdZero.toLatin1();
- iRollAxis= settings.RollAxis;
- iPitchAxis= settings.PitchAxis;
- iYawAxis= settings.YawAxis;
- iXAxis= settings.XAxis;
- iYAxis= settings.YAxis;
- iZAxis= settings.ZAxis;
+ iDelayInit=settings.DelayInit;
+ iDelayStart=settings.DelayStart;
+ iDelaySeq=settings.DelaySeq;
+
+ bBigEndian=settings.BigEndian;
}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTracker - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
+////////////////////////////////////////////////////////////////////////////////
+#ifdef OPENTRACK_API
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
+#else
+#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
+FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker()
+#endif
{
- return new FTNoIR_Tracker;
+ return new FTNoIR_Tracker;
}
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
index af583d11..a1b4ecda 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
@@ -1,46 +1,68 @@
#ifndef FTNOIR_TRACKER_HAT_H
#define FTNOIR_TRACKER_HAT_H
-#include "facetracknoir/global-settings.h"
-#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#ifdef OPENTRACK_API
+# include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+# include "facetracknoir/global-settings.h"
+#endif
#include "ftnoir_tracker_hat_settings.h"
#include "ftnoir_arduino_type.h"
-
+#include <QObject>
+#include <QPalette>
+#include <QtGui>
+#include <QByteArray>
+#include <QMessageBox>
#include <QtSerialPort/QSerialPort>
-#include <QThread>
-#include <QTimer>
-#include <QSettings>
+#include <QtSerialPort/QSerialPortInfo>
#include <QMutex>
#include <QMutexLocker>
-#include <cmath>
+#include <QSettings>
-class FTNoIR_Tracker : public ITracker, QThread
-{
+#define VER_FILEVERSION_STR "Version 2.0.7\0"
+class FTNoIR_Tracker : public QObject, public ITracker
+{
+ Q_OBJECT
public:
FTNoIR_Tracker();
- virtual ~FTNoIR_Tracker() virt_override;
-
- virtual void StartTracker( QFrame* frame ) virt_override;
- virtual bool GiveHeadPoseData(double *data) virt_override;
-
+ ~FTNoIR_Tracker();
+
+#ifdef OPENTRACK_API
+ virtual void StartTracker(QFrame*);
+ virtual bool GiveHeadPoseData(double* data);
+#else
+ void Initialize( QFrame *videoframe );
+ virtual void StartTracker(HWND parent_window);
+ virtual void StopTracker(bool exit);
+ virtual bool GiveHeadPoseData(THeadPoseData *data);
+#endif
void applysettings(const TrackerSettings& settings);
void notifyCenter();
- void center();
+ bool notifyZeroed();
void reset();
- void sendcmd(QString* cmd);
- void get_info(QString* info , int* tps );
+ void SerialInfo();
+ void sendcmd(const QByteArray &cmd);
+ void get_info( int *tps );
+
+private Q_SLOTS:
+ void SerialRead();
+
+signals:
+ void sendMsgInfo(const QByteArray &MsgInfo);
-protected:
- void run(); // qthread override run method
private:
+ QSerialPort *ComPort;
TArduinoData ArduinoData, HAT ; // Trame from Arduino
- QByteArray datagram;
- QSerialPort* SerialPort;
- volatile bool stop;
- QMutex lock;
- QString sSerialPortName; // Port serial name
+ QByteArray dataRead;
+ QByteArray dataToSend;
+ QByteArray Begin;
+ QByteArray End;
+ QMutex mutex;
+ int frame_cnt;
+
+ TrackerSettings settings;
+
bool bEnableRoll;
bool bEnablePitch;
bool bEnableYaw;
@@ -55,23 +77,54 @@ private:
bool bInvertY;
bool bInvertZ;
+ int iRollAxe;
+ int iPitchAxe;
+ int iYawAxe;
+ int iXAxe;
+ int iYAxe;
+ int iZAxe;
+
+ QByteArray sCmdStart;
+ QByteArray sCmdStop;
+ QByteArray sCmdInit;
+ QByteArray sCmdReset;
+ QByteArray sCmdCenter;
+ QByteArray sCmdZero;
+
+ int iDelayInit;
+ int iDelayStart;
+ int iDelaySeq;
+
+ bool bBigEndian;
+
+ QString sSerialPortName;
+ QSerialPort::BaudRate iBaudRate;
+ QSerialPort::DataBits iDataBits;
+ QSerialPort::Parity iParity;
+ QSerialPort::StopBits iStopBits;
+ QSerialPort::FlowControl iFlowControl;
+
+ int CptError;
- int iRollAxis;
- int iPitchAxis;
- int iYawAxis;
- int iXAxis;
- int iYAxis;
- int iZAxis;
};
-class FTNoIR_TrackerDll : public Metadata
+
+//*******************************************************************************************************
+// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
+//*******************************************************************************************************
+class TrackerDll :
+#if defined(OPENTRACK_API)
+ public Metadata
+#else
+ public ITrackerDll
+#endif
{
public:
- FTNoIR_TrackerDll();
- ~FTNoIR_TrackerDll();
+ TrackerDll();
+ ~TrackerDll();
- void getFullName(QString *strToBeFilled);
+ void getFullName(QString *strToBeFilled);
void getShortName(QString *strToBeFilled);
void getDescription(QString *strToBeFilled);
void getIcon(QIcon *icon);
@@ -82,4 +135,5 @@ private:
QString trackerDescription;
};
+
#endif // FTNOIR_TRACKER_HAT_H
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
index 1fa482c7..14b6ef0d 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
@@ -1,9 +1,34 @@
+/********************************************************************************
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
+* *
+* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
+* Homepage: http://hatire.sourceforge.net *
+* *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
#include "ftnoir_tracker_hat.h"
#include "ftnoir_tracker_hat_dialog.h"
-#include <QMessageBox>
-#include <QDebug>
-#include <QtSerialPort/QSerialPortInfo>
+#include <QScrollBar>
//*******************************************************************************************************
// FaceTrackNoIR Client Settings-dialog.
@@ -12,16 +37,22 @@
//
// Constructor for server-settings-dialog
//
-TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDirty(false), timer(this)
+TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this)
{
-
+
ui.setupUi( this );
settings.load_ini();
- foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) {
- ui.cbSerialPort->addItem(PortInfo.portName());
+ ui.label_version->setText(VER_FILEVERSION_STR);
+
+ // make SerialPort list
+ ui.cbSerialPort->clear();
+ foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) {
+ ui.cbSerialPort->addItem(PortInfo.portName());
}
+
+ // Stop if no SerialPort dispo
if (ui.cbSerialPort->count()<1) {
QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible");
} else {
@@ -34,7 +65,44 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir
ui.cbSerialPort-> setCurrentIndex(indxport);
}
}
-
+ // Serial config
+ ui.QCB_Serial_baudRate->clear();
+ ui.QCB_Serial_baudRate->addItem(QLatin1String("9600"),QSerialPort::Baud9600);
+ ui.QCB_Serial_baudRate->addItem(QLatin1String("19200"),QSerialPort::Baud19200);
+ 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->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate));
+
+ ui.QCB_Serial_dataBits->clear();
+ ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5);
+ ui.QCB_Serial_dataBits->addItem(QLatin1String("6"), QSerialPort::Data6);
+ ui.QCB_Serial_dataBits->addItem(QLatin1String("7"), QSerialPort::Data7);
+ ui.QCB_Serial_dataBits->addItem(QLatin1String("8"), QSerialPort::Data8);
+ ui.QCB_Serial_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits));
+
+ ui.QCB_Serial_parity->clear();
+ ui.QCB_Serial_parity->addItem(QLatin1String("None"), QSerialPort::NoParity);
+ ui.QCB_Serial_parity->addItem(QLatin1String("Even"), QSerialPort::EvenParity);
+ ui.QCB_Serial_parity->addItem(QLatin1String("Odd"), QSerialPort::OddParity);
+ ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity);
+ ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity);
+ ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity));
+
+ ui.QCB_Serial_stopBits->clear();
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop);
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop);
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop);
+ ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits));
+
+
+ ui.QCB_Serial_flowControl->clear();
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("None"), QSerialPort::NoFlowControl);
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl);
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl);
+ ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl));
+
+
ui.chkEnableRoll->setChecked(settings.EnableRoll);
ui.chkEnablePitch->setChecked(settings.EnablePitch);
ui.chkEnableYaw->setChecked(settings.EnableYaw);
@@ -49,18 +117,34 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir
ui.chkInvertY->setChecked(settings.InvertY);
ui.chkInvertZ->setChecked(settings.InvertZ);
- ui.cb_roll->setCurrentIndex(settings.RollAxis);
- ui.cb_pitch->setCurrentIndex(settings.PitchAxis);
- ui.cb_yaw->setCurrentIndex(settings.YawAxis);
- ui.cb_x->setCurrentIndex(settings.XAxis);
- ui.cb_y->setCurrentIndex(settings.YAxis);
- ui.cb_z->setCurrentIndex(settings.ZAxis);
+
+ ui.cb_roll->setCurrentIndex(settings.RollAxe);
+ ui.cb_pitch->setCurrentIndex(settings.PitchAxe);
+ ui.cb_yaw->setCurrentIndex(settings.YawAxe);
+ ui.cb_x->setCurrentIndex(settings.XAxe);
+ ui.cb_y->setCurrentIndex(settings.YAxe);
+ ui.cb_z->setCurrentIndex(settings.ZAxe);
+
+ ui.le_cmd_start->setText(settings.CmdStart);
+ ui.le_cmd_stop->setText(settings.CmdStop);
+ ui.le_cmd_init->setText(settings.CmdInit);
+ ui.le_cmd_reset->setText(settings.CmdReset);
+ ui.le_cmd_center->setText(settings.CmdCenter);
+ ui.le_cmd_zero->setText(settings.CmdZero);
+
+ ui.spb_BeforeInit->setValue(settings.DelayInit);
+ ui.spb_BeforeStart->setValue(settings.DelayStart);
+ ui.spb_AfterStart->setValue(settings.DelaySeq);
+
+ ui.cb_Endian->setChecked(settings.BigEndian);
+
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave()));
+
connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) );
connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
@@ -84,11 +168,35 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir
connect(ui.cb_y, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_y(int)));
connect(ui.cb_z, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_z(int)));
+ connect(ui.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString)));
+ connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString)));
+ connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString)));
+ connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString)));
+ connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString)));
+ connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString)));
+
+ connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int)));
+ connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int)));
+ connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int)));
+
+ connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) );
+
+
+ connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) );
+ connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) );
+ connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) );
+ connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) );
+ 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.btnZero, SIGNAL(clicked()), this, SLOT(doZero()));
connect(ui.btnSend, SIGNAL(clicked()), this, SLOT(doSend()));
+ connect(ui.btn_icone, SIGNAL(clicked()), this, SLOT(doSerialInfo()));
+
connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
+
}
//
@@ -97,6 +205,9 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir
TrackerControls::~TrackerControls() {
}
+//
+// Initialize tracker-client-dialog
+//
void TrackerControls::Initialize(QWidget *parent) {
QPoint offsetpos(100, 100);
if (parent) {
@@ -105,72 +216,111 @@ void TrackerControls::Initialize(QWidget *parent) {
show();
}
+
+//
+// Apply online settings to tracker
+//
void TrackerControls::settings_changed()
{
settingsDirty = true;
if (theTracker) theTracker->applysettings(settings);
}
+
+//
+// Center asked to ARDUINO
+//
void TrackerControls::doCenter() {
- if (theTracker) theTracker->center();
+ if (theTracker) theTracker->notifyCenter();
}
+//
+// Zero asked to ARDUINO
+//
+void TrackerControls::doZero() {
+ if (theTracker) theTracker->notifyZeroed();
+}
+
+
+//
+// Reset asked to ARDUINO
+//
void TrackerControls::doReset() {
if (theTracker) theTracker->reset();
}
+
+//
+// Serial Info debug
+//
+void TrackerControls::doSerialInfo() {
+ if (theTracker) theTracker->SerialInfo();
+}
+
+
+//
+// Send command to ARDUINO
+//
void TrackerControls::doSend() {
if (theTracker) {
if (!ui.lineSend->text().isEmpty()) {
- QString cmd;
- cmd=ui.lineSend->text();
- theTracker->sendcmd(&cmd);
- ui.lineSend->clear();
+ theTracker->sendcmd(ui.lineSend->text().toLatin1());
}
}
}
+
+//
+// Display FPS of Arduino.
+//
void TrackerControls::poll_tracker_info()
{
if (theTracker)
{
- QString info;
- int num_trame;
int nb_trame;
- theTracker->get_info(&info,&num_trame);
- if ( !info.isNull()) {
- ui.lab_vstatus->setText(info);
- ui.pteINFO->moveCursor(QTextCursor::End);
- ui.pteINFO->insertPlainText(info);
- }
+ theTracker->get_info(&nb_trame);
+ ui.lab_vtps->setText(QString::number(nb_trame*(1000/last_time.elapsed())));
+ last_time.restart();
+ }
+}
- if (pre_frame<num_trame)
- { nb_trame=num_trame-pre_frame;}
- else
- {nb_trame=(1000-pre_frame)+num_trame;}
- ui.lab_vtps->setText(QString::number(nb_trame*(1000/timer.interval())));
- pre_frame=num_trame;
- }
-
+void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
+{
+ QApplication::beep();
+ ui.pteINFO->moveCursor(QTextCursor::End);
+ ui.pteINFO->insertPlainText(QString(MsgInfo));
+ QScrollBar *bar = ui.pteINFO->verticalScrollBar();
+ bar->setValue(bar->maximum());
}
+
void TrackerControls::doSave() {
settingsDirty=false;
- settings.save_ini();
+ settings.save_ini();
}
+
+//
+// OK clicked on server-dialog
+//
void TrackerControls::doOK() {
settingsDirty=false;
- settings.save_ini();
+ settings.save_ini();
this->close();
}
+//
+// Cancel clicked on server-dialog
+//
void TrackerControls::doCancel() {
- if (settingsDirty) {
+ //
+ // Ask if changed Settings should be saved
+ //
+ if (settingsDirty) {
int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
switch (ret) {
case QMessageBox::Save:
@@ -181,8 +331,10 @@ void TrackerControls::doCancel() {
close();
break;
case QMessageBox::Cancel:
+ // Cancel was clicked
break;
default:
+ // should never be reached
break;
}
}
@@ -193,22 +345,44 @@ void TrackerControls::doCancel() {
void TrackerControls::registerTracker(ITracker *tracker) {
- theTracker = dynamic_cast<FTNoIR_Tracker*>(tracker);
+ theTracker = static_cast<FTNoIR_Tracker*>(tracker);
+ connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray)));
+
if (isVisible() && settingsDirty) theTracker->applysettings(settings);
+
ui.cbSerialPort->setEnabled(false);
- timer.start(250);
+ ui.pteINFO->clear();
ui.lab_vstatus->setText("HAT START");
+ last_time.start();
+ timer.start(250);
+
}
+
void TrackerControls::unRegisterTracker() {
- theTracker = NULL;
- ui.cbSerialPort->setEnabled(true);
+ theTracker=NULL;
timer.stop();
+ ui.cbSerialPort->setEnabled(true);
ui.lab_vstatus->setText("HAT STOPPED");
ui.lab_vtps->setText("");
}
-extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog()
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker-settings dialog object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
+#ifdef OPENTRACK_API
+extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
+#else
+#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
+FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
+#endif
{
return new TrackerControls;
}
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
index 25bd839c..e413ded6 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
@@ -1,35 +1,41 @@
#ifndef FTNOIR_TRACKER_HAT_DIALOG_H
#define FTNOIR_TRACKER_HAT_DIALOG_H
+#ifdef OPENTRACK_API
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#else
+#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
+#endif
#include "ftnoir_tracker_hat_settings.h"
#include "ftnoir_tracker_hat.h"
#include "ui_ftnoir_hatcontrols.h"
-
+#include <QObject>
+#include <QTime>
#include <QTimer>
#include <QMessageBox>
+#include <QMetaType>
+// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
-
public:
explicit TrackerControls();
- virtual ~TrackerControls() virt_override;
-
+ virtual ~TrackerControls();
void Initialize(QWidget *parent) virt_override;
void registerTracker(ITracker *tracker) virt_override;
void unRegisterTracker() virt_override;
private:
Ui::UIHATControls ui;
- int pre_frame;
FTNoIR_Tracker *theTracker;
+ QTime last_time;
+
+public slots:
+ void WriteMsgInfo(const QByteArray &MsgInfo);
protected slots:
- void set_mod_port(const QString & val) { settings.SerialPortName =val;
- QMessageBox::warning(this,"FaceTrackNoIR Error", settings.SerialPortName);
- settings_changed(); }
+ void set_mod_port(const QString & val) { settings.SerialPortName =val; settings_changed(); }
void set_ena_roll(bool val) { settings.EnableRoll = val; settings_changed(); }
void set_ena_pitch(bool val) { settings.EnablePitch = val; settings_changed(); }
void set_ena_yaw(bool val) { settings.EnableYaw = val; settings_changed(); }
@@ -45,20 +51,41 @@ protected slots:
void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); }
- void set_rot_roll(int val) { settings.RollAxis = val; settings_changed(); }
- void set_rot_pitch(int val) { settings.PitchAxis = val; settings_changed(); }
- void set_rot_yaw(int val) { settings.YawAxis = val; settings_changed(); }
- void set_acc_x(int val) { settings.XAxis = val; settings_changed(); }
- void set_acc_y(int val) { settings.YAxis = val; settings_changed(); }
- void set_acc_z(int val) { settings.ZAxis = val; settings_changed(); }
+ void set_rot_roll(int val) { settings.RollAxe = val; settings_changed(); }
+ void set_rot_pitch(int val) { settings.PitchAxe = val; settings_changed(); }
+ void set_rot_yaw(int val) { settings.YawAxe = val; settings_changed(); }
+ void set_acc_x(int val) { settings.XAxe = val; settings_changed(); }
+ void set_acc_y(int val) { settings.YAxe = val; settings_changed(); }
+ void set_acc_z(int val) { settings.ZAxe = val; settings_changed(); }
+
+ void set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); }
+ void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); }
+ void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); }
+ void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); }
+ void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); }
+ void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); }
+
+ void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); }
+ void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); }
+ void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); }
+
+ void set_endian(bool val) { settings.BigEndian = val; settings_changed(); }
+
+ void set_mod_baud(int val) { settings.pBaudRate = static_cast<QSerialPort::BaudRate>(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); }
+ void set_mod_dataBits(int val) { settings.pDataBits = static_cast<QSerialPort::DataBits>(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); }
+ void set_mod_parity(int val) { settings.pParity = static_cast<QSerialPort::Parity>(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); }
+ void set_mod_stopBits(int val) { settings.pStopBits = static_cast<QSerialPort::StopBits>(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); }
+ void set_mod_flowControl(int val) { settings.pFlowControl = static_cast<QSerialPort::FlowControl>(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); }
void doOK();
void doCancel();
void doSave();
void doReset();
void doCenter();
+ void doZero();
void doSend();
void poll_tracker_info();
+ void doSerialInfo();
protected:
bool settingsDirty;
@@ -67,5 +94,4 @@ protected:
QTimer timer;
};
-
#endif //FTNOIR_TRACKER_HAT_DIALOG_H
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp
index cd1475f8..5f82d5a0 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp
@@ -1,38 +1,81 @@
+/********************************************************************************
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
+* *
+* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
+* Homepage: http://hatire.sourceforge.net *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
+
#include "ftnoir_tracker_hat.h"
#include <QIcon>
#include <QDebug>
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
+TrackerDll::TrackerDll() {
+ //populate the description strings
trackerFullName = "Hatire Arduino";
trackerShortName = "HAT";
- trackerDescription = "Hatire Arduino";
+ trackerDescription = "FaceTrackNoIR HAT";
}
-FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
+TrackerDll::~TrackerDll()
{
+
}
-void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
+void TrackerDll::getFullName(QString *strToBeFilled)
{
*strToBeFilled = trackerFullName;
}
-void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
+void TrackerDll::getShortName(QString *strToBeFilled)
{
*strToBeFilled = trackerShortName;
}
-void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
+void TrackerDll::getDescription(QString *strToBeFilled)
{
*strToBeFilled = trackerDescription;
}
-void FTNoIR_TrackerDll::getIcon(QIcon *icon)
+void TrackerDll::getIcon(QIcon *icon)
{
*icon = QIcon(":/images/hat.png");
}
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
+
+#ifdef OPENTRACK_API
+# include "facetracknoir/global-settings.h"
extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+#else
+# pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
+FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll()
+#endif
{
- return new FTNoIR_TrackerDll;
+ return new TrackerDll;
}
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
index a9466304..0be912f2 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
@@ -1,12 +1,38 @@
+/********************************************************************************
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
+* *
+* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
+* Homepage: http://hatire.sourceforge.net *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
#include <QCoreApplication>
#include <QSettings>
+#include <QVariant>
#include "ftnoir_tracker_hat_settings.h"
void TrackerSettings::load_ini()
{
- qDebug("TrackerSettings::load_ini()");
- QSettings settings("opentrack");
+ QSettings settings("opentrack"); // Registry settings (in HK_USER)
QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
@@ -30,12 +56,33 @@ void TrackerSettings::load_ini()
InvertZ = iniFile.value( "InvertZ", 0 ).toBool();
- RollAxis=iniFile.value("RollAxis",1).toInt();
- PitchAxis=iniFile.value("PitchAxis",2).toInt();
- YawAxis=iniFile.value("YawAxis",0).toInt();
- XAxis=iniFile.value("XAxis",1).toInt();
- YAxis=iniFile.value("YAxis",2).toInt();
- ZAxis=iniFile.value("ZAxis",0).toInt();
+ RollAxe=iniFile.value("RollAxe",1).toInt();
+ PitchAxe=iniFile.value("PitchAxe",2).toInt();
+ YawAxe=iniFile.value("YawAxe",0).toInt();
+ XAxe=iniFile.value("XAxe",1).toInt();
+ YAxe=iniFile.value("YAxe",2).toInt();
+ ZAxe=iniFile.value("ZAxe",0).toInt();
+
+
+ CmdStart=iniFile.value ( "CmdStart").toString();
+ CmdStop=iniFile.value ( "CmdStop" ).toString();
+ CmdInit=iniFile.value ( "CmdInit" ).toString();
+ CmdReset=iniFile.value ( "CmdReset" ).toString();
+ CmdCenter=iniFile.value ( "CmdCenter" ).toString();
+ CmdZero=iniFile.value ( "CmdZero" ).toString();
+
+ DelayInit=iniFile.value("DelayInit",0).toInt();
+ DelayStart=iniFile.value("DelayStart",0).toInt();
+ DelaySeq=iniFile.value("DelaySeq",0).toInt();
+
+ BigEndian=iniFile.value("BigEndian",0).toBool();
+
+
+ pBaudRate=static_cast<QSerialPort::BaudRate>(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt());
+ pDataBits=static_cast<QSerialPort::DataBits>(iniFile.value("DataBits",QSerialPort::Data8).toInt());
+ pParity=static_cast<QSerialPort::Parity>(iniFile.value("Parity",QSerialPort::NoParity).toInt());
+ pStopBits=static_cast<QSerialPort::StopBits>(iniFile.value("StopBits",QSerialPort::OneStop).toInt());
+ pFlowControl=static_cast<QSerialPort::FlowControl>(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt());
iniFile.endGroup();
}
@@ -43,9 +90,8 @@ void TrackerSettings::load_ini()
void TrackerSettings::save_ini() const
{
- qDebug("TrackerSettings::save_ini()");
- QSettings settings("opentrack");
+ QSettings settings("opentrack"); // Registry settings (in HK_USER)
QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
@@ -67,12 +113,33 @@ void TrackerSettings::save_ini() const
iniFile.setValue( "InvertY", InvertY );
iniFile.setValue( "InvertZ", InvertZ );
- iniFile.setValue ( "RollAxis", RollAxis );
- iniFile.setValue ( "PitchAxis", PitchAxis );
- iniFile.setValue ( "YawAxis",YawAxis );
- iniFile.setValue ( "XAxis", XAxis );
- iniFile.setValue ( "YAxis", YAxis );
- iniFile.setValue ( "ZAxis", ZAxis );
+ iniFile.setValue ( "RollAxe", RollAxe );
+ iniFile.setValue ( "PitchAxe", PitchAxe );
+ iniFile.setValue ( "YawAxe",YawAxe );
+ iniFile.setValue ( "XAxe", XAxe );
+ iniFile.setValue ( "YAxe", YAxe );
+ iniFile.setValue ( "ZAxe", ZAxe );
+
+ iniFile.setValue ( "CmdStart",CmdStart.toLatin1());
+ iniFile.setValue ( "CmdStop",CmdStop.toLatin1());
+ iniFile.setValue ( "CmdInit",CmdInit.toLatin1());
+ iniFile.setValue ( "CmdReset",CmdReset.toLatin1());
+ iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() );
+ iniFile.setValue ( "CmdZero",CmdZero.toLatin1() );
+
+ iniFile.setValue ( "DelayInit",DelayInit);
+ iniFile.setValue ( "DelayStart",DelayStart);
+ iniFile.setValue ( "DelaySeq",DelaySeq);
+
+ iniFile.setValue("BigEndian",BigEndian);
+
+ iniFile.setValue("BaudRate",pBaudRate);
+ iniFile.setValue("DataBits",pDataBits);
+ iniFile.setValue("Parity",pParity);
+ iniFile.setValue("StopBits",pStopBits);
+ iniFile.setValue("FlowControl",pFlowControl);
+
iniFile.endGroup();
}
+
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
index d6cf4fd9..2e84bde8 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
@@ -8,13 +8,15 @@
#ifndef FTNOIR_TRACKER_HAT_SETTINGS_H
#define FTNOIR_TRACKER_HAT_SETTINGS_H
-#include <QString>
+#include <QtSerialPort/QSerialPort>
//-----------------------------------------------------------------------------
struct TrackerSettings
{
- QString SerialPortName;
+ void load_ini();
+ void save_ini() const;
+
bool EnableRoll;
bool EnablePitch;
bool EnableYaw;
@@ -30,15 +32,34 @@ struct TrackerSettings
bool InvertZ;
- int RollAxis;
- int PitchAxis;
- int YawAxis;
- int XAxis;
- int YAxis;
- int ZAxis;
+ int RollAxe;
+ int PitchAxe;
+ int YawAxe;
+ int XAxe;
+ int YAxe;
+ int ZAxe;
+
+ QString CmdStart;
+ QString CmdStop;
+ QString CmdInit;
+ QString CmdReset;
+ QString CmdCenter;
+ QString CmdZero;
+
+ int DelayInit;
+ int DelayStart;
+ int DelaySeq;
+
+ bool BigEndian;
+
+ QString SerialPortName;
+ QSerialPort::BaudRate pBaudRate;
+ QSerialPort::DataBits pDataBits;
+ QSerialPort::Parity pParity;
+ QSerialPort::StopBits pStopBits;
+ QSerialPort::FlowControl pFlowControl;
- void load_ini();
- void save_ini() const;
};
-#endif //FTNOIR_TRACKER_HAT_SETTINGS_H
+
+#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file