43 lines
940 B
C++
43 lines
940 B
C++
//LightController.h
|
|
#pragma once
|
|
#include <QObject>
|
|
#include <QtSerialPort/QSerialPort>
|
|
#include <QString>
|
|
|
|
class LightController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Channel { CH1 = 0, CH2 = 1, ALL = 2 };
|
|
Q_ENUM(Channel)
|
|
|
|
explicit LightController(QObject* parent = nullptr);
|
|
~LightController();
|
|
|
|
public slots:
|
|
bool open(const QString& portName);
|
|
void close();
|
|
|
|
bool setBrightness(Channel ch, int value);
|
|
bool setBrightnessValue(int channel, int value);
|
|
bool setAlwaysOn();
|
|
bool setAlwaysOff();
|
|
bool softTrigger(Channel ch);
|
|
|
|
public:
|
|
bool isOpen() const;
|
|
|
|
signals:
|
|
void connected();
|
|
void disconnected();
|
|
void errorOccurred(const QString& msg);
|
|
void commandSent(const QString& cmd, const QString& response);
|
|
|
|
private:
|
|
bool sendCommand(const QString& cmd, QString& response);
|
|
QString buildBrightnessCmd(Channel ch, int value);
|
|
|
|
QSerialPort* m_serial;
|
|
};
|