0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 06:41:25 +03:00

added ignore freq compile option - use when frequency scanning, see README.md

This commit is contained in:
OneOfEleven 2023-11-03 15:19:29 +00:00
parent a3d603ea83
commit fba4ece9fd
10 changed files with 219 additions and 9 deletions

View File

@ -62,6 +62,7 @@ ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_FREQ_SEARCH_TIMEOUT := 0
ENABLE_CODE_SEARCH_TIMEOUT := 0
ENABLE_SCAN_IGNORE_LIST := 1
# Kill and Revive 400 B
ENABLE_KILL_REVIVE := 0
# AM Fix 800 B
@ -176,6 +177,9 @@ OBJS += app/generic.o
OBJS += app/main.o
OBJS += app/menu.o
OBJS += app/search.o
ifeq ($(ENABLE_SCAN_IGNORE_LIST),1)
OBJS += freq_ignore.o
endif
ifeq ($(ENABLE_PANADAPTER),1)
OBJS += app/spectrum.o
endif
@ -405,6 +409,9 @@ endif
ifeq ($(ENABLE_CODE_SEARCH_TIMEOUT),1)
CFLAGS += -DENABLE_CODE_SEARCH_TIMEOUT
endif
ifeq ($(ENABLE_SCAN_IGNORE_LIST),1)
CFLAGS += -DENABLE_SCAN_IGNORE_LIST
endif
ifeq ($(ENABLE_KILL_REVIVE),1)
CFLAGS += -DENABLE_KILL_REVIVE
endif

View File

@ -79,6 +79,7 @@ ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
ENABLE_FREQ_SEARCH_TIMEOUT := 0 timeout if FREQ not found when using F+4 search function
ENABLE_CODE_SEARCH_TIMEOUT := 0 timeout if CTCSS/CDCSS not found when using F+* search function
ENABLE_SCAN_IGNORE_LIST := 0 ignore selected frequencies when scanning - frequencies added to list with */scan button whilst scanning
ENABLE_KILL_REVIVE := 0 include kill and revive code
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to help prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it)

View File

@ -31,6 +31,9 @@
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
#ifdef ENABLE_SCAN_IGNORE_LIST
#include "freq_ignore.h"
#endif
#include "functions.h"
#include "misc.h"
#include "settings.h"
@ -247,6 +250,10 @@ void ACTION_Scan(bool bRestart)
// start scanning
#ifdef ENABLE_SCAN_IGNORE_LIST
FI_clear_freq_ignored();
#endif
g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);

View File

@ -50,6 +50,9 @@
#include "dtmf.h"
#include "external/printf/printf.h"
#include "frequencies.h"
#ifdef ENABLE_SCAN_IGNORE_LIST
#include "freq_ignore.h"
#endif
#include "functions.h"
#include "helper/battery.h"
#ifdef ENABLE_MDC1200
@ -669,12 +672,27 @@ static void APP_next_freq(void)
{
frequency_band_t new_band;
const frequency_band_t old_band = FREQUENCY_GetBand(g_rx_vfo->freq_config_rx.frequency);
const uint32_t frequency = APP_set_frequency_by_step(g_rx_vfo, g_scan_state_dir);
uint32_t frequency = APP_set_frequency_by_step(g_rx_vfo, g_scan_state_dir);
g_rx_vfo->freq_config_rx.frequency = frequency;
#ifdef ENABLE_SCAN_IGNORE_LIST
while (FI_freq_ignored(frequency) >= 0)
{
uint32_t next_frequency;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("skipping %u\r\n", frequency);
#endif
next_frequency = APP_set_frequency_by_step(g_rx_vfo, g_scan_state_dir); // skip to next frequency
if (frequency == next_frequency)
break;
frequency = next_frequency;
g_rx_vfo->freq_config_rx.frequency = frequency;
}
#endif
new_band = FREQUENCY_GetBand(frequency);
g_rx_vfo->freq_config_rx.frequency = frequency;
g_rx_vfo->freq_in_channel = 0xff;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
@ -682,7 +700,7 @@ static void APP_next_freq(void)
#endif
if (new_band != old_band)
{ // original slow method
{ // original slower method
RADIO_ApplyOffset(g_rx_vfo, false);
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);

View File

@ -35,6 +35,9 @@
#endif
#include "dtmf.h"
#include "frequencies.h"
#ifdef ENABLE_SCAN_IGNORE_LIST
#include "freq_ignore.h"
#endif
#include "misc.h"
#include "radio.h"
#include "settings.h"
@ -807,14 +810,30 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
return;
}
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT)
{ // RF scanning or TX'ing
if (g_current_function == FUNCTION_TRANSMIT)
return;
}
if (!g_fkey_pressed)
{ // pressed without the F-key
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ // RF scanning
if (scanning_paused())
{
FI_add_freq_ignored(g_rx_vfo->freq_config_rx.frequency);
// immediately continue the scan
g_scan_pause_tick_10ms = 0;
g_scan_pause_time_mode = false;
g_squelch_open = false;
g_rx_reception_mode = RX_MODE_NONE;
FUNCTION_Select(FUNCTION_FOREGROUND);
}
return;
}
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
{ // start entering a DTMF string
@ -833,6 +852,9 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
{ // with the F-key
g_fkey_pressed = false;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
return; // RF scanning
if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save))
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;

