forked from Sepanta/console-emulator
10 changed files with 208 additions and 40 deletions
@ -1,20 +1,30 @@ |
|||
#ifndef CONSOLE_H |
|||
#define CONSOLE_H |
|||
|
|||
#include <QObject> |
|||
|
|||
#include "Pushbutton.h" |
|||
|
|||
class DataSender; |
|||
|
|||
class Console |
|||
class Console: public QObject |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
private: |
|||
DataSender* _dataSender; |
|||
PushButton _dual; |
|||
|
|||
public: |
|||
Console(); |
|||
void injectDataSender(DataSender* sender); |
|||
void test(); |
|||
void dualPress(); |
|||
void dualRelease(); |
|||
void pressDual(); |
|||
void releaseDual(); |
|||
|
|||
|
|||
signals: |
|||
void dualLedChanged(int value); |
|||
}; |
|||
|
|||
#endif // CONSOLE_H
|
|||
|
@ -0,0 +1,24 @@ |
|||
#ifndef LED_H |
|||
#define LED_H |
|||
|
|||
#include <QObject> |
|||
|
|||
class Led : public QObject |
|||
{ |
|||
Q_OBJECT |
|||
private: |
|||
char _functionCode; |
|||
bool _hasLed; |
|||
|
|||
public: |
|||
Led(); |
|||
Led(char functionCode); |
|||
void newData(QByteArray data); |
|||
|
|||
signals: |
|||
void ledChanged(char value); |
|||
|
|||
|
|||
}; |
|||
|
|||
#endif // LED_H
|
@ -0,0 +1,20 @@ |
|||
#ifndef PUSHBUTTON_H |
|||
#define PUSHBUTTON_H |
|||
|
|||
#include "Led.h" |
|||
|
|||
class PushButton |
|||
{ |
|||
private: |
|||
char _functionCode; |
|||
Led _led ; |
|||
|
|||
public: |
|||
PushButton(char functionCode); |
|||
PushButton(char functionCode, char ledFunctionCode); |
|||
QByteArray press(); |
|||
QByteArray release(); |
|||
Led* getLed(); |
|||
}; |
|||
|
|||
#endif // PUSHBUTTON_H
|
@ -0,0 +1,19 @@ |
|||
#ifndef ROTAYBUTTON_H |
|||
#define ROTAYBUTTON_H |
|||
|
|||
#include "Led.h" |
|||
|
|||
class RotayButton |
|||
{ |
|||
private: |
|||
char _functionCode; |
|||
Led _led; |
|||
public: |
|||
|
|||
RotayButton(char functionCode); |
|||
RotayButton(char functionCode, char ledFunctionCode); |
|||
Led* getLed(); |
|||
QByteArray rotate(int value); |
|||
}; |
|||
|
|||
#endif // ROTAYBUTTON_H
|
@ -0,0 +1,16 @@ |
|||
#include "../../include/model/Led.h" |
|||
|
|||
|
|||
Led::Led() |
|||
{ |
|||
_hasLed = false; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
Led::Led(char functionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
_hasLed = true; |
|||
} |
|||
|
|||
//********************************************************************************
|
@ -0,0 +1,58 @@ |
|||
#include "../../include/model/Pushbutton.h" |
|||
|
|||
//********************************************************************************
|
|||
PushButton::PushButton(char functionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
PushButton::PushButton(char functionCode, char ledFunctionCode) : |
|||
_led(ledFunctionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
QByteArray PushButton::press() |
|||
{ |
|||
QByteArray arr; |
|||
|
|||
arr.resize(8); |
|||
arr[0] = 0x00; |
|||
arr[1] = 0x01; |
|||
arr[2] = 0x04; |
|||
arr[3] = _functionCode; |
|||
arr[4] = 0x01; |
|||
arr[5] = 0x00; |
|||
arr[6] = 0x00; |
|||
arr[7] = 0x00; |
|||
return arr; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
|
|||
QByteArray PushButton::release() |
|||
{ |
|||
QByteArray arr; |
|||
|
|||
arr.resize(8); |
|||
arr[0] = 0x00; |
|||
arr[1] = 0x01; |
|||
arr[2] = 0x04; |
|||
arr[3] = _functionCode; |
|||
arr[4] = 0x00; |
|||
arr[5] = 0x00; |
|||
arr[6] = 0x00; |
|||
arr[7] = 0x00; |
|||
return arr; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
Led *PushButton::getLed() |
|||
|
|||
{ |
|||
return &_led; |
|||
} |
|||
|
|||
//********************************************************************************
|
@ -0,0 +1,29 @@ |
|||
#include "../../include/model/RotayButton.h" |
|||
|
|||
|
|||
RotayButton::RotayButton(char functionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
RotayButton::RotayButton(char functionCode, char ledFunctionCode): |
|||
_led(ledFunctionCode) |
|||
{ |
|||
_functionCode = functionCode; |
|||
|
|||
} |
|||
|
|||
//********************************************************************************
|
|||
Led *RotayButton::getLed() |
|||
{ |
|||
return &_led; |
|||
} |
|||
|
|||
//********************************************************************************
|
|||
QByteArray RotayButton::rotate(int value) |
|||
{ |
|||
|
|||
} |
|||
|
|||
//********************************************************************************
|
Loading…
Reference in new issue