master
Yorick GEOFFRE 2 years ago
parent 11068c9352
commit 74aba4f4fa

@ -0,0 +1,6 @@
#include "command.h"
Command::Command()
{
}

@ -0,0 +1,13 @@
#ifndef COMMAND_H
#define COMMAND_H
#include <QObject>
class Command
{
public:
Command();
virtual void exec() = 0;
};
#endif // COMMAND_H

@ -0,0 +1,18 @@
#ifndef DATAPOLLCOMMAND_H
#define DATAPOLLCOMMAND_H
#include <QObject>
#include "command.h"
#include "src/MLX90640_API.h"
class DataPollCommand : public QObject, public Command
{
protected:
MLX90640* _thermal;
public:
DataPollCommand(MLX90640* thermal) : _thermal(thermal){}
void exec() override {_thermal->getData();}
};
#endif // DATAPOLLCOMMAND_H

File diff suppressed because it is too large Load Diff

@ -0,0 +1,24 @@
#include "pollingtimer.h"
#include <chrono>
void PollingTimer::start(){
shouldRun = true;
}
void PollingTimer::stop(){
shouldRun = false;
}
void PollingTimer::doLoop(){
std::chrono::steady_clock::time_point begin;
std::chrono::steady_clock::time_point end;
while(shouldRun){
begin = std::chrono::steady_clock::now();
_c->exec();
end = std::chrono::steady_clock::now();
std::this_thread::sleep_for(
std::chrono::microseconds((this->timeout)
- std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()));
}
}

@ -0,0 +1,26 @@
#ifndef POLLINGTIMER_H
#define POLLINGTIMER_H
#include <QObject>
#include <atomic>
#include <thread>
#include "command.h"
class PollingTimer
{
protected:
std::atomic<bool> shouldRun;
std::thread* myThread;
Command* _c;
unsigned int timeout;
void doLoop();
public:
PollingTimer(Command* c) : shouldRun(false), _c(c){}
void start();
void stop();
};
#endif // POLLINGTIMER_H

@ -0,0 +1,6 @@
#include "thermaldatarenderer.h"
ThermalDataRenderer::ThermalDataRenderer()
{
}

@ -0,0 +1,18 @@
#ifndef THERMALDATARENDERER_H
#define THERMALDATARENDERER_H
#include <QObject>
#include <QVector>
#include <QColor>
class ThermalDataRenderer
{
bool direct = false;
QVector<QColor> renderBuffer;
float minValue = 0.0f;
float maxValue = 0.0f;
public:
ThermalDataRenderer();
};
#endif // THERMALDATARENDERER_H

@ -15,11 +15,14 @@ TARGET = thermi2c
CONFIG += sailfishapp
SOURCES += src/thermi2c.cpp \
command.cpp \
pollingtimer.cpp \
src/mlx90640_API.cpp \
src/mlx90640_I2C_Driver.cpp \
src/conv.cpp \
src/i2cdriversingleton.cpp \
src/i2cif.cpp
src/i2cif.cpp \
thermaldatarenderer.cpp
DISTFILES += qml/thermi2c.qml \
qml/cover/CoverPage.qml \
@ -44,8 +47,12 @@ CONFIG += sailfishapp_i18n
TRANSLATIONS += translations/thermi2c-de.ts
HEADERS += \
command.h \
datapollcommand.h \
pollingtimer.h \
src/mlx90640_API.h \
src/mlx90640_I2C_Driver.h \
src/conv.h \
src/i2cdriversingleton.h \
src/i2cif.h
src/i2cif.h \
thermaldatarenderer.h

Loading…
Cancel
Save