LedDisplay/OmobiDisplayApp/omobidisplaybackend.h
Dorian Zedler fb7063de2c
- Many styling improvements and additions
- Added some real commands
-> App should be fully functional now, as soon as the esp is finished
2020-10-13 01:58:14 +02:00

63 lines
1.8 KiB
C++

#ifndef OMOBIDISPLAYBACKEND_H
#define OMOBIDISPLAYBACKEND_H
#include <QObject>
#include <QJsonDocument>
#include <qbluetoothleuart.h>
#include <omobidisplaytextmodel.h>
class OmobiDisplayBackend : public QObject
{
Q_OBJECT
Q_PROPERTY(QBluetoothLeUart* bleController READ getBleController NOTIFY bleControllerChanged)
Q_PROPERTY(OmobiDisplayAppState state READ getState WRITE setState NOTIFY stateChanged)
Q_PROPERTY(OmobiDisplayTextModel* displayTextModel READ getDisplayTextModel NOTIFY displayTextModelChanged)
Q_PROPERTY(int displayBrightness READ getDisplayBrightness WRITE setDisplayBrightness NOTIFY displayBrightnessChanged)
public:
explicit OmobiDisplayBackend(QObject *parent = nullptr);
enum OmobiDisplayAppState {
Idle,
Scanning,
ReadyToConnect,
Connecting,
Connected
};
Q_ENUM(OmobiDisplayAppState)
private:
OmobiDisplayAppState state;
QBluetoothLeUart *ble;
OmobiDisplayTextModel* displayTextModel;
int displayBrightness;
public slots:
Q_INVOKABLE void startScanning();
Q_INVOKABLE QBluetoothLeUart* getBleController();
Q_INVOKABLE OmobiDisplayAppState getState();
Q_INVOKABLE OmobiDisplayTextModel* getDisplayTextModel();
Q_INVOKABLE int getDisplayBrightness();
Q_INVOKABLE void setDisplayBrightness(int brightness);
private slots:
void handleBluetoothStateChange(QBluetoothLeUart::BluetoothLeUartState state);
void handleFoundNewDevice(QBluetoothLeUartDevice* device);
void DataHandler(QString s);
void handleBluetoothDeviceConected();
void handleDisplayTextModelDataChanged();
void setState(OmobiDisplayAppState state);
signals:
void stateChanged();
void bleControllerChanged();
void displayTextModelChanged();
void displayBrightnessChanged();
};
#endif // OMOBIDISPLAYBACKEND_H