0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 22:29:50 +03:00

FM radio updates - faster scanning and gui update, also some renames

This commit is contained in:
OneOfEleven
2023-10-28 14:07:41 +01:00
parent 0082876274
commit 4153389778
36 changed files with 431 additions and 337 deletions

View File

@ -31,7 +31,7 @@ void UI_DisplayAircopy(void)
const uint8_t errors = g_aircopy_rx_errors_fsk_crc + g_aircopy_rx_errors_magic + g_aircopy_rx_errors_crc;
char str[17];
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
return;
// clear screen/display buffer

View File

@ -18,6 +18,7 @@
#include "app/fm.h"
#include "driver/backlight.h"
#include "driver/bk1080.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "misc.h"
@ -30,7 +31,7 @@
void UI_DisplayFM(void)
{
unsigned int i;
char String[16];
char str[22];
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
@ -38,8 +39,8 @@ void UI_DisplayFM(void)
if (g_eeprom.key_lock && g_keypad_locked > 0)
{ // tell user how to unlock the keyboard
backlight_turn_on(0);
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
UI_PrintString("Long press #", 0, LCD_WIDTH - 1, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH - 1, 3, 8);
ST7565_BlitFullScreen();
return;
}
@ -48,7 +49,7 @@ void UI_DisplayFM(void)
// *************************************
// upper text line
UI_PrintString("FM", 0, 127, 0, 12);
UI_PrintString("FM", 0, LCD_WIDTH - 1, 0, 12);
// *************************************
// middle text line
@ -56,16 +57,16 @@ void UI_DisplayFM(void)
if (g_ask_to_save)
{
const unsigned int freq = g_eeprom.fm_frequency_playing;
sprintf(String, "SAVE %u.%u ?", freq / 10, freq % 10);
sprintf(str, "SAVE %u.%u ?", freq / 10, freq % 10);
}
else
if (g_ask_to_delete)
{
strcpy(String, "DELETE ?");
strcpy(str, "DELETE ?");
}
else
{
memset(String, 0, sizeof(String));
memset(str, 0, sizeof(str));
if (g_fm_scan_state == FM_SCAN_OFF)
{
@ -75,43 +76,43 @@ void UI_DisplayFM(void)
{
if (g_eeprom.fm_frequency_playing == g_fm_channels[i])
{
sprintf(String, "VFO (CH %u)", 1 + i);
sprintf(str, "VFO (CH %u)", 1 + i);
break;
}
}
if (i >= ARRAY_SIZE(g_fm_channels))
strcpy(String, "VFO");
strcpy(str, "VFO");
}
else
sprintf(String, "CH %u", 1 + g_eeprom.fm_selected_channel);
sprintf(str, "CH %u", 1 + g_eeprom.fm_selected_channel);
}
else
if (!g_fm_auto_scan)
strcpy(String, "FREQ SCAN");
strcpy(str, "FREQ SCAN");
else
sprintf(String, "A-SCAN %2u", 1 + g_fm_channel_position);
sprintf(str, "A-SCAN %2u", 1 + g_fm_channel_position);
}
UI_PrintString(String, 0, 127, 2, 10);
UI_PrintString(str, 0, LCD_WIDTH - 1, 2, 10);
// *************************************
// lower text line
memset(String, 0, sizeof(String));
memset(str, 0, sizeof(str));
if (g_ask_to_save)
{ // channel mode
const unsigned int chan = g_fm_channel_position;
const uint32_t freq = g_fm_channels[chan];
UI_GenerateChannelString(String, chan, ' ');
UI_GenerateChannelString(str, chan, ' ');
if (FM_CheckValidChannel(chan))
sprintf(String + strlen(String), " (%u.%u)", freq / 10, freq % 10);
sprintf(str + strlen(str), " (%u.%u)", freq / 10, freq % 10);
}
else
if (g_eeprom.fm_channel_mode && g_input_box_index > 0)
{ // user is entering a channel number
UI_GenerateChannelString(String, g_fm_channel_position, ' ');
UI_GenerateChannelString(str, g_fm_channel_position, ' ');
}
else
if (!g_ask_to_delete)
@ -119,8 +120,12 @@ void UI_DisplayFM(void)
if (g_input_box_index == 0)
{ // frequency mode
const uint32_t freq = g_eeprom.fm_frequency_playing;
NUMBER_ToDigits(freq * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true);
NUMBER_ToDigits(freq * 10000, str);
#ifdef ENABLE_TRIM_TRAILING_ZEROS
UI_DisplayFrequency(str, 30, 4, false, true);
#else
UI_DisplayFrequency(str, 23, 4, false, true);
#endif
}
else
{ // user is entering a frequency
@ -131,10 +136,23 @@ void UI_DisplayFM(void)
{ // delete channel
const uint32_t chan = g_eeprom.fm_selected_channel;
const uint32_t freq = g_fm_channels[chan];
sprintf(String, "CH %u (%u.%u)", 1 + chan, freq / 10, freq % 10);
sprintf(str, "CH %u (%u.%u)", 1 + chan, freq / 10, freq % 10);
}
UI_PrintString(String, 0, 127, 4, (strlen(String) >= 8) ? 8 : 10);
UI_PrintString(str, 0, LCD_WIDTH - 1, 4, (strlen(str) >= 8) ? 8 : 10);
// *************************************
{
const uint16_t val_07 = BK1080_ReadRegister(0x07);
const uint16_t val_0A = BK1080_ReadRegister(0x0A);
sprintf(str, "%s %s %2udBuV %2u",
((val_0A >> 9) & 1u) ? "STE" : "ste",
((val_0A >> 8) & 1u) ? "ST" : "st",
(val_0A >> 0) & 0x00ff,
(val_07 >> 0) & 0x000f);
UI_PrintStringSmall(str, 0, LCD_WIDTH, 6);
}
// *************************************

View File

@ -86,7 +86,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
{
unsigned int timeout_secs = 0;
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return false;
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_TX_TIMEOUT)
@ -100,7 +100,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
else
timeout_secs = 60 * 15; // 15 minutes
if (timeout_secs == 0 || g_tx_timer_count_down_500ms == 0)
if (timeout_secs == 0 || g_tx_timer_tick_500ms == 0)
return false;
{
@ -108,7 +108,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
const unsigned int txt_width = 7 * 6; // 6 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const unsigned int secs = g_tx_timer_count_down_500ms / 2;
const unsigned int secs = g_tx_timer_tick_500ms / 2;
const unsigned int level = ((secs * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding
// const unsigned int level = (((timeout_secs - secs) * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding
const unsigned int len = (level <= bar_width) ? level : bar_width;
@ -178,7 +178,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
bool UI_DisplayAudioBar(const bool now)
{
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return false;
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_AUDIO_BAR)
@ -198,7 +198,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
const unsigned int txt_width = 7 * 3; // 3 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const unsigned int secs = g_tx_timer_count_down_500ms / 2;
const unsigned int secs = g_tx_timer_tick_500ms / 2;
uint8_t *p_line = g_frame_buffer[line];
char s[16];
@ -272,7 +272,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
#endif
if (g_current_function == FUNCTION_TRANSMIT ||
g_screen_to_display != DISPLAY_MAIN ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false; // display is in use
@ -381,7 +381,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
return; // display is in use
#endif
if (g_current_function == FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return; // display is in use
p_line = g_frame_buffer[Line - 1];
@ -448,7 +448,7 @@ void UI_DisplayMain(void)
// clear the screen
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
if (g_serial_config_count_down_500ms > 0)
if (g_serial_config_tick_500ms > 0)
{
backlight_turn_on(10); // 5 seconds
UI_PrintString("UART", 0, LCD_WIDTH, 1, 8);
@ -910,7 +910,7 @@ void UI_DisplayMain(void)
}
if (g_center_line == CENTER_LINE_NONE &&
g_screen_to_display == DISPLAY_MAIN &&
g_current_display_screen == DISPLAY_MAIN &&
g_dtmf_call_state == DTMF_CALL_STATE_NONE)
{ // we're free to use the middle line
@ -979,7 +979,7 @@ void UI_DisplayMain(void)
const unsigned int len = strlen(g_dtmf_rx_live);
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_DTMF_DEC;
@ -994,7 +994,7 @@ void UI_DisplayMain(void)
const unsigned int len = g_dtmf_rx_index;
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_DTMF_DEC;
@ -1009,7 +1009,7 @@ void UI_DisplayMain(void)
else
if (g_charging_with_type_c)
{ // show the battery charge state
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_CHARGE_DATA;

View File

@ -34,7 +34,7 @@ void UI_DisplaySearch(void)
char String[17];
bool text_centered = false;
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
return;
// clear display buffer

View File

@ -102,7 +102,7 @@ void UI_DisplayStatus(const bool test_display)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || test_display)
{
// don't display this if in search mode
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
{
if (g_scan_next_channel <= USER_CHANNEL_LAST)
{ // channel mode
@ -145,7 +145,7 @@ void UI_DisplayStatus(const bool test_display)
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
(g_current_function != FUNCTION_FOREGROUND && g_current_function != FUNCTION_POWER_SAVE) ||
g_screen_to_display == DISPLAY_SEARCH)
g_current_display_screen == DISPLAY_SEARCH)
{
memcpy(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
}

10
ui/ui.c
View File

@ -35,7 +35,7 @@
#include "ui/search.h"
#include "ui/ui.h"
gui_display_type_t g_screen_to_display;
gui_display_type_t g_current_display_screen;
gui_display_type_t g_request_display_screen = DISPLAY_INVALID;
uint8_t g_ask_for_confirmation;
bool g_ask_to_save;
@ -45,7 +45,7 @@ void GUI_DisplayScreen(void)
{
g_update_display = false;
switch (g_screen_to_display)
switch (g_current_display_screen)
{
case DISPLAY_MAIN:
UI_DisplayMain();
@ -81,12 +81,12 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
if (Display == DISPLAY_INVALID)
return;
if (g_screen_to_display != Display)
if (g_current_display_screen != Display)
{
DTMF_clear_input_box();
g_input_box_index = 0;
g_in_sub_menu = false;
g_in_sub_menu = false;
g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_scan_state_dir = SCAN_STATE_DIR_OFF;
#ifdef ENABLE_FMRADIO
@ -100,6 +100,6 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
g_update_status = true;
}
g_screen_to_display = Display;
g_current_display_screen = Display;
g_update_display = true;
}

View File

@ -31,7 +31,7 @@ enum gui_display_type_e
};
typedef enum gui_display_type_e gui_display_type_t;
extern gui_display_type_t g_screen_to_display;
extern gui_display_type_t g_current_display_screen;
extern gui_display_type_t g_request_display_screen;
extern uint8_t g_ask_for_confirmation;
extern bool g_ask_to_save;