diff --git a/main.cpp b/main.cpp
index 35f7cb69a72dd173880f4fd3cf24debb9351f924..f7c77150640aed2abf35b8ca85b1d2d1e7344d35 100644 (file)
--- a/main.cpp
+++ b/main.cpp
#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);
QQmlComponent component(&engine, QUrl("qrc:/main.qml"));
QObject *object = component.create();
+ printf("Usage: mmwavegesture-hmi <# of iterations to open the lock> -platform eglfs\n");
+ printf("Default settings: # of iterations to open the lock = 1; password = 6843\n");
+
if(object == NULL){
qDebug() << "Cannot create root object\n";
return -1;
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);
+ gestureReaderThread = new SerialReaderThread();
+ /*Connect the signals and slots between gestureRaederThread and Keyword object */
+ QObject::connect(gestureReaderThread, &SerialReaderThread::downGesture, &keyword, &Keyword::handleDownGesture, Qt::BlockingQueuedConnection );
+ QObject::connect(gestureReaderThread, &SerialReaderThread::rightGesture, &keyword, &Keyword::handleRightGesture, Qt::BlockingQueuedConnection );
+ QObject::connect(gestureReaderThread, &SerialReaderThread::motionDetected, &keyword, &Keyword::handleMotionDetected, Qt::BlockingQueuedConnection );
+ QObject::connect(gestureReaderThread, &SerialReaderThread::noActivity, &keyword, &Keyword::handleNoActivity, Qt::BlockingQueuedConnection );
+ QObject::connect(&keyword, &Keyword::keywordQuit, gestureReaderThread, &SerialReaderThread::handleQuit, Qt::QueuedConnection);
+ QObject::connect(gestureReaderThread, &SerialReaderThread::srtQuit, &app, &QGuiApplication::quit, Qt::QueuedConnection);
- /* Check if password key is provided as cmd line argument, else use default */
- checkUserPassword(argc, argv, &keyword);
+ if(argc > 1){
+ keyword.m_numtimes_keyword_match = atoi(argv[1]);
+ qDebug() << "number of iterations to open the lock: " << keyword.m_numtimes_keyword_match;
+ }
/* Start thread that reads the gesture from mmWave Sensor and take predetermined action per the gestures received */
gestureReaderThread->start();
- return app.exec();
+ app.exec();
+
+ qDebug() << "QGuiApplication execution over\n";
+
+ return 0;
}