diff --git a/.gitignore b/.gitignore index fab7372d796ea95c80d02df6caa7eb2b411a7ac1..9956744767c3cea2ff6cb7181a0dce4eedc39539 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # This file is used to ignore files which are generated # ---------------------------------------------------------------------------- - +build-MiniMatrixRPi-Desktop_Qt_5_12_2_GCC_64bit-Debug *~ *.autosave *.a diff --git a/MiniMatrixRPi/animhandler.cpp b/MiniMatrixRPi/animhandler.cpp index 14c9d7173764a180e854389ca60441fd64819ca2..1791bd35c27483d4114d03704e206efcf3f368ac 100644 --- a/MiniMatrixRPi/animhandler.cpp +++ b/MiniMatrixRPi/animhandler.cpp @@ -2,3 +2,55 @@ +void AnimHandler::start() +{ + mode = START; +} +void AnimHandler::pause() +{ + mode = PAUSE; +} +void AnimHandler::stop() +{ + mode = STOP; +} +void AnimHandler::enableExit() +{ + exitThread = true; +} + +void AnimHandler::run() { + qDebug() << "STARTED BITCHES"; + while (!exitThread) { + if (lastmode != mode) + { + switch (mode) { + case STOP: emit onStoped(); break; + case START: emit onStarted(); break; + case PAUSE: emit onPaused(); break; + } + } + lastmode = mode; + switch (mode) { + case STOP: break; + case START: break; + case PAUSE: break; + default: mode = STOP; break; + } + progress++; + emit progressUpdate(progress); + usleep(100); + } + qDebug() << "KÖRTE"; + emit resultReady("ALMA"); +} + +void AnimHandler::openFile(const QString filepath) { + this->filepath = filepath; + if (!file.isOpen()) + file.close(); + file.setFileName(filepath); + file.open(QIODevice::ReadOnly | QIODevice::Text); +} + + diff --git a/MiniMatrixRPi/animhandler.h b/MiniMatrixRPi/animhandler.h index 7c6d8e3dd6e97c23a7944c26d8f5131dafab3943..3396265e73d8eb93c124f95b8f1f3b9a8a757f4a 100644 --- a/MiniMatrixRPi/animhandler.h +++ b/MiniMatrixRPi/animhandler.h @@ -3,34 +3,33 @@ #include <QThread> #include <QDebug> - - - +#include <QFile> class AnimHandler: public QThread { Q_OBJECT - void run() override { - qDebug() << "STARTED BITCHES"; - while (!exitThread) { - usleep(100); - progress++; - emit progressUpdate(progress); - } - qDebug() << "KÖRTE"; - emit resultReady("ALMA"); - } + void run() override; private: - bool exitThread = false; uint32_t progress = 0; + bool exitThread = false; + enum Mode {STOP=0, START, PAUSE} mode = STOP; + enum Mode lastmode = mode; + QFile file; + QString filepath; + +public: + void openFile(const QString filepath); public slots: - void enableExit() - { - exitThread = true; - } + void start(); + void pause(); + void stop(); + void enableExit(); signals: + void onPaused(); + void onStarted(); + void onStoped(); void progressUpdate(uint32_t progress); void resultReady(const QString &result); };