Binary file not shown.

Binary file not shown.

125
freq_ignore.c Normal file
View File

@ -0,0 +1,125 @@
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
#include "freq_ignore.h"
#include "misc.h"
// a list of frequencies to ignore/skip when scanning
uint32_t ignore_frequencies[256];
int ignore_frequencies_count = 0;
void FI_clear_freq_ignored(void)
{ // clear the ignore list
ignore_frequencies_count = 0;
}
int FI_freq_ignored(const uint32_t frequency)
{ // return index of the ignored frequency
if (frequency == 0 || frequency == 0xffffffff || ignore_frequencies_count <= 0)
return -1;
if (ignore_frequencies_count > 4)
{ // binary search .. becomes much faster than sequencial as the list grows
int low = 0;
int high = ignore_frequencies_count;
while (low < high)
{
register int mid = (low + high) / 2;
register uint32_t freq = ignore_frequencies[mid];
if (freq > frequency)
high = mid;
else
if (freq < frequency)
low = mid + 1;
else
return mid;
}
}
else
{ // sequencial search
int i;
for (i = 0; i < ignore_frequencies_count; i++)
{
register uint32_t freq = ignore_frequencies[i];
if (frequency == freq)
return i; // found it
if (frequency < freq)
return -1; // can exit loop early as the list is sorted by frequency
}
}
return -1; // not found
}
void FI_add_freq_ignored(const uint32_t frequency)
{ // add a new frequency to the ignore list
int i;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("ignore %u\r\n", frequency);
#endif
if (ignore_frequencies_count >= (int)ARRAY_SIZE(ignore_frequencies))
{ // the list is full
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("ignore full\r\n");
#endif
return;
}
for (i = 0; i < ignore_frequencies_count; i++)
{
register uint32_t freq = ignore_frequencies[i];
if (frequency == freq)
{ // already in the list
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("ignore already\r\n");
#endif
return;
}
if (frequency < freq)
break;
}
// found the location to store the new frequency - the list is kept sorted by frequency
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("ignore adding ..\r\n");
#endif
// make room for the new frequency
if (i < ignore_frequencies_count)
memmove(&ignore_frequencies[i + 1], &ignore_frequencies[i], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - i - 1));
// add the frequency to the list
ignore_frequencies[i] = frequency;
ignore_frequencies_count++;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
for (i = 0; i < ignore_frequencies_count; i++)
UART_printf("%2u %10u\r\n", i, ignore_frequencies[i]);
#endif
}
void FI_sub_freq_ignored(const uint32_t frequency)
{ // remove a frequency from the ignore list
int index = FI_freq_ignored(frequency);
if (index >= 0)
{
if (index < (ignore_frequencies_count - 1))
memmove(&ignore_frequencies[index], &ignore_frequencies[index + 1], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - 1));
ignore_frequencies_count--;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("ignore freq ..\r\n");
for (index = 0; index < ignore_frequencies_count; index++)
UART_printf("%2u %10u\r\n", index, ignore_frequencies[index]);
#endif
}
}

30
freq_ignore.h Normal file
View File

@ -0,0 +1,30 @@
/* Copyright 2023 One of Eleven
* 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.
*/
#ifndef FREQ_IGNORE_H
#define FREQ_IGNORE_H
#include <stdint.h>
#ifdef ENABLE_SCAN_IGNORE_LIST
void FI_clear_freq_ignored(void);
int FI_freq_ignored(const uint32_t frequency);
void FI_add_freq_ignored(const uint32_t frequency);
void FI_sub_freq_ignored(const uint32_t frequency);
#endif
#endif

View File

@ -187,7 +187,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
const int16_t s0_dBm = -147; // S0 .. base level
const int16_t s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point
const int16_t bar_max_dBm = s9_dBm + 30; // S9+30dB
const int16_t bar_max_dBm = s9_dBm + 60; // S9+60dB
// const int16_t bar_min_dBm = s0_dBm + (6 * 0); // S0
const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4