0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-30 07:11:26 +03:00

fix tx tones

This commit is contained in:
OneOfEleven 2023-11-03 18:41:54 +00:00
parent 474317c149
commit e2e030aed4
16 changed files with 470 additions and 460 deletions

View File

@ -57,7 +57,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_CONTRAST := 0 ENABLE_CONTRAST := 0
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_DTMF_CALL_FLASH_LIGHT := 1 ENABLE_DTMF_CALL_FLASH_LIGHT := 1
ENABLE_FLASH_LIGHT_SOS_TONE := 0 ENABLE_FLASH_LIGHT_SOS_TONE := 1
ENABLE_SHOW_CHARGE_LEVEL := 0 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

View File

@ -28,7 +28,7 @@
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
#ifdef ENABLE_AM_FIX //#define SET_RSSI_COMP
typedef struct typedef struct
{ {
@ -328,9 +328,14 @@
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
{ {
const int16_t new_rssi = rssi - rssi_gain_diff[vfo]; const int16_t new_rssi = rssi - rssi_gain_diff[vfo];
const uint16_t new_glitch = BK4819_GetGlitchIndicator();
const uint16_t new_noise = BK4819_GetExNoiceIndicator();
if (g_current_rssi[vfo] != new_rssi) if (g_current_rssi[vfo] != new_rssi)
{ {
g_current_rssi[vfo] = new_rssi; g_current_rssi[vfo] = new_rssi;
g_current_glitch[vfo] = new_glitch;
g_current_noise[vfo] = new_noise;
if (display_update_tick == 0) if (display_update_tick == 0)
{ // trigger a display update { // trigger a display update
@ -426,8 +431,10 @@
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make // offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
#ifdef SET_RSSI_COMP
// RF gain difference from original QS setting // RF gain difference from original QS setting
rssi_gain_diff[vfo] = ((int16_t)gain_table[index].gain_dB - gain_table[original_index].gain_dB) * 2; rssi_gain_diff[vfo] = ((int16_t)gain_table[index].gain_dB - gain_table[original_index].gain_dB) * 2;
#endif
} }
// save the corrected RSSI level // save the corrected RSSI level
@ -459,5 +466,3 @@
} }
#endif #endif
#endif

View File

@ -16,11 +16,11 @@
*/ */
#ifndef AM_FIXH #ifndef AM_FIXH
#define AM_FIXH
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef ENABLE_AM_FIX
extern int16_t rssi_gain_diff[2]; extern int16_t rssi_gain_diff[2];
void AM_fix_init(void); void AM_fix_init(void);
@ -31,5 +31,3 @@
#endif #endif
#endif #endif
#endif

View File

@ -83,6 +83,8 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
static void APP_update_rssi(const int vfo) static void APP_update_rssi(const int vfo)
{ {
int16_t rssi = BK4819_GetRSSI(); int16_t rssi = BK4819_GetRSSI();
uint8_t glitch = BK4819_GetGlitchIndicator();
uint8_t noise = BK4819_GetExNoiceIndicator();
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// add RF gain adjust compensation // add RF gain adjust compensation
@ -94,8 +96,10 @@ static void APP_update_rssi(const int vfo)
return; // no change return; // no change
g_current_rssi[vfo] = rssi; g_current_rssi[vfo] = rssi;
g_current_glitch[vfo] = glitch;
g_current_noise[vfo] = noise;
UI_update_rssi(rssi, vfo); UI_update_rssi(rssi, glitch, noise, vfo);
} }
static void APP_check_for_new_receive(void) static void APP_check_for_new_receive(void)
@ -1560,7 +1564,7 @@ void APP_process_flash_light_10ms(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
#ifdef ENABLE_FLASH_LIGHT_SOS_TONE #ifdef ENABLE_FLASH_LIGHT_SOS_TONE
if (!g_squelch_open && !g_monitor_enabled && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER)) if (!g_squelch_open && !g_monitor_enabled && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER))
BK4819_StartTone1(880, 50); BK4819_StartTone1(880, 50, g_current_function == FUNCTION_TRANSMIT);
#endif #endif
} }
} }

View File

@ -819,6 +819,7 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF) if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ // RF scanning { // RF scanning
#ifdef ENABLE_SCAN_IGNORE_LIST
if (scanning_paused()) if (scanning_paused())
{ {
FI_add_freq_ignored(g_rx_vfo->freq_config_rx.frequency); FI_add_freq_ignored(g_rx_vfo->freq_config_rx.frequency);
@ -830,6 +831,7 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
} }
#endif
return; return;
} }

View File

@ -173,7 +173,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
} }
// BK4819_PlayTone(ToneFrequency, true); // BK4819_PlayTone(ToneFrequency, true);
BK4819_StartTone1(ToneFrequency, 96); BK4819_StartTone1(ToneFrequency, 96, false);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);

View File

@ -881,7 +881,7 @@ void BK4819_EnableDTMF(void)
(15u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15 (15u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15
} }
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level) void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx)
{ {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
@ -895,12 +895,16 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level)
BK4819_WriteRegister(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); BK4819_WriteRegister(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(0x30, 0); BK4819_WriteRegister(0x30, 0);
#if 1
if (!tx)
{
BK4819_WriteRegister(0x30, BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_TX_DSP); BK4819_REG_30_ENABLE_TX_DSP);
#else }
else
{
BK4819_WriteRegister(0x30, BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_VCO_CALIB | BK4819_REG_30_ENABLE_VCO_CALIB |
BK4819_REG_30_ENABLE_UNKNOWN | BK4819_REG_30_ENABLE_UNKNOWN |
@ -913,13 +917,14 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level)
BK4819_REG_30_ENABLE_TX_DSP | // BK4819_REG_30_ENABLE_TX_DSP | //
// BK4819_REG_30_ENABLE_RX_DSP | // BK4819_REG_30_ENABLE_RX_DSP |
0); 0);
#endif }
BK4819_WriteRegister(0x71, scale_freq(frequency)); BK4819_WriteRegister(0x71, scale_freq(frequency));
BK4819_ExitTxMute(); BK4819_ExitTxMute();
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
if (!tx)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
} }
@ -978,7 +983,7 @@ void BK4819_StopTones(const bool tx)
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level) void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level)
{ {
const uint16_t prev_af = BK4819_ReadRegister(0x47); const uint16_t prev_af = BK4819_ReadRegister(0x47);
BK4819_StartTone1(tone_Hz, level); BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT);
SYSTEM_DelayMs(delay - 2); SYSTEM_DelayMs(delay - 2);
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT); BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
BK4819_WriteRegister(0x47, prev_af); BK4819_WriteRegister(0x47, prev_af);
@ -996,9 +1001,9 @@ void BK4819_PlayRoger(void)
#endif #endif
const uint16_t prev_af = BK4819_ReadRegister(0x47); const uint16_t prev_af = BK4819_ReadRegister(0x47);
BK4819_StartTone1(tone1_Hz, 96); BK4819_StartTone1(tone1_Hz, 96, true);
SYSTEM_DelayMs(80 - 2); SYSTEM_DelayMs(80 - 2);
BK4819_StartTone1(tone2_Hz, 96); BK4819_StartTone1(tone2_Hz, 96, true);
SYSTEM_DelayMs(80); SYSTEM_DelayMs(80);
BK4819_StopTones(true); BK4819_StopTones(true);
BK4819_WriteRegister(0x47, prev_af); BK4819_WriteRegister(0x47, prev_af);

View File

@ -103,7 +103,7 @@ void BK4819_SetCompander(const unsigned int mode);
void BK4819_DisableVox(void); void BK4819_DisableVox(void);
void BK4819_DisableDTMF(void); void BK4819_DisableDTMF(void);
void BK4819_EnableDTMF(void); void BK4819_EnableDTMF(void);
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level); void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx);
void BK4819_StopTones(const bool tx); void BK4819_StopTones(const bool tx);
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level); void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level);
void BK4819_EnterTxMute(void); void BK4819_EnterTxMute(void);

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
#include "misc.h" #include "misc.h"
// a list of frequencies to ignore/skip when scanning // a list of frequencies to ignore/skip when scanning
uint32_t ignore_frequencies[256]; uint32_t ignore_frequencies[64];
int ignore_frequencies_count = 0; int ignore_frequencies_count = 0;
void FI_clear_freq_ignored(void) void FI_clear_freq_ignored(void)

View File

@ -220,7 +220,7 @@ void FUNCTION_Select(function_type_t Function)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
BK4819_StartTone1(500, 28); BK4819_StartTone1(500, 28, g_current_function == FUNCTION_TRANSMIT);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);

4
misc.c
View File

@ -234,7 +234,9 @@ volatile bool g_flag_tail_tone_elimination_complete;
volatile uint16_t g_boot_tick_10ms = 4000 / 10; // 4 seconds volatile uint16_t g_boot_tick_10ms = 4000 / 10; // 4 seconds
int16_t g_current_rssi[2] = {0, 0}; // now one per VFO int16_t g_current_rssi[2] = {0, 0};
uint16_t g_current_glitch[2] = {0, 0};
uint16_t g_current_noise[2] = {0, 0};
uint8_t g_mic_sensitivity_tuning; uint8_t g_mic_sensitivity_tuning;

6
misc.h
View File

