mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-29 14:51:26 +03:00
added ignore freq compile option - use when frequency scanning, see README.md
This commit is contained in:
parent
a3d603ea83
commit
fba4ece9fd
7
Makefile
7
Makefile
@ -62,6 +62,7 @@ ENABLE_SHOW_CHARGE_LEVEL := 0
|
|||||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
ENABLE_REVERSE_BAT_SYMBOL := 1
|
||||||
ENABLE_FREQ_SEARCH_TIMEOUT := 0
|
ENABLE_FREQ_SEARCH_TIMEOUT := 0
|
||||||
ENABLE_CODE_SEARCH_TIMEOUT := 0
|
ENABLE_CODE_SEARCH_TIMEOUT := 0
|
||||||
|
ENABLE_SCAN_IGNORE_LIST := 1
|
||||||
# Kill and Revive 400 B
|
# Kill and Revive 400 B
|
||||||
ENABLE_KILL_REVIVE := 0
|
ENABLE_KILL_REVIVE := 0
|
||||||
# AM Fix 800 B
|
# AM Fix 800 B
|
||||||
@ -176,6 +177,9 @@ OBJS += app/generic.o
|
|||||||
OBJS += app/main.o
|
OBJS += app/main.o
|
||||||
OBJS += app/menu.o
|
OBJS += app/menu.o
|
||||||
OBJS += app/search.o
|
OBJS += app/search.o
|
||||||
|
ifeq ($(ENABLE_SCAN_IGNORE_LIST),1)
|
||||||
|
OBJS += freq_ignore.o
|
||||||
|
endif
|
||||||
ifeq ($(ENABLE_PANADAPTER),1)
|
ifeq ($(ENABLE_PANADAPTER),1)
|
||||||
OBJS += app/spectrum.o
|
OBJS += app/spectrum.o
|
||||||
endif
|
endif
|
||||||
@ -405,6 +409,9 @@ endif
|
|||||||
ifeq ($(ENABLE_CODE_SEARCH_TIMEOUT),1)
|
ifeq ($(ENABLE_CODE_SEARCH_TIMEOUT),1)
|
||||||
CFLAGS += -DENABLE_CODE_SEARCH_TIMEOUT
|
CFLAGS += -DENABLE_CODE_SEARCH_TIMEOUT
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(ENABLE_SCAN_IGNORE_LIST),1)
|
||||||
|
CFLAGS += -DENABLE_SCAN_IGNORE_LIST
|
||||||
|
endif
|
||||||
ifeq ($(ENABLE_KILL_REVIVE),1)
|
ifeq ($(ENABLE_KILL_REVIVE),1)
|
||||||
CFLAGS += -DENABLE_KILL_REVIVE
|
CFLAGS += -DENABLE_KILL_REVIVE
|
||||||
endif
|
endif
|
||||||
|
@ -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_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_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_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_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 := 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)
|
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it)
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||||
|
#include "freq_ignore.h"
|
||||||
|
#endif
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -247,6 +250,10 @@ void ACTION_Scan(bool bRestart)
|
|||||||
|
|
||||||
// start scanning
|
// start scanning
|
||||||
|
|
||||||
|
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||||
|
FI_clear_freq_ignored();
|
||||||
|
#endif
|
||||||
|
|
||||||
g_monitor_enabled = false;
|
g_monitor_enabled = false;
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||||
|
|
||||||
|
28
app/app.c
28
app/app.c
@ -50,6 +50,9 @@
|
|||||||
#include "dtmf.h"
|
#include "dtmf.h"
|
||||||
#include "external/printf/printf.h"
|
#include "external/printf/printf.h"
|
||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
|
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||||
|
#include "freq_ignore.h"
|
||||||
|
#endif
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "helper/battery.h"
|
#include "helper/battery.h"
|
||||||
#ifdef ENABLE_MDC1200
|
#ifdef ENABLE_MDC1200
|
||||||
@ -668,13 +671,28 @@ void APP_stop_scan(void)
|
|||||||
static void APP_next_freq(void)
|
static void APP_next_freq(void)
|
||||||
{
|
{
|
||||||
frequency_band_t new_band;
|
frequency_band_t new_band;
|
||||||
const frequency_band_t old_band = FREQUENCY_GetBand(g_rx_vfo->freq_config_rx.frequency);
|
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);
|
new_band = FREQUENCY_GetBand(frequency);
|
||||||
|
|
||||||
g_rx_vfo->freq_config_rx.frequency = frequency;
|
|
||||||
|
|
||||||
g_rx_vfo->freq_in_channel = 0xff;
|
g_rx_vfo->freq_in_channel = 0xff;
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
@ -682,7 +700,7 @@ static void APP_next_freq(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (new_band != old_band)
|
if (new_band != old_band)
|
||||||
{ // original slow method
|
{ // original slower method
|
||||||
|
|
||||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||||
|
28
app/main.c
28
app/main.c
@ -35,6 +35,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "dtmf.h"
|
#include "dtmf.h"
|
||||||
#include "frequencies.h"
|
#include "frequencies.h"
|
||||||
|
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||||
|
#include "freq_ignore.h"
|
||||||
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -807,14 +810,30 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT)
|
if (g_current_function == FUNCTION_TRANSMIT)
|
||||||
{ // RF scanning or TX'ing
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_fkey_pressed)
|
if (!g_fkey_pressed)
|
||||||
{ // pressed without the F-key
|
{ // 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))
|
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||||
{ // start entering a DTMF string
|
{ // start entering a DTMF string
|
||||||
|
|
||||||
@ -833,6 +852,9 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
|||||||
{ // with the F-key
|
{ // with the F-key
|
||||||
g_fkey_pressed = false;
|
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))
|
if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||||
{
|
{
|
||||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
125
freq_ignore.c
Normal file
125
freq_ignore.c
Normal 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
30
freq_ignore.h
Normal 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
|
||||||
|
|
@ -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 s0_dBm = -147; // S0 .. base level
|
||||||
|
|
||||||
const int16_t s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point
|
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 * 0); // S0
|
||||||
const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4
|
const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user