From 44d4d25f4f2fb35febd26c87c4001952c51e5687 Mon Sep 17 00:00:00 2001 From: eshifri Date: Tue, 20 Jul 2021 19:55:23 -0700 Subject: [PATCH] [color] Fix timer display problem --- radio/src/gui/colorlcd/widgets/timer.cpp | 6 +++ radio/src/gui/colorlcd/widgets/value.cpp | 57 +++++++++++++++--------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/timer.cpp b/radio/src/gui/colorlcd/widgets/timer.cpp index 389303acb..eb2c0db2a 100644 --- a/radio/src/gui/colorlcd/widgets/timer.cpp +++ b/radio/src/gui/colorlcd/widgets/timer.cpp @@ -21,6 +21,12 @@ #include "opentx.h" #include "widgets_container_impl.h" +// libopemui defines TIMOUR as zero +#ifdef TIMEHOUR +#undef TIMEHOUR +#define TIMEHOUR 0x2000 +#endif + class TimerWidget: public Widget { public: diff --git a/radio/src/gui/colorlcd/widgets/value.cpp b/radio/src/gui/colorlcd/widgets/value.cpp index 6c8821a2a..e2ed19f9a 100644 --- a/radio/src/gui/colorlcd/widgets/value.cpp +++ b/radio/src/gui/colorlcd/widgets/value.cpp @@ -86,30 +86,45 @@ class ValueWidget: public Widget if (timerState.val < 0) { color = ALARM_COLOR; } - 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); - } - - if (field == MIXSRC_TX_TIME) { - drawTimer(dc, xValue, yValue, getValue(MIXSRC_TX_TIME), - attrValue | FONT(XL) | color); - } - - if (field >= MIXSRC_FIRST_TELEM) { - TelemetryItem & telemetryItem = telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3]; - if (!telemetryItem.isAvailable() || telemetryItem.isOld()) { - color = TEXT_DISABLE_COLOR; + if (persistentData->options[2].value.boolValue) { + drawSource(dc, xLabel + 1, yLabel + 1, field, attrLabel | COLOR2FLAGS(BLACK)); + drawTimer(dc, xValue + 1, yValue + 1, abs(timerState.val), + attrValue | FONT(STD) | COLOR2FLAGS(BLACK)); } - } + drawSource(dc, xLabel, yLabel, field, attrLabel | color); + drawTimer(dc, xValue, yValue, abs(timerState.val), + attrValue | FONT(STD) | color); - if (persistentData->options[2].value.boolValue) { - drawSource(dc,xLabel + 1, yLabel + 1, field, attrLabel | COLOR2FLAGS(BLACK)); - drawSourceValue(dc, xValue + 1, yValue + 1, field, attrValue | COLOR2FLAGS(BLACK)); - } + } else if (field == MIXSRC_TX_TIME) { + int32_t tme = getValue(MIXSRC_TX_TIME); + if (persistentData->options[2].value.boolValue) { + drawSource(dc, xLabel + 1, yLabel + 1, field, COLOR2FLAGS(BLACK)); + drawTimer(dc, xValue + 1, yValue + 1, tme, + attrValue | FONT(STD) | COLOR2FLAGS(BLACK)); + } + drawSource(dc, xLabel, yLabel, field, attrLabel | color); + drawTimer(dc, xValue, yValue, tme, + attrValue | FONT(STD) | color); + } else { - drawSource(dc, xLabel, yLabel, field, attrLabel | color); - drawSourceValue(dc, xValue, yValue, field, attrValue | color); + if (field >= MIXSRC_FIRST_TELEM) { + TelemetryItem& telemetryItem = + telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3]; + if (!telemetryItem.isAvailable() || telemetryItem.isOld()) { + color = TEXT_DISABLE_COLOR; + } + } + + if (persistentData->options[2].value.boolValue) { + 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 | color); + drawSourceValue(dc, xValue, yValue, field, attrValue | color); + } } void checkEvents() override