feat(color): Add 'popup' option for GVARs already present on B&W (#4554)

This commit is contained in:
philmoz
2024-01-26 20:13:42 +10:00
committed by GitHub
parent 5fd1154da6
commit 8381a68a91
7 changed files with 28 additions and 14 deletions
+5
View File
@@ -492,6 +492,11 @@ class GVarEditWindow : public Page
});
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);
char flightModeName[16];
FlightModeData* fmData;
+4 -4
View File
@@ -115,8 +115,8 @@ void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info, bool wait
class BubbleDialog : public Window
{
public:
BubbleDialog(const char* message, int timeout) :
Window(MainWindow::instance(), rect_t{50, LCD_H - 100, LCD_W - 100, 50}, OPAQUE, 0, etx_bubble_popup_create)
BubbleDialog(const char* message, int timeout, coord_t width) :
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());
@@ -143,7 +143,7 @@ class BubbleDialog : public Window
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);
}
+1 -1
View File
@@ -28,6 +28,6 @@ typedef std::function<void(const char *, const char *, int, int)> ProgressHandle
void POPUP_INFORMATION(const char * message);
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_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();
+6 -1
View File
@@ -61,7 +61,12 @@ void setGVarValue(uint8_t gv, int16_t value, int8_t fm)
{
fm = getGVarFlightMode(fm, gv);
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;
}
}
}
-7
View File
@@ -23,13 +23,6 @@
// GVars have one value per flight mode
#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)
uint8_t getGVarFlightMode(uint8_t fm, uint8_t gv);
+11
View File
@@ -626,6 +626,17 @@ void perMain()
guiMain(0);
// For color screens show a popup deferred from another task
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
guiMain(evt);
#endif
+1 -1
View File
@@ -958,7 +958,7 @@ void checkTrims()
killTrimEvents(event);
}
SET_GVAR_VALUE(gvar, phase, after);
setGVarValue(gvar, after, mixerCurrentFlightMode);
}
else
#endif