0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 22:58:04 +03:00

Some fixes to the FM radio, more are needed

This commit is contained in:
OneOfEleven
2023-10-10 16:04:59 +01:00
parent 774e34bf43
commit 72f3fd8d85
9 changed files with 317 additions and 295 deletions

View File

@ -19,6 +19,7 @@
#include <string.h>
#include "app/fm.h"
#include "driver/backlight.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "misc.h"
@ -35,11 +36,23 @@ void UI_DisplayFM(void)
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
memset(String, 0, sizeof(String));
strcpy(String, "FM");
UI_PrintString(String, 0, 127, 0, 12);
// *************************************
if (g_eeprom.key_lock && g_keypad_locked > 0)
{ // tell user how to unlock the keyboard
backlight_turn_on();
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
ST7565_BlitFullScreen();
return;
}
// *************************************
UI_PrintString("FM", 0, 127, 0, 12);
// *************************************
memset(String, 0, sizeof(String));
if (g_ask_to_save)
{
strcpy(String, "SAVE?");
@ -51,11 +64,13 @@ void UI_DisplayFM(void)
}
else
{
memset(String, 0, sizeof(String));
if (g_fm_scan_state == FM_SCAN_OFF)
{
if (!g_eeprom.fm_is_channel_mode)
{
for (i = 0; i < 20; i++)
for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++)
{
if (g_eeprom.fm_frequency_playing == g_fm_channels[i])
{
@ -64,23 +79,25 @@ void UI_DisplayFM(void)
}
}
if (i == 20)
if (i >= ARRAY_SIZE(g_fm_channels))
strcpy(String, "VFO");
}
else
sprintf(String, "MR(CH%02u)", g_eeprom.fm_selected_channel + 1);
}
else
{
if (!g_fm_auto_scan)
strcpy(String, "M-SCAN");
else
sprintf(String, "A-SCAN(%u)", g_fm_channel_position + 1);
}
if (!g_fm_auto_scan)
strcpy(String, "M-SCAN");
else
sprintf(String, "A-SCAN(%u)", g_fm_channel_position + 1);
}
UI_PrintString(String, 0, 127, 2, 10);
// *************************************
memset(String, 0, sizeof(String));
if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0))
{
UI_GenerateChannelString(String, g_fm_channel_position);
@ -94,16 +111,17 @@ void UI_DisplayFM(void)
UI_DisplayFrequency(String, 23, 4, false, true);
}
else
{
UI_DisplayFrequency(g_input_box, 23, 4, true, false);
ST7565_BlitFullScreen();
return;
}
}
else
{
sprintf(String, "CH-%02u", g_eeprom.fm_selected_channel + 1);
UI_PrintString(String, 0, 127, 4, 10);
}
UI_PrintString(String, 0, 127, 4, 10);
// *************************************
ST7565_BlitFullScreen();
}