0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

fix tx offset entry in menu "Tx OFS"

This commit is contained in:
OneOfEleven
2023-10-26 13:46:12 +01:00
parent 4397931cfb
commit 39fdb7ed33
13 changed files with 652 additions and 476 deletions

View File

@ -88,7 +88,7 @@ void AIRCOPY_init(void)
g_fsk_write_index = 0;
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
BK4819_start_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
GUI_SelectNextDisplay(DISPLAY_AIRCOPY);
}
@ -281,13 +281,13 @@ void AIRCOPY_process_fsk_tx_10ms(void)
if (g_aircopy_state == AIRCOPY_RX)
{
g_fsk_write_index = 0;
BK4819_start_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
}
else
if (g_aircopy_state == AIRCOPY_TX)
{
g_fsk_write_index = 0;
BK4819_start_fsk_rx(AIRCOPY_REQ_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx(AIRCOPY_REQ_PACKET_SIZE);
}
}
@ -352,7 +352,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
{ // FSK RX is disabled, enable it
g_fsk_write_index = 0;
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
BK4819_start_fsk_rx((g_aircopy_state == AIRCOPY_TX) ? AIRCOPY_REQ_PACKET_SIZE : AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx((g_aircopy_state == AIRCOPY_TX) ? AIRCOPY_REQ_PACKET_SIZE : AIRCOPY_DATA_PACKET_SIZE);
}
status = BK4819_ReadRegister(0x0C);
@ -415,7 +415,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
// restart the RX
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
BK4819_start_fsk_rx((g_aircopy_state == AIRCOPY_TX) ? AIRCOPY_REQ_PACKET_SIZE : AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx((g_aircopy_state == AIRCOPY_TX) ? AIRCOPY_REQ_PACKET_SIZE : AIRCOPY_DATA_PACKET_SIZE);
g_update_display = true;
@ -601,7 +601,7 @@ send_req:
}
AIRCOPY_stop_fsk_tx();
BK4819_start_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
}
static void AIRCOPY_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
@ -733,7 +733,7 @@ static void AIRCOPY_Key_EXIT(bool key_pressed, bool key_held)
g_aircopy_rx_errors_crc = 0;
g_aircopy_state = AIRCOPY_RX;
BK4819_start_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
BK4819_start_aircopy_fsk_rx(AIRCOPY_DATA_PACKET_SIZE);
g_update_display = true;
GUI_DisplayScreen();

View File

@ -69,10 +69,10 @@
// original QS front end register settings
// 0x03BE 00000 011 101 11 110
const uint8_t orig_lna_short = 3; // 0dB
const uint8_t orig_lna = 5; // -4dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
const uint8_t orig_lnas = 3; // 0dB
const uint8_t orig_lna = 5; // -4dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
static void APP_process_key(const key_code_t Key, const bool key_pressed, const bool key_held);
@ -558,12 +558,6 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
#ifdef ENABLE_AM_FIX
{ // RF RX front end gain
// original setting
uint16_t lna_short = orig_lna_short;
uint16_t lna = orig_lna;
uint16_t mixer = orig_mixer;
uint16_t pga = orig_pga;
if (g_rx_vfo->am_mode && g_setting_am_fix)
{ // AM RX mode
if (reset_am_fix)
@ -571,8 +565,8 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
AM_fix_10ms(chan);
}
else
{
BK4819_WriteRegister(0x13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
{ // original setting
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
}
}
#else

View File

@ -23,7 +23,7 @@
#include "frequencies.h"
#include "radio.h"
extern const uint8_t orig_lna_short;
extern const uint8_t orig_lnas;
extern const uint8_t orig_lna;
extern const uint8_t orig_mixer;
extern const uint8_t orig_pga;

View File

@ -32,6 +32,7 @@
#include "driver/gpio.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "driver/uart.h"
#include "frequencies.h"
#include "helper/battery.h"
#include "misc.h"
@ -44,10 +45,6 @@
#include "ui/menu.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifdef ENABLE_F_CAL_MENU
void writeXtalFreqCal(const int32_t value, const bool update_eeprom)
{
@ -1442,7 +1439,7 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
{
uint32_t Frequency;
if (g_input_box_index < 6)
if (g_input_box_index < 8)
{ // not yet enough characters
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
@ -1457,7 +1454,23 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
NUMBER_Get(g_input_box, &Frequency);
g_input_box_index = 0;
g_sub_menu_selection = FREQUENCY_floor_to_step(Frequency + (g_tx_vfo->step_freq / 2), g_tx_vfo->step_freq, 0, Frequency + (g_tx_vfo->step_freq / 2));
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 3 %u\r\n", Frequency);
#endif
#if 0
{ // round
const uint32_t step_size = g_tx_vfo->step_freq;
Frequency = ((Frequency + (step_size / 2)) / step_size) * step_size;
}
#endif
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 4 %u\r\n", Frequency);
#endif
g_sub_menu_selection = Frequency;
return;
}
@ -1617,16 +1630,16 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
if (!g_in_sub_menu)
{
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (g_menu_cursor != MENU_SCRAMBLER)
g_another_voice_id = g_menu_list[g_menu_list_sorted[g_menu_cursor]].voice_id;
#endif
#endif
#if 1
#if 1
if (g_menu_cursor == MENU_MEM_DEL || g_menu_cursor == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0))
return; // invalid channel
#endif
#endif
g_ask_for_confirmation = 0;
g_in_sub_menu = true;
@ -1705,44 +1718,44 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
if (g_menu_cursor == MENU_RESET)
{
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
#endif
#endif
MENU_AcceptSetting();
#if defined(ENABLE_OVERLAY)
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
#else
NVIC_SystemReset();
#endif
#endif
}
g_flag_accept_setting = true;
g_in_sub_menu = false;
g_in_sub_menu = false;
g_ask_for_confirmation = 0;
}
}
else
{
g_flag_accept_setting = true;
g_in_sub_menu = false;
g_in_sub_menu = false;
}
}
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
{
g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_update_status = true;
}
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (g_menu_cursor == MENU_SCRAMBLER)
g_another_voice_id = (g_sub_menu_selection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else
g_another_voice_id = VOICE_ID_CONFIRM;
#endif
#endif
g_input_box_index = 0;
}
@ -1874,22 +1887,6 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
return;
}
if (g_menu_cursor == MENU_OFFSET)
{
int32_t Offset = (Direction * g_tx_vfo->step_freq) + g_sub_menu_selection;
if (Offset < 99999990)
{
if (Offset < 0)
Offset = 99999990;
}
else
Offset = 0;
g_sub_menu_selection = FREQUENCY_floor_to_step(Offset, g_tx_vfo->step_freq, 0, Offset);
g_request_display_screen = DISPLAY_MENU;
return;
}
VFO = 0;
#pragma GCC diagnostic push
@ -1897,6 +1894,34 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
switch (g_menu_cursor)
{
case MENU_OFFSET:
{
const int32_t max_freq = 100000000;
const int32_t step_size = g_tx_vfo->step_freq;
int32_t offset = (int32_t)g_sub_menu_selection + (Direction * step_size);
// wrap
if (offset >= max_freq)
offset = 0;
else
if (offset < 0)
offset = max_freq - step_size;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 1 %u %u\r\n", offset, step_size);
#endif
offset = ((offset + (step_size / 2)) / step_size) * step_size; // round
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 2 %u %u\r\n", offset, step_size);
#endif
g_sub_menu_selection = offset;
g_request_display_screen = DISPLAY_MENU;
return;
}
case MENU_MEM_DEL:
case MENU_1_CALL:
case MENU_MEM_NAME: