author | Manisha Agrawal <manisha.agrawal@ti.com> | |
Fri, 19 Oct 2018 19:34:52 +0000 (19:34 +0000) | ||
committer | Manisha Agrawal <manisha.agrawal@ti.com> | |
Tue, 23 Oct 2018 18:08:04 +0000 (18:08 +0000) |
Gesture Controlled Human-Machine Interace with Sitara AM device and mmWave
Radar IWR1632 chip. mmWave Radar IWR1632 chip detects the gesture,
Sitara AM device receives the gesture over USB UART, parses the signal and
controls the HMI.
Signed-off-by: Manisha Agrawal <manisha.agrawal@ti.com>
Radar IWR1632 chip. mmWave Radar IWR1632 chip detects the gesture,
Sitara AM device receives the gesture over USB UART, parses the signal and
controls the HMI.
Signed-off-by: Manisha Agrawal <manisha.agrawal@ti.com>
Digit.qml | [new file with mode: 0644] | patch | blob |
keyword.cpp | [new file with mode: 0755] | patch | blob |
keyword.h | [new file with mode: 0755] | patch | blob |
lock_unlock.gif | [new file with mode: 0755] | patch | blob |
main.cpp | [new file with mode: 0644] | patch | blob |
main.qml | [new file with mode: 0644] | patch | blob |
mmwavegesture.pro | [new file with mode: 0644] | patch | blob |
mmwgesturein.h | [new file with mode: 0755] | patch | blob |
qml.qrc | [new file with mode: 0644] | patch | blob |
serialreaderthread.cpp | [new file with mode: 0644] | patch | blob |
serialreaderthread.h | [new file with mode: 0644] | patch | blob |
diff --git a/Digit.qml b/Digit.qml
--- /dev/null
+++ b/Digit.qml
@@ -0,0 +1,106 @@
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+import QtQuick 2.0
+
+Rectangle {
+ id: digitItem
+ width: size
+ height: size
+
+ clip: true
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: "black"
+ }
+
+ GradientStop {
+ position: 0.5
+ color: "#222222"
+ }
+
+ GradientStop {
+ position: 1.0
+ color: "black"
+ }
+ }
+
+ property color borderColor: "black"
+ property int borderWidth: 1
+ border.color: borderColor
+ border.width: borderWidth
+
+ property int digit: 0
+ property int size: 80
+
+
+ onDigitChanged: { digitPath.currentIndex = digit; }
+
+ PathView {
+ id: digitPath
+ objectName: "digitPathObj"
+
+ width: digitItem.size
+ height: digitItem.size * 10
+
+ anchors.centerIn: parent
+
+ model: [3, 4, 5, 6, 7, 8]
+
+ delegate: Text {
+ width: digitItem.size
+ height: digitItem.size
+
+ text: modelData;
+
+ color: "white";
+
+ horizontalAlignment: Text.AlignHCenter;
+ verticalAlignment: Text.AlignVCenter;
+
+ font.pointSize: digitItem.size-4;
+ }
+
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+
+ path: Path {
+ startX: digitPath.width / 2
+ startY: 0
+
+ PathLine { x: digitPath.width / 2; y: digitPath.height }
+ }
+ }
+}
diff --git a/keyword.cpp b/keyword.cpp
--- /dev/null
+++ b/keyword.cpp
@@ -0,0 +1,117 @@
+/*\r
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/\r
+*\r
+*\r
+* Redistribution and use in source and binary forms, with or without\r
+* modification, are permitted provided that the following conditions\r
+* are met:\r
+*\r
+* Redistributions of source code must retain the above copyright\r
+* notice, this list of conditions and the following disclaimer.\r
+*\r
+* Redistributions in binary form must reproduce the above copyright\r
+* notice, this list of conditions and the following disclaimer in the\r
+* documentation and/or other materials provided with the\r
+* distribution.\r
+*\r
+* Neither the name of Texas Instruments Incorporated nor the names of\r
+* its contributors may be used to endorse or promote products derived\r
+* from this software without specific prior written permission.\r
+*\r
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*\r
+*/\r
+#include <QCoreApplication>\r
+#include <QDebug>\r
+#include "keyword.h"\r
+\r
+QT_USE_NAMESPACE\r
+\r
+Keyword::Keyword(QObject *qmlCompObject)\r
+{\r
+ m_digitArray[0] = qmlCompObject->findChild<QObject *>("myDigit1");\r
+ m_digitArray[1] = qmlCompObject->findChild<QObject *>("myDigit2");\r
+ m_digitArray[2] = qmlCompObject->findChild<QObject *>("myDigit3");\r
+ m_digitArray[3] = qmlCompObject->findChild<QObject *>("myDigit4");\r
+\r
+ m_qmlCompObject = qmlCompObject;\r
+\r
+ /* Substract the keyword with 3 as the keyword is matched to the "model" index and not\r
+ * the value at that index. Check the PathView in Digit.qml to understand model. A PathView\r
+ * displays data from models created from built-in QML types. A model provides a\r
+ * set of data that is used to create the items for the view. To avoid many scrolls to\r
+ * to set the password, password is restricted between 3 and 8 and mmWave part number is\r
+ * 6843, which is set as initial password*/\r
+ m_keyword[0] -= 3;\r
+ m_keyword[1] -= 3;\r
+ m_keyword[2] -= 3;\r
+ m_keyword[3] -= 3;\r
+\r
+ qDebug() << " keyword index" << m_keyword[0] << m_keyword[1] << m_keyword[2] << m_keyword[3];\r
+ m_activeIndex = 0;\r
+\r
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "red");\r
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);\r
+ m_digitArray[m_activeIndex]->setProperty("digit", m_counter[0]);\r
+\r
+ for (int i = 1; i < 4; i++){\r
+ if(m_digitArray[i]){\r
+ m_digitArray[i]->setProperty("borderColor", "black");\r
+ m_digitArray[i]->setProperty("borderWidth", 1);\r
+ m_digitArray[i]->setProperty("digit", m_counter[i]);\r
+ }\r
+ }\r
+}\r
+\r
+Keyword::~Keyword()\r
+{\r
+}\r
+\r
+void Keyword::handleDownGesture()\r
+{\r
+ bool keyMatch = false;\r
+ m_counter[m_activeIndex] = (m_counter[m_activeIndex] + 1) % 6;\r
+\r
+ m_digitArray[m_activeIndex]->setProperty("digit", m_counter[m_activeIndex]);\r
+\r
+ keyMatch = ((m_digitArray[0]->property("digit") == m_keyword[0]) &&\r
+ (m_digitArray[1]->property("digit") == m_keyword[1]) &&\r
+ (m_digitArray[2]->property("digit") == m_keyword[2]) &&\r
+ (m_digitArray[3]->property("digit") == m_keyword[3]));\r
+\r
+ if (keyMatch == true){\r
+ m_qmlCompObject->setProperty("mypaused", false);\r
+ }\r
+}\r
+\r
+void Keyword::handleRightGesture()\r
+{\r
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "black");\r
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 2);\r
+ m_activeIndex = (m_activeIndex + 1) % 4;\r
+\r
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "red");\r
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);\r
+}\r
+\r
+void Keyword::handleMotionDetected()\r
+{\r
+ m_qmlCompObject->setProperty("color", "gray");\r
+ m_qmlCompObject->setProperty("myvisibility", true);\r
+}\r
+\r
+void Keyword::handleNoActivity()\r
+{\r
+ m_qmlCompObject->setProperty("color", "black");\r
+ m_qmlCompObject->setProperty("myvisibility", false);\r
+}\r
diff --git a/keyword.h b/keyword.h
--- /dev/null
+++ b/keyword.h
@@ -0,0 +1,72 @@
+/*\r
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/\r
+*\r
+*\r
+* Redistribution and use in source and binary forms, with or without\r
+* modification, are permitted provided that the following conditions\r
+* are met:\r
+*\r
+* Redistributions of source code must retain the above copyright\r
+* notice, this list of conditions and the following disclaimer.\r
+*\r
+* Redistributions in binary form must reproduce the above copyright\r
+* notice, this list of conditions and the following disclaimer in the\r
+* documentation and/or other materials provided with the\r
+* distribution.\r
+*\r
+* Neither the name of Texas Instruments Incorporated nor the names of\r
+* its contributors may be used to endorse or promote products derived\r
+* from this software without specific prior written permission.\r
+*\r
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*\r
+*/\r
+#ifndef KEYWORD_H\r
+#define KEYWORD_H\r
+\r
+#include <QByteArray>\r
+#include <QObject>\r
+\r
+\r
+QT_USE_NAMESPACE\r
+\r
+QT_BEGIN_NAMESPACE\r
+\r
+QT_END_NAMESPACE\r
+\r
+class Keyword : public QObject\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ Keyword(QObject *object);\r
+ ~Keyword();\r
+ char m_keyword[4] = {6, 8, 4, 3};\r
+\r
+signals:\r
+ void keywordMatched();\r
+\r
+public slots:\r
+ void handleDownGesture();\r
+ void handleRightGesture();\r
+ void handleMotionDetected();\r
+ void handleNoActivity();\r
+\r
+private:\r
+ QObject *m_digitArray[4] = {nullptr};\r
+ unsigned char m_counter[4] = {0, 0, 4, 4};\r
+ unsigned char m_activeIndex = 0;\r
+ QObject *m_qmlCompObject;\r
+};\r
+\r
+#endif\r
diff --git a/lock_unlock.gif b/lock_unlock.gif
new file mode 100755 (executable)
index 0000000..8c37661
Binary files /dev/null and b/lock_unlock.gif differ
index 0000000..8c37661
Binary files /dev/null and b/lock_unlock.gif differ
diff --git a/main.cpp b/main.cpp
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,117 @@
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#include <QGuiApplication>
+#include <QQmlEngine>
+#include <qqml.h>
+#include <QQmlComponent>
+#include <QtSerialPort/QSerialPort>
+#include <QDebug>
+#include <QQmlContext>
+#include <QScreen>
+
+#include "keyword.h"
+#include "serialreaderthread.h"
+
+void checkUserPassword(int argc, char *argv[], Keyword *keyword)
+{
+ if(argc > 1){
+ char *pw = argv[1];
+ keyword->m_keyword[0] = pw[0];
+ keyword->m_keyword[1] = pw[1];
+ keyword->m_keyword[2] = pw[2];
+ keyword->m_keyword[3] = pw[3];
+ qDebug() << pw[0] << pw[1] << pw[2] << pw[3];
+
+ }
+ else{
+ printf("User can set four digit password through command line argument\n");
+ printf("The digits should be between 3 and 8\n");
+ printf("Example usage: mmWaveGesture 7364");
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:/main.qml"));
+ QObject *object = component.create();
+
+ if(object == NULL){
+ qDebug() << "Cannot create root object\n";
+ return -1;
+ }
+
+ /* Set the main window property like image name, displayed width and height of the image */
+ QScreen *screen = QGuiApplication::primaryScreen();
+ QRect screenGeometry = screen->geometry();
+ int width = screenGeometry.width();
+ int height = screenGeometry.height();
+ object->setProperty("width", width);
+ object->setProperty("height", height);
+ object->setProperty("mysource", "lock_unlock.gif");
+
+ /* Open the serial port. Serail port property gets set by SerialReaderThread Object */
+ QSerialPort serialPort;
+ QString serialPortName = "/dev/ttyACM1";// "XDS110 Class Auxiliary Data Port";
+ serialPort.setPortName(serialPortName);
+
+ if (!serialPort.open(QIODevice::ReadOnly)) {
+ qDebug() << QObject::tr("Failed to open port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
+ return -1;
+ }
+ qDebug() << "opened serial port";
+
+ /* Create Keyword and gestureReaderThread object. Connect the signals emitted by gestureRaederThread with the slots in the Keyword object */
+ Keyword keyword(object);
+ SerialReaderThread *gestureReaderThread;
+ gestureReaderThread = new SerialReaderThread(&serialPort);
+
+ /*Connect the signals emitted by gestureRaederThread with the slots in the Keyword object */
+ QObject::connect(gestureReaderThread, &SerialReaderThread::downGesture, &keyword, &Keyword::handleDownGesture);
+ QObject::connect(gestureReaderThread, &SerialReaderThread::rightGesture, &keyword, &Keyword::handleRightGesture);
+ QObject::connect(gestureReaderThread, &SerialReaderThread::motionDetected, &keyword, &Keyword::handleMotionDetected);
+ QObject::connect(gestureReaderThread, &SerialReaderThread::noActivity, &keyword, &Keyword::handleNoActivity);
+
+
+ /* Check if password key is provided as cmd line argument, else use default */
+ checkUserPassword(argc, argv, &keyword);
+
+ /* Start thread that reads the gesture from mmWave Sensor and take predetermined action per the gestures received */
+ gestureReaderThread->start();
+
+ return app.exec();
+}
+
diff --git a/main.qml b/main.qml
--- /dev/null
+++ b/main.qml
@@ -0,0 +1,67 @@
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+import QtQuick 2.9
+import QtQuick.Window 2.2
+
+Window{
+ id:mainWindow
+ visible: true
+ width: 1920
+ height: 1080
+ title: qsTr("mmWave + Sitara Gesture Control Demo")
+ color: "black"
+ property string mysource
+ property bool mypaused : true
+ property bool myvisibility: false
+
+ Digit { id: digit1; visible: myvisibility; objectName: "myDigit1"; x:parent.width*0.25; y:parent.height * 0.7; size:parent.width*0.10}
+ Digit { id: digit2; visible: myvisibility; objectName: "myDigit2"; anchors.left:digit1.right; anchors.leftMargin:0.033*parent.width; y:digit1.y; size:parent.width*0.10}
+ Digit { id: digit3; visible: myvisibility; objectName: "myDigit3"; anchors.left:digit2.right; anchors.leftMargin:0.033*parent.width; y:digit1.y; size:parent.width*0.10}
+ Digit { id: digit4; visible: myvisibility; objectName: "myDigit4"; anchors.left:digit3.right; anchors.leftMargin:0.033*parent.width; y:digit1.y; size:parent.width*0.10}
+
+ property int activeid: 0
+
+ AnimatedImage{
+ id:lock
+ visible: myvisibility
+ source: mainWindow.mysource
+ width:parent.width/2; height: parent.height/2
+ property int idx: 1
+ x:(parent.width-width)/2
+ y: (parent.height-height)/4
+ paused: mainWindow.mypaused
+ onFrameChanged: if(currentFrame==frameCount-1) { mainWindow.mypaused = true; }
+ }
+}
diff --git a/mmwavegesture.pro b/mmwavegesture.pro
--- /dev/null
+++ b/mmwavegesture.pro
@@ -0,0 +1,36 @@
+QT += quick serialport core
+
+#QT += quick core
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += main.cpp keyword.cpp serialreaderthread.cpp
+
+HEADERS += keyword.h serialreaderthread.h \
+ mmwgesturein.h
+
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+DISTFILES +=
diff --git a/mmwgesturein.h b/mmwgesturein.h
--- /dev/null
+++ b/mmwgesturein.h
@@ -0,0 +1,78 @@
+/*\r
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/\r
+*\r
+*\r
+* Redistribution and use in source and binary forms, with or without\r
+* modification, are permitted provided that the following conditions\r
+* are met:\r
+*\r
+* Redistributions of source code must retain the above copyright\r
+* notice, this list of conditions and the following disclaimer.\r
+*\r
+* Redistributions in binary form must reproduce the above copyright\r
+* notice, this list of conditions and the following disclaimer in the\r
+* documentation and/or other materials provided with the\r
+* distribution.\r
+*\r
+* Neither the name of Texas Instruments Incorporated nor the names of\r
+* its contributors may be used to endorse or promote products derived\r
+* from this software without specific prior written permission.\r
+*\r
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+*\r
+*/\r
+#ifndef MMWGESTUREIN_H\r
+#define MMWGESTUREIN_H\r
+\r
+/* Bit Field definitions for gesture report */\r
+\r
+/* Mode indicator bits */\r
+#define GESTURE_MODE_BIT_SHIFT 0U\r
+#define GESTURE_MODE_BIT_END 2U\r
+#define GESTURE_MODE_BIT_MASK 0x7U\r
+\r
+#define GESTURE_ERROR_BIT_SHIFT 3U\r
+#define GESTURE_ERROR_BIT_END 3U\r
+#define GESTURE_ERROR_BIT_MASK 0x8U\r
+\r
+#define GESTURE_MODET_BIT_SHIFT 4U\r
+#define GESTURE_MODET_BIT_END 4U\r
+#define GESTURE_MODET_BIT_MASK 0x10U\r
+\r
+/* Detected Gesture Type*/\r
+#define GESTURE_TYPE_BIT_SHIFT 0U\r
+#define GESTURE_TYPE_BIT_END 7U\r
+#define GESTURE_TYPE_BIT_MASK 0x7F\r
+\r
+/* Enum definitions for gesture mode information */\r
+typedef enum Gesture_mode_type_e\r
+{\r
+ GESTURE_MODE_IDLE = 2,\r
+ GESTURE_MODE_GESTURE = 4\r
+}Gesture_mode_type;\r
+\r
+typedef enum Gesture_gesture_type_e\r
+{\r
+ GESTURE_TYPE_NONE = 1U,\r
+ GESTURE_TYPE_UP_TO_DOWN = 2,\r
+ GESTURE_TYPE_DOWN_TO_UP = 4,\r
+ GESTURE_TYPE_LEFT_TO_RIGHT = 8,\r
+ GESTURE_TYPE_RIGHT_TO_LEFT = 16,\r
+ GESTURE_TYPE_CCW_ROTATION = 32, /* Counter ClockWise Rotation */\r
+ GESTURE_TYPE_CW_ROTATION = 64 /* ClockWise Rotation */\r
+}Gesture_gesture_type;\r
+\r
+\r
+\r
+#endif /* MMWGESTUREIN_H */\r
+\r
diff --git a/qml.qrc b/qml.qrc
--- /dev/null
+++ b/qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>Digit.qml</file>
+ <file>lock_unlock.gif</file>
+ </qresource>
+</RCC>
diff --git a/serialreaderthread.cpp b/serialreaderthread.cpp
--- /dev/null
+++ b/serialreaderthread.cpp
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#include <QDebug>
+#include <termios.h>
+#include "serialreaderthread.h"
+#include "mmwgesturein.h"
+
+SerialReaderThread::SerialReaderThread(QSerialPort *serialPort)
+{
+ m_serialPort = serialPort;
+
+ serialPort->setBaudRate(921600, QSerialPort::Input);
+ serialPort->setDataBits(QSerialPort::Data8);
+ serialPort->setParity(QSerialPort::NoParity);
+ serialPort->setStopBits(QSerialPort::OneStop);
+ serialPort->setFlowControl(QSerialPort::NoFlowControl);
+
+ m_privmode = GESTURE_MODE_IDLE;
+}
+
+SerialReaderThread::~SerialReaderThread(void){}
+
+
+void SerialReaderThread::run()
+{
+ while (1){
+
+ if ( m_serialPort->bytesAvailable() > 0 || m_serialPort->waitForReadyRead(10))
+ {
+ QByteArray ba;
+ ba=m_serialPort->readAll();
+
+ //Burst size is of 8 bytes. Less than 8 bytes is not useful to parse\n");
+ if(ba.size() < 8){
+ continue;
+ }
+
+
+ //parse further if magic word 0x12, 0x34, 0x56, 0x78 is found
+ if (((unsigned char)ba[0] == 0x12) && ((unsigned char)ba[1] == 0x34) && (
+ (unsigned char)ba[2] == 0x56) && ((unsigned char)ba[3] == 0x78)){
+
+ //parse for error bits. Process further only if there's no error in the mode info
+ if(! (ba[4] & GESTURE_ERROR_BIT_MASK)){
+
+ Gesture_mode_type mode_info = (Gesture_mode_type)((ba[4] & (GESTURE_MODE_BIT_MASK)) >> GESTURE_MODE_BIT_SHIFT);
+
+ switch(mode_info){
+ case GESTURE_MODE_IDLE: if (m_privmode == GESTURE_MODE_GESTURE) emit noActivity();
+ m_privmode = GESTURE_MODE_IDLE;
+ break;
+ case GESTURE_MODE_GESTURE: if(m_privmode == GESTURE_MODE_IDLE) emit motionDetected();
+ m_privmode = GESTURE_MODE_GESTURE;
+ {
+ Gesture_gesture_type gesture_type = (Gesture_gesture_type)((ba[5] & GESTURE_TYPE_BIT_MASK) >> GESTURE_TYPE_BIT_SHIFT);
+ switch(gesture_type){
+ case GESTURE_TYPE_UP_TO_DOWN: emit downGesture(); break;
+ case GESTURE_TYPE_RIGHT_TO_LEFT: emit rightGesture(); break;
+ default: //qDebug() << "unrecognized gesture" << gesture_type;
+ break;
+ }
+ }
+ break;
+ // default: qDebug() << "Unrecognized mode received" << mode_info;
+ break;
+ }
+
+ }
+ }
+ msleep(1);
+ }
+ }
+}
diff --git a/serialreaderthread.h b/serialreaderthread.h
--- /dev/null
+++ b/serialreaderthread.h
@@ -0,0 +1,63 @@
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#ifndef SERIALREADERTHREAD_H
+#define SERIALREADERTHREAD_H
+
+#include <unistd.h>
+#include <QThread>
+#include <QtSerialPort/QSerialPort>
+#include "keyword.h"
+#include "mmwgesturein.h"
+
+class SerialReaderThread : public QThread
+{
+ Q_OBJECT
+
+public:
+ SerialReaderThread(QSerialPort *);
+ ~SerialReaderThread(void);
+
+signals:
+ void downGesture();
+ void rightGesture();
+ void motionDetected();
+ void noActivity();
+protected:
+ void run();
+
+private:
+ QSerialPort *m_serialPort;
+ Gesture_mode_type m_privmode;
+};
+#endif // SERIALREADERTHREAD_H