mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
Preparation for custom popups
This commit is contained in:
parent
12434590f4
commit
269365fd75
25 changed files with 124 additions and 135 deletions
|
@ -265,8 +265,7 @@ uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint
|
||||||
|
|
||||||
#define WARNING_TYPE_ASTERISK 0
|
#define WARNING_TYPE_ASTERISK 0
|
||||||
#define WARNING_TYPE_CONFIRM 1
|
#define WARNING_TYPE_CONFIRM 1
|
||||||
#define WARNING_TYPE_INPUT 2
|
#define WARNING_TYPE_INFO 2
|
||||||
#define WARNING_TYPE_INFO 4
|
|
||||||
|
|
||||||
extern const char * warningText;
|
extern const char * warningText;
|
||||||
extern const char * warningInfoText;
|
extern const char * warningInfoText;
|
||||||
|
|
|
@ -20,17 +20,39 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
void displayPresetChoice(event_t event)
|
void runPopupCurvePreset(event_t event)
|
||||||
{
|
{
|
||||||
runPopupWarning(event);
|
warningResult = false;
|
||||||
lcdDrawNumber(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45*warningInputValue/4, LEFT|INVERS);
|
|
||||||
|
drawMessageBox();
|
||||||
|
|
||||||
|
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, STR_POPUPS_ENTER_EXIT);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
warningResult = true;
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
|
warningText = NULL;
|
||||||
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
s_editMode = EDIT_MODIFY_FIELD;
|
||||||
|
reusableBuffer.curveEdit.preset = checkIncDec(event, reusableBuffer.curveEdit.preset, -4, 4);
|
||||||
|
s_editMode = EDIT_SELECT_FIELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcdDrawNumber(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45 * reusableBuffer.curveEdit.preset / 4, LEFT|INVERS);
|
||||||
lcdDrawChar(lcdLastRightPos, WARNING_LINE_Y, '@', INVERS);
|
lcdDrawChar(lcdLastRightPos, WARNING_LINE_Y, '@', INVERS);
|
||||||
|
|
||||||
if (warningResult) {
|
if (warningResult) {
|
||||||
warningResult = 0;
|
warningResult = 0;
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
int8_t * points = curveAddress(s_curveChan);
|
int8_t * points = curveAddress(s_curveChan);
|
||||||
int k = 25 * warningInputValue;
|
int k = 25 * reusableBuffer.curveEdit.preset;
|
||||||
int dx = 2000 / (5+crv.points-1);
|
int dx = 2000 / (5+crv.points-1);
|
||||||
for (uint8_t i=0; i<5+crv.points; i++) {
|
for (uint8_t i=0; i<5+crv.points; i++) {
|
||||||
int x = -1000 + i * dx;
|
int x = -1000 + i * dx;
|
||||||
|
@ -45,7 +67,8 @@ void displayPresetChoice(event_t event)
|
||||||
void onCurveOneMenu(const char * result)
|
void onCurveOneMenu(const char * result)
|
||||||
{
|
{
|
||||||
if (result == STR_CURVE_PRESET) {
|
if (result == STR_CURVE_PRESET) {
|
||||||
POPUP_INPUT(STR_PRESET, displayPresetChoice, 0, -4, 4);
|
reusableBuffer.curveEdit.preset = 4; // 45°
|
||||||
|
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
|
||||||
}
|
}
|
||||||
else if (result == STR_MIRROR) {
|
else if (result == STR_MIRROR) {
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
|
|
|
@ -27,9 +27,6 @@ uint8_t warningType;
|
||||||
uint8_t warningResult = 0;
|
uint8_t warningResult = 0;
|
||||||
|
|
||||||
uint8_t warningInfoFlags = ZCHAR;
|
uint8_t warningInfoFlags = ZCHAR;
|
||||||
int16_t warningInputValue;
|
|
||||||
int16_t warningInputValueMin;
|
|
||||||
int16_t warningInputValueMax;
|
|
||||||
|
|
||||||
void drawMessageBox()
|
void drawMessageBox()
|
||||||
{
|
{
|
||||||
|
@ -97,7 +94,7 @@ void runPopupWarning(event_t event)
|
||||||
if (warningInfoText) {
|
if (warningInfoText) {
|
||||||
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
||||||
}
|
}
|
||||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, warningType == WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS));
|
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, warningType == WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS_ENTER_EXIT));
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVT_KEY_BREAK(KEY_ENTER):
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
if (warningType == WARNING_TYPE_ASTERISK)
|
if (warningType == WARNING_TYPE_ASTERISK)
|
||||||
|
@ -108,11 +105,5 @@ void runPopupWarning(event_t event)
|
||||||
warningText = NULL;
|
warningText = NULL;
|
||||||
warningType = WARNING_TYPE_ASTERISK;
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
if (warningType != WARNING_TYPE_INPUT) break;
|
|
||||||
s_editMode = EDIT_MODIFY_FIELD;
|
|
||||||
warningInputValue = checkIncDec(event, warningInputValue, warningInputValueMin, warningInputValueMax);
|
|
||||||
s_editMode = EDIT_SELECT_FIELD;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,6 @@ void runPopupWarning(event_t event);
|
||||||
#define DRAW_MESSAGE_BOX(title) (warningText = title, drawMessageBox(), warningText = NULL)
|
#define DRAW_MESSAGE_BOX(title) (warningText = title, drawMessageBox(), warningText = NULL)
|
||||||
|
|
||||||
extern void (*popupFunc)(event_t event);
|
extern void (*popupFunc)(event_t event);
|
||||||
extern int16_t warningInputValue;
|
|
||||||
extern int16_t warningInputValueMin;
|
|
||||||
extern int16_t warningInputValueMax;
|
|
||||||
extern uint8_t warningInfoFlags;
|
extern uint8_t warningInfoFlags;
|
||||||
|
|
||||||
#if !defined(GUI)
|
#if !defined(GUI)
|
||||||
|
@ -54,7 +51,7 @@ extern uint8_t warningInfoFlags;
|
||||||
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_WARNING(s) (warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_WARNING(s) (warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_INPUT(s, func, start, min, max) (warningText = s, warningType = WARNING_TYPE_INPUT, popupFunc = func, warningInputValue = start, warningInputValueMin = min, warningInputValueMax = max)
|
#define POPUP_INPUT(s, func) (warningText = s, popupFunc = func)
|
||||||
#define WARNING_INFO_FLAGS warningInfoFlags
|
#define WARNING_INFO_FLAGS warningInfoFlags
|
||||||
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,17 +20,41 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
void displayPresetChoice(event_t event)
|
void runPopupCurvePreset(event_t event)
|
||||||
{
|
{
|
||||||
runPopupWarning(event);
|
warningResult = false;
|
||||||
lcdDrawNumber(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45*warningInputValue/4, LEFT|INVERS);
|
|
||||||
|
drawMessageBox(warningText);
|
||||||
|
|
||||||
|
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, STR_POPUPS_ENTER_EXIT);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
if (warningType == WARNING_TYPE_ASTERISK)
|
||||||
|
break;
|
||||||
|
warningResult = true;
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
|
warningText = NULL;
|
||||||
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
s_editMode = EDIT_MODIFY_FIELD;
|
||||||
|
reusableBuffer.curveEdit.preset = checkIncDec(event, reusableBuffer.curveEdit.preset, -4, +4);
|
||||||
|
s_editMode = EDIT_SELECT_FIELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcdDrawNumber(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45 * reusableBuffer.curveEdit.preset / 4, LEFT|INVERS);
|
||||||
lcdDrawChar(lcdLastRightPos, WARNING_LINE_Y, '@', INVERS);
|
lcdDrawChar(lcdLastRightPos, WARNING_LINE_Y, '@', INVERS);
|
||||||
|
|
||||||
if (warningResult) {
|
if (warningResult) {
|
||||||
warningResult = 0;
|
warningResult = 0;
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
int8_t * points = curveAddress(s_curveChan);
|
int8_t * points = curveAddress(s_curveChan);
|
||||||
int k = 25 * warningInputValue;
|
int k = 25 * reusableBuffer.curveEdit.preset;
|
||||||
int dx = 2000 / (5+crv.points-1);
|
int dx = 2000 / (5+crv.points-1);
|
||||||
for (uint8_t i=0; i<5+crv.points; i++) {
|
for (uint8_t i=0; i<5+crv.points; i++) {
|
||||||
int x = -1000 + i * dx;
|
int x = -1000 + i * dx;
|
||||||
|
@ -45,7 +69,8 @@ void displayPresetChoice(event_t event)
|
||||||
void onCurveOneMenu(const char * result)
|
void onCurveOneMenu(const char * result)
|
||||||
{
|
{
|
||||||
if (result == STR_CURVE_PRESET) {
|
if (result == STR_CURVE_PRESET) {
|
||||||
POPUP_INPUT(STR_PRESET, displayPresetChoice, 0, -4, 4);
|
reusableBuffer.curveEdit.preset = 4; // 45°
|
||||||
|
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
|
||||||
}
|
}
|
||||||
else if (result == STR_MIRROR) {
|
else if (result == STR_MIRROR) {
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
|
|
|
@ -26,9 +26,6 @@ uint8_t warningInfoLength;
|
||||||
uint8_t warningType;
|
uint8_t warningType;
|
||||||
uint8_t warningResult = 0;
|
uint8_t warningResult = 0;
|
||||||
uint8_t warningInfoFlags = ZCHAR;
|
uint8_t warningInfoFlags = ZCHAR;
|
||||||
int16_t warningInputValue;
|
|
||||||
int16_t warningInputValueMin;
|
|
||||||
int16_t warningInputValueMax;
|
|
||||||
|
|
||||||
void drawMessageBox(const char * title)
|
void drawMessageBox(const char * title)
|
||||||
{
|
{
|
||||||
|
@ -94,23 +91,17 @@ void runPopupWarning(event_t event)
|
||||||
if (warningInfoText) {
|
if (warningInfoText) {
|
||||||
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
||||||
}
|
}
|
||||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS));
|
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS_ENTER_EXIT));
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVT_KEY_BREAK(KEY_ENTER):
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
if (warningType == WARNING_TYPE_ASTERISK)
|
if (warningType == WARNING_TYPE_ASTERISK)
|
||||||
break;
|
break;
|
||||||
warningResult = true;
|
warningResult = true;
|
||||||
// no break
|
// no break
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_EXIT):
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
warningText = NULL;
|
warningText = NULL;
|
||||||
warningType = WARNING_TYPE_ASTERISK;
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
if (warningType == WARNING_TYPE_INPUT) {
|
|
||||||
s_editMode = EDIT_MODIFY_FIELD;
|
|
||||||
warningInputValue = checkIncDec(event, warningInputValue, warningInputValueMin, warningInputValueMax);
|
|
||||||
s_editMode = EDIT_SELECT_FIELD;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,13 @@ void runPopupWarning(event_t event);
|
||||||
#define DRAW_MESSAGE_BOX(title) drawMessageBox(title)
|
#define DRAW_MESSAGE_BOX(title) drawMessageBox(title)
|
||||||
|
|
||||||
extern void (*popupFunc)(event_t event);
|
extern void (*popupFunc)(event_t event);
|
||||||
extern int16_t warningInputValue;
|
|
||||||
extern int16_t warningInputValueMin;
|
|
||||||
extern int16_t warningInputValueMax;
|
|
||||||
extern uint8_t warningInfoFlags;
|
extern uint8_t warningInfoFlags;
|
||||||
|
|
||||||
#define DISPLAY_WARNING (*popupFunc)
|
#define DISPLAY_WARNING (*popupFunc)
|
||||||
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_WARNING(s) (warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_WARNING(s) (warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_INPUT(s, func, start, min, max) (warningText = s, warningType = WARNING_TYPE_INPUT, popupFunc = func, warningInputValue = start, warningInputValueMin = min, warningInputValueMax = max)
|
#define POPUP_INPUT(s, func) (warningText = s, popupFunc = func)
|
||||||
#define WARNING_INFO_FLAGS warningInfoFlags
|
#define WARNING_INFO_FLAGS warningInfoFlags
|
||||||
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
||||||
|
|
||||||
|
|
|
@ -469,9 +469,6 @@ void showMessageBox(const char * title);
|
||||||
void runPopupWarning(event_t event);
|
void runPopupWarning(event_t event);
|
||||||
|
|
||||||
extern void (* popupFunc)(event_t event);
|
extern void (* popupFunc)(event_t event);
|
||||||
extern int16_t warningInputValue;
|
|
||||||
extern int16_t warningInputValueMin;
|
|
||||||
extern int16_t warningInputValueMax;
|
|
||||||
extern uint8_t warningInfoFlags;
|
extern uint8_t warningInfoFlags;
|
||||||
|
|
||||||
#define DISPLAY_WARNING (*popupFunc)
|
#define DISPLAY_WARNING (*popupFunc)
|
||||||
|
@ -479,7 +476,7 @@ extern uint8_t warningInfoFlags;
|
||||||
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_WARNING(s) (warningType = WARNING_TYPE_ASTERISK, warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_WARNING(s) (warningType = WARNING_TYPE_ASTERISK, warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
#define POPUP_CONFIRMATION(s) (warningText = s, warningType = WARNING_TYPE_CONFIRM, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||||
#define POPUP_INPUT(s, func, start, min, max) (warningText = s, warningType = WARNING_TYPE_INPUT, popupFunc = func, warningInputValue = start, warningInputValueMin = min, warningInputValueMax = max)
|
#define POPUP_INPUT(s, func) (warningText = s, popupFunc = func)
|
||||||
#define WARNING_INFO_FLAGS warningInfoFlags
|
#define WARNING_INFO_FLAGS warningInfoFlags
|
||||||
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,36 @@ void drawCurve(int x, int y, int width)
|
||||||
drawFunction(applyCurrentCurve, x, y, width);
|
drawFunction(applyCurrentCurve, x, y, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayPresetChoice(event_t event)
|
void runPopupCurvePreset(event_t event)
|
||||||
{
|
{
|
||||||
runPopupWarning(event);
|
warningResult = false;
|
||||||
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y-10, 45*warningInputValue/4, LEFT|INVERS, 0, NULL, "@");
|
|
||||||
|
theme->drawMessageBox(warningText, warningInfoText, STR_POPUPS_ENTER_EXIT, warningType);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
warningResult = true;
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
|
warningText = NULL;
|
||||||
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
s_editMode = EDIT_MODIFY_FIELD;
|
||||||
|
reusableBuffer.curveEdit.preset = checkIncDec(event, reusableBuffer.curveEdit.preset, -4, +4);
|
||||||
|
s_editMode = EDIT_SELECT_FIELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y-10, 45 * reusableBuffer.curveEdit.preset / 4, LEFT|INVERS, 0, NULL, "@");
|
||||||
|
|
||||||
if (warningResult) {
|
if (warningResult) {
|
||||||
warningResult = 0;
|
warningResult = 0;
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
int8_t * points = curveAddress(s_curveChan);
|
int8_t * points = curveAddress(s_curveChan);
|
||||||
int k = 25 * warningInputValue;
|
int k = 25 * reusableBuffer.curveEdit.preset;
|
||||||
int dx = 2000 / (5+crv.points-1);
|
int dx = 2000 / (5+crv.points-1);
|
||||||
for (uint8_t i=0; i<5+crv.points; i++) {
|
for (uint8_t i=0; i<5+crv.points; i++) {
|
||||||
int x = -1000 + i * dx;
|
int x = -1000 + i * dx;
|
||||||
|
@ -49,7 +69,8 @@ void displayPresetChoice(event_t event)
|
||||||
void onCurveOneMenu(const char * result)
|
void onCurveOneMenu(const char * result)
|
||||||
{
|
{
|
||||||
if (result == STR_CURVE_PRESET) {
|
if (result == STR_CURVE_PRESET) {
|
||||||
POPUP_INPUT(STR_PRESET, displayPresetChoice, 0, -4, 4);
|
reusableBuffer.curveEdit.preset = 4; // 45°
|
||||||
|
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
|
||||||
}
|
}
|
||||||
else if (result == STR_MIRROR) {
|
else if (result == STR_MIRROR) {
|
||||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||||
|
|
|
@ -26,9 +26,6 @@ uint8_t warningInfoLength;
|
||||||
uint8_t warningType;
|
uint8_t warningType;
|
||||||
uint8_t warningResult = 0;
|
uint8_t warningResult = 0;
|
||||||
uint8_t warningInfoFlags = ZCHAR;
|
uint8_t warningInfoFlags = ZCHAR;
|
||||||
int16_t warningInputValue;
|
|
||||||
int16_t warningInputValueMin;
|
|
||||||
int16_t warningInputValueMax;
|
|
||||||
void (*popupFunc)(event_t event) = NULL;
|
void (*popupFunc)(event_t event) = NULL;
|
||||||
const char *popupMenuItems[POPUP_MENU_MAX_LINES];
|
const char *popupMenuItems[POPUP_MENU_MAX_LINES];
|
||||||
uint8_t s_menu_item = 0;
|
uint8_t s_menu_item = 0;
|
||||||
|
@ -80,7 +77,7 @@ void runPopupWarning(event_t event)
|
||||||
{
|
{
|
||||||
warningResult = false;
|
warningResult = false;
|
||||||
|
|
||||||
theme->drawMessageBox(warningText, warningInfoText, WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS), warningType);
|
theme->drawMessageBox(warningText, warningInfoText, WARNING_TYPE_INFO ? STR_OK : (warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS_ENTER_EXIT_ENTER_EXIT), warningType);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVT_KEY_BREAK(KEY_ENTER):
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
@ -88,16 +85,11 @@ void runPopupWarning(event_t event)
|
||||||
break;
|
break;
|
||||||
warningResult = true;
|
warningResult = true;
|
||||||
// no break
|
// no break
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_EXIT):
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
warningText = NULL;
|
warningText = NULL;
|
||||||
warningType = WARNING_TYPE_ASTERISK;
|
warningType = WARNING_TYPE_ASTERISK;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
if (warningType != WARNING_TYPE_INPUT) break;
|
|
||||||
s_editMode = EDIT_MODIFY_FIELD;
|
|
||||||
warningInputValue = checkIncDec(event, warningInputValue, warningInputValueMin, warningInputValueMax);
|
|
||||||
s_editMode = EDIT_SELECT_FIELD;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -930,55 +930,6 @@ static int luaGetGeneralSettings(lua_State * L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*luadoc
|
|
||||||
@function popupInput(title, event, input, min, max)
|
|
||||||
|
|
||||||
Raises a pop-up on screen that allows uses input
|
|
||||||
|
|
||||||
@param title (string) text to display
|
|
||||||
|
|
||||||
@param event (number) the event variable that is passed in from the
|
|
||||||
Run function (key pressed)
|
|
||||||
|
|
||||||
@param input (number) value that can be adjusted by the +/- keys
|
|
||||||
|
|
||||||
@param min (number) min value that input can reach (by pressing the - key)
|
|
||||||
|
|
||||||
@param max (number) max value that input can reach
|
|
||||||
|
|
||||||
@retval number result of the input adjustment
|
|
||||||
|
|
||||||
@retval "OK" user pushed ENT key
|
|
||||||
|
|
||||||
@retval "CANCEL" user pushed EXIT key
|
|
||||||
|
|
||||||
@notice Use only from stand-alone and telemetry scripts.
|
|
||||||
|
|
||||||
@status current Introduced in 2.0.0
|
|
||||||
*/
|
|
||||||
static int luaPopupInput(lua_State * L)
|
|
||||||
{
|
|
||||||
event_t event = luaL_checkinteger(L, 2);
|
|
||||||
warningInputValue = luaL_checkinteger(L, 3);
|
|
||||||
warningInputValueMin = luaL_checkinteger(L, 4);
|
|
||||||
warningInputValueMax = luaL_checkinteger(L, 5);
|
|
||||||
warningText = luaL_checkstring(L, 1);
|
|
||||||
warningType = WARNING_TYPE_INPUT;
|
|
||||||
runPopupWarning(event);
|
|
||||||
if (warningResult) {
|
|
||||||
warningResult = 0;
|
|
||||||
lua_pushstring(L, "OK");
|
|
||||||
}
|
|
||||||
else if (!warningText) {
|
|
||||||
lua_pushstring(L, "CANCEL");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lua_pushinteger(L, warningInputValue);
|
|
||||||
}
|
|
||||||
warningText = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*luadoc
|
/*luadoc
|
||||||
@function popupWarning(title, event)
|
@function popupWarning(title, event)
|
||||||
|
|
||||||
|
@ -1338,7 +1289,7 @@ const luaL_Reg opentxLib[] = {
|
||||||
{ "playDuration", luaPlayDuration },
|
{ "playDuration", luaPlayDuration },
|
||||||
{ "playTone", luaPlayTone },
|
{ "playTone", luaPlayTone },
|
||||||
{ "playHaptic", luaPlayHaptic },
|
{ "playHaptic", luaPlayHaptic },
|
||||||
{ "popupInput", luaPopupInput },
|
// { "popupInput", luaPopupInput },
|
||||||
{ "popupWarning", luaPopupWarning },
|
{ "popupWarning", luaPopupWarning },
|
||||||
{ "popupConfirmation", luaPopupConfirmation },
|
{ "popupConfirmation", luaPopupConfirmation },
|
||||||
{ "defaultStick", luaDefaultStick },
|
{ "defaultStick", luaDefaultStick },
|
||||||
|
|
|
@ -1171,6 +1171,11 @@ union ReusableBuffer
|
||||||
uint32_t step;
|
uint32_t step;
|
||||||
} spectrum;
|
} spectrum;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int8_t preset;
|
||||||
|
} curveEdit;
|
||||||
|
|
||||||
#if defined(STM32)
|
#if defined(STM32)
|
||||||
// Data for the USB mass storage driver. If USB mass storage runs no menu is not allowed to be displayed
|
// Data for the USB mass storage driver. If USB mass storage runs no menu is not allowed to be displayed
|
||||||
uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET];
|
uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET];
|
||||||
|
|
|
@ -115,7 +115,7 @@ const char STR_OPEN9X[] =
|
||||||
;
|
;
|
||||||
|
|
||||||
// The 0-terminated-strings
|
// The 0-terminated-strings
|
||||||
const char STR_POPUPS[] = TR_POPUPS;
|
const char STR_POPUPS_ENTER_EXIT[] = TR_POPUPS_ENTER_EXIT;
|
||||||
const char STR_OK[] = TR_OK;
|
const char STR_OK[] = TR_OK;
|
||||||
#if !defined(OFS_EXIT)
|
#if !defined(OFS_EXIT)
|
||||||
const char STR_EXIT[] = TR_EXIT;
|
const char STR_EXIT[] = TR_EXIT;
|
||||||
|
|
|
@ -328,11 +328,11 @@ extern const char STR_BLUETOOTH_LOCAL_ADDR[];
|
||||||
// The 0-terminated-strings
|
// The 0-terminated-strings
|
||||||
#define NO_INDENT(x) (x)+LEN_INDENT
|
#define NO_INDENT(x) (x)+LEN_INDENT
|
||||||
|
|
||||||
extern const char STR_POPUPS[];
|
extern const char STR_POPUPS_ENTER_EXIT[];
|
||||||
extern const char STR_OK[];
|
extern const char STR_OK[];
|
||||||
|
|
||||||
#if defined(OFS_EXIT)
|
#if defined(OFS_EXIT)
|
||||||
#define STR_EXIT (STR_POPUPS + OFS_EXIT)
|
#define STR_EXIT (STR_POPUPS_ENTER_EXIT + OFS_EXIT)
|
||||||
#else
|
#else
|
||||||
extern const char STR_EXIT[];
|
extern const char STR_EXIT[];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -533,10 +533,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
#define TR_POPUPS_ENTER_EXIT TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -539,10 +539,10 @@
|
||||||
#define TR_EXIT "[EXIT]"
|
#define TR_EXIT "[EXIT]"
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -538,10 +538,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
#define TR_POPUPS_ENTER_EXIT TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -537,10 +537,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -529,10 +529,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -550,10 +550,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
#define TR_POPUPS_ENTER_EXIT TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -539,10 +539,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -534,10 +534,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -540,10 +540,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -536,10 +536,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -548,10 +548,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
#define TR_POPUPS_ENTER_EXIT TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER
|
||||||
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
|
||||||
#else
|
#else
|
||||||
#define TR_POPUPS TR_ENTER "\010" TR_EXIT
|
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
|
||||||
#define OFS_EXIT sizeof(TR_ENTER)
|
#define OFS_EXIT sizeof(TR_ENTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue