mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
fix dual-watch/panadapter bug
This commit is contained in:
parent
046d88bb58
commit
90b0435ed7
2
Makefile
2
Makefile
@ -76,7 +76,7 @@ ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1
|
||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
||||
ENABLE_COPY_CHAN_TO_VFO_TO_CHAN := 1
|
||||
# Rx Signal Bar 400 B
|
||||
ENABLE_RX_SIGNAL_BAR := 1
|
||||
ENABLE_RX_SIGNAL_BAR := 0
|
||||
# Tx Audio Bar 300 B
|
||||
ENABLE_TX_AUDIO_BAR := 0
|
||||
# Side Button Menu 300 B
|
||||
|
116
app/app.c
116
app/app.c
@ -499,7 +499,7 @@ bool APP_start_listening(void)
|
||||
#endif
|
||||
|
||||
if (g_squelch_open)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // green LED on
|
||||
|
||||
if (g_eeprom.config.setting.backlight_on_tx_rx >= 2)
|
||||
BACKLIGHT_turn_on(backlight_tx_rx_time_secs);
|
||||
@ -511,15 +511,16 @@ bool APP_start_listening(void)
|
||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||
g_vfo_rssi_bar_level[(chan + 1) & 1u] = 0;
|
||||
|
||||
// enable/disable AFC
|
||||
switch (g_rx_vfo->channel.mod_mode)
|
||||
{
|
||||
case MOD_MODE_FM:
|
||||
case MOD_MODE_AM:
|
||||
BK4819_set_AFC(2);
|
||||
BK4819_set_AFC(2); // enable a bit
|
||||
break;
|
||||
default:
|
||||
case MOD_MODE_DSB:
|
||||
BK4819_set_AFC(0);
|
||||
BK4819_set_AFC(0); // disable
|
||||
break;
|
||||
}
|
||||
|
||||
@ -552,6 +553,18 @@ bool APP_start_listening(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
{ // we're code scanning
|
||||
g_css_scan_mode = CSS_SCAN_MODE_FOUND;
|
||||
}
|
||||
else
|
||||
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
|
||||
{ // dual watch is enabled
|
||||
g_dual_watch_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_rx_vfo_is_active = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_mode)
|
||||
@ -565,20 +578,7 @@ bool APP_start_listening(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
g_css_scan_mode = CSS_SCAN_MODE_FOUND;
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
|
||||
{ // dual watch is active
|
||||
|
||||
g_dual_watch_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_rx_vfo_is_active = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
// AF gain - original QS values
|
||||
// AF gain
|
||||
// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM)
|
||||
// {
|
||||
// BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000
|
||||
@ -594,11 +594,12 @@ bool APP_start_listening(void)
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
BK1080_Init(0, false); // disable the FM radio audio
|
||||
BK1080_Init(0, false); // disable FM radio audio
|
||||
#endif
|
||||
|
||||
FUNCTION_Select(FUNCTION_RECEIVE);
|
||||
|
||||
// set modulation mode FM, AM etc
|
||||
#ifdef ENABLE_VOICE
|
||||
#ifdef MUTE_AUDIO_FOR_VOICE
|
||||
if (g_voice_write_index == 0)
|
||||
@ -611,9 +612,10 @@ bool APP_start_listening(void)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("mode %u\r\n", g_rx_vfo->channel.mod_mode);
|
||||
// UART_printf("mod mode %u\r\n", g_rx_vfo->channel.mod_mode);
|
||||
#endif
|
||||
|
||||
// speaker on
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
if (g_current_display_screen != DISPLAY_MENU)
|
||||
@ -814,23 +816,6 @@ static void APP_next_channel(void)
|
||||
|
||||
// Fallthrough
|
||||
|
||||
// this bit doesn't yet work if the other VFO is a frequency
|
||||
case SCAN_NEXT_CHAN_DUAL_WATCH:
|
||||
// dual watch is enabled - include the other VFO in the scan
|
||||
// if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
|
||||
// {
|
||||
// chan = (g_rx_vfo + 1) & 1u;
|
||||
// chan = g_eeprom.config.setting.indices.vfo[chan].screen;
|
||||
// if (chan <= USER_CHANNEL_LAST)
|
||||
// {
|
||||
// g_scan_current_scan_list = SCAN_NEXT_CHAN_DUAL_WATCH;
|
||||
// g_scan_next_channel = chan;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
case SCAN_NEXT_CHAN_USER:
|
||||
g_scan_current_scan_list = SCAN_NEXT_CHAN_USER;
|
||||
@ -912,10 +897,6 @@ static bool APP_toggle_dual_watch_vfo(void)
|
||||
if (g_dual_watch_tick_10ms > 0)
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_SendText("dual wot\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_noaa_mode)
|
||||
{
|
||||
@ -934,9 +915,13 @@ static bool APP_toggle_dual_watch_vfo(void)
|
||||
{ // toggle between VFO's
|
||||
g_rx_vfo_num = (g_rx_vfo_num + 1) & 1u;
|
||||
g_rx_vfo = &g_vfo_info[g_rx_vfo_num];
|
||||
g_update_status = true;
|
||||
// g_update_status = true;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("dw %u\r\n", g_rx_vfo_num);
|
||||
#endif
|
||||
|
||||
RADIO_setup_registers(false);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -959,8 +944,45 @@ void APP_process_radio_interrupts(void)
|
||||
uint16_t int_bits;
|
||||
|
||||
const uint16_t reg_c = BK4819_read_reg(0x0C);
|
||||
if ((reg_c & 1u) == 0)
|
||||
break;
|
||||
|
||||
// if ((reg_c & (2u << 1))
|
||||
// { // VOX
|
||||
// }
|
||||
|
||||
if (reg_c & (1u << 1))
|
||||
{ // squelch is open
|
||||
if (!g_squelch_open)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("sq open\r\n");
|
||||
#endif
|
||||
g_squelch_open = true;
|
||||
//APP_update_rssi(g_rx_vfo_num, false);
|
||||
g_update_rssi = true;
|
||||
if (g_monitor_enabled)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // green LED on
|
||||
g_update_display = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // squelch is closed
|
||||
if (g_squelch_open)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("sq close\r\n");
|
||||
#endif
|
||||
g_squelch_open = false;
|
||||
//APP_update_rssi(g_rx_vfo_num, false);
|
||||
g_update_rssi = true;
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // green LED off
|
||||
if (!g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_update_display = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((reg_c & (1u << 0)) == 0)
|
||||
break; // no interrupt flags
|
||||
|
||||
BK4819_write_reg(0x02, 0);
|
||||
int_bits = BK4819_read_reg(0x02);
|
||||
@ -1111,7 +1133,7 @@ void APP_process_radio_interrupts(void)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (int_bits & BK4819_REG_02_SQUELCH_CLOSED)
|
||||
{
|
||||
g_squelch_open = false;
|
||||
@ -1122,7 +1144,7 @@ void APP_process_radio_interrupts(void)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("sq close\r\n");
|
||||
UART_SendText("sq closed\r\n");
|
||||
#endif
|
||||
|
||||
//APP_update_rssi(g_rx_vfo_num, false);
|
||||
@ -1136,7 +1158,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_squelch_open = true;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("sq open\r\n");
|
||||
UART_SendText("sq opened\r\n");
|
||||
#endif
|
||||
|
||||
//APP_update_rssi(g_rx_vfo_num, false);
|
||||
@ -1147,7 +1169,7 @@ void APP_process_radio_interrupts(void)
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
*/
|
||||
#ifdef ENABLE_MDC1200
|
||||
MDC1200_process_rx(int_bits);
|
||||
#endif
|
||||
|
@ -549,6 +549,10 @@ void BK4819_set_rf_frequency(const uint32_t frequency, const bool trigger_update
|
||||
BK4819_write_reg(0x30, reg & ~BK4819_REG_30_ENABLE_VCO_CALIB);
|
||||
BK4819_write_reg(0x30, reg);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("bk freq %4u.%05u\n", frequency / 100000, frequency % 100000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BK4819_SetupSquelch(
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
1
misc.h
1
misc.h
@ -107,7 +107,6 @@ typedef enum css_scan_mode_e css_scan_mode_t;
|
||||
enum scan_next_chan_e {
|
||||
SCAN_NEXT_CHAN_SCANLIST1 = 0,
|
||||
SCAN_NEXT_CHAN_SCANLIST2,
|
||||
SCAN_NEXT_CHAN_DUAL_WATCH,
|
||||
SCAN_NEXT_CHAN_USER,
|
||||
SCAN_NEXT_NUM
|
||||
};
|
||||
|
@ -141,6 +141,7 @@ void PAN_process_10ms(void)
|
||||
g_reduced_service ||
|
||||
g_current_function == FUNCTION_POWER_SAVE ||
|
||||
g_current_display_screen == DISPLAY_SEARCH ||
|
||||
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
|
26
radio.c
26
radio.c
@ -735,10 +735,10 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
|
||||
#endif
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // speaker off
|
||||
}
|
||||
|
||||
// turn green LED off
|
||||
// green LED off
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false);
|
||||
|
||||
Bandwidth = RADIO_set_bandwidth(Bandwidth, g_rx_vfo->channel.mod_mode);
|
||||
@ -757,18 +757,17 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_RED, false); // LED off
|
||||
BK4819_SetupPowerAmplifier(0, 0);
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_RED, false); // red LED off
|
||||
BK4819_SetupPowerAmplifier(0, 0); //
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
|
||||
|
||||
while (1)
|
||||
{ // wait for interrupts to clear
|
||||
do { // wait for interrupts to clear
|
||||
const uint16_t int_bits = BK4819_read_reg(0x0C);
|
||||
if ((int_bits & (1u << 0)) == 0)
|
||||
break;
|
||||
BK4819_write_reg(0x02, 0); // clear the interrupt bits
|
||||
BK4819_write_reg(0x02, 0); // clear the interrupt bits ?
|
||||
SYSTEM_DelayMs(1);
|
||||
}
|
||||
} while (1);
|
||||
BK4819_write_reg(0x3F, 0); // disable interrupts
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -778,9 +777,11 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
#endif
|
||||
Frequency = g_rx_vfo->p_rx->frequency;
|
||||
|
||||
BK4819_set_rf_frequency(Frequency, false);
|
||||
// set VCO/PLL frequency
|
||||
BK4819_set_rf_frequency(Frequency, true);
|
||||
BK4819_set_rf_filter_path(Frequency);
|
||||
|
||||
// set squelch level
|
||||
BK4819_SetupSquelch(
|
||||
g_rx_vfo->squelch_open_rssi_thresh, g_rx_vfo->squelch_close_rssi_thresh,
|
||||
g_rx_vfo->squelch_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh,
|
||||
@ -804,7 +805,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
}
|
||||
|
||||
if (!g_monitor_enabled)
|
||||
{
|
||||
{ // set modulation mode FM, AM etc
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
|
||||
#endif
|
||||
@ -885,7 +886,6 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
else
|
||||
{
|
||||
BK4819_set_CTCSS_freq(0); // NOAA 1050Hz stuff
|
||||
|
||||
interrupt_mask |= BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
|
||||
}
|
||||
#endif
|
||||
@ -927,6 +927,10 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
|
||||
// if (g_monitor_enabled)
|
||||
// GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("setup-reg %4u.%05u MHz, %u\r\n", Frequency / 100000, Frequency % 100000, Bandwidth);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
|
25
ui/main.c
25
ui/main.c
@ -399,7 +399,6 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
|
||||
const bool valid = (g_panadapter_cycles > 0 && !g_monitor_enabled && g_current_function != FUNCTION_TRANSMIT) ? true : false;
|
||||
const unsigned int line = (g_eeprom.config.setting.tx_vfo_num == 0) ? 4 : 0;
|
||||
uint8_t *base_line = g_frame_buffer[line + 2];
|
||||
uint8_t max_rssi;
|
||||
uint8_t min_rssi;
|
||||
uint8_t span_rssi;
|
||||
unsigned int i;
|
||||
@ -410,6 +409,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
|
||||
g_reduced_service ||
|
||||
g_current_display_screen != DISPLAY_MAIN ||
|
||||
g_current_function == FUNCTION_POWER_SAVE ||
|
||||
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF ||
|
||||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
|
||||
g_dtmf_input_mode)
|
||||
{ // don't draw the panadapter
|
||||
@ -422,21 +422,18 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
|
||||
if (valid)
|
||||
{
|
||||
// auto vertical scale
|
||||
max_rssi = g_panadapter_max_rssi;
|
||||
min_rssi = g_panadapter_min_rssi;
|
||||
span_rssi = max_rssi - min_rssi;
|
||||
span_rssi = g_panadapter_max_rssi - min_rssi;
|
||||
if (span_rssi < 30)
|
||||
span_rssi = 30;
|
||||
if (min_rssi > (255 - span_rssi))
|
||||
min_rssi = 255 - span_rssi;
|
||||
max_rssi = min_rssi + span_rssi;
|
||||
|
||||
#if 0
|
||||
{ // show the min/max RSSI values
|
||||
char str[16];
|
||||
sprintf(str, "%u", min_rssi);
|
||||
UI_PrintStringSmall(str, 2, 0, line + 0);
|
||||
//sprintf(str, "%u", max_rssi);
|
||||
sprintf(str, "%u", span_rssi);
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - 2 - (7 * strlen(str)), 0, line + 0);
|
||||
}
|
||||
@ -550,7 +547,7 @@ void UI_DisplayMain(void)
|
||||
pan_enabled = false;
|
||||
|
||||
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF && g_rx_vfo_is_active)
|
||||
current_vfo_num = g_rx_vfo_num; // we're currently monitoring the other VFO
|
||||
current_vfo_num = g_rx_vfo_num;
|
||||
}
|
||||
|
||||
// clear the screen buffer
|
||||
@ -673,25 +670,15 @@ void UI_DisplayMain(void)
|
||||
g_center_line = CENTER_LINE_IN_USE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// highlight the selected/used VFO with a marker
|
||||
if (single_vfo < 0)
|
||||
{
|
||||
if (vfo_num == main_vfo_num)
|
||||
memcpy(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT));
|
||||
memcpy(p_line0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT));
|
||||
else
|
||||
if (g_eeprom.config.setting.cross_vfo != CROSS_BAND_OFF || vfo_num == current_vfo_num)
|
||||
memcpy(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT));
|
||||
}
|
||||
}
|
||||
else
|
||||
if (single_vfo < 0)
|
||||
{ // highlight the selected/used VFO with a marker
|
||||
if (vfo_num == main_vfo_num)
|
||||
memcpy(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT));
|
||||
else
|
||||
if (g_eeprom.config.setting.cross_vfo != CROSS_BAND_OFF || vfo_num == current_vfo_num)
|
||||
memcpy(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT));
|
||||
memcpy(p_line0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT));
|
||||
}
|
||||
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user