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

improve TX offset menu function

This commit is contained in:
OneOfEleven 2023-11-03 10:39:43 +00:00
parent 7e5605cd18
commit 5ca9733a4c
10 changed files with 98 additions and 106 deletions

View File

@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
# UART Programming 2.9 kB # UART Programming 2.9 kB
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 0 ENABLE_UART_DEBUG := 1
# AirCopy 2.5 kB # AirCopy 2.5 kB
ENABLE_AIRCOPY := 0 ENABLE_AIRCOPY := 0
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1
@ -21,7 +21,7 @@ ENABLE_AIRCOPY_RX_REBOOT := 0
ENABLE_FMRADIO_64_76 := 0 ENABLE_FMRADIO_64_76 := 0
ENABLE_FMRADIO_76_90 := 0 ENABLE_FMRADIO_76_90 := 0
ENABLE_FMRADIO_76_108 := 0 ENABLE_FMRADIO_76_108 := 0
ENABLE_FMRADIO_875_108 := 0 ENABLE_FMRADIO_875_108 := 1
ENABLE_FMRADIO_64_108 := 0 ENABLE_FMRADIO_64_108 := 0
# NOAA 1.2 kB # NOAA 1.2 kB
ENABLE_NOAA := 0 ENABLE_NOAA := 0
@ -36,7 +36,7 @@ ENABLE_REDUCE_LOW_MID_TX_POWER := 1
ENABLE_ALARM := 0 ENABLE_ALARM := 0
ENABLE_TX1750 := 0 ENABLE_TX1750 := 0
# MDC1200 2.8 kB # MDC1200 2.8 kB
ENABLE_MDC1200 := 1 ENABLE_MDC1200 := 0
ENABLE_MDC1200_SHOW_OP_ARG := 1 ENABLE_MDC1200_SHOW_OP_ARG := 1
ENABLE_PWRON_PASSWORD := 0 ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 0 ENABLE_RESET_AES_KEY := 0

View File

@ -908,16 +908,19 @@ void APP_process_radio_interrupts(void)
int_bits = BK4819_ReadRegister(0x02); int_bits = BK4819_ReadRegister(0x02);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
{ #ifdef ENABLE_AIRCOPY
int i; if (g_current_display_screen != DISPLAY_AIRCOPY)
UART_printf("int bits %04X %04X ", reg_c, int_bits); #endif
for (i = 15; i >= 0; i--) {
UART_printf("%c", (reg_c & (1u << i)) ? '#' : '.'); int i;
UART_SendText(" "); UART_printf("int bits %04X %04X ", reg_c, int_bits);
for (i = 15; i >= 0; i--) for (i = 15; i >= 0; i--)
UART_printf("%c", (int_bits & (1u << i)) ? '#' : '.'); UART_printf("%c", (reg_c & (1u << i)) ? '#' : '.');
UART_SendText("\r\n"); UART_SendText(" ");
} for (i = 15; i >= 0; i--)
UART_printf("%c", (int_bits & (1u << i)) ? '#' : '.');
UART_SendText("\r\n");
}
#endif #endif
if (int_bits & BK4819_REG_02_DTMF_5TONE_FOUND) if (int_bits & BK4819_REG_02_DTMF_5TONE_FOUND)

View File

