feat(color): Add 'popup' option for GVARs already present on B&W (#4554)
This commit is contained in:
@@ -492,6 +492,11 @@ class GVarEditWindow : public Page
|
|||||||
});
|
});
|
||||||
max->setAccelFactor(16);
|
max->setAccelFactor(16);
|
||||||
|
|
||||||
|
line = window->newLine(&grid);
|
||||||
|
new StaticText(line, rect_t{}, STR_POPUP, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
grid.nextCell();
|
||||||
|
new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(gvar->popup));
|
||||||
|
|
||||||
line = window->newLine(&grid);
|
line = window->newLine(&grid);
|
||||||
char flightModeName[16];
|
char flightModeName[16];
|
||||||
FlightModeData* fmData;
|
FlightModeData* fmData;
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info, bool wait
|
|||||||
class BubbleDialog : public Window
|
class BubbleDialog : public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BubbleDialog(const char* message, int timeout) :
|
BubbleDialog(const char* message, int timeout, coord_t width) :
|
||||||
Window(MainWindow::instance(), rect_t{50, LCD_H - 100, LCD_W - 100, 50}, OPAQUE, 0, etx_bubble_popup_create)
|
Window(MainWindow::instance(), rect_t{(LCD_W - width) / 2, LCD_H - 100, width, 50}, OPAQUE, 0, etx_bubble_popup_create)
|
||||||
{
|
{
|
||||||
lv_obj_set_parent(lvobj, lv_layer_top());
|
lv_obj_set_parent(lvobj, lv_layer_top());
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ class BubbleDialog : public Window
|
|||||||
uint32_t endTime;
|
uint32_t endTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
void POPUP_BUBBLE(const char* message, uint32_t timeout)
|
void POPUP_BUBBLE(const char* message, uint32_t timeout, coord_t width)
|
||||||
{
|
{
|
||||||
new BubbleDialog(message, timeout);
|
new BubbleDialog(message, timeout, width);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ typedef std::function<void(const char *, const char *, int, int)> ProgressHandle
|
|||||||
void POPUP_INFORMATION(const char * message);
|
void POPUP_INFORMATION(const char * message);
|
||||||
void POPUP_WARNING(const char * message, const char * info = nullptr);
|
void POPUP_WARNING(const char * message, const char * info = nullptr);
|
||||||
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr, bool waitForClose = true);
|
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr, bool waitForClose = true);
|
||||||
void POPUP_BUBBLE(const char * message, uint32_t timeout);
|
void POPUP_BUBBLE(const char * message, uint32_t timeout, coord_t width = LCD_W - 100);
|
||||||
|
|
||||||
void show_ui_popup();
|
void show_ui_popup();
|
||||||
|
|||||||
+6
-1
@@ -61,7 +61,12 @@ void setGVarValue(uint8_t gv, int16_t value, int8_t fm)
|
|||||||
{
|
{
|
||||||
fm = getGVarFlightMode(fm, gv);
|
fm = getGVarFlightMode(fm, gv);
|
||||||
if (GVAR_VALUE(gv, fm) != value) {
|
if (GVAR_VALUE(gv, fm) != value) {
|
||||||
SET_GVAR_VALUE(gv, fm, value);
|
GVAR_VALUE(gv, fm) = value;
|
||||||
|
storageDirty(EE_MODEL);
|
||||||
|
if (g_model.gvars[gv].popup) {
|
||||||
|
gvarLastChanged = gv;
|
||||||
|
gvarDisplayTimer = GVAR_DISPLAY_TIME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,6 @@
|
|||||||
|
|
||||||
// GVars have one value per flight mode
|
// GVars have one value per flight mode
|
||||||
#define GVAR_VALUE(gv, fm) g_model.flightModeData[fm].gvars[gv]
|
#define GVAR_VALUE(gv, fm) g_model.flightModeData[fm].gvars[gv]
|
||||||
#define SET_GVAR_VALUE(idx, phase, value) \
|
|
||||||
GVAR_VALUE(idx, phase) = value; \
|
|
||||||
storageDirty(EE_MODEL); \
|
|
||||||
if (g_model.gvars[idx].popup) { \
|
|
||||||
gvarLastChanged = idx; \
|
|
||||||
gvarDisplayTimer = GVAR_DISPLAY_TIME; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(GVARS)
|
#if defined(GVARS)
|
||||||
uint8_t getGVarFlightMode(uint8_t fm, uint8_t gv);
|
uint8_t getGVarFlightMode(uint8_t fm, uint8_t gv);
|
||||||
|
|||||||
@@ -626,6 +626,17 @@ void perMain()
|
|||||||
guiMain(0);
|
guiMain(0);
|
||||||
// For color screens show a popup deferred from another task
|
// For color screens show a popup deferred from another task
|
||||||
show_ui_popup();
|
show_ui_popup();
|
||||||
|
// Show GVAR popup
|
||||||
|
if (gvarDisplayTimer > 0) {
|
||||||
|
char s[30], *p;
|
||||||
|
p = strAppendStringWithIndex(s, STR_GV, gvarLastChanged + 1);
|
||||||
|
p = strAppend(p, " ", 1);
|
||||||
|
p = strAppend(p, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME);
|
||||||
|
p = strAppend(p, " = ", 3);
|
||||||
|
p = strAppendSigned(p, GVAR_VALUE(gvarLastChanged, getGVarFlightMode(mixerCurrentFlightMode, gvarLastChanged)));
|
||||||
|
POPUP_BUBBLE(s, gvarDisplayTimer * 10, 200);
|
||||||
|
gvarDisplayTimer = 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
guiMain(evt);
|
guiMain(evt);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -958,7 +958,7 @@ void checkTrims()
|
|||||||
killTrimEvents(event);
|
killTrimEvents(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_GVAR_VALUE(gvar, phase, after);
|
setGVarValue(gvar, after, mixerCurrentFlightMode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user