forked from Sepanta/console-emulator
14 changed files with 403 additions and 311 deletions
@ -0,0 +1,39 @@ |
|||||
|
#ifndef BUTTONHELPER_H |
||||
|
#define BUTTONHELPER_H |
||||
|
|
||||
|
#define PUSH_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ |
||||
|
private: \ |
||||
|
PushButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ |
||||
|
public: \ |
||||
|
void press ## CAPITAL_NAME() \ |
||||
|
{ \ |
||||
|
auto arr = _ ## SMALL_NAME.press(); \ |
||||
|
_dataSender->send(arr); \ |
||||
|
} \ |
||||
|
void release ## CAPITAL_NAME() \ |
||||
|
{ \ |
||||
|
auto arr = _ ## SMALL_NAME.release(); \ |
||||
|
_dataSender->send(arr); \ |
||||
|
} \ |
||||
|
signals: \ |
||||
|
void SMALL_NAME ## LedChanged(int value) |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
#define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \ |
||||
|
private: \ |
||||
|
PushButton _ ## SMALL_NAME{FUNC_CODE}; \ |
||||
|
public: \ |
||||
|
void press ## CAPITAL_NAME() \ |
||||
|
{ \ |
||||
|
auto arr = _ ## SMALL_NAME.press(); \ |
||||
|
_dataSender->send(arr); \ |
||||
|
} \ |
||||
|
void release ## CAPITAL_NAME() \ |
||||
|
{ \ |
||||
|
auto arr = _ ## SMALL_NAME.release(); \ |
||||
|
_dataSender->send(arr); \ |
||||
|
} \ |
||||
|
signals: \ |
||||
|
void SMALL_NAME ## LedChanged(int value) |
||||
|
|
||||
|
#endif //BUTTONHELPER_H
|
@ -0,0 +1,134 @@ |
|||||
|
#ifndef FUNCTIONCODES_H |
||||
|
#define FUNCTIONCODES_H |
||||
|
|
||||
|
//Buttons
|
||||
|
#define DUAL_FC 0x1D |
||||
|
#define QUAD_FC 0x1C |
||||
|
#define SINGLE_FC 0x1B |
||||
|
#define P1_FC 0x21 |
||||
|
#define P2_FC 0x22 |
||||
|
#define P3_FC 0x23 |
||||
|
#define P4_FC 0x24 |
||||
|
#define EXIT_FC 0x0C |
||||
|
#define FREEZE_FC 0x15 |
||||
|
#define POINTER_FC 0x0D |
||||
|
#define AUTOSET_FC 0x14 |
||||
|
#define ABC_FC 0x0E |
||||
|
#define FOUR_D_FC 0x13 |
||||
|
#define CLEAR_FC 0x10 |
||||
|
#define THREE_D_FC 0x12 |
||||
|
#define MEASURE_FC 0x11 |
||||
|
#define BODY_MARK_FC 0x0F |
||||
|
#define PATIENT_FC 0x02 |
||||
|
#define UTILS_FC 0x03 |
||||
|
#define DVD_FC 0x04 |
||||
|
#define REPORT_FC 0x05 |
||||
|
#define PROBE_FC 0x06 |
||||
|
#define ARCHIVE_FC 0x07 |
||||
|
#define END_FC 0x08 |
||||
|
#define XTD_FC 0x16 |
||||
|
#define BF_FC 0x17 |
||||
|
#define P5_FC 0x25 |
||||
|
#define P6_FC 0x26 |
||||
|
|
||||
|
#define JOYSTICK1_TOP_FC 0x39 |
||||
|
#define JOYSTICK2_TOP_FC 0x3C |
||||
|
#define JOYSTICK3_TOP_FC 0x3F |
||||
|
#define JOYSTICK4_TOP_FC 0x42 |
||||
|
#define JOYSTICK5_TOP_FC 0x45 |
||||
|
#define DEPTHTOP_FC 0x33 |
||||
|
#define FOCUSTOP_FC 0x36 |
||||
|
|
||||
|
#define JOYSTICK1_CENTER_FC 0x38 |
||||
|
#define JOYSTICK2_CENTER_FC 0x3B |
||||
|
#define JOYSTICK3_CENTER_FC 0x3E |
||||
|
#define JOYSTICK4_CENTER_FC 0x41 |
||||
|
#define JOYSTICK5_CENTER_FC 0x44 |
||||
|
#define DEPTH_CENTER_FC 0x32 |
||||
|
#define FOCUS_CENTER_FC 0x35 |
||||
|
#define MODE_PW_CENTER_FC 0x49 |
||||
|
#define MODE_M_CENTER_FC 0x4A |
||||
|
#define MODE_PD_CENTER_FC 0x4B |
||||
|
#define MODE_C_CENTER_FC 0x4C |
||||
|
#define MODE_2D_CENTER_FC 0x4D |
||||
|
|
||||
|
#define JOYSTICK1_BOTTOM_FC 0x37 |
||||
|
#define JOYSTICK2_BOTTOM_FC 0x3A |
||||
|
#define JOYSTICK3_BOTTOM_FC 0x3D |
||||
|
#define JOYSTICK4_BOTTOM_FC 0x40 |
||||
|
#define JOYSTICK5_BOTTOM_FC 0x43 |
||||
|
#define DEPTH_BOTTOM_FC 0x31 |
||||
|
#define FOCUS_BOTTOM_FC 0x34 |
||||
|
|
||||
|
//Trackball
|
||||
|
#define TRACKBALL_TOP_FC 0x2A |
||||
|
#define TRACKBALL_BOTTOM_FC 0x2B |
||||
|
#define TRACKBALL_RIGHT_FC 0x2C |
||||
|
#define TRACKBALL_LEFT_FC 0x2D |
||||
|
#define TRACKBALL_TOP_RIGHT_FC 0x2E |
||||
|
#define TRACKBALL_BOTTOM_RIGHT_FC 0x28 |
||||
|
#define TRACKBALL_TOP_LEFT_FC 0x2F |
||||
|
#define TRACKBALL_TOP_BOTTOM_FC 0x29 |
||||
|
|
||||
|
//Joystick
|
||||
|
#define JOYSTICK1_FC 0x56 |
||||
|
#define JOYSTICK2_FC 0x57 |
||||
|
#define JOYSTICK3_FC 0x58 |
||||
|
#define JOYSTICK4_FC 0x59 |
||||
|
#define JOYSTICK5_FC 0x5A |
||||
|
#define DEPTH_FC 0x52 |
||||
|
#define FOCUS_FC 0x51 |
||||
|
#define MODE_PW_FC 0x5E |
||||
|
#define MODE_M_FC 0x5F |
||||
|
#define MODE_PD_FC 0x60 |
||||
|
#define MODE_C_FC 0x61 |
||||
|
#define MODE_2D_FC 0x62 |
||||
|
|
||||
|
//Leds
|
||||
|
#define DUAL_LED_FC 0X82 |
||||
|
#define QUAD_LED_FC 0X81 |
||||
|
#define SINGLE_LED_FC 0X80 |
||||
|
#define P1_LED_FC 0X86 |
||||
|
#define P2_LED_FC 0X87 |
||||
|
#define P3_LED_FC 0X88 |
||||
|
#define P4_LED_FC 0X89 |
||||
|
#define EXIT_LED_FC 0X71 |
||||
|
#define FREEZE_LED_FC 0X7A |
||||
|
#define POINTER_LED_FC 0X72 |
||||
|
#define AUTOSET_LED_FC 0X79 |
||||
|
#define ABC_LED_FC 0X73 |
||||
|
#define FOUR_D_LED_FC 0X78 |
||||
|
#define CLEAR_LED_FC 0X75 |
||||
|
#define THREE_D_LED_FC 0X77 |
||||
|
#define MEASURE_LED_FC 0X76 |
||||
|
#define BODY_MARK_LED_FC 0X74 |
||||
|
#define POWER_LED_FC 0X66 |
||||
|
#define PATIENT_LED_FC 0X67 |
||||
|
#define UTILS_LED_FC 0X68 |
||||
|
#define DVD_LED_FC 0X69 |
||||
|
#define REPORT_LED_FC 0X6A |
||||
|
#define PROBE_LED_FC 0X6B |
||||
|
#define ARCHIVE_LED_FC 0X6C |
||||
|
#define END_LED_FC 0X6D |
||||
|
#define XTD_LED_FC 0X7B |
||||
|
#define BF_LED_FC 0X7C |
||||
|
#define P5_LED_FC 0X8A |
||||
|
#define P6_LED_FC 0X8B |
||||
|
|
||||
|
#define MODE_PW_LED_FC 0X98 |
||||
|
#define MODE_2D_LED_FC 0X9A |
||||
|
#define MODE_M_LED_FC 0X9C |
||||
|
#define MODE_C_LED_FC 0X9E |
||||
|
#define MODE_PD_LED_FC 0X9F |
||||
|
#define QUADRAT_LED_FC 0X9D |
||||
|
#define X_LED_FC 0X9B |
||||
|
#define Y_LED_FC 0X99 |
||||
|
#define Z_LED_FC 0X97 |
||||
|
|
||||
|
#define ZOOM_LED_FC 0X8F |
||||
|
#define DEPTH_LED_FC 0X90 |
||||
|
#define ANGLE_LED_FC 0X91 |
||||
|
#define FOCUS_ZONE_LED_FC 0X92 |
||||
|
#define FOCUS_DEPTH_LED_FC 0X93 |
||||
|
|
||||
|
#endif //FUNCTIONCODES_H
|
@ -0,0 +1,22 @@ |
|||||
|
#ifndef PUSHBUTTON_H |
||||
|
#define PUSHBUTTON_H |
||||
|
|
||||
|
#include "Led.h" |
||||
|
|
||||
|
class PushButton |
||||
|
{ |
||||
|
private: |
||||
|
char _functionCode; |
||||
|
Led _led; |
||||
|
|
||||
|
QByteArray generateCode(bool isPressed); |
||||
|
|
||||
|
public: |
||||
|
PushButton(char functionCode); |
||||
|
PushButton(char functionCode, char ledFunctionCode); |
||||
|
QByteArray press(); |
||||
|
QByteArray release(); |
||||
|
Led* getLed(); |
||||
|
}; |
||||
|
|
||||
|
#endif //PUSHBUTTON_H
|
@ -1,20 +0,0 @@ |
|||||
#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,52 @@ |
|||||
|
#include "model/PushButton.h" |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
QByteArray PushButton::generateCode(bool isPressed) |
||||
|
{ |
||||
|
QByteArray arr; |
||||
|
|
||||
|
arr.resize(8); |
||||
|
arr[0] = 0x00; |
||||
|
arr[1] = 0x01; |
||||
|
arr[2] = 0x04; |
||||
|
arr[3] = _functionCode; |
||||
|
arr[4] = isPressed ? 0x01 : 0x00; |
||||
|
arr[5] = 0x00; |
||||
|
arr[6] = 0x00; |
||||
|
arr[7] = 0x00; |
||||
|
|
||||
|
return arr; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
PushButton::PushButton(char functionCode) |
||||
|
{ |
||||
|
_functionCode = functionCode; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
PushButton::PushButton(char functionCode, char ledFunctionCode) : |
||||
|
_led(ledFunctionCode) |
||||
|
{ |
||||
|
_functionCode = functionCode; |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
QByteArray PushButton::press() |
||||
|
{ |
||||
|
return generateCode(true); |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
|
||||
|
QByteArray PushButton::release() |
||||
|
{ |
||||
|
return generateCode(false); |
||||
|
} |
||||
|
|
||||
|
/*************************************************************************************************/ |
||||
|
Led* PushButton::getLed() |
||||
|
|
||||
|
{ |
||||
|
return &_led; |
||||
|
} |
@ -1,58 +0,0 @@ |
|||||
#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; |
|
||||
} |
|
||||
|
|
||||
//********************************************************************************
|
|
Loading…
Reference in new issue