@ -1433,6 +1433,11 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
{ {
uint32_t Frequency; uint32_t Frequency;
NUMBER_Get(g_input_box, &Frequency);
if (g_input_box_index > 0)
g_sub_menu_selection = Frequency;
if (g_input_box_index < 8) if (g_input_box_index < 8)
{ // not yet enough characters { // not yet enough characters
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -1441,13 +1446,12 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
return; return;
} }
g_input_box_index = 0;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
NUMBER_Get(g_input_box, &Frequency);
g_input_box_index = 0;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 3 %u\r\n", Frequency); UART_printf("offset 3 %u\r\n", Frequency);
#endif #endif
@ -1460,7 +1464,7 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
#endif #endif
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("offset 4 %u\r\n", Frequency); // UART_printf("offset 4 %u\r\n", Frequency);
#endif #endif
g_sub_menu_selection = Frequency; g_sub_menu_selection = Frequency;
@ -1575,9 +1579,9 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
g_input_box_index = 0; g_input_box_index = 0;
g_flag_refresh_menu = true; g_flag_refresh_menu = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
} }
else else
g_input_box[--g_input_box_index] = 10; g_input_box[--g_input_box_index] = 10;
@ -1588,9 +1592,9 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
return; return;
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
g_request_display_screen = DISPLAY_MAIN; g_request_display_screen = DISPLAY_MAIN;
@ -1604,9 +1608,9 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
{ {
MENU_stop_css_scan(); MENU_stop_css_scan();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
g_request_display_screen = DISPLAY_MENU; g_request_display_screen = DISPLAY_MENU;
} }

Binary file not shown.

Binary file not shown.

View File

