2023-09-09 08:03:56 +01:00
|
|
|
/* Copyright 2023 Dual Tachyon
|
|
|
|
* https://github.com/DualTachyon
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-09-30 11:22:19 +01:00
|
|
|
#include "app/dtmf.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "app/generic.h"
|
2023-10-14 14:07:05 +01:00
|
|
|
#include "app/search.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "audio.h"
|
2023-10-13 15:12:32 +01:00
|
|
|
#include "board.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "driver/bk4819.h"
|
2023-10-11 16:02:45 +01:00
|
|
|
#include "driver/uart.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "frequencies.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "radio.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "ui/inputbox.h"
|
|
|
|
#include "ui/ui.h"
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
search_css_state_t g_search_css_state;
|
|
|
|
bool g_search_use_css_result;
|
|
|
|
dcs_code_type_t g_search_css_result_type;
|
|
|
|
uint8_t g_search_css_result_code;
|
|
|
|
|
|
|
|
bool g_search_flag_start_scan;
|
|
|
|
bool g_search_flag_stop_scan;
|
|
|
|
|
|
|
|
uint8_t g_search_show_chan_prefix;
|
|
|
|
|
|
|
|
bool g_search_single_frequency;
|
|
|
|
uint16_t g_search_freq_css_timer_10ms;
|
|
|
|
uint8_t g_search_delay_10ms;
|
|
|
|
uint8_t g_search_hit_count;
|
|
|
|
|
|
|
|
search_edit_state_t g_search_edit_state;
|
|
|
|
|
|
|
|
uint8_t g_search_channel;
|
|
|
|
uint32_t g_search_frequency;
|
|
|
|
step_setting_t g_search_step_setting;
|
|
|
|
|
|
|
|
static void SEARCH_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-11 16:02:45 +01:00
|
|
|
if (key_held || key_pressed)
|
2023-10-09 17:01:26 +01:00
|
|
|
return;
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_edit_state == SEARCH_EDIT_STATE_SAVE_CHAN)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-09 17:01:26 +01:00
|
|
|
uint16_t Channel;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-10-05 22:44:44 +01:00
|
|
|
|
2023-10-20 18:00:36 +01:00
|
|
|
INPUTBOX_append(Key);
|
2023-10-05 22:44:44 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
if (g_input_box_index < 3)
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_VOICE
|
|
|
|
g_another_voice_id = (voice_id_t)Key;
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
g_input_box_index = 0;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1;
|
|
|
|
if (Channel <= USER_CHANNEL_LAST)
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_VOICE
|
|
|
|
g_another_voice_id = (voice_id_t)Key;
|
|
|
|
#endif
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_show_chan_prefix = RADIO_CheckValidChannel(Channel, false, 0);
|
|
|
|
g_search_channel = (uint8_t)Channel;
|
2023-10-09 17:01:26 +01:00
|
|
|
return;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
}
|
2023-10-09 17:01:26 +01:00
|
|
|
|
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
static void SEARCH_Key_EXIT(bool key_pressed, bool key_held)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-11 16:02:45 +01:00
|
|
|
if (key_held || key_pressed)
|
2023-10-09 17:01:26 +01:00
|
|
|
return;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
|
|
|
|
|
|
|
|
switch (g_search_edit_state)
|
2023-10-09 17:01:26 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_NONE:
|
2023-10-09 17:01:26 +01:00
|
|
|
g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx;
|
2023-10-13 07:49:59 +01:00
|
|
|
g_update_status = true;
|
|
|
|
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
|
|
|
g_flag_reset_vfos = true;
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_flag_stop_scan = true;
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-10-13 07:49:59 +01:00
|
|
|
g_another_voice_id = VOICE_ID_CANCEL;
|
2023-10-09 17:01:26 +01:00
|
|
|
#endif
|
2023-10-13 07:49:59 +01:00
|
|
|
|
|
|
|
g_request_display_screen = DISPLAY_MAIN;
|
|
|
|
g_update_display = true;
|
2023-10-09 17:01:26 +01:00
|
|
|
break;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_SAVE_CHAN:
|
2023-10-09 17:01:26 +01:00
|
|
|
if (g_input_box_index > 0)
|
|
|
|
{
|
|
|
|
g_input_box[--g_input_box_index] = 10;
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-10-13 07:49:59 +01:00
|
|
|
g_update_display = true;
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
2023-10-09 17:01:26 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_SAVE_CONFIRM:
|
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_NONE;
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-10-13 07:49:59 +01:00
|
|
|
g_another_voice_id = VOICE_ID_CANCEL;
|
2023-10-09 17:01:26 +01:00
|
|
|
#endif
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-12 23:43:45 +01:00
|
|
|
g_request_display_screen = DISPLAY_MAIN;
|
2023-10-13 07:49:59 +01:00
|
|
|
g_update_display = true;
|
2023-10-09 17:01:26 +01:00
|
|
|
break;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
2023-10-13 15:12:32 +01:00
|
|
|
|
|
|
|
#pragma GCC diagnostic pop
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
|
|
|
uint8_t Channel;
|
|
|
|
|
2023-10-11 16:02:45 +01:00
|
|
|
if (key_held || key_pressed)
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_css_state == SEARCH_CSS_STATE_OFF && !g_search_single_frequency)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_css_state == SEARCH_CSS_STATE_SCANNING)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_single_frequency)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_css_state == SEARCH_CSS_STATE_FAILED && g_search_single_frequency)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 07:49:59 +01:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
switch (g_search_edit_state)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_NONE:
|
|
|
|
|
|
|
|
if (!g_search_single_frequency)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-18 16:17:41 +01:00
|
|
|
// determine what the current step size is for the detected frequency
|
|
|
|
// use the 7 VFO channels/bands to determine it
|
|
|
|
const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
|
|
|
|
g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
|
|
|
|
{ // round to nearest step size
|
|
|
|
const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
|
|
|
|
g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
|
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)
|
2023-10-12 23:43:45 +01:00
|
|
|
{ // save to channel
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_channel = g_tx_vfo->channel_save;
|
|
|
|
g_search_show_chan_prefix = RADIO_CheckValidChannel(g_tx_vfo->channel_save, false, 0);
|
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_SAVE_CHAN;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
2023-10-13 07:49:59 +01:00
|
|
|
{ // save to VFO
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_SAVE_CONFIRM;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 07:49:59 +01:00
|
|
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
|
|
|
//UART_SendText("edit none\r\n");
|
|
|
|
#endif
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_css_state = SEARCH_CSS_STATE_FOUND;
|
2023-10-08 11:40:17 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-10-08 17:14:13 +01:00
|
|
|
g_another_voice_id = VOICE_ID_MEMORY_CHANNEL;
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
2023-10-07 15:12:53 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-10-08 20:23:37 +01:00
|
|
|
g_update_status = true;
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_SAVE_CHAN:
|
2023-10-13 07:49:59 +01:00
|
|
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
|
|
|
UART_SendText("edit save chan\r\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (g_input_box_index > 0)
|
|
|
|
break;
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_input_box_index == 0)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_SAVE_CONFIRM;
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-10-13 15:12:32 +01:00
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
2023-10-13 07:49:59 +01:00
|
|
|
|
|
|
|
// break;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
case SEARCH_EDIT_STATE_SAVE_CONFIRM:
|
2023-10-11 16:02:45 +01:00
|
|
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
2023-10-13 07:49:59 +01:00
|
|
|
UART_SendText("edit save confirm\r\n");
|
2023-10-11 16:02:45 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (!g_search_single_frequency)
|
|
|
|
{ // save to VFO
|
|
|
|
RADIO_InitInfo(g_tx_vfo, g_tx_vfo->channel_save, g_search_frequency);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_use_css_result)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
g_tx_vfo->freq_config_rx.code_type = g_search_css_result_type;
|
|
|
|
g_tx_vfo->freq_config_rx.code = g_search_css_result_code;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
g_tx_vfo->freq_config_tx = g_tx_vfo->freq_config_rx;
|
2023-10-13 15:12:32 +01:00
|
|
|
g_tx_vfo->step_setting = g_search_step_setting;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-17 11:05:41 +01:00
|
|
|
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
|
|
|
|
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
|
2023-09-11 00:02:57 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_tx_vfo->freq_config_rx.code_type = g_search_css_result_type;
|
|
|
|
g_tx_vfo->freq_config_rx.code = g_search_css_result_code;
|
2023-10-13 07:49:59 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_tx_vfo->freq_config_tx.code_type = g_search_css_result_type;
|
|
|
|
g_tx_vfo->freq_config_tx.code = g_search_css_result_code;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
Channel = g_search_channel;
|
2023-10-08 17:14:13 +01:00
|
|
|
g_eeprom.user_channel[g_eeprom.tx_vfo] = Channel;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
Channel = FREQ_CHANNEL_FIRST + g_tx_vfo->band;
|
2023-10-08 17:14:13 +01:00
|
|
|
g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-08 23:08:18 +01:00
|
|
|
g_tx_vfo->channel_save = Channel;
|
2023-10-08 17:14:13 +01:00
|
|
|
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
|
2023-10-08 23:08:18 +01:00
|
|
|
g_request_save_channel = 2;
|
2023-10-07 15:12:53 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-10-08 17:14:13 +01:00
|
|
|
g_another_voice_id = VOICE_ID_CONFIRM;
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
2023-10-07 15:12:53 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (!g_search_single_frequency)
|
2023-10-13 07:49:59 +01:00
|
|
|
{ // FREQ/CTCSS/CDCSS search mode .. do another search
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_css_state = SEARCH_CSS_STATE_REPEAT;
|
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_NONE;
|
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-10-13 07:49:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // CTCSS/CDCSS search mode .. only do a single search
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_css_state = SEARCH_CSS_STATE_OFF;
|
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_NONE;
|
2023-10-13 07:49:59 +01:00
|
|
|
g_request_display_screen = DISPLAY_MAIN;
|
|
|
|
}
|
2023-10-07 15:12:53 +01:00
|
|
|
|
2023-10-13 07:49:59 +01:00
|
|
|
g_update_display = true;
|
|
|
|
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
}
|
2023-10-13 07:49:59 +01:00
|
|
|
|
|
|
|
#pragma GCC diagnostic pop
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
static void SEARCH_Key_STAR(bool key_pressed, bool key_held)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-11 16:02:45 +01:00
|
|
|
if (key_held || key_pressed)
|
2023-10-09 17:01:26 +01:00
|
|
|
return;
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
|
|
g_search_flag_start_scan = true;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
static void SEARCH_Key_UP_DOWN(bool key_pressed, bool pKeyHeld, int8_t Direction)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
|
|
|
if (pKeyHeld)
|
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
if (!key_pressed)
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-11 16:02:45 +01:00
|
|
|
if (key_pressed)
|
2023-09-09 08:03:56 +01:00
|
|
|
return;
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
g_input_box_index = 0;
|
|
|
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_edit_state == SEARCH_EDIT_STATE_SAVE_CHAN)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_channel = NUMBER_AddWithWraparound(g_search_channel, Direction, 0, USER_CHANNEL_LAST);
|
|
|
|
g_search_show_chan_prefix = RADIO_CheckValidChannel(g_search_channel, false, 0);
|
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
2023-10-08 20:23:37 +01:00
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-16 06:43:42 +01:00
|
|
|
void SEARCH_process_key(key_code_t Key, bool key_pressed, bool key_held)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
|
|
|
switch (Key)
|
|
|
|
{
|
|
|
|
case KEY_0:
|
|
|
|
case KEY_1:
|
|
|
|
case KEY_2:
|
|
|
|
case KEY_3:
|
|
|
|
case KEY_4:
|
|
|
|
case KEY_5:
|
|
|
|
case KEY_6:
|
|
|
|
case KEY_7:
|
|
|
|
case KEY_8:
|
|
|
|
case KEY_9:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_DIGITS(Key, key_pressed, key_held);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_MENU:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_MENU(key_pressed, key_held);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_UP:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_UP_DOWN(key_pressed, key_held, 1);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_DOWN:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_UP_DOWN(key_pressed, key_held, -1);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_EXIT:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_EXIT(key_pressed, key_held);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_STAR:
|
2023-10-13 15:12:32 +01:00
|
|
|
SEARCH_Key_STAR(key_pressed, key_held);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
case KEY_PTT:
|
2023-10-08 20:23:37 +01:00
|
|
|
GENERIC_Key_PTT(key_pressed);
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
default:
|
2023-10-08 20:23:37 +01:00
|
|
|
if (!key_held && key_pressed)
|
|
|
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
2023-09-09 08:03:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
void SEARCH_Start(void)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
|
|
|
uint8_t BackupStep;
|
2023-10-07 10:59:24 +01:00
|
|
|
uint16_t BackupStepFreq;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
BK4819_StopScan();
|
2023-09-11 00:02:57 +01:00
|
|
|
|
2023-10-16 06:43:42 +01:00
|
|
|
RADIO_select_vfos();
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-10-08 20:23:37 +01:00
|
|
|
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save))
|
|
|
|
g_rx_vfo->channel_save = FREQ_CHANNEL_FIRST + BAND6_400MHz;
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
BackupStep = g_rx_vfo->step_setting;
|
|
|
|
BackupStepFreq = g_rx_vfo->step_freq;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
RADIO_InitInfo(g_rx_vfo, g_rx_vfo->channel_save, g_rx_vfo->p_rx->frequency);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 17:01:26 +01:00
|
|
|
g_rx_vfo->step_setting = BackupStep;
|
|
|
|
g_rx_vfo->step_freq = BackupStepFreq;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-16 06:43:42 +01:00
|
|
|
RADIO_setup_registers(true);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-10-08 20:23:37 +01:00
|
|
|
g_is_noaa_mode = false;
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_search_single_frequency)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_css_state = SEARCH_CSS_STATE_SCANNING;
|
|
|
|
g_search_frequency = g_rx_vfo->p_rx->frequency;
|
|
|
|
g_search_step_setting = g_rx_vfo->step_setting;
|
2023-09-18 11:29:28 +01:00
|
|
|
|
2023-10-17 21:22:40 +01:00
|
|
|
BK4819_set_rf_filter_path(g_search_frequency);
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
BK4819_SetScanFrequency(g_search_frequency);
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_css_state = SEARCH_CSS_STATE_OFF;
|
|
|
|
g_search_frequency = 0xFFFFFFFF;
|
2023-09-18 11:29:28 +01:00
|
|
|
|
2023-10-17 21:22:40 +01:00
|
|
|
#if 1
|
|
|
|
// this is why it needs such a strong signal
|
|
|
|
BK4819_set_rf_filter_path(0xFFFFFFFF); // disable the LNA filter paths
|
|
|
|
#else
|
|
|
|
BK4819_set_rf_filter_path(g_rx_vfo->p_rx->frequency); // lets have a play ;)
|
|
|
|
#endif
|
|
|
|
|
2023-09-09 08:03:56 +01:00
|
|
|
BK4819_EnableFrequencyScan();
|
|
|
|
}
|
|
|
|
|
2023-09-30 11:22:19 +01:00
|
|
|
DTMF_clear_RX();
|
|
|
|
|
2023-10-13 15:12:32 +01:00
|
|
|
#ifdef ENABLE_VOX
|
|
|
|
g_vox_lost = false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_cxcss_tail_found = false;
|
|
|
|
g_cdcss_lost = false;
|
|
|
|
g_cdcss_code_type = 0;
|
|
|
|
g_ctcss_lost = false;
|
|
|
|
|
2023-10-23 14:02:54 +01:00
|
|
|
g_squelch_open = false;
|
2023-10-13 15:12:32 +01:00
|
|
|
g_search_delay_10ms = scan_freq_css_delay_10ms;
|
|
|
|
g_search_css_result_type = CODE_TYPE_NONE;
|
|
|
|
g_search_css_result_code = 0xff;
|
|
|
|
g_search_hit_count = 0;
|
|
|
|
g_search_use_css_result = false;
|
|
|
|
g_search_edit_state = SEARCH_EDIT_STATE_NONE;
|
|
|
|
g_search_freq_css_timer_10ms = 0;
|
|
|
|
// g_search_flag_start_scan = false;
|
|
|
|
|
|
|
|
g_request_display_screen = DISPLAY_SEARCH;
|
|
|
|
g_update_status = true;
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|