From f4154dde3ada7acc668a2958e2a3d7d1bf797884 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Sat, 17 Feb 2024 05:01:13 +0100 Subject: [PATCH] New design Dual Watch --- app/spectrum.c | 52 ++++++++++++----------- ui/helper.c | 32 ++++++++++++++ ui/helper.h | 3 ++ ui/main.c | 111 ++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 158 insertions(+), 40 deletions(-) diff --git a/app/spectrum.c b/app/spectrum.c index cc892ae..6979afb 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -149,12 +149,14 @@ static void SetRegMenuValue(uint8_t st, bool add) { // GUI functions -static void PutPixel(uint8_t x, uint8_t y, bool fill) { - UI_DrawPixelBuffer(gFrameBuffer, x, y, fill); -} -static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { - UI_DrawPixelBuffer(&gStatusLine, x, y, fill); -} +#ifndef ENABLE_FEAT_F4HWN + static void PutPixel(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(gFrameBuffer, x, y, fill); + } + static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(&gStatusLine, x, y, fill); + } +#endif static void DrawVLine(int sy, int ey, int nx, bool fill) { for (int i = sy; i <= ey; i++) { @@ -164,29 +166,31 @@ static void DrawVLine(int sy, int ey, int nx, bool fill) { } } -static void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, - bool statusbar, bool fill) { - uint8_t c; - uint8_t pixels; - const uint8_t *p = (const uint8_t *)pString; +#ifndef ENABLE_FEAT_F4HWN + static void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, + bool statusbar, bool fill) { + uint8_t c; + uint8_t pixels; + const uint8_t *p = (const uint8_t *)pString; - while ((c = *p++) && c != '\0') { - c -= 0x20; - for (int i = 0; i < 3; ++i) { - pixels = gFont3x5[c][i]; - for (int j = 0; j < 6; ++j) { - if (pixels & 1) { - if (statusbar) - PutPixelStatus(x + i, y + j, fill); - else - PutPixel(x + i, y + j, fill); + while ((c = *p++) && c != '\0') { + c -= 0x20; + for (int i = 0; i < 3; ++i) { + pixels = gFont3x5[c][i]; + for (int j = 0; j < 6; ++j) { + if (pixels & 1) { + if (statusbar) + PutPixelStatus(x + i, y + j, fill); + else + PutPixel(x + i, y + j, fill); + } + pixels >>= 1; } - pixels >>= 1; } + x += 4; } - x += 4; } -} +#endif // Utility functions diff --git a/ui/helper.c b/ui/helper.c index 0ed8758..47b470b 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -218,6 +218,38 @@ static void sort(int16_t *a, int16_t *b) } } } + + void PutPixel(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(gFrameBuffer, x, y, fill); + } + + void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(&gStatusLine, x, y, fill); + } + + void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, + bool statusbar, bool fill) { + uint8_t c; + uint8_t pixels; + const uint8_t *p = (const uint8_t *)pString; + + while ((c = *p++) && c != '\0') { + c -= 0x20; + for (int i = 0; i < 3; ++i) { + pixels = gFont3x5[c][i]; + for (int j = 0; j < 6; ++j) { + if (pixels & 1) { + if (statusbar) + PutPixelStatus(x + i, y + j, fill); + else + PutPixel(x + i, y + j, fill); + } + pixels >>= 1; + } + } + x += 4; + } + } #endif void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) diff --git a/ui/helper.h b/ui/helper.h index 27b339b..b90afc6 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -34,6 +34,9 @@ void UI_DisplayPopup(const char *string); void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black); #ifdef ENABLE_FEAT_F4HWN void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); + void PutPixel(uint8_t x, uint8_t y, bool fill); + void PutPixelStatus(uint8_t x, uint8_t y, bool fill); + void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, bool statusbar, bool fill); #endif void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); diff --git a/ui/main.c b/ui/main.c index dc781d1..1a3c2e8 100644 --- a/ui/main.c +++ b/ui/main.c @@ -363,8 +363,16 @@ void DisplayRSSIBar(const bool now) #endif #ifdef ENABLE_FEAT_F4HWN - sprintf(str, "% 4d", -rssi_dBm); - UI_PrintStringSmallNormal(str, LCD_WIDTH + 8, 0, line - 1); + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { + sprintf(str, "%3d", -rssi_dBm); + UI_PrintStringSmallNormal(str, LCD_WIDTH + 8, 0, line - 1); + } + else + { + sprintf(str, "%04d %s", -rssi_dBm, "dBm"); + GUI_DisplaySmallest(str, 2, 25, false, true); + } if(overS9Bars == 0) { sprintf(str, "S%d", s_level); @@ -372,10 +380,8 @@ void DisplayRSSIBar(const bool now) else { sprintf(str, "+%02d", overS9dBm); } - if(gSetting_set_met) - UI_PrintStringSmallNormal(str, LCD_WIDTH + 38, 0, line - 1); - else - UI_PrintStringSmallBold(str, LCD_WIDTH + 38, 0, line - 1); + + UI_PrintStringSmallNormal(str, LCD_WIDTH + 38, 0, line - 1); #else if(overS9Bars == 0) { sprintf(str, "% 4d S%d", -rssi_dBm, s_level); @@ -992,28 +998,93 @@ void UI_DisplayMain(void) s = gModulationStr[mod]; break; } + +#if ENABLE_FEAT_F4HWN + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { + UI_PrintStringSmallNormal(s, LCD_WIDTH + 24, 0, line + 1); + } + else + { + GUI_DisplaySmallest(s, 24, line == 0 ? 17 : 49, false, true); + } +#else UI_PrintStringSmallNormal(s, LCD_WIDTH + 24, 0, line + 1); +#endif if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) { // show the TX power - const char pwr_list[][2] = {"L","M","H"}; int i = vfoInfo->OUTPUT_POWER % 3; +#if ENABLE_FEAT_F4HWN + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { + const char pwr_list[][2] = {"L","M","H"}; + UI_PrintStringSmallNormal(pwr_list[i], LCD_WIDTH + 46, 0, line + 1); + } + else + { + const char *powerNames[] = {"LOW", "MID", "HIGH"}; + GUI_DisplaySmallest(powerNames[i], 37, line == 0 ? 17 : 49, false, true); + } +#else + const char pwr_list[][2] = {"L","M","H"}; UI_PrintStringSmallNormal(pwr_list[i], LCD_WIDTH + 46, 0, line + 1); +#endif } if (vfoInfo->freq_config_RX.Frequency != vfoInfo->freq_config_TX.Frequency) { // show the TX offset symbol const char dir_list[][2] = {"", "+", "-"}; int i = vfoInfo->TX_OFFSET_FREQUENCY_DIRECTION % 3; +#if ENABLE_FEAT_F4HWN + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 54, 0, line + 1); } + else + { + UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 60, 0, line + 1); + } +#else + UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 54, 0, line + 1); +#endif + } // show the TX/RX reverse symbol if (vfoInfo->FrequencyReverse) +#if ENABLE_FEAT_F4HWN + { + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { + UI_PrintStringSmallNormal("R", LCD_WIDTH + 62, 0, line + 1); + } + else + { + GUI_DisplaySmallest("R", 62, line == 0 ? 17 : 49, false, true); + } + } +#else UI_PrintStringSmallNormal("R", LCD_WIDTH + 62, 0, line + 1); +#endif +#if ENABLE_FEAT_F4HWN + if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) + { + if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) + UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1); + } + else + { + const char *bandWidthNames[] = {"WIDE", "NARROW"}; + if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) + GUI_DisplaySmallest(bandWidthNames[1], 76, line == 0 ? 17 : 49, false, true); + else + GUI_DisplaySmallest(bandWidthNames[0], 76, line == 0 ? 17 : 49, false, true); + } +#else if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1); +#endif #ifdef ENABLE_DTMF_CALLING // show the DTMF decoding symbol @@ -1030,22 +1101,30 @@ void UI_DisplayMain(void) #ifdef ENABLE_FEAT_F4HWN if(isMainVFO) { - if(gMonitor) - { - sprintf(String, "%s", "MON"); - } - else - { - sprintf(String, "SQL %d", gEeprom.SQUELCH_LEVEL); - } if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0) { + if(gMonitor) + { + sprintf(String, "%s", "MON"); + } + else + { + sprintf(String, "SQL %d", gEeprom.SQUELCH_LEVEL); + } UI_PrintStringSmallNormal(String, 91, 0, 2); } else { - UI_PrintStringSmallNormal(String, 91, 0, line + 2); + if(gMonitor) + { + sprintf(String, "%s", "MONIT"); + } + else + { + sprintf(String, "SQL %d", gEeprom.SQUELCH_LEVEL); + } + GUI_DisplaySmallest(String, 106, line == 0 ? 17 : 49, false, true); } } #endif