From 84e0d6e5a6b52ba338f55830bc800e7b41f6532d Mon Sep 17 00:00:00 2001 From: eshifri Date: Fri, 18 Jun 2021 14:00:14 -0700 Subject: [PATCH 01/11] change sign for number edit --- radio/src/gui/colorlcd/widgets/value.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index b79a19d89..22fd4d3b7 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -90,6 +90,11 @@ class ValueWidget: public Widget drawTimer(dc, xValue, yValue, abs(timerState.val), attrValue | FONT(XL) | CUSTOM_COLOR); } + if (field == MIXSRC_TX_TIME) { + drawTimer(dc, xValue, yValue, getValue(MIXSRC_TX_TIME), + attrValue | FONT(XL) | CUSTOM_COLOR); + } + if (field >= MIXSRC_FIRST_TELEM) { TelemetryItem & telemetryItem = telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3]; // TODO macro to convert a source to a telemetry index if (!telemetryItem.isAvailable() || telemetryItem.isOld()) { From 0d5504686eba05ef961e20c79580e6dfa549a48a Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Jun 2021 12:07:55 +0200 Subject: [PATCH 02/11] Remove widgets from the layout as a FormGroup as well and fix the focus order pointers. Resolves #257 and potentially more. --- radio/src/gui/colorlcd/layout.cpp | 2 -- .../colorlcd/widgets/widgets_container_impl.h | 19 +++++++++++++------ radio/src/thirdparty/libopenui | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/radio/src/gui/colorlcd/layout.cpp b/radio/src/gui/colorlcd/layout.cpp index 10cdf1a96..862168d1f 100644 --- a/radio/src/gui/colorlcd/layout.cpp +++ b/radio/src/gui/colorlcd/layout.cpp @@ -123,8 +123,6 @@ void loadCustomScreens() } auto topbar = viewMain->getTopbar(); - - // TODO: how to reload this guy? topbar->load(); viewMain->setCurrentMainView(0); diff --git a/radio/src/gui/colorlcd/widgets/widgets_container_impl.h b/radio/src/gui/colorlcd/widgets/widgets_container_impl.h index 0fb615c3a..9d2836781 100644 --- a/radio/src/gui/colorlcd/widgets/widgets_container_impl.h +++ b/radio/src/gui/colorlcd/widgets/widgets_container_impl.h @@ -43,10 +43,12 @@ class WidgetsContainerImpl: public WidgetsContainer // remove old one if existing removeWidget(index); - Widget * widget = nullptr; + Widget* widget = nullptr; if (factory) { - strncpy(persistentData->zones[index].widgetName, factory->getName(), sizeof(ZonePersistentData::widgetName)); - widget = factory->create(this, getZone(index), &persistentData->zones[index].widgetData); + strncpy(persistentData->zones[index].widgetName, factory->getName(), + sizeof(ZonePersistentData::widgetName)); + widget = factory->create(this, getZone(index), + &persistentData->zones[index].widgetData); } widgets[index] = widget; @@ -61,12 +63,16 @@ class WidgetsContainerImpl: public WidgetsContainer if (index >= N) return; - if (widgets[index]) + if (widgets[index]) { + removeField(widgets[index]); widgets[index]->deleteLater(); + } widgets[index] = nullptr; - memset(persistentData->zones[index].widgetName, 0, sizeof(ZonePersistentData::widgetName)); - memset(&persistentData->zones[index].widgetData, 0, sizeof(Widget::PersistentData)); + memset(persistentData->zones[index].widgetName, 0, + sizeof(ZonePersistentData::widgetName)); + memset(&persistentData->zones[index].widgetData, 0, + sizeof(Widget::PersistentData)); } Widget * getWidget(unsigned int index) override @@ -89,6 +95,7 @@ class WidgetsContainerImpl: public WidgetsContainer // remove old widget if (widgets[i]) { + removeField(widgets[i]); widgets[i]->deleteLater(); widgets[i] = nullptr; } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 6b661c490..d1c94e627 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 6b661c4907bcafc08436e5c96fc5a38e9eb6e499 +Subproject commit d1c94e6279e7b829f4b0953bc4bea1100bae5543 From 82f60cdc81f2d12259b577dfc907c00879cdcd91 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Jun 2021 14:48:41 +0200 Subject: [PATCH 03/11] Fix model names on model select page with not yet converted models Resolves #248 --- radio/src/gui/colorlcd/model_select.cpp | 23 +++++++++++++++---- radio/src/storage/conversions/conversions.cpp | 6 ++--- radio/src/storage/modelslist.cpp | 4 +++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/radio/src/gui/colorlcd/model_select.cpp b/radio/src/gui/colorlcd/model_select.cpp index 9a4a0115b..04e08f621 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -108,15 +108,30 @@ class ModelButton : public Button if (strncmp(modelCell->modelFilename, g_eeGeneral.currModelFilename, LEN_MODEL_FILENAME) == 0) { memcpy(&partialModel.header, &g_model.header, sizeof(partialModel)); + version = EEPROM_VER; } else { error = readModel(modelCell->modelFilename, (uint8_t *)&partialModel.header, sizeof(partialModel), &version); - if (!error) { - if (modelCell->modelName[0] == '\0' && - partialModel.header.name[0] != '\0') { - modelCell->setModelName(partialModel.header.name); + } + + if (!error) { + if (modelCell->modelName[0] == '\0' && + partialModel.header.name[0] != '\0') { + + if (version == 219) { + size_t len = sizeof(partialModel.header.name); + char* str = partialModel.header.name; + for (int i=0; i < len; i++) { + str[i] = zchar2char(str[i]); + } + // Trim string + while(len > 0 && str[len-1]) { + if (str[len - 1] != ' ' && str[len - 1] != '\0') break; + str[--len] = '\0'; + } } + modelCell->setModelName(partialModel.header.name); } } diff --git a/radio/src/storage/conversions/conversions.cpp b/radio/src/storage/conversions/conversions.cpp index 7071b7540..34430cce6 100644 --- a/radio/src/storage/conversions/conversions.cpp +++ b/radio/src/storage/conversions/conversions.cpp @@ -59,6 +59,9 @@ void convertRadioData(int version) RAISE_ALERT(STR_STORAGE_WARNING, STR_SDCARD_CONVERSION_REQUIRE, NULL, AU_NONE); + // Load models list before converting + modelslist.load(); + unsigned converted = 0; auto to_convert = modelslist.getModelsCount() + 1; @@ -76,9 +79,6 @@ void convertRadioData(int version) RTOS_WAIT_MS(200); #endif - // Load models list before converting - modelslist.load(); - const char* error = nullptr; for (auto category_ptr : modelslist.getCategories()) { for (auto model_ptr : *category_ptr) { diff --git a/radio/src/storage/modelslist.cpp b/radio/src/storage/modelslist.cpp index b871c5732..1ba806284 100644 --- a/radio/src/storage/modelslist.cpp +++ b/radio/src/storage/modelslist.cpp @@ -48,7 +48,9 @@ ModelCell::~ModelCell() void ModelCell::setModelName(char * name) { strncpy(modelName, name, LEN_MODEL_NAME); - if (modelName[0] == 0) { + modelName[LEN_MODEL_NAME] = '\0'; + + if (modelName[0] == '\0') { char * tmp; strncpy(modelName, modelFilename, LEN_MODEL_NAME); tmp = (char *) memchr(modelName, '.', LEN_MODEL_NAME); From afe7c13b8b81a2f26f4fa17f2502d5aa207356c7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Jun 2021 16:25:20 +0200 Subject: [PATCH 04/11] Fix conversion of input line name, curve names, and write radio.bin to disk early Resolves #264 Resolves #255 --- radio/src/storage/conversions/conversions.cpp | 2 ++ radio/src/storage/conversions/conversions_219_220.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/radio/src/storage/conversions/conversions.cpp b/radio/src/storage/conversions/conversions.cpp index 34430cce6..0e474d1c4 100644 --- a/radio/src/storage/conversions/conversions.cpp +++ b/radio/src/storage/conversions/conversions.cpp @@ -71,6 +71,8 @@ void convertRadioData(int version) #if STORAGE_CONVERSIONS < 220 if (version == 219) { convertRadioData_219_to_220(g_eeGeneral); + storageDirty(EE_GENERAL); + storageCheck(true); } #endif converted++; diff --git a/radio/src/storage/conversions/conversions_219_220.cpp b/radio/src/storage/conversions/conversions_219_220.cpp index 8c6d841f1..9fb21e390 100644 --- a/radio/src/storage/conversions/conversions_219_220.cpp +++ b/radio/src/storage/conversions/conversions_219_220.cpp @@ -109,7 +109,7 @@ void convertModelData_219_to_220(ModelData &model) convertToStr(model.header.name, LEN_MODEL_NAME_219); for (uint8_t i=0; i Date: Sat, 19 Jun 2021 16:55:35 +0200 Subject: [PATCH 05/11] Add special function parameter for "Adjust" function Resolves #253 --- radio/src/gui/colorlcd/special_functions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index 5c79687e0..e781bcb56 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -250,6 +250,19 @@ class SpecialFunctionEditPage : public Page }); break; } + + case FUNC_ADJUST_GVAR: { + //TODO: GVAR choice: CFN_GVAR_INDEX(cfn) + new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), + STR_VALUE); + auto choice = + new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, + MAX_GVARS - 1, GET_SET_DEFAULT(CFN_GVAR_INDEX(cfn))); + choice->setTextHandler([](int32_t value) { + return std::string(STR_GV) + std::to_string(value); + }); + grid.nextLine(); + } } if (HAS_ENABLE_PARAM(func)) { From 869bcc09b70f18c31bbd3371c84b05b3dac36540 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Jun 2021 17:05:55 +0200 Subject: [PATCH 06/11] Fix displaying ModelBmp on small surfaces Resolves #269 --- radio/src/gui/colorlcd/widgets/modelbmp.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index daf5977f7..3eee954d0 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -97,7 +97,12 @@ class ModelBitmapWidget: public Widget TRACE("could not load bitmap '%s'", filename.c_str()); return; } - buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + + if (rect.h >= 96 && rect.w >= 120) { + buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + } else { + buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height()); + } } } }; From 9737ce80ff79226a012cd49489d8103fb028325c Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Jun 2021 08:08:23 +0200 Subject: [PATCH 07/11] Fixed Adjust GVAR special function Resolves #277 --- radio/src/gui/colorlcd/special_functions.cpp | 119 +++++++++++++++++-- 1 file changed, 109 insertions(+), 10 deletions(-) diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index e781bcb56..3faf9d9ad 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -252,16 +252,89 @@ class SpecialFunctionEditPage : public Page } case FUNC_ADJUST_GVAR: { - //TODO: GVAR choice: CFN_GVAR_INDEX(cfn) + new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), - STR_VALUE); - auto choice = + STR_GLOBALVAR); + auto gvarchoice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, MAX_GVARS - 1, GET_SET_DEFAULT(CFN_GVAR_INDEX(cfn))); - choice->setTextHandler([](int32_t value) { - return std::string(STR_GV) + std::to_string(value); + gvarchoice->setTextHandler([](int32_t value) { + return std::string(STR_GV) + std::to_string(value + 1); }); grid.nextLine(); + + new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), + STR_MODE); + auto modechoice = + new Choice(specialFunctionOneWindow, grid.getFieldSlot(), + FUNC_ADJUST_GVAR_CONSTANT, FUNC_ADJUST_GVAR_INCDEC, + GET_DEFAULT(CFN_GVAR_MODE(cfn)), nullptr); + grid.nextLine(); + + modechoice->setTextHandler([](int32_t value) { + switch (value) { + case FUNC_ADJUST_GVAR_CONSTANT: + return std::string(STR_CONSTANT); + case FUNC_ADJUST_GVAR_SOURCE: + return std::string(STR_MIXSOURCE); + case FUNC_ADJUST_GVAR_GVAR: + return std::string(STR_GLOBALVAR); + case FUNC_ADJUST_GVAR_INCDEC: + return std::string(STR_INCDEC); + } + return std::string("---"); + }); + + modechoice->setSetValueHandler([=](int32_t newValue) { + CFN_GVAR_MODE(cfn) = newValue; + CFN_PARAM(cfn) = 0; + SET_DIRTY(); + updateSpecialFunctionOneWindow(); + }); + + switch (CFN_GVAR_MODE(cfn)) { + case FUNC_ADJUST_GVAR_CONSTANT: { + //TODO: label + int16_t val_min, val_max; + getMixSrcRange(CFN_GVAR_INDEX(cfn) + MIXSRC_FIRST_GVAR, val_min, + val_max); + new NumberEdit(specialFunctionOneWindow, grid.getFieldSlot(), + val_min, val_max, GET_SET_DEFAULT(CFN_PARAM(cfn))); + break; + } + case FUNC_ADJUST_GVAR_SOURCE: + //TODO: label + new SourceChoice(specialFunctionOneWindow, grid.getFieldSlot(), + 0, MIXSRC_LAST_CH, GET_SET_DEFAULT(CFN_PARAM(cfn))); + break; + case FUNC_ADJUST_GVAR_GVAR: { + auto gvarchoice = + new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, + MAX_GVARS - 1, GET_SET_DEFAULT(CFN_PARAM(cfn))); + gvarchoice->setTextHandler([](int32_t value) { + return std::string(STR_GV) + std::to_string(value + 1); + }); + gvarchoice->setAvailableHandler([=](int value) { + return CFN_GVAR_INDEX(cfn) != value; + }); + break; + } + case FUNC_ADJUST_GVAR_INCDEC: { + int16_t val_min, val_max; + getMixSrcRange(CFN_GVAR_INDEX(cfn) + MIXSRC_FIRST_GVAR, val_min, val_max); + getGVarIncDecRange(val_min, val_max); + auto numedit = new NumberEdit(specialFunctionOneWindow, + grid.getFieldSlot(), val_min, val_max, + GET_SET_DEFAULT(CFN_PARAM(cfn))); + numedit->setDisplayHandler( + [](BitmapBuffer *dc, LcdFlags flags, int value) { + dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, abs(value), + flags, 0, value >= 0 ? "+= " : "-= ", nullptr); + }); + break; + } + } + grid.nextLine(); } } @@ -403,12 +476,18 @@ class SpecialFunctionButton : public Button dc->drawNumber(col2, line2, CFN_PARAM(cfn)); break; - case FUNC_TRAINER: - drawSource( - dc, col1, line2, - CFN_CH_INDEX(cfn) == 0 ? 0 : MIXSRC_Rud + CFN_CH_INDEX(cfn) - 1); + case FUNC_TRAINER: { + std::string text; + int16_t value = CFN_CH_INDEX(cfn); + if (value == 0) + text = std::string(STR_STICKS); + else if (value == NUM_STICKS + 1) + text = std::string(STR_CHANS); + else + text = TEXT_AT_INDEX(STR_VSRCRAW, value); + dc->drawText(col1, line2, text.c_str(), 0); break; - + } case FUNC_RESET: if (CFN_PARAM(cfn) < FUNC_RESET_PARAM_FIRST_TELEM) { dc->drawTextAtIndex(col1, line2, STR_VFSWRESET, CFN_PARAM(cfn)); @@ -463,6 +542,26 @@ class SpecialFunctionButton : public Button dc->drawNumber(col3, line1, CFN_PARAM(cfn), PREC1, sizeof(CFN_PARAM(cfn)), nullptr, "s"); break; + + case FUNC_ADJUST_GVAR: + switch(CFN_GVAR_MODE(cfn)) { + case FUNC_ADJUST_GVAR_CONSTANT: + dc->drawNumber(col1, line2, CFN_PARAM(cfn), 0); + break; + case FUNC_ADJUST_GVAR_SOURCE: + drawSource(dc, col1, line2, CFN_PARAM(cfn), 0); + break; + case FUNC_ADJUST_GVAR_GVAR: + drawSource(dc, col1, line2, CFN_PARAM(cfn) + MIXSRC_FIRST_GVAR, 0); + break; + case FUNC_ADJUST_GVAR_INCDEC: { + int16_t value = CFN_PARAM(cfn); + std::string text(value >= 0 ? "+= " : "-= "); + text += std::to_string(abs(value)); + dc->drawText(col1, line2, text.c_str()); + break; + } + } } if (HAS_ENABLE_PARAM(func)) { theme->drawCheckBox(dc, CFN_ACTIVE(cfn), col3, line2); From 1d050efa6da7cc5d5b7fe8644f98a9fd2246718b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Jun 2021 08:29:20 +0200 Subject: [PATCH 08/11] Fix cluttered GPS position display Resolves #273 --- radio/src/gui/colorlcd/draw_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/draw_functions.cpp b/radio/src/gui/colorlcd/draw_functions.cpp index 122c0ac91..70355d4e1 100644 --- a/radio/src/gui/colorlcd/draw_functions.cpp +++ b/radio/src/gui/colorlcd/draw_functions.cpp @@ -317,7 +317,7 @@ coord_t drawGPSCoord(BitmapBuffer * dc, coord_t x, coord_t y, int32_t value, con } *tmp++ = direction[value>=0 ? 0 : 1]; *tmp = '\0'; - dc->drawText(x, y, s, flags); + x += dc->drawText(x, y, s, flags); return x; } From f3b50c177ca78154b36aeb07e89828b8ba391c7a Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Jun 2021 09:32:10 +0200 Subject: [PATCH 09/11] Fixed cluttered GPS display if right-aligned. --- radio/src/gui/colorlcd/draw_functions.cpp | 11 +++++------ radio/src/thirdparty/libopenui | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/colorlcd/draw_functions.cpp b/radio/src/gui/colorlcd/draw_functions.cpp index 70355d4e1..687aeab62 100644 --- a/radio/src/gui/colorlcd/draw_functions.cpp +++ b/radio/src/gui/colorlcd/draw_functions.cpp @@ -317,17 +317,16 @@ coord_t drawGPSCoord(BitmapBuffer * dc, coord_t x, coord_t y, int32_t value, con } *tmp++ = direction[value>=0 ? 0 : 1]; *tmp = '\0'; - x += dc->drawText(x, y, s, flags); + x = dc->drawText(x, y, s, flags); return x; } void drawGPSPosition(BitmapBuffer * dc, coord_t x, coord_t y, int32_t longitude, int32_t latitude, LcdFlags flags) { - if (flags & EXPANDED) { - drawGPSCoord(dc, x, y, latitude, "NS", flags, true); - drawGPSCoord(dc, x, y + FH, longitude, "EW", flags, true); - } - else { + if (flags & RIGHT) { + x = drawGPSCoord(dc, x, y, longitude, "EW", flags, false); + drawGPSCoord(dc, x - 5, y, latitude, "NS", flags, false); + } else { x = drawGPSCoord(dc, x, y, latitude, "NS", flags, false); drawGPSCoord(dc, x + 5, y, longitude, "EW", flags, false); } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index d1c94e627..bca0e093b 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit d1c94e6279e7b829f4b0953bc4bea1100bae5543 +Subproject commit bca0e093b001596d27cc8297a3ec142a3b42239b From 3b317848720ff83cd435d47a550249fe9d10deaf Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Jun 2021 09:33:27 +0200 Subject: [PATCH 10/11] Fixed value widget colors --- radio/src/gui/colorlcd/widgets/value.cpp | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index 22fd4d3b7..f6515f731 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -26,10 +26,11 @@ const coord_t NUMBERS_PADDING = 4; class ValueWidget: public Widget { public: - ValueWidget(const WidgetFactory * factory, FormGroup * parent, const rect_t & rect, Widget::PersistentData * persistentData): - Widget(factory, parent, rect, persistentData) - { - } + ValueWidget(const WidgetFactory* factory, FormGroup* parent, + const rect_t& rect, Widget::PersistentData* persistentData) : + Widget(factory, parent, rect, persistentData) + { + } void refresh(BitmapBuffer * dc) override { @@ -37,11 +38,12 @@ class ValueWidget: public Widget mixsrc_t field = persistentData->options[0].value.unsignedValue; // get color from options[1] - lcdSetColor(persistentData->options[1].value.unsignedValue); + LcdFlags color = COLOR2FLAGS(persistentData->options[1].value.unsignedValue); coord_t xValue, yValue, xLabel, yLabel; LcdFlags attrValue, attrLabel = 0; + bool twolines = false; if (width() < 120 && height() < 50) { xValue = 0; yValue = 14; @@ -64,7 +66,8 @@ class ValueWidget: public Widget yLabel = 2; if (field >= MIXSRC_FIRST_TELEM) { if (isGPSSensor(1 + (field - MIXSRC_FIRST_TELEM) / 3)) { - attrValue = LEFT | FONT(L) | EXPANDED; + attrValue = LEFT | FONT(L);// | EXPANDED; // TODO + twolines = true; } else { attrValue = LEFT | FONT(XL); @@ -72,7 +75,8 @@ class ValueWidget: public Widget } #if defined(INTERNAL_GPS) else if (field == MIXSRC_TX_GPS) { - attrValue = LEFT | FONT(L) | EXPANDED; + attrValue = LEFT | FONT(L);// | EXPANDED; // TODO + twolines = true; } #endif else { @@ -87,28 +91,28 @@ class ValueWidget: public Widget } drawSource(dc, NUMBERS_PADDING, 2, field, CUSTOM_COLOR); drawSource(dc, NUMBERS_PADDING + 1, 3, field, BLACK); - drawTimer(dc, xValue, yValue, abs(timerState.val), attrValue | FONT(XL) | CUSTOM_COLOR); + drawTimer(dc, xValue, yValue, abs(timerState.val), attrValue | FONT(XL) | color); } if (field == MIXSRC_TX_TIME) { drawTimer(dc, xValue, yValue, getValue(MIXSRC_TX_TIME), - attrValue | FONT(XL) | CUSTOM_COLOR); + attrValue | FONT(XL) | color); } if (field >= MIXSRC_FIRST_TELEM) { - TelemetryItem & telemetryItem = telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3]; // TODO macro to convert a source to a telemetry index + TelemetryItem & telemetryItem = telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3]; if (!telemetryItem.isAvailable() || telemetryItem.isOld()) { - lcdSetColor(lcdColorTable[TEXT_DISABLE_COLOR_INDEX]); + color = TEXT_DISABLE_COLOR; } } if (persistentData->options[2].value.boolValue) { - drawSource(dc,xLabel + 1, yLabel + 1, field, attrLabel | BLACK); - drawSourceValue(dc, xValue + 1, yValue + 1, field, attrValue | BLACK); + drawSource(dc,xLabel + 1, yLabel + 1, field, attrLabel | COLOR2FLAGS(BLACK)); + drawSourceValue(dc, xValue + 1, yValue + 1, field, attrValue | COLOR2FLAGS(BLACK)); } - drawSource(dc, xLabel, yLabel, field, attrLabel | CUSTOM_COLOR); - drawSourceValue(dc, xValue, yValue, field, attrValue | CUSTOM_COLOR); + drawSource(dc, xLabel, yLabel, field, attrLabel | color); + drawSourceValue(dc, xValue, yValue, field, attrValue | color); } void checkEvents() override From 3472bbdc781a93ef87fc6273b255889da921860e Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Jun 2021 10:35:35 +0200 Subject: [PATCH 11/11] Fixed 2 lines display of GPS values --- radio/src/gui/colorlcd/draw_functions.cpp | 15 ++++++++++----- radio/src/gui/colorlcd/widgets/value.cpp | 15 ++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/radio/src/gui/colorlcd/draw_functions.cpp b/radio/src/gui/colorlcd/draw_functions.cpp index 687aeab62..0b2ca84f3 100644 --- a/radio/src/gui/colorlcd/draw_functions.cpp +++ b/radio/src/gui/colorlcd/draw_functions.cpp @@ -323,12 +323,17 @@ coord_t drawGPSCoord(BitmapBuffer * dc, coord_t x, coord_t y, int32_t value, con void drawGPSPosition(BitmapBuffer * dc, coord_t x, coord_t y, int32_t longitude, int32_t latitude, LcdFlags flags) { - if (flags & RIGHT) { - x = drawGPSCoord(dc, x, y, longitude, "EW", flags, false); - drawGPSCoord(dc, x - 5, y, latitude, "NS", flags, false); + if (flags & PREC1) { + drawGPSCoord(dc, x, y, latitude, "NS", flags, false); + drawGPSCoord(dc, x, y + FH, longitude, "EW", flags, false); } else { - x = drawGPSCoord(dc, x, y, latitude, "NS", flags, false); - drawGPSCoord(dc, x + 5, y, longitude, "EW", flags, false); + if (flags & RIGHT) { + x = drawGPSCoord(dc, x, y, longitude, "EW", flags, false); + drawGPSCoord(dc, x - 5, y, latitude, "NS", flags, false); + } else { + x = drawGPSCoord(dc, x, y, latitude, "NS", flags, false); + drawGPSCoord(dc, x + 5, y, longitude, "EW", flags, false); + } } } diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index f6515f731..6c8821a2a 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -43,7 +43,6 @@ class ValueWidget: public Widget coord_t xValue, yValue, xLabel, yLabel; LcdFlags attrValue, attrLabel = 0; - bool twolines = false; if (width() < 120 && height() < 50) { xValue = 0; yValue = 14; @@ -57,7 +56,7 @@ class ValueWidget: public Widget yValue = -2; xLabel = NUMBERS_PADDING; yLabel = +2; - attrValue = RIGHT | NO_UNIT | FONT(XL); + attrValue = RIGHT | NO_UNIT | FONT(L); } else { xValue = NUMBERS_PADDING; @@ -66,8 +65,7 @@ class ValueWidget: public Widget yLabel = 2; if (field >= MIXSRC_FIRST_TELEM) { if (isGPSSensor(1 + (field - MIXSRC_FIRST_TELEM) / 3)) { - attrValue = LEFT | FONT(L);// | EXPANDED; // TODO - twolines = true; + attrValue = LEFT | FONT(L) | PREC1; } else { attrValue = LEFT | FONT(XL); @@ -75,8 +73,7 @@ class ValueWidget: public Widget } #if defined(INTERNAL_GPS) else if (field == MIXSRC_TX_GPS) { - attrValue = LEFT | FONT(L);// | EXPANDED; // TODO - twolines = true; + attrValue = LEFT | FONT(L) | PREC1; } #endif else { @@ -87,10 +84,10 @@ class ValueWidget: public Widget if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER) { TimerState & timerState = timersStates[field - MIXSRC_FIRST_TIMER]; if (timerState.val < 0) { - lcdSetColor(lcdColorTable[ALARM_COLOR_INDEX]); + color = ALARM_COLOR; } - drawSource(dc, NUMBERS_PADDING, 2, field, CUSTOM_COLOR); - drawSource(dc, NUMBERS_PADDING + 1, 3, field, BLACK); + drawSource(dc, NUMBERS_PADDING, 2, field, color); + drawSource(dc, NUMBERS_PADDING + 1, 3, field, COLOR2FLAGS(BLACK)); drawTimer(dc, xValue, yValue, abs(timerState.val), attrValue | FONT(XL) | color); }