From 0c2fc6184c60e3c938ad1eff9dafdb2dd5cbec2f Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Tue, 12 Dec 2023 00:52:26 +0100 Subject: [PATCH] Fix #234: Bring back FM radio status indicator, show dual watch inactive while in FM radio --- app/fm.c | 1 + bitmaps.c | 20 ++++++++++++++++++-- bitmaps.h | 6 +++--- ui/status.c | 31 ++++++++++++++++++------------- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/fm.c b/app/fm.c index 200916938..5e9086fd2 100644 --- a/app/fm.c +++ b/app/fm.c @@ -623,6 +623,7 @@ void FM_Play(void) void FM_Start(void) { + gDualWatchActive = false; gFmRadioMode = true; gFM_ScanState = FM_SCAN_OFF; gFM_RestoreCountdown_10ms = 0; diff --git a/bitmaps.c b/bitmaps.c index d4ef948a3..d9e1700b0 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -42,6 +42,20 @@ const uint8_t BITMAP_RX[8] = 0b00000000 }; +const uint8_t BITMAP_FM[10] = +{ // "FM" + 0b00000000, + 0b01111111, + 0b00001001, + 0b00000001, + 0b00000000, + 0b01111111, + 0b00000010, + 0b00001100, + 0b00000010, + 0b01111111 +}; + const uint8_t BITMAP_BatteryLevel[2] = { 0b01011101, @@ -170,8 +184,9 @@ const uint8_t BITMAP_XB[12] = }; -const uint8_t BITMAP_TDR1[15] = +const uint8_t BITMAP_TDR1[16] = { // "DWR" + 0b00000000, 0b01111111, 0b01000001, 0b01000001, @@ -189,8 +204,9 @@ const uint8_t BITMAP_TDR1[15] = 0b01000110 }; -const uint8_t BITMAP_TDR2[9] = +const uint8_t BITMAP_TDR2[10] = { // "><" .. DW on hold + 0b00000000, 0b00100010, 0b00110110, 0b00011100, diff --git a/bitmaps.h b/bitmaps.h index 15bf900c0..5bf65b5b9 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -7,7 +7,7 @@ extern const uint8_t BITMAP_POWERSAVE[8]; extern const uint8_t BITMAP_TX[8]; extern const uint8_t BITMAP_RX[8]; - +extern const uint8_t BITMAP_FM[10]; extern const uint8_t BITMAP_BatteryLevel[2]; extern const uint8_t BITMAP_BatteryLevel1[17]; @@ -23,8 +23,8 @@ extern const uint8_t BITMAP_F_Key[6]; extern const uint8_t BITMAP_XB[12]; -extern const uint8_t BITMAP_TDR1[15]; -extern const uint8_t BITMAP_TDR2[9]; +extern const uint8_t BITMAP_TDR1[16]; +extern const uint8_t BITMAP_TDR2[10]; #ifdef ENABLE_VOICE extern const uint8_t BITMAP_VoicePrompt[9]; diff --git a/ui/status.c b/ui/status.c index db50ce1f1..c9320629d 100644 --- a/ui/status.c +++ b/ui/status.c @@ -70,6 +70,13 @@ void UI_DisplayStatus() x1 = x + 10; } else +#endif +#ifdef ENABLE_FMRADIO + if (gFmRadioMode) { // FM indicator + memcpy(line + x, BITMAP_FM, sizeof(BITMAP_FM)); + x1 = x + sizeof(BITMAP_FM); + } + else #endif { // SCAN indicator if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) { @@ -84,11 +91,11 @@ void UI_DisplayStatus() else { // frequency mode s = "S"; } - UI_PrintStringSmallBuffer(s, line + x); - x1 = x + 7; + UI_PrintStringSmallBuffer(s, line + x + 1); + x1 = x + 10; } } - x += 7; // font character width + x += 10; // font character width #ifdef ENABLE_VOICE // VOICE indicator @@ -96,35 +103,33 @@ void UI_DisplayStatus() memcpy(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); x1 = x + sizeof(BITMAP_VoicePrompt); } - x += sizeof(BITMAP_VoicePrompt) + 1; + x += sizeof(BITMAP_VoicePrompt); #endif - x++; if(!SCANNER_IsScanning()) { uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2; if(dw == 1 || dw == 3) { // DWR - dual watch + respond if(gDualWatchActive) - memcpy(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5)); + memcpy(line + x + (dw==1?0:2), BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5)); else memcpy(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2)); } else if(dw == 2) { // XB - crossband - memcpy(line + x, BITMAP_XB, sizeof(BITMAP_XB)); + memcpy(line + x + 2, BITMAP_XB, sizeof(BITMAP_XB)); } } - x += sizeof(BITMAP_TDR1) + 2; + x += sizeof(BITMAP_TDR1) + 1; #ifdef ENABLE_VOX // VOX indicator if (gEeprom.VOX_SWITCH) { memcpy(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); - x1 = x + sizeof(BITMAP_VOX); + x1 = x + sizeof(BITMAP_VOX) + 1; } - x += sizeof(BITMAP_VOX) + 2; + x += sizeof(BITMAP_VOX) + 1; #endif - x = MAX(x, 61u); - x1 = x; + x = MAX(x1, 61u); // KEY-LOCK indicator if (gEeprom.KEY_LOCK) { @@ -140,7 +145,7 @@ void UI_DisplayStatus() { // battery voltage or percentage char s[8] = ""; - unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 3; + unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0; if (gChargingWithTypeC) x2 -= sizeof(BITMAP_USB_C); // the radio is on charge