0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 06:11:24 +03:00

fix saving user TX power level

This commit is contained in:
OneOfEleven 2023-11-25 08:52:23 +00:00
parent a49af16dda
commit 1d9cdeecf5
9 changed files with 46 additions and 48 deletions

View File

@ -143,6 +143,7 @@ void toggle_chan_scanlist(void)
RADIO_select_vfos();
RADIO_apply_offset(g_tx_vfo, false);
RADIO_ConfigureSquelch(g_tx_vfo);
// RADIO_ConfigureTXPower(g_tx_vfo);
RADIO_setup_registers(true);

View File

@ -1697,21 +1697,18 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
g_ask_for_confirmation = 0;
g_in_sub_menu = true;
// if (g_menu_cursor != MENU_DTMF_LIST)
{
g_input_box_index = 0;
g_edit_index = -1;
}
return;
}
if (g_menu_cursor == MENU_TX_POWER)
{
if (g_in_sub_menu && g_sub_menu_selection == OUTPUT_POWER_USER)
if (g_sub_menu_selection == OUTPUT_POWER_USER)
{
if (g_edit_index < 0)
{
{ // start editing the power level
g_edit_index = g_tx_vfo->channel.tx_power_user;
}
else
@ -1719,6 +1716,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
g_tx_vfo->channel.tx_power_user = g_edit_index;
g_request_save_channel = 1;
g_flag_accept_setting = true;
g_in_sub_menu = false;
g_edit_index = -1;
}

View File

@ -62,6 +62,7 @@ void BACKLIGHT_set_brightness(unsigned int brightness)
if (brightness > BACKLIGHT_MAX_BRIGHTNESS)
brightness = BACKLIGHT_MAX_BRIGHTNESS;
// 0 ~ 1023 logify it though
PWM_PLUS0_CH0_COMP = (1023ul * brightness * brightness * brightness) / (BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS);
//PWM_PLUS0_SWLOAD = 1;
}

View File

@ -47,24 +47,20 @@ void I2C_Stop(void)
uint8_t I2C_Read(const bool end, const bool fast)
{
const unsigned int delay = fast ? 2 : 4;
unsigned int i;
uint8_t Data;
int i = 8;
uint8_t data = 0;
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
Data = 0;
for (i = 0; i < 8; i++)
while (--i >= 0)
{
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(delay);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(delay);
Data <<= 1;
SYSTICK_Delay250ns(delay);
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA))
Data |= 1U;
data = (data << 1) | (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA) ? 1u : 0u);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(delay);
}
@ -84,37 +80,38 @@ uint8_t I2C_Read(const bool end, const bool fast)
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(delay);
return Data;
return data;
}
int I2C_Write(uint8_t Data)
int I2C_Write(uint8_t data) //, const bool fast)
{
uint8_t i;
const unsigned int delay = 4; // fast ? 2 : 4;
int i = 8;
int ret = -1;
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(4);
for (i = 0; i < 8; i++)
SYSTICK_Delay250ns(delay);
while (--i >= 0)
{
if ((Data & 0x80) == 0)
if ((data & 0x80) == 0)
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
else
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
Data <<= 1;
SYSTICK_Delay250ns(4);
data <<= 1;
SYSTICK_Delay250ns(delay);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(4);
SYSTICK_Delay250ns(delay);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(4);
SYSTICK_Delay250ns(delay);
}
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
SYSTICK_Delay250ns(4);
SYSTICK_Delay250ns(delay);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(4);
SYSTICK_Delay250ns(delay);
for (i = 0; i < 255; i++)
{
@ -126,7 +123,7 @@ int I2C_Write(uint8_t Data)
}
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
SYSTICK_Delay250ns(4);
SYSTICK_Delay250ns(delay);
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;

View File

@ -29,7 +29,7 @@ void I2C_Start(void);
void I2C_Stop(void);
uint8_t I2C_Read(const bool end, const bool fast);
int I2C_Write(uint8_t Data);
int I2C_Write(uint8_t data);
int I2C_ReadBuffer(void *pBuffer, unsigned int Size, const bool fast);
int I2C_WriteBuffer(const void *pBuffer, unsigned int Size);

Binary file not shown.

Binary file not shown.

View File

@ -473,11 +473,11 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, v
p_vfo->channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
#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);
// 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 (mode < 2 && channel <= USER_CHANNEL_LAST)
if (mode <= 1 && channel <= USER_CHANNEL_LAST)
return;
{ // save the channel to EEPROM
@ -493,7 +493,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, v
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);
// 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));
@ -507,25 +507,27 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, v
EEPROM_WriteBuffer8(addr + 8, ((uint8_t *)&m_channel) + 8);
}
// ****************
// SETTINGS_save_vfo_indices();
SETTINGS_save_chan_attribs_name(channel, p_vfo);
/*
if (channel > USER_CHANNEL_LAST)
return;
if (channel <= USER_CHANNEL_LAST)
{ // user channel, it has a channel name
memset(&g_eeprom.config.channel_name[channel], (p_vfo != NULL) ? 0x00 : 0xff, sizeof(g_eeprom.config.channel_name[channel]));
// user channel, it has a channel name
SETTINGS_save_chan_name(channel);
// memset(&g_eeprom.config.channel_name[channel], (p_vfo != NULL) ? 0x00 : 0xff, sizeof(g_eeprom.config.channel_name[channel]));
// SETTINGS_save_chan_name(channel);
if (p_vfo != NULL)
memcpy(g_eeprom.config.channel_name[channel].name, p_vfo->channel_name.name, sizeof(g_eeprom.config.channel_name[channel].name));
else
memset(&g_eeprom.config.channel_name[channel], 0xff, sizeof(g_eeprom.config.channel_name[channel]));
// save the channel name
if (mode >= 3 || p_vfo == NULL)
SETTINGS_save_chan_name(channel);
}
*/
}
void SETTINGS_save_chan_name(const unsigned int channel)
@ -562,7 +564,7 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_
}
if (channel <= USER_CHANNEL_LAST)
{ // user memory channel
{ // user channel
if (p_vfo != NULL)
{
memset(&g_eeprom.config.channel_name[channel], 0, sizeof(g_eeprom.config.channel_name[channel]));

View File

@ -692,8 +692,7 @@ void UI_DisplayMain(void)
{ // frequency mode
// show the frequency band number
const unsigned int x = 2; // was 14
// sprintf(String, "FB%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
sprintf(str, "VFO%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
sprintf(str, "F%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
UI_PrintStringSmall(str, x, 0, line + 1);
}
#ifdef ENABLE_NOAA