forked from Sepanta/console-emulator
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.0 KiB
81 lines
3.0 KiB
#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}; \
|
|
void init ## CAPITAL_NAME() \
|
|
{ \
|
|
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\
|
|
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\
|
|
} \
|
|
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); \
|
|
} \
|
|
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
|
|
|
|
/*************************************************************************************************/
|
|
#define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
|
|
private: \
|
|
PushButton _ ## SMALL_NAME{FUNC_CODE}; \
|
|
void init ## CAPITAL_NAME() \
|
|
{ \
|
|
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\
|
|
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\
|
|
} \
|
|
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); \
|
|
} \
|
|
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
|
|
|
|
/*************************************************************************************************/
|
|
#define ROTARY_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \
|
|
private: \
|
|
RotaryButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \
|
|
void init ## CAPITAL_NAME() \
|
|
{ \
|
|
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\
|
|
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\
|
|
} \
|
|
public: \
|
|
void rotate ## CAPITAL_NAME(int value) \
|
|
{ \
|
|
auto arr = _ ## SMALL_NAME.rotate(value); \
|
|
_dataSender->send(arr); \
|
|
} \
|
|
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
|
|
|
|
/*************************************************************************************************/
|
|
#define ROTARY_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \
|
|
private: \
|
|
RotaryButton _ ## SMALL_NAME{FUNC_CODE}; \
|
|
void init ## CAPITAL_NAME() \
|
|
{ \
|
|
connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData);\
|
|
connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, SIGNAL(SMALL_NAME ## LedChanged(char)));\
|
|
} \
|
|
public: \
|
|
void rotate ## CAPITAL_NAME(int value) \
|
|
{ \
|
|
auto arr = _ ## SMALL_NAME.rotate(value); \
|
|
_dataSender->send(arr); \
|
|
} \
|
|
Q_SIGNAL void SMALL_NAME ## LedChanged(char value)
|
|
|
|
#endif //BUTTONHELPER_H
|
|
|