@ -321,7 +321,11 @@ extern volatile bool g_next_time_slice_40ms;
extern volatile bool g_schedule_noaa; extern volatile bool g_schedule_noaa;
#endif #endif
extern volatile bool g_flag_tail_tone_elimination_complete; extern volatile bool g_flag_tail_tone_elimination_complete;
extern int16_t g_current_rssi[2]; // now one per VFO
extern int16_t g_current_rssi[2];
extern uint16_t g_current_glitch[2];
extern uint16_t g_current_noise[2];
extern volatile uint16_t g_boot_tick_10ms; extern volatile uint16_t g_boot_tick_10ms;
extern uint8_t g_mic_sensitivity_tuning; extern uint8_t g_mic_sensitivity_tuning;

View File

@ -55,27 +55,13 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
for (i = 0; i < max_width; i += 2) for (i = 0; i < max_width; i += 2)
line[i] = (i <= len) ? 0x7f : 0x41; line[i] = (i <= len) ? 0x7f : 0x41;
#else #else
// segmented bar // segmented bar
for (i = 0; i < max_width; i += 4) for (i = 0; i < max_width; i += 4)
{
for (int k = i - 4; k < i && k < len; k++) for (int k = i - 4; k < i && k < len; k++)
{
if (k >= 0) if (k >= 0)
// line[k] = (k < (i - 1)) ? 0x7f : 0x00; // line[k] = (k < (i - 1)) ? 0x7f : 0x00;
if (k < (i - 1)) if (k < (i - 1))
line[k] = 0x7f; line[k] = 0x7f;
// line[k] = 0x3e;
}
}
#if 0
// top/bottom lines
for (i = 0; i < len; i += 2)
line[i] |= 0x41;
for (i &= ~3u ; i < max_width; i += 4)
line[i] = 0x41;
#endif
#endif #endif
} }
@ -179,10 +165,14 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
#endif #endif
#ifdef ENABLE_RX_SIGNAL_BAR #ifdef ENABLE_RX_SIGNAL_BAR
bool UI_DisplayRSSIBar(const int16_t rssi, const bool now) bool UI_DisplayRSSIBar(const int16_t rssi, const int16_t glitch, const int16_t noise, const bool now)
{ {
if (g_eeprom.config.setting.enable_rssi_bar) if (g_eeprom.config.setting.enable_rssi_bar)
{ {
(void)glitch; // TODO:
(void)noise;
// const int16_t s0_dBm = -127; // S0 .. base level // const int16_t s0_dBm = -127; // S0 .. base level
const int16_t s0_dBm = -147; // S0 .. base level const int16_t s0_dBm = -147; // S0 .. base level
@ -245,14 +235,14 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
} }
#endif #endif
void UI_update_rssi(const int16_t rssi, const int vfo) void UI_update_rssi(const int16_t rssi, const int16_t glitch, const int16_t noise, const int vfo)
{ {
#ifdef ENABLE_RX_SIGNAL_BAR #ifdef ENABLE_RX_SIGNAL_BAR
if (g_center_line == CENTER_LINE_RSSI) if (g_center_line == CENTER_LINE_RSSI)
{ // optional larger RSSI dBm, S-point and bar level { // optional larger RSSI dBm, S-point and bar level
//if (g_current_function == FUNCTION_RECEIVE && g_squelch_open) //if (g_current_function == FUNCTION_RECEIVE && g_squelch_open)
if (g_current_function == FUNCTION_RECEIVE) if (g_current_function == FUNCTION_RECEIVE)
UI_DisplayRSSIBar(rssi, true); UI_DisplayRSSIBar(rssi, glitch, noise, true);
} }
#endif #endif
@ -921,7 +911,7 @@ void UI_DisplayMain(void)
if (rx && g_eeprom.config.setting.enable_rssi_bar) if (rx && g_eeprom.config.setting.enable_rssi_bar)
{ {
g_center_line = CENTER_LINE_RSSI; g_center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(g_current_rssi[g_rx_vfo_num], false); UI_DisplayRSSIBar(g_current_rssi[g_rx_vfo_num], g_current_glitch[g_rx_vfo_num], g_current_noise[g_rx_vfo_num], false);
} }
else else
#endif #endif

View File

@ -34,7 +34,7 @@ extern center_line_t g_center_line;
#ifdef ENABLE_TX_AUDIO_BAR #ifdef ENABLE_TX_AUDIO_BAR
bool UI_DisplayAudioBar(const bool now); bool UI_DisplayAudioBar(const bool now);
#endif #endif
void UI_update_rssi(const int16_t rssi, const int vfo); void UI_update_rssi(const int16_t rssi, const int16_t glitch, const int16_t noise, const int vfo);
void UI_DisplayMain(void); void UI_DisplayMain(void);
#endif #endif