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

Lots n lots

This commit is contained in:
OneOfEleven
2023-10-29 22:33:38 +00:00
parent 230fdccf10
commit f3e347bc5a
39 changed files with 951 additions and 770 deletions

View File

@ -41,13 +41,14 @@
#include "radio.h"
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
#include "ui/main.h"
#include "ui/menu.h"
#include "ui/ui.h"
bool scanning_paused(void)
{
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
g_scan_pause_10ms > 0 && g_scan_pause_10ms <= (200 / 10))
g_scan_pause_tick_10ms > 0 && g_scan_pause_tick_10ms <= (200 / 10))
{ // scanning isn't paused
return false;
}
@ -130,6 +131,7 @@ void toggle_chan_scanlist(void)
RADIO_select_vfos();
RADIO_ApplyOffset(g_tx_vfo, false);
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
RADIO_setup_registers(true);
// find the first channel that contains this frequency
@ -427,7 +429,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
{ // key held down
if (key_pressed)
{ // and pressed
{
if (g_current_display_screen == DISPLAY_MAIN)
{
if (g_input_box_index > 0)
@ -473,7 +475,9 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
INPUTBOX_append(Key);
g_request_display_screen = DISPLAY_MAIN;
UI_DisplayMain();
// g_request_display_screen = DISPLAY_MAIN;
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
{ // user is entering channel number
@ -483,9 +487,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
if (g_input_box_index != 3)
{
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
g_another_voice_id = (voice_id_t)Key;
#endif
g_request_display_screen = DISPLAY_MAIN;
return;
}
@ -500,7 +503,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
}
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
g_another_voice_id = (voice_id_t)Key;
#endif
g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
@ -508,6 +511,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_update_display = true;
return;
}
@ -521,7 +525,6 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
#endif
return;
}
@ -578,6 +581,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE;
g_update_display = true;
return;
}
@ -594,7 +598,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
#endif
g_request_display_screen = DISPLAY_MAIN;
// g_request_display_screen = DISPLAY_MAIN;
return;
}
@ -611,13 +615,16 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_eeprom.screen_channel[Vfo] = Channel;
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_update_display = true;
return;
}
}
#endif
g_request_display_screen = DISPLAY_MAIN;
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
g_update_display = true;
// g_request_display_screen = DISPLAY_MAIN;
}
void MAIN_Key_EXIT(bool key_pressed, bool key_held)
@ -671,18 +678,36 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
return;
}
if (key_held && key_pressed)
{ // exit key held down
if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode)
{ // cancel key input mode (channel/frequency entry)
g_dtmf_input_mode = false;
g_dtmf_input_box_index = 0;
memset(g_dtmf_string, 0, sizeof(g_dtmf_string));
g_input_box_index = 0;
g_request_display_screen = DISPLAY_MAIN;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
if (!key_held)
return;
if (key_pressed)
return;
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
{
ACTION_FM();
return;
}
#endif
if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode)
{ // cancel key input mode (channel/frequency entry)
g_dtmf_input_mode = false;
g_dtmf_input_box_index = 0;
memset(g_dtmf_string, 0, sizeof(g_dtmf_string));
g_input_box_index = 0;
g_request_display_screen = DISPLAY_MAIN;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
if (g_flash_light_state != FLASHLIGHT_OFF && g_flash_light_state != FLASHLIGHT_SOS)
{ // the the flash light off
g_flash_light_state = FLASHLIGHT_OFF;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
return;
}
}
@ -831,14 +856,17 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
if (!key_pressed)
{
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(Channel))
{ // key released in frequency mode
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
(Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
{ // key released
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
if (key_held && !monitor_was_enabled && g_current_function == FUNCTION_MONITOR)
if (key_held && !monitor_was_enabled)
{ // re-enable the squelch
APP_start_listening(FUNCTION_RECEIVE);
g_monitor_enabled = false;
APP_start_listening();
}
#endif
@ -898,7 +926,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
uint8_t Next;
if (IS_FREQ_CHANNEL(Channel))
{ // step/down in frequency
{ // frequency mode
frequency_band_t new_band;
const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency);
@ -947,7 +975,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
if (key_held && key_pressed && !monitor_was_enabled)
{ // open the squelch if the user holds the key down
g_monitor_enabled = true;
APP_start_listening(FUNCTION_MONITOR);
APP_start_listening();
}
#endif
@ -958,9 +986,20 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
return;
}
// suppress audio click
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false;
// channel mode
g_tx_vfo->freq_in_channel = 0xff;
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
if (!key_held && key_pressed)
monitor_was_enabled = g_monitor_enabled;
if (key_held && key_pressed && !monitor_was_enabled)
{ // open the squelch if the user holds the key down
g_monitor_enabled = true;
APP_start_listening();
}
#endif
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
if (Next == 0xFF)
@ -989,20 +1028,23 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
}
#endif
g_request_save_vfo = true;
if (!key_held && key_pressed) // save when the user releases the button - save a LOT of eeprom wear
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
return;
}
// g_speaker_enabled = false;
// g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false;
// jump to the next channel
APP_channel_next(false, Direction);
// go NOW
g_scan_pause_10ms = 0;
g_scan_pause_tick_10ms = 0;
g_scan_pause_time_mode = false;
g_squelch_open = false;
g_rx_reception_mode = RX_MODE_NONE;
@ -1020,9 +1062,12 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && key != KEY_PTT && key != KEY_EXIT)
{
if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
if (g_current_display_screen == DISPLAY_FM)
{
if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
}
#endif
@ -1061,10 +1106,10 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
MAIN_Key_MENU(key_pressed, key_held);
break;
case KEY_UP:
MAIN_Key_UP_DOWN(key_pressed, key_held, 1);
MAIN_Key_UP_DOWN(key_pressed, key_held, SCAN_STATE_DIR_FORWARD);
break;
case KEY_DOWN:
MAIN_Key_UP_DOWN(key_pressed, key_held, -1);
MAIN_Key_UP_DOWN(key_pressed, key_held, SCAN_STATE_DIR_REVERSE);
break;
case KEY_EXIT:
MAIN_Key_EXIT(key_pressed, key_held);