mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
fix saving user TX power level
This commit is contained in:
parent
a49af16dda
commit
1d9cdeecf5
@ -143,6 +143,7 @@ void toggle_chan_scanlist(void)
|
|||||||
|
|
||||||
RADIO_select_vfos();
|
RADIO_select_vfos();
|
||||||
RADIO_apply_offset(g_tx_vfo, false);
|
RADIO_apply_offset(g_tx_vfo, false);
|
||||||
|
|
||||||
RADIO_ConfigureSquelch(g_tx_vfo);
|
RADIO_ConfigureSquelch(g_tx_vfo);
|
||||||
// RADIO_ConfigureTXPower(g_tx_vfo);
|
// RADIO_ConfigureTXPower(g_tx_vfo);
|
||||||
RADIO_setup_registers(true);
|
RADIO_setup_registers(true);
|
||||||
|
@ -1697,21 +1697,18 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
|
|||||||
g_ask_for_confirmation = 0;
|
g_ask_for_confirmation = 0;
|
||||||
g_in_sub_menu = true;
|
g_in_sub_menu = true;
|
||||||
|
|
||||||
// if (g_menu_cursor != MENU_DTMF_LIST)
|
|
||||||
{
|
|
||||||
g_input_box_index = 0;
|
g_input_box_index = 0;
|
||||||
g_edit_index = -1;
|
g_edit_index = -1;
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_menu_cursor == MENU_TX_POWER)
|
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)
|
if (g_edit_index < 0)
|
||||||
{
|
{ // start editing the power level
|
||||||
g_edit_index = g_tx_vfo->channel.tx_power_user;
|
g_edit_index = g_tx_vfo->channel.tx_power_user;
|
||||||
}
|
}
|
||||||
else
|
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_tx_vfo->channel.tx_power_user = g_edit_index;
|
||||||
g_request_save_channel = 1;
|
g_request_save_channel = 1;
|
||||||
|
|
||||||
|
g_flag_accept_setting = true;
|
||||||
g_in_sub_menu = false;
|
g_in_sub_menu = false;
|
||||||
g_edit_index = -1;
|
g_edit_index = -1;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ void BACKLIGHT_set_brightness(unsigned int brightness)
|
|||||||
if (brightness > BACKLIGHT_MAX_BRIGHTNESS)
|
if (brightness > BACKLIGHT_MAX_BRIGHTNESS)
|
||||||
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_CH0_COMP = (1023ul * brightness * brightness * brightness) / (BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS);
|
||||||
//PWM_PLUS0_SWLOAD = 1;
|
//PWM_PLUS0_SWLOAD = 1;
|
||||||
}
|
}
|
||||||
|
39
driver/i2c.c
39
driver/i2c.c
@ -47,24 +47,20 @@ void I2C_Stop(void)
|
|||||||
uint8_t I2C_Read(const bool end, const bool fast)
|
uint8_t I2C_Read(const bool end, const bool fast)
|
||||||
{
|
{
|
||||||
const unsigned int delay = fast ? 2 : 4;
|
const unsigned int delay = fast ? 2 : 4;
|
||||||
unsigned int i;
|
int i = 8;
|
||||||
uint8_t Data;
|
uint8_t data = 0;
|
||||||
|
|
||||||
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
|
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
|
||||||
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
||||||
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
|
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
|
||||||
|
|
||||||
Data = 0;
|
while (--i >= 0)
|
||||||
for (i = 0; i < 8; i++)
|
|
||||||
{
|
{
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(delay);
|
SYSTICK_Delay250ns(delay);
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(delay);
|
SYSTICK_Delay250ns(delay);
|
||||||
Data <<= 1;
|
data = (data << 1) | (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA) ? 1u : 0u);
|
||||||
SYSTICK_Delay250ns(delay);
|
|
||||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA))
|
|
||||||
Data |= 1U;
|
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(delay);
|
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);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(delay);
|
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;
|
int ret = -1;
|
||||||
|
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
for (i = 0; i < 8; i++)
|
while (--i >= 0)
|
||||||
{
|
{
|
||||||
if ((Data & 0x80) == 0)
|
if ((data & 0x80) == 0)
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||||
else
|
else
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||||
Data <<= 1;
|
data <<= 1;
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
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_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
|
||||||
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
||||||
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
|
GPIOA->DIR &= ~GPIO_DIR_11_MASK;
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
|
|
||||||
for (i = 0; i < 255; i++)
|
for (i = 0; i < 255; i++)
|
||||||
{
|
{
|
||||||
@ -126,7 +123,7 @@ int I2C_Write(uint8_t Data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||||
SYSTICK_Delay250ns(4);
|
SYSTICK_Delay250ns(delay);
|
||||||
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
||||||
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
||||||
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
||||||
|
@ -29,7 +29,7 @@ void I2C_Start(void);
|
|||||||
void I2C_Stop(void);
|
void I2C_Stop(void);
|
||||||
|
|
||||||
uint8_t I2C_Read(const bool end, const bool fast);
|
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_ReadBuffer(void *pBuffer, unsigned int Size, const bool fast);
|
||||||
int I2C_WriteBuffer(const void *pBuffer, unsigned int Size);
|
int I2C_WriteBuffer(const void *pBuffer, unsigned int Size);
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
24
settings.c
24
settings.c
@ -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;
|
p_vfo->channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode < 2 && channel <= USER_CHANNEL_LAST)
|
if (mode <= 1 && channel <= USER_CHANNEL_LAST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{ // save the channel to EEPROM
|
{ // 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));
|
memset(&m_channel, 0xff, sizeof(t_channel));
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#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
|
#endif
|
||||||
|
|
||||||
memcpy(&g_eeprom.config.channel[chan], &m_channel, sizeof(t_channel));
|
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);
|
EEPROM_WriteBuffer8(addr + 8, ((uint8_t *)&m_channel) + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****************
|
|
||||||
|
|
||||||
// SETTINGS_save_vfo_indices();
|
// SETTINGS_save_vfo_indices();
|
||||||
|
|
||||||
SETTINGS_save_chan_attribs_name(channel, p_vfo);
|
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
|
||||||
{ // 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]));
|
|
||||||
|
|
||||||
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)
|
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));
|
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
|
// save the channel name
|
||||||
if (mode >= 3 || p_vfo == NULL)
|
if (mode >= 3 || p_vfo == NULL)
|
||||||
SETTINGS_save_chan_name(channel);
|
SETTINGS_save_chan_name(channel);
|
||||||
}
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void SETTINGS_save_chan_name(const unsigned int 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)
|
if (channel <= USER_CHANNEL_LAST)
|
||||||
{ // user memory channel
|
{ // user channel
|
||||||
if (p_vfo != NULL)
|
if (p_vfo != NULL)
|
||||||
{
|
{
|
||||||
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]));
|
||||||
|
@ -692,8 +692,7 @@ void UI_DisplayMain(void)
|
|||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
// show the frequency band number
|
// show the frequency band number
|
||||||
const unsigned int x = 2; // was 14
|
const unsigned int x = 2; // was 14
|
||||||
// sprintf(String, "FB%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
|
sprintf(str, "F%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
|
||||||
sprintf(str, "VFO%u", 1 + scrn_chan - FREQ_CHANNEL_FIRST);
|
|
||||||
UI_PrintStringSmall(str, x, 0, line + 1);
|
UI_PrintStringSmall(str, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user