mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 20:10:08 +03:00
Cosmetics
This commit is contained in:
parent
6504b4f69c
commit
f5c60a86a9
24 changed files with 171 additions and 126 deletions
|
@ -29,7 +29,7 @@ ConfirmDialog::ConfirmDialog(const char *title, const char *message, std::functi
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void ConfirmDialog::onKeyEvent(event_t event)
|
||||
void ConfirmDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConfirmDialog: public Dialog {
|
|||
ConfirmDialog(const char * title, const char * message, std::function<void(void)> confirmHandler);
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,17 +22,17 @@
|
|||
#ifndef _CURVE_H_
|
||||
#define _CURVE_H_
|
||||
|
||||
#include "window.h"
|
||||
#include "form.h"
|
||||
|
||||
struct CurvePoint {
|
||||
point_t coords;
|
||||
LcdFlags flags;
|
||||
};
|
||||
|
||||
class Curve: public Window {
|
||||
class Curve: public FormField {
|
||||
public:
|
||||
Curve(Window * parent, const rect_t & rect, std::function<int(int)> function, std::function<int()> position=nullptr):
|
||||
Window(parent, rect, OPAQUE),
|
||||
FormField(parent, rect, OPAQUE),
|
||||
function(std::move(function)),
|
||||
position(std::move(position))
|
||||
{
|
||||
|
@ -51,6 +51,8 @@ class Curve: public Window {
|
|||
if (position) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
FormField::checkEvents();
|
||||
}
|
||||
|
||||
void addPoint(const point_t & point, LcdFlags flags);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "keyboard_curve.h"
|
||||
#include "opentx.h" // TODO for applyCustomCurve
|
||||
|
||||
CurveEdit::CurveEdit(Window * parent, const rect_t &rect, uint8_t index) :
|
||||
CurveEdit::CurveEdit(Window * parent, const rect_t & rect, uint8_t index) :
|
||||
Curve(parent, rect, [=](int x) -> int {
|
||||
return applyCustomCurve(x, index);
|
||||
}),
|
||||
|
@ -54,13 +54,9 @@ bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
|
|||
{
|
||||
if (!hasFocus()) {
|
||||
setFocus();
|
||||
update();
|
||||
}
|
||||
|
||||
CurveKeyboard * keyboard = CurveKeyboard::instance();
|
||||
if (keyboard->getField() != this) {
|
||||
keyboard->setField(this);
|
||||
}
|
||||
CurveKeyboard::show(this, isCustomCurve());
|
||||
|
||||
CurveInfo & curve = g_model.curves[index];
|
||||
for (int i=0; i<5 + curve.points; i++) {
|
||||
|
@ -79,13 +75,13 @@ bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
|
|||
|
||||
void CurveEdit::onFocusLost()
|
||||
{
|
||||
CurveKeyboard::instance()->disable(true);
|
||||
CurveKeyboard::hide();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CurveEdit::next()
|
||||
{
|
||||
if (++current == points.size()) {
|
||||
if (current++ == points.size()) {
|
||||
current = 0;
|
||||
}
|
||||
update();
|
||||
|
@ -94,7 +90,7 @@ void CurveEdit::next()
|
|||
void CurveEdit::previous()
|
||||
{
|
||||
if (current-- == 0) {
|
||||
current = points.size() - 1;
|
||||
current = points.size();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
@ -118,7 +114,7 @@ void CurveEdit::down()
|
|||
void CurveEdit::right()
|
||||
{
|
||||
CurveInfo & curve = g_model.curves[index];
|
||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points - 1) {
|
||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
|
||||
int8_t * points = curveAddress(index);
|
||||
int8_t * point = &points[5 + curve.points + current - 1];
|
||||
int8_t xmax = (current == (curve.points - 2) ? +100 : *(point + 1));
|
||||
|
@ -131,7 +127,7 @@ void CurveEdit::right()
|
|||
void CurveEdit::left()
|
||||
{
|
||||
CurveInfo & curve = g_model.curves[index];
|
||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points - 1) {
|
||||
if (curve.type == CURVE_TYPE_CUSTOM && current != 0 && current != curve.points + 5 - 1) {
|
||||
int8_t * points = curveAddress(index);
|
||||
int8_t * point = &points[5 + curve.points + current - 1];
|
||||
int8_t xmin = (current == 1 ? -100 : *(point - 1));
|
||||
|
@ -145,3 +141,40 @@ bool CurveEdit::isCustomCurve()
|
|||
{
|
||||
return g_model.curves[index].type == CURVE_TYPE_CUSTOM;
|
||||
}
|
||||
|
||||
void CurveEdit::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
switch (event) {
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
case EVT_VIRTUAL_KEY_LEFT:
|
||||
left();
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_RIGHT:
|
||||
right();
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_UP:
|
||||
up();
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_DOWN:
|
||||
down();
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_PREVIOUS:
|
||||
previous();
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_NEXT:
|
||||
next();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
FormField::onEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,18 +24,18 @@
|
|||
#include "curve.h"
|
||||
|
||||
class CurveEdit: public Curve {
|
||||
friend class CurveKeyboard;
|
||||
|
||||
public:
|
||||
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
// no permanent refresh
|
||||
Curve::checkEvents();
|
||||
}
|
||||
|
||||
void update();
|
||||
|
||||
void onEvent(event_t event) override;
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void FullScreenDialog::paint(BitmapBuffer * dc)
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void FullScreenDialog::onKeyEvent(event_t event)
|
||||
void FullScreenDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class FullScreenDialog : public Dialog {
|
|||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include "keyboard_curve.h"
|
||||
#include "curveedit.h"
|
||||
#include "button.h"
|
||||
#include "lcd.h"
|
||||
|
||||
|
@ -27,76 +26,65 @@ constexpr coord_t KEYBOARD_HEIGHT = 110;
|
|||
|
||||
CurveKeyboard * CurveKeyboard::_instance = nullptr;
|
||||
|
||||
CurveKeyboard::CurveKeyboard():
|
||||
Keyboard<CurveEdit>(KEYBOARD_HEIGHT)
|
||||
CurveKeyboard::CurveKeyboard() :
|
||||
Keyboard(KEYBOARD_HEIGHT)
|
||||
{
|
||||
// up
|
||||
new TextButton(this, {LCD_W/2 - 20, 5, 40, 40}, "\200",
|
||||
new TextButton(this, {LCD_W / 2 - 20, 5, 40, 40}, "\200",
|
||||
[=]() -> uint8_t {
|
||||
if (field) {
|
||||
field->up();
|
||||
}
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_UP);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
// down
|
||||
new TextButton(this, {LCD_W/2 - 20, 65, 40, 40}, "\201",
|
||||
new TextButton(this, {LCD_W / 2 - 20, 65, 40, 40}, "\201",
|
||||
[=]() -> uint8_t {
|
||||
field->down();
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_DOWN);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
// left
|
||||
left = new TextButton(this, {LCD_W / 2 - 70, 35, 40, 40}, "\177",
|
||||
[=]() -> uint8_t {
|
||||
if (field) {
|
||||
field->left();
|
||||
}
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_LEFT);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
// right
|
||||
right = new TextButton(this, {LCD_W / 2 + 30, 35, 40, 40}, "\176",
|
||||
[=]() -> uint8_t {
|
||||
if (field) {
|
||||
field->right();
|
||||
}
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_RIGHT);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
// next
|
||||
new TextButton(this, {LCD_W/2 + 80, 35, 60, 40}, "Next",
|
||||
new TextButton(this, {LCD_W / 2 + 80, 35, 60, 40}, "Next",
|
||||
[=]() -> uint8_t {
|
||||
if (field) {
|
||||
field->next();
|
||||
}
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_NEXT);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
// previous
|
||||
new TextButton(this, {LCD_W / 2 - 140, 35, 60, 40}, "Prev",
|
||||
[=]() -> uint8_t {
|
||||
if (field) {
|
||||
field->previous();
|
||||
}
|
||||
return 0;
|
||||
putEvent(EVT_VIRTUAL_KEY_PREVIOUS);
|
||||
return 0;
|
||||
}, BUTTON_BACKGROUND | BUTTON_NOFOCUS);
|
||||
|
||||
}
|
||||
|
||||
void CurveKeyboard::enableRightLeft(bool enable)
|
||||
{
|
||||
TRACE("STOP %d", enable);
|
||||
left->enable(enable);
|
||||
right->enable(enable);
|
||||
}
|
||||
|
||||
CurveKeyboard::~CurveKeyboard()
|
||||
{
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
void CurveKeyboard::setField(CurveEdit * field)
|
||||
{
|
||||
Keyboard<CurveEdit>::setField(field);
|
||||
bool custom = field->isCustomCurve();
|
||||
left->enable(custom);
|
||||
right->enable(custom);
|
||||
}
|
||||
|
||||
void CurveKeyboard::paint(BitmapBuffer * dc)
|
||||
{
|
||||
lcdSetColor(RGB(0xE0, 0xE0, 0xE0));
|
||||
|
|
|
@ -22,17 +22,14 @@
|
|||
#define _KEYBOARD_CURVE_H_
|
||||
|
||||
#include "keyboard_base.h"
|
||||
#include "curveedit.h"
|
||||
|
||||
class Button;
|
||||
|
||||
class CurveKeyboard : public Keyboard<CurveEdit> {
|
||||
friend class CurveEdit;
|
||||
|
||||
class CurveKeyboard : public Keyboard {
|
||||
public:
|
||||
CurveKeyboard();
|
||||
|
||||
~CurveKeyboard();
|
||||
~CurveKeyboard() override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
|
@ -41,15 +38,16 @@ class CurveKeyboard : public Keyboard<CurveEdit> {
|
|||
}
|
||||
#endif
|
||||
|
||||
static CurveKeyboard * instance()
|
||||
void enableRightLeft(bool enable);
|
||||
|
||||
static void show(FormField * field, bool enableRightLeft)
|
||||
{
|
||||
if (!_instance)
|
||||
_instance = new CurveKeyboard();
|
||||
return _instance;
|
||||
_instance->setField(field);
|
||||
_instance->enableRightLeft(enableRightLeft);
|
||||
}
|
||||
|
||||
void setField(CurveEdit * field);
|
||||
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -249,7 +249,7 @@ class BindWaitDialog: public Dialog {
|
|||
void checkEvents() override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override
|
||||
void onEvent(event_t event) override
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ void RadioCalibrationPage::checkEvents()
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void RadioCalibrationPage::onKeyEvent(event_t event)
|
||||
void RadioCalibrationPage::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
@ -257,7 +257,7 @@ void RadioCalibrationPage::onKeyEvent(event_t event)
|
|||
|
||||
}
|
||||
else {
|
||||
Page::onKeyEvent(event);
|
||||
Page::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,7 @@ class RadioCalibrationPage: public Page {
|
|||
void checkEvents() override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -67,7 +67,7 @@ class LayoutChoice: public FormField {
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override
|
||||
void onEvent(event_t event) override
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
@ -77,7 +77,7 @@ class LayoutChoice: public FormField {
|
|||
openMenu();
|
||||
}
|
||||
else {
|
||||
FormField::onKeyEvent(event);
|
||||
FormField::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -113,7 +113,7 @@ void SourceChoice::openMenu()
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void SourceChoice::onKeyEvent(event_t event)
|
||||
void SourceChoice::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
@ -123,7 +123,7 @@ void SourceChoice::onKeyEvent(event_t event)
|
|||
openMenu();
|
||||
}
|
||||
else {
|
||||
FormField::onKeyEvent(event);
|
||||
FormField::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -133,6 +133,7 @@ bool SourceChoice::onTouchEnd(coord_t, coord_t)
|
|||
{
|
||||
openMenu();
|
||||
setFocus();
|
||||
setEditMode(true);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,7 @@ class SourceChoice : public FormField {
|
|||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
|
|
|
@ -97,7 +97,7 @@ void SwitchChoice::openMenu()
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void SwitchChoice::onKeyEvent(event_t event)
|
||||
void SwitchChoice::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
@ -107,7 +107,7 @@ void SwitchChoice::onKeyEvent(event_t event)
|
|||
openMenu();
|
||||
}
|
||||
else {
|
||||
FormField::onKeyEvent(event);
|
||||
FormField::onEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -117,6 +117,7 @@ bool SwitchChoice::onTouchEnd(coord_t, coord_t)
|
|||
{
|
||||
openMenu();
|
||||
setFocus();
|
||||
setEditMode(true);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ class SwitchChoice : public FormField {
|
|||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
|
|
|
@ -45,7 +45,7 @@ void TimeEdit::paint(BitmapBuffer * dc)
|
|||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
// TODO could be moved to BaseNumberEdit
|
||||
void TimeEdit::onKeyEvent(event_t event)
|
||||
void TimeEdit::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event);
|
||||
|
||||
|
@ -70,7 +70,7 @@ void TimeEdit::onKeyEvent(event_t event)
|
|||
}
|
||||
}
|
||||
|
||||
FormField::onKeyEvent(event);
|
||||
FormField::onEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -81,16 +81,16 @@ bool TimeEdit::onTouchEnd(coord_t x, coord_t y)
|
|||
setFocus();
|
||||
}
|
||||
|
||||
NumberKeyboard * keyboard = NumberKeyboard::instance();
|
||||
if (keyboard->getField() != this) {
|
||||
keyboard->setField(this);
|
||||
}
|
||||
// NumberKeyboard * keyboard = NumberKeyboard::instance();
|
||||
// if (keyboard->getField() != this) {
|
||||
// keyboard->setField(this);
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TimeEdit::onFocusLost()
|
||||
{
|
||||
NumberKeyboard::instance()->disable(true);
|
||||
// NumberKeyboard::instance()->disable(true);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@ class TimeEdit : public BaseNumberEdit {
|
|||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
|
|
|
@ -165,7 +165,7 @@ ViewMain::~ViewMain()
|
|||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void ViewMain::onKeyEvent(event_t event)
|
||||
void ViewMain::onEvent(event_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case EVT_KEY_LONG(KEY_MODEL):
|
||||
|
|
|
@ -40,7 +40,7 @@ class ViewMain: public Window {
|
|||
|
||||
protected:
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onKeyEvent(event_t event) override;
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
void checkEvents() override;
|
||||
|
|
|
@ -44,13 +44,10 @@ Key keys[NUM_KEYS];
|
|||
|
||||
event_t getEvent(bool trim)
|
||||
{
|
||||
event_t evt = s_evt;
|
||||
int8_t k = EVT_KEY_MASK(s_evt) - TRM_BASE;
|
||||
bool trim_evt = (k>=0 && k<TRM_LAST-TRM_BASE+1);
|
||||
|
||||
if (trim == trim_evt) {
|
||||
event_t event = s_evt;
|
||||
if (trim == IS_TRIM_EVENT(event)) {
|
||||
s_evt = 0;
|
||||
return evt;
|
||||
return event;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
|
|
|
@ -26,39 +26,74 @@
|
|||
#include "opentx_types.h"
|
||||
#include "libopenui/src/libopenui_types.h"
|
||||
|
||||
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
||||
constexpr event_t EVT_REFRESH = 0x1000;
|
||||
constexpr event_t EVT_ENTRY = 0x1001;
|
||||
constexpr event_t EVT_ENTRY_UP = 0x1002;
|
||||
constexpr event_t EVT_ROTARY_LEFT = 0x1003;
|
||||
constexpr event_t EVT_ROTARY_RIGHT = 0x1004;
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
constexpr event_t _MSK_KEY_BREAK = 0x0200;
|
||||
constexpr event_t _MSK_KEY_REPT = 0x0400;
|
||||
constexpr event_t _MSK_KEY_FIRST = 0x0600;
|
||||
constexpr event_t _MSK_KEY_LONG = 0x0800;
|
||||
constexpr event_t _MSK_KEY_FLAGS = 0x0E00;
|
||||
constexpr event_t _MSK_KEY_BREAK = 0x0200;
|
||||
constexpr event_t _MSK_KEY_REPT = 0x0400;
|
||||
constexpr event_t _MSK_KEY_FIRST = 0x0600;
|
||||
constexpr event_t _MSK_KEY_LONG = 0x0800;
|
||||
constexpr event_t _MSK_KEY_FLAGS = 0x0E00;
|
||||
#else
|
||||
constexpr event_t _MSK_KEY_BREAK = 0x20;
|
||||
constexpr event_t _MSK_KEY_REPT = 0x40;
|
||||
constexpr event_t _MSK_KEY_FIRST = 0x60;
|
||||
constexpr event_t _MSK_KEY_LONG = 0x80;
|
||||
constexpr event_t _MSK_KEY_FLAGS = 0xE0;
|
||||
constexpr event_t EVT_ENTRY = 0xBF;
|
||||
constexpr event_t EVT_ENTRY_UP = 0xBE;
|
||||
constexpr event_t _MSK_KEY_BREAK = 0x0020;
|
||||
constexpr event_t _MSK_KEY_REPT = 0x0040;
|
||||
constexpr event_t _MSK_KEY_FIRST = 0x0060;
|
||||
constexpr event_t _MSK_KEY_LONG = 0x0080;
|
||||
constexpr event_t _MSK_KEY_FLAGS = 0x00E0;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
constexpr event_t _MSK_VIRTUAL_KEY = 0x1000;
|
||||
constexpr event_t _MSK_VIRTUAL_KEY = 0x2000;
|
||||
|
||||
constexpr event_t EVT_VIRTUAL_KEY(uint8_t key)
|
||||
{
|
||||
return (key | _MSK_VIRTUAL_KEY);
|
||||
}
|
||||
|
||||
constexpr event_t EVT_VIRTUAL_KEY_MIN = EVT_VIRTUAL_KEY('m');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_MAX = EVT_VIRTUAL_KEY('M');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_PLUS = EVT_VIRTUAL_KEY('+');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_MINUS = EVT_VIRTUAL_KEY('-');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_FORWARD = EVT_VIRTUAL_KEY('F');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_BACKWARD = EVT_VIRTUAL_KEY('B');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_DEFAULT = EVT_VIRTUAL_KEY('0');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_UP = EVT_VIRTUAL_KEY('U');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_DOWN = EVT_VIRTUAL_KEY('D');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_LEFT = EVT_VIRTUAL_KEY('L');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_RIGHT = EVT_VIRTUAL_KEY('R');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_NEXT = EVT_VIRTUAL_KEY('N');
|
||||
constexpr event_t EVT_VIRTUAL_KEY_PREVIOUS = EVT_VIRTUAL_KEY('P');
|
||||
|
||||
constexpr bool IS_VIRTUAL_KEY_EVENT(event_t event)
|
||||
{
|
||||
return (event & 0xF000) == _MSK_VIRTUAL_KEY;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define EVT_VIRTUAL_KEY(key) ((key) | _MSK_VIRTUAL_KEY)
|
||||
|
||||
// normal order of events is: FIRST, LONG, REPEAT, REPEAT, ..., BREAK
|
||||
#define EVT_KEY_MASK(e) ((e) & 0x1F)
|
||||
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) // fired when key is pressed
|
||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while
|
||||
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) // fired when key is held pressed long enough, fires multiple times with increasing speed
|
||||
constexpr event_t EVT_KEY_BREAK(event_t key)
|
||||
constexpr event_t EVT_KEY_BREAK(uint8_t key)
|
||||
{
|
||||
return (key | _MSK_KEY_BREAK); // fired when key is released (short or long), but only if the event was not killed
|
||||
}
|
||||
|
||||
constexpr bool IS_KEY_EVENT(event_t event)
|
||||
{
|
||||
return (event & 0xF000) == 0; // fired when key is released (short or long), but only if the event was not killed
|
||||
}
|
||||
|
||||
constexpr bool IS_TRIM_EVENT(event_t event)
|
||||
{
|
||||
return (IS_KEY_EVENT(event) && EVT_KEY_MASK(event) >= TRM_BASE);
|
||||
}
|
||||
|
||||
#define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST)
|
||||
#define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG)
|
||||
#define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT)
|
||||
|
@ -67,22 +102,16 @@ constexpr event_t EVT_KEY_BREAK(event_t key)
|
|||
#if defined(PCBXLITE)
|
||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||
#define EVT_ROTARY_LEFT 0xDF00
|
||||
#define EVT_ROTARY_RIGHT 0xDE00
|
||||
#define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||
#elif defined(PCBFRSKY) && defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||
#define EVT_ROTARY_LEFT 0xDF00
|
||||
#define EVT_ROTARY_RIGHT 0xDE00
|
||||
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT)
|
||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT)
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#define EVT_ROTARY_BREAK 0xcf
|
||||
#define EVT_ROTARY_LONG 0xce
|
||||
#define EVT_ROTARY_LEFT 0xdf
|
||||
#define EVT_ROTARY_RIGHT 0xde
|
||||
#define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
|
||||
#define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||
#else
|
||||
|
@ -90,10 +119,6 @@ constexpr event_t EVT_KEY_BREAK(event_t key)
|
|||
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
#define EVT_REFRESH 0xDD00
|
||||
#endif
|
||||
|
||||
class Key
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -218,8 +218,8 @@ char * getCurveString(char * dest, int idx)
|
|||
idx = -idx;
|
||||
}
|
||||
|
||||
if (ZEXIST(g_model.curves[idx - 1].name))
|
||||
zchar2str(s, g_model.curves[idx - 1].name, LEN_CURVE_NAME);
|
||||
if (g_model.curves[idx - 1].name[0])
|
||||
strAppend(s, g_model.curves[idx - 1].name, LEN_CURVE_NAME);
|
||||
else
|
||||
strAppendStringWithIndex(s, STR_CV, idx);
|
||||
|
||||
|
@ -234,8 +234,8 @@ char * getGVarString(char * dest, int idx)
|
|||
idx = -idx-1;
|
||||
}
|
||||
|
||||
if (ZEXIST(g_model.gvars[idx].name))
|
||||
zchar2str(s, g_model.gvars[idx].name, LEN_GVAR_NAME);
|
||||
if (g_model.gvars[idx].name[0])
|
||||
strAppend(s, g_model.gvars[idx].name, LEN_GVAR_NAME);
|
||||
else
|
||||
strAppendStringWithIndex(s, STR_GV, idx+1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue