0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

fix unable to enter freq/chan

This commit is contained in:
OneOfEleven 2023-11-05 10:48:37 +00:00
parent 359fa3bf47
commit 4bc506a0f7
9 changed files with 111 additions and 91 deletions

View File

@ -54,7 +54,7 @@ ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0 ENABLE_F_CAL_MENU := 0
ENABLE_TX_UNLOCK := 0 ENABLE_TX_UNLOCK := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_CONTRAST := 1 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 := 1 ENABLE_FLASH_LIGHT_SOS_TONE := 1

View File

@ -1233,6 +1233,11 @@ void APP_check_keys(void)
// ***************** // *****************
// PTT is treated completely separately from all the other buttons // PTT is treated completely separately from all the other buttons
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// if (g_input_box_index > 0)
// UART_printf("1 index %u %u\r\n", g_input_box_index, g_flash_light_blink_tick_10ms);
#endif
if (ptt_pressed) if (ptt_pressed)
{ // PTT pressed { // PTT pressed
@ -1262,11 +1267,9 @@ void APP_check_keys(void)
else else
{ // PTT released { // PTT released
#ifdef ENABLE_KILL_REVIVE if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0)
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_eeprom.config.setting.tx_enable || g_eeprom.config.setting.radio_disabled) {
#else // if (g_ptt_debounce > 0)
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_eeprom.config.setting.tx_enable)
#endif
{ {
if (--g_ptt_debounce <= 0) if (--g_ptt_debounce <= 0)
{ // stop TX'ing { // stop TX'ing
@ -1279,6 +1282,12 @@ void APP_check_keys(void)
} }
} }
} }
}
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// if (g_input_box_index > 0)
// UART_printf("2 index %u %u\r\n", g_input_box_index, g_flash_light_blink_tick_10ms);
#endif
// ***************** // *****************
// button processing (non-PTT) // button processing (non-PTT)
@ -1326,6 +1335,7 @@ void APP_check_keys(void)
// g_update_display = true; // g_update_display = true;
} }
} }
if (g_key_debounce_repeat > 0) if (g_key_debounce_repeat > 0)
g_key_debounce_repeat--; g_key_debounce_repeat--;
} }
@ -2561,10 +2571,6 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
} }
#endif #endif
// key beep
// if (Key != KEY_PTT && !key_held && key_pressed)
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// ******************** // ********************
if (Key == KEY_EXIT && key_held && key_pressed) if (Key == KEY_EXIT && key_held && key_pressed)

View File

