forked from Sepanta/console-emulator
miladS
10 months ago
11 changed files with 171 additions and 30 deletions
@ -0,0 +1,29 @@ |
|||||
|
#ifndef DropDown_H |
||||
|
#define DropDown_H |
||||
|
|
||||
|
#define PROTOCOL_LENGTH 8 |
||||
|
#define MESSAGE_DIRECTION 0x00 |
||||
|
#define DropDownDataLength 0x02 |
||||
|
#define DropDownType 0x03 |
||||
|
#define ProbA 0x00 |
||||
|
#define ProbB 0x01 |
||||
|
#define ProbNC 0x02 |
||||
|
#define TIME_TAG 0x00 |
||||
|
|
||||
|
#include "Led.h" |
||||
|
|
||||
|
class DropDown |
||||
|
{ |
||||
|
private: |
||||
|
char _functionCode; |
||||
|
Led _led; |
||||
|
|
||||
|
public: |
||||
|
DropDown(char functionCode); |
||||
|
DropDown(char functionCode, char ledFunctionCode); |
||||
|
|
||||
|
Led* getLed(); |
||||
|
QByteArray select(int value); |
||||
|
}; |
||||
|
|
||||
|
#endif //DropDown_H
|
@ -0,0 +1,38 @@ |
|||||
|
#include "model/DropDown.h" |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
DropDown::DropDown(char functionCode) |
||||
|
{ |
||||
|
_functionCode = functionCode; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
DropDown::DropDown(char functionCode, char ledFunctionCode) : |
||||
|
_led(ledFunctionCode) |
||||
|
{ |
||||
|
_functionCode = functionCode; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
Led* DropDown::getLed() |
||||
|
{ |
||||
|
return &_led; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
QByteArray DropDown::select(int value) |
||||
|
{ |
||||
|
QByteArray arr; |
||||
|
|
||||
|
arr.resize(PROTOCOL_LENGTH); |
||||
|
arr[0] = MESSAGE_DIRECTION; |
||||
|
arr[1] = DropDownDataLength; |
||||
|
arr[2] = DropDownType; |
||||
|
arr[3] = _functionCode; |
||||
|
arr[4] = static_cast<char>(value >> PROTOCOL_LENGTH); |
||||
|
arr[5] = static_cast<char>(value); |
||||
|
arr[6] = TIME_TAG; |
||||
|
arr[7] = TIME_TAG; |
||||
|
|
||||
|
return arr; |
||||
|
} |
Loading…
Reference in new issue