@ -63,7 +63,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
if (Channel > USER_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
return false; return false;
if (g_user_channel_attributes[Channel].band > BAND7_470MHz) if (g_eeprom.config.channel_attributes[Channel].band > BAND7_470MHz)
return false; return false;
if (bCheckScanList) if (bCheckScanList)
@ -71,7 +71,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
switch (VFO) switch (VFO)
{ {
case 0: case 0:
if (g_user_channel_attributes[Channel].scanlist1 == 0) if (g_eeprom.config.channel_attributes[Channel].scanlist1 == 0)
return false; return false;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -79,7 +79,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
break; break;
case 1: case 1:
if (g_user_channel_attributes[Channel].scanlist2 == 0) if (g_eeprom.config.channel_attributes[Channel].scanlist2 == 0)
return false; return false;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -208,7 +208,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
chan = CHANNEL_NUM(channel, VFO); chan = CHANNEL_NUM(channel, VFO);
attributes = g_user_channel_attributes[channel]; attributes = g_eeprom.config.channel_attributes[channel];
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("config chan 1 %u %u %u %u %u\r\n", channel, chan, attributes.band, attributes.scanlist1, attributes.scanlist2); // UART_printf("config chan 1 %u %u %u %u %u\r\n", channel, chan, attributes.band, attributes.scanlist1, attributes.scanlist2);

View File

@ -41,9 +41,7 @@ static const uint32_t DEFAULT_FREQUENCY_TABLE[] =
43350000 // 43350000 //
}; };
t_eeprom g_eeprom; t_eeprom g_eeprom;
t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
void SETTINGS_write_eeprom_config(void) void SETTINGS_write_eeprom_config(void)
{ // save the entire EEPROM config contents { // save the entire EEPROM config contents
@ -352,19 +350,21 @@ void SETTINGS_read_eeprom(void)
} }
} }
#endif
#if 1
{ // 0D60 { // 0D60
for (index = 0; index < 7; index++) // default VFO attribs for (index = 0; index < 7; index++) // default VFO attribs
g_eeprom.config.channel_attributes[200 + index].attributes = 0xC0 | index; g_eeprom.config.channel_attributes[200 + index].attributes = 0xC0 | index;
g_eeprom.config.channel_attributes[200 + 7].attributes = 0x00; g_eeprom.config.channel_attributes[200 + 7].attributes = 0x00;
SETTINGS_save_attributes(); // SETTINGS_save_attributes();
} }
#endif #endif
memcpy(&g_user_channel_attributes, &g_eeprom.config.channel_attributes, sizeof(g_user_channel_attributes));
// **************************************** // ****************************************
memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3)); memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3));
@ -446,48 +446,51 @@ void SETTINGS_save(void)
void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, vfo_info_t *p_vfo, const unsigned int mode) void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, vfo_info_t *p_vfo, const unsigned int mode)
{ {
const unsigned int chan = CHANNEL_NUM(channel, vfo); if (!IS_USER_CHANNEL(channel) && !IS_FREQ_CHANNEL(channel))
t_channel *p_channel = &g_eeprom.config.channel[chan];
unsigned int eeprom_addr = chan * 16;
if (IS_NOAA_CHANNEL(channel))
return; return;
if (mode < 2 && channel <= USER_CHANNEL_LAST)
return;
// ****************
if (p_vfo != NULL) if (p_vfo != NULL)
{ {
memset(p_channel, 0, sizeof(t_channel));
p_vfo->channel.frequency = p_vfo->freq_config_rx.frequency; p_vfo->channel.frequency = p_vfo->freq_config_rx.frequency;
p_vfo->channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code; p_vfo->channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code;
p_vfo->channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code; p_vfo->channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code;
p_vfo->channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type; p_vfo->channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type;
p_vfo->channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type; p_vfo->channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
memcpy(p_channel, &p_vfo->channel, sizeof(t_channel)); #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("save chan 1 %u %u %u %uHz %uHz\r\n", channel, vfo, mode, p_vfo->channel.frequency * 10, p_vfo->channel.tx_offset * 10);
#endif
}
if (IS_USER_CHANNEL(channel)) if (mode < 2 && channel <= USER_CHANNEL_LAST)
g_eeprom.config.channel_attributes[channel] = g_user_channel_attributes[channel]; return;
{ // save the channel to EEPROM
const unsigned int chan = CHANNEL_NUM(channel, vfo);
const unsigned int addr = sizeof(t_channel) * chan;
t_channel m_channel;
if (p_vfo != NULL)
memcpy(&m_channel, &p_vfo->channel, sizeof(t_channel));
else
if (channel <= USER_CHANNEL_LAST)
memset(&m_channel, 0xff, sizeof(t_channel));
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("save chan 2 %04X %3u %3u %u %u %uHz %uHz\r\n", addr, chan, channel, vfo, mode, m_channel.frequency * 10, m_channel.tx_offset * 10);
#endif
memcpy(&g_eeprom.config.channel[chan], &m_channel, sizeof(t_channel));
g_eeprom.config.channel_attributes[channel] = p_vfo->channel_attributes;
memset(&g_eeprom.config.channel_name[channel], 0, sizeof(g_eeprom.config.channel_name[channel])); memset(&g_eeprom.config.channel_name[channel], 0, sizeof(g_eeprom.config.channel_name[channel]));
memcpy(g_eeprom.config.channel_name[channel].name, p_vfo->channel_name.name, sizeof(g_eeprom.config.channel_name[channel].name)); memcpy(g_eeprom.config.channel_name[channel].name, p_vfo->channel_name.name, sizeof(g_eeprom.config.channel_name[channel].name));
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) EEPROM_WriteBuffer8(addr + 0, ((uint8_t *)&m_channel) + 0);
// UART_printf("save chan %04X %3u %3u %u %u %uHz\r\n", eeprom_addr, chan, channel, vfo, mode, p_channel->frequency * 10); EEPROM_WriteBuffer8(addr + 8, ((uint8_t *)&m_channel) + 8);
#endif
} }
else
if (channel <= USER_CHANNEL_LAST)
{ // user channel
memset(p_channel, 0xff, sizeof(t_channel));
}
EEPROM_WriteBuffer8(eeprom_addr + 0, ((uint8_t *)p_channel) + 0);
EEPROM_WriteBuffer8(eeprom_addr + 8, ((uint8_t *)p_channel) + 8);
// **************** // ****************
@ -525,28 +528,19 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_
{ {
const unsigned int index = channel & ~7u; // eeprom writes are always 8 bytes in length const unsigned int index = channel & ~7u; // eeprom writes are always 8 bytes in length
if (channel >= ARRAY_SIZE(g_user_channel_attributes)) if (!IS_USER_CHANNEL(channel) && !IS_FREQ_CHANNEL(channel))
return;
if (IS_NOAA_CHANNEL(channel))
return; return;
if (p_vfo != NULL) if (p_vfo != NULL)
{ // channel attributes { // channel attributes
g_eeprom.config.channel_attributes[channel] = p_vfo->channel_attributes;
t_channel_attrib attribs = p_vfo->channel_attributes; EEPROM_WriteBuffer8(0x0D60 + index, &g_eeprom.config.channel_attributes[index]);
g_user_channel_attributes[channel] = attribs; // remember new attributes
g_eeprom.config.channel_attributes[channel] = attribs;
EEPROM_WriteBuffer8(0x0D60 + index, &g_user_channel_attributes[index]);
} }
else else
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
{ // user channel { // user channel
g_user_channel_attributes[channel].attributes = 0xff;
g_eeprom.config.channel_attributes[channel].attributes = 0xff; g_eeprom.config.channel_attributes[channel].attributes = 0xff;
EEPROM_WriteBuffer8(0x0D60 + index, &g_eeprom.config.channel_attributes[index]);
EEPROM_WriteBuffer8(0x0D60 + index, &g_user_channel_attributes[index]);
} }
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
@ -586,12 +580,10 @@ unsigned int SETTINGS_find_channel(const uint32_t frequency)
for (chan = 0; chan <= USER_CHANNEL_LAST; chan++) for (chan = 0; chan <= USER_CHANNEL_LAST; chan++)
{ {
const uint32_t freq = g_eeprom.config.channel[chan].frequency; const uint32_t freq = g_eeprom.config.channel[chan].frequency;
if (g_eeprom.config.channel_attributes[chan].band > BAND7_470MHz || freq == 0 || freq == 0xffffffff)
if (g_user_channel_attributes[chan].band > BAND7_470MHz || freq == 0 || freq == 0xffffffff)
continue; continue;
if (freq == frequency) if (freq == frequency)
return chan; // found it return chan; // found it
} }
return 0xffffffff; return 0xffffffff;
@ -606,7 +598,7 @@ uint32_t SETTINGS_fetch_channel_frequency(const int channel)
freq = g_eeprom.config.channel[channel].frequency; freq = g_eeprom.config.channel[channel].frequency;
if (g_user_channel_attributes[channel].band > BAND7_470MHz || freq == 0 || freq == 0xffffffff) if (g_eeprom.config.channel_attributes[channel].band > BAND7_470MHz || freq == 0 || freq == 0xffffffff)
return 0; return 0;
return freq; return freq;
@ -656,7 +648,7 @@ void SETTINGS_fetch_channel_name(char *s, const int channel)
if (channel < 0 || channel > (int)USER_CHANNEL_LAST) if (channel < 0 || channel > (int)USER_CHANNEL_LAST)
return; return;
if (g_user_channel_attributes[channel].band > BAND7_470MHz) if (g_eeprom.config.channel_attributes[channel].band > BAND7_470MHz)
return; return;
memcpy(s, &g_eeprom.config.channel_name[channel], 10); memcpy(s, &g_eeprom.config.channel_name[channel], 10);

View File

@ -237,6 +237,11 @@ typedef union {
uint8_t attributes; uint8_t attributes;
} __attribute__((packed)) t_channel_attrib; } __attribute__((packed)) t_channel_attrib;
typedef struct {
char name[10];
uint8_t unused[6];
} __attribute__((packed)) t_channel_name;
// user configuration // user configuration
typedef struct { typedef struct {
@ -409,10 +414,7 @@ typedef struct {
} __attribute__((packed)) setting; } __attribute__((packed)) setting;
// 0x0F50 // 0x0F50
struct { t_channel_name channel_name[USER_CHANNEL_LAST - USER_CHANNEL_FIRST + 1];
char name[10];
uint8_t unused[6]; // 0xff's
} __attribute__((packed)) channel_name[USER_CHANNEL_LAST - USER_CHANNEL_FIRST + 1];
// 0x1BD0 // 0x1BD0
uint8_t unused13[16 * 3]; // 0xff's .. free to use uint8_t unused13[16 * 3]; // 0xff's .. free to use
@ -516,6 +518,10 @@ typedef struct
typedef struct vfo_info_t typedef struct vfo_info_t
{ {
t_channel channel;
t_channel_attrib channel_attributes;
t_channel_name channel_name;
uint8_t channel_save; uint8_t channel_save;
freq_config_t freq_config_rx; freq_config_t freq_config_rx;
@ -523,25 +529,18 @@ typedef struct vfo_info_t
freq_config_t *p_rx; freq_config_t *p_rx;
freq_config_t *p_tx; freq_config_t *p_tx;
t_channel channel;
t_channel_attrib channel_attributes;
struct {
char name[10];
uint8_t unused[6];
} channel_name;
uint16_t step_freq; uint16_t step_freq;
uint8_t freq_in_channel; // channel number where we also found this VFO's frequency uint8_t freq_in_channel; // first channel number we found this VFO's frequency in
uint8_t squelch_open_rssi_thresh;
uint8_t squelch_close_rssi_thresh;
uint8_t squelch_open_noise_thresh;
uint8_t squelch_close_noise_thresh;
uint8_t squelch_open_glitch_thresh; uint8_t squelch_open_glitch_thresh;
uint8_t squelch_open_rssi_thresh;
uint8_t squelch_open_noise_thresh;
uint8_t squelch_close_glitch_thresh; uint8_t squelch_close_glitch_thresh;
uint8_t squelch_close_rssi_thresh;
uint8_t squelch_close_noise_thresh;
uint8_t txp_calculated_setting; uint8_t txp_calculated_setting;
@ -549,8 +548,7 @@ typedef struct vfo_info_t
// ************************************************ // ************************************************
extern t_eeprom g_eeprom; extern t_eeprom g_eeprom;
extern t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
void SETTINGS_read_eeprom(void); void SETTINGS_read_eeprom(void);
void SETTINGS_write_eeprom_config(void); void SETTINGS_write_eeprom_config(void);

View File

@ -700,13 +700,11 @@ void UI_DisplayMain(void)
unsigned int x = LCD_WIDTH - 1 - sizeof(BITMAP_SCANLIST2) - sizeof(BITMAP_SCANLIST1); unsigned int x = LCD_WIDTH - 1 - sizeof(BITMAP_SCANLIST2) - sizeof(BITMAP_SCANLIST1);
const t_channel_attrib attributes = g_user_channel_attributes[scrn_chan]; if (g_vfo_info[vfo_num].channel_attributes.scanlist1)
if (attributes.scanlist1)
memcpy(p_line0 + x, BITMAP_SCANLIST1, sizeof(BITMAP_SCANLIST1)); memcpy(p_line0 + x, BITMAP_SCANLIST1, sizeof(BITMAP_SCANLIST1));
x += sizeof(BITMAP_SCANLIST1); x += sizeof(BITMAP_SCANLIST1);
if (attributes.scanlist2) if (g_vfo_info[vfo_num].channel_attributes.scanlist2)
memcpy(p_line0 + x, BITMAP_SCANLIST2, sizeof(BITMAP_SCANLIST2)); memcpy(p_line0 + x, BITMAP_SCANLIST2, sizeof(BITMAP_SCANLIST2));
//x += sizeof(BITMAP_SCANLIST2); //x += sizeof(BITMAP_SCANLIST2);
} }

View File

@ -672,10 +672,7 @@ void UI_DisplayMenu(void)
channel_setting = true; channel_setting = true;
if (!g_in_sub_menu || g_input_box_index == 0) if (!g_in_sub_menu || g_input_box_index == 0)
{ {
sprintf(str, "%d.%05u", g_sub_menu_selection / 100000, abs(g_sub_menu_selection) % 100000); sprintf(str, "%03d.%05u", g_sub_menu_selection / 100000, abs(g_sub_menu_selection) % 100000);
#ifdef ENABLE_TRIM_TRAILING_ZEROS
NUMBER_trim_trailing_zeros(str);
#endif
UI_PrintString(str, sub_menu_x1, sub_menu_x2, 1, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 1, 8);
} }
else else