@ -444,6 +444,10 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_key_input_count_down = key_input_timeout_500ms; g_key_input_count_down = key_input_timeout_500ms;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("key0 %u\r\n", Key);
#endif
if (key_held) if (key_held)
{ // key held down { // key held down
@ -483,7 +487,10 @@ void MAIN_Key_DIGITS(key_code_t Key, 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)
return;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ {
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -493,16 +500,20 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
INPUTBOX_append(Key); INPUTBOX_append(Key);
UI_DisplayMain(); // UI_DisplayMain();
// g_request_display_screen = DISPLAY_MAIN; g_request_display_screen = DISPLAY_MAIN;
if (IS_USER_CHANNEL(g_tx_vfo->channel_save)) if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
{ // user is entering channel number { // user is entering channel number
uint16_t Channel; const unsigned int chan = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1;
if (g_input_box_index != 3) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("key2 %u %u\r\n", chan, g_input_box_index);
#endif
if (g_input_box_index < 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
@ -512,9 +523,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_input_box_index = 0; g_input_box_index = 0;
Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1; if (!RADIO_CheckValidChannel(chan, false, 0))
if (!RADIO_CheckValidChannel(Channel, false, 0))
{ {
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -524,8 +533,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
g_eeprom.config.setting.indices.vfo[vfo].user = (uint8_t)Channel; g_eeprom.config.setting.indices.vfo[vfo].user = chan;
g_eeprom.config.setting.indices.vfo[vfo].screen = (uint8_t)Channel; g_eeprom.config.setting.indices.vfo[vfo].screen = chan;
g_request_save_vfo = true; g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
@ -536,7 +545,13 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
{ // user is entering a frequency { // user is entering a frequency
uint32_t Frequency; uint32_t freq;
NUMBER_Get(g_input_box, &freq);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("key2 %u %u\r\n", freq, g_input_box_index);
#endif
if (g_input_box_index < 6) if (g_input_box_index < 6)
{ {
@ -548,23 +563,21 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_input_box_index = 0; g_input_box_index = 0;
NUMBER_Get(g_input_box, &Frequency);
// clamp the frequency entered to some valid value // clamp the frequency entered to some valid value
if (Frequency < FREQ_BAND_TABLE[0].lower) if (freq < FREQ_BAND_TABLE[0].lower)
Frequency = FREQ_BAND_TABLE[0].lower; freq = FREQ_BAND_TABLE[0].lower;
else else
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower) if (freq >= BX4819_BAND1.upper && freq < BX4819_BAND2.lower)
{ {
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2; const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_BAND1.upper : BX4819_BAND2.lower; freq = (freq < center) ? BX4819_BAND1.upper : BX4819_BAND2.lower;
} }
else else
if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) if (freq > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper)
Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper; freq = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper;
{ {
const frequency_band_t band = FREQUENCY_GetBand(Frequency); const frequency_band_t band = FREQUENCY_GetBand(freq);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
@ -582,21 +595,21 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
} }
#if 0 #if 0
Frequency += g_tx_vfo->step_freq / 2; // for rounding to nearest step size freq += g_tx_vfo->step_freq / 2; // for rounding to nearest step size
Frequency = FREQUENCY_floor_to_step(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].lower, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].upper); freq = FREQUENCY_floor_to_step(freq, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].lower, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].upper);
#endif #endif
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower) if (freq >= BX4819_BAND1.upper && freq < BX4819_BAND2.lower)
{ // clamp the frequency to the limit { // clamp the frequency to the limit
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2; const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_BAND1.upper - g_tx_vfo->step_freq : BX4819_BAND2.lower; freq = (freq < center) ? BX4819_BAND1.upper - g_tx_vfo->step_freq : BX4819_BAND2.lower;
} }
g_tx_vfo->freq_config_rx.frequency = Frequency; g_tx_vfo->freq_config_rx.frequency = freq;
g_tx_vfo->freq_config_tx.frequency = Frequency; g_tx_vfo->freq_config_tx.frequency = freq;
// find the first channel that contains this frequency // find the first channel that contains this frequency
g_tx_vfo->freq_in_channel = SETTINGS_find_channel(Frequency); g_tx_vfo->freq_in_channel = SETTINGS_find_channel(freq);
g_request_save_channel = 1; g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE; g_vfo_configure_mode = VFO_CONFIGURE;

Binary file not shown.

Binary file not shown.

View File

@ -17,8 +17,8 @@
#include "misc.h" #include "misc.h"
#include "ui/inputbox.h" #include "ui/inputbox.h"
unsigned int g_input_box_index;
char g_input_box[8]; char g_input_box[8];
uint8_t g_input_box_index;
uint32_t INPUTBOX_value(void) uint32_t INPUTBOX_value(void)
{ {
@ -56,4 +56,3 @@ void INPUTBOX_append(const key_code_t Digit)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
} }

View File

@ -21,8 +21,8 @@
#include "driver/keyboard.h" #include "driver/keyboard.h"
extern unsigned int g_input_box_index;
extern char g_input_box[8]; extern char g_input_box[8];
extern uint8_t g_input_box_index;
uint32_t INPUTBOX_value(void); uint32_t INPUTBOX_value(void);
void INPUTBOX_append(const key_code_t Digit); void INPUTBOX_append(const key_code_t Digit);

View File

@ -44,6 +44,12 @@
//#define SHOW_RX_TEST_VALUES //#define SHOW_RX_TEST_VALUES
//const int rssi_offset_band_123 = 0;
//const int rssi_offset_band_4567 = 0;
const int rssi_offset_band_123 = -16;
const int rssi_offset_band_4567 = 24;
center_line_t g_center_line = CENTER_LINE_NONE; center_line_t g_center_line = CENTER_LINE_NONE;
// *************************************************************************** // ***************************************************************************
@ -170,14 +176,13 @@ 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 uint16_t glitch, const uint16_t noise, const bool now) bool UI_DisplayRSSIBar(const int rssi, const unsigned int glitch, const unsigned int noise, const bool now)
{ {
if (g_eeprom.config.setting.enable_rssi_bar) if (g_eeprom.config.setting.enable_rssi_bar)
{ {
#ifdef SHOW_RX_TEST_VALUES #ifdef SHOW_RX_TEST_VALUES
const unsigned int line = 3; const unsigned int line = 3;
uint8_t *p_line = g_frame_buffer[line];
char str[22]; char str[22];
#ifdef ENABLE_KEYLOCK #ifdef ENABLE_KEYLOCK
@ -189,9 +194,9 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
return false; // display is in use return false; // display is in use
if (now) if (now)
memset(p_line, 0, LCD_WIDTH); memset(g_frame_buffer[line], 0, LCD_WIDTH);
sprintf(str, "r %3u g %3u n %3u", (uint16_t )rssi, glitch, noise); sprintf(str, "r %3d g %3u n %3u", rssi, glitch, noise);
UI_PrintStringSmall(str, 2, 0, line); UI_PrintStringSmall(str, 2, 0, line);
if (now) if (now)
@ -204,13 +209,13 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
(void)glitch; // TODO: (void)glitch; // TODO:
(void)noise; (void)noise;
// const int16_t s0_dBm = -127; // S0 .. base level // const int s0_dBm = -127; // S0 .. base level
const int16_t s0_dBm = -147; // S0 .. base level const int s0_dBm = -147; // S0 .. base level
const int16_t s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point const int s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point
const int16_t bar_max_dBm = s9_dBm + 60; // S9+60dB const int bar_max_dBm = s9_dBm + 60; // S9+60dB
// const int16_t bar_min_dBm = s0_dBm + (6 * 0); // S0 // const int bar_min_dBm = s0_dBm + (6 * 0); // S0
const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4 const int bar_min_dBm = s0_dBm + (6 * 4); // S4
// ************ // ************
@ -218,13 +223,12 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x; const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const int16_t rssi_dBm = (rssi / 2) - 160; const int rssi_dBm = (rssi / 2) - 160;
const int16_t clamped_dBm = (rssi_dBm <= bar_min_dBm) ? bar_min_dBm : (rssi_dBm >= bar_max_dBm) ? bar_max_dBm : rssi_dBm; const int clamped_dBm = (rssi_dBm <= bar_min_dBm) ? bar_min_dBm : (rssi_dBm >= bar_max_dBm) ? bar_max_dBm : rssi_dBm;
const unsigned int bar_range_dB = bar_max_dBm - bar_min_dBm; const unsigned int bar_range_dB = bar_max_dBm - bar_min_dBm;
const unsigned int len = ((clamped_dBm - bar_min_dBm) * bar_width) / bar_range_dB; const unsigned int len = ((clamped_dBm - bar_min_dBm) * bar_width) / bar_range_dB;
const unsigned int line = 3; const unsigned int line = 3;
uint8_t *p_line = g_frame_buffer[line];
char s[16]; char s[16];
@ -239,7 +243,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
return false; // display is in use return false; // display is in use
if (now) if (now)
memset(p_line, 0, LCD_WIDTH); memset(g_frame_buffer[line], 0, LCD_WIDTH);
if (rssi_dBm >= (s9_dBm + 6)) if (rssi_dBm >= (s9_dBm + 6))
{ // S9+XXdB, 1dB increment { // S9+XXdB, 1dB increment
@ -254,7 +258,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
} }
UI_PrintStringSmall(s, 2, 0, line); UI_PrintStringSmall(s, 2, 0, line);
draw_bar(p_line + bar_x, len, bar_width); draw_bar(g_frame_buffer[line] + bar_x, len, bar_width);
if (now) if (now)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
@ -268,27 +272,31 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
} }
#endif #endif
void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t noise, const int vfo) void UI_update_rssi(const int rssi, const unsigned int glitch, const unsigned int noise, const unsigned 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 { // large RSSI dBm, S-point, bar level
const int rssi_level = (g_tx_vfo->channel_attributes.band < 3) ? rssi + rssi_offset_band_123 : rssi + rssi_offset_band_4567;
//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, glitch, noise, true); UI_DisplayRSSIBar(rssi_level, glitch, noise, true);
} }
#else #else
(void)glitch; (void)glitch;
(void)noise; (void)noise;
#endif #endif
{ // original little RS bars { // original little RSSI bars
// const int16_t dBm = (rssi / 2) - 160; const unsigned int line = (vfo == 0) ? 3 : 7;
const uint8_t line = (vfo == 0) ? 3 : 7;
uint8_t *pline = g_frame_buffer[line - 1]; uint8_t *pline = g_frame_buffer[line - 1];
unsigned int rssi_level = 0; unsigned int rssi_level = 0;
int16_t rssi_cal[7]; int rssi_cal[7];
#if 1 #if 1
if (g_tx_vfo->channel_attributes.band < 3) if (g_tx_vfo->channel_attributes.band < 3)
@ -306,10 +314,10 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no
rssi_cal[6] = g_eeprom.calib.rssi_cal.band_4567[3]; rssi_cal[6] = g_eeprom.calib.rssi_cal.band_4567[3];
} }
#else #else
rssi_cal[0] = (-110 + 160) * 2; // -110 dBm rssi_cal[0] = (-110 + rssi_dBm_offset) * 2; // -110 dBm
rssi_cal[2] = ( -90 + 160) * 2; // -90 dBm rssi_cal[2] = ( -90 + rssi_dBm_offset) * 2; // -90 dBm
rssi_cal[4] = ( -70 + 160) * 2; // -70 dBm rssi_cal[4] = ( -70 + rssi_dBm_offset) * 2; // -70 dBm
rssi_cal[6] = ( -50 + 160) * 2; // -50 dBm rssi_cal[6] = ( -50 + rssi_dBm_offset) * 2; // -50 dBm
#endif #endif
// linear interpolate the 4 values into 7 // linear interpolate the 4 values into 7
rssi_cal[1] = (rssi_cal[0] + rssi_cal[2]) / 2; rssi_cal[1] = (rssi_cal[0] + rssi_cal[2]) / 2;
@ -339,9 +347,6 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no
if (rssi >= rssi_cal[0] || g_current_function == FUNCTION_NEW_RECEIVE) if (rssi >= rssi_cal[0] || g_current_function == FUNCTION_NEW_RECEIVE)
rssi_level = 1; rssi_level = 1;
// if (g_vfo_rssi_bar_level[vfo] == rssi_level)
// return;
g_vfo_rssi_bar_level[vfo] = rssi_level; g_vfo_rssi_bar_level[vfo] = rssi_level;
// ********************************************************** // **********************************************************
@ -354,12 +359,8 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN) if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return; // display is in use return; // display is in use
pline = g_frame_buffer[line - 1];
memset(pline, 0, 23); memset(pline, 0, 23);
// untested !!!
if (rssi_level == 0) if (rssi_level == 0)
pline = NULL; pline = NULL;
else else
@ -946,8 +947,9 @@ void UI_DisplayMain(void)
// show the RX RSSI dBm, S-point and signal strength bar graph // show the RX RSSI dBm, S-point and signal strength bar graph
if (rx && g_eeprom.config.setting.enable_rssi_bar) if (rx && g_eeprom.config.setting.enable_rssi_bar)
{ {
const int rssi_level = (g_tx_vfo->channel_attributes.band < 3) ? g_current_rssi[g_rx_vfo_num] + rssi_offset_band_123 : g_current_rssi[g_rx_vfo_num] + rssi_offset_band_4567;
g_center_line = CENTER_LINE_RSSI; g_center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(g_current_rssi[g_rx_vfo_num], g_current_glitch[g_rx_vfo_num], g_current_noise[g_rx_vfo_num], false); UI_DisplayRSSIBar(rssi_level, 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 uint16_t glitch, const uint16_t noise, const int vfo); void UI_update_rssi(const int rssi, const unsigned int glitch, const unsigned int noise, const unsigned int vfo);
void UI_DisplayMain(void); void UI_DisplayMain(void);
#endif #endif