mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 06:11:24 +03:00
Simplified user TX power menu
This commit is contained in:
parent
f24b6b41bf
commit
ecfc99c81c
60
app/menu.c
60
app/menu.c
@ -125,11 +125,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
*pMax = ARRAY_SIZE(g_sub_menu_tx_power) - 1;
|
||||
break;
|
||||
|
||||
case MENU_TX_POWER_USER:
|
||||
*pMin = 0;
|
||||
*pMax = 15;
|
||||
break;
|
||||
|
||||
case MENU_SHIFT_DIR:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(g_sub_menu_shift_dir) - 1;
|
||||
@ -436,11 +431,6 @@ void MENU_AcceptSetting(void)
|
||||
g_request_save_channel = 1;
|
||||
return;
|
||||
|
||||
case MENU_TX_POWER_USER:
|
||||
g_tx_vfo->channel.tx_power_user = g_sub_menu_selection;
|
||||
g_request_save_channel = 1;
|
||||
break;
|
||||
|
||||
case MENU_TX_CDCSS:
|
||||
pConfig = &g_tx_vfo->freq_config_tx;
|
||||
|
||||
@ -1018,10 +1008,6 @@ void MENU_ShowCurrentSetting(void)
|
||||
g_sub_menu_selection = g_tx_vfo->channel.tx_power;
|
||||
break;
|
||||
|
||||
case MENU_TX_POWER_USER:
|
||||
g_sub_menu_selection = g_tx_vfo->channel.tx_power_user;
|
||||
break;
|
||||
|
||||
case MENU_RX_CDCSS:
|
||||
switch (g_tx_vfo->freq_config_rx.code_type)
|
||||
{
|
||||
@ -1085,11 +1071,11 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_MEM_SAVE:
|
||||
#if 0
|
||||
#if 0
|
||||
g_sub_menu_selection = g_eeprom.config.setting.indices.vfo[0].user;
|
||||
#else
|
||||
#else
|
||||
g_sub_menu_selection = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
case MENU_MEM_NAME:
|
||||
@ -1424,6 +1410,11 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
|
||||
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (g_menu_cursor == MENU_TX_POWER && g_sub_menu_selection == OUTPUT_POWER_USER && g_edit_index >= 0)
|
||||
{ // currently editing the user TX power level
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0)
|
||||
{ // currently editing the channel name
|
||||
|
||||
@ -1715,6 +1706,26 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_menu_cursor == MENU_TX_POWER)
|
||||
{
|
||||
if (g_in_sub_menu && g_sub_menu_selection == OUTPUT_POWER_USER)
|
||||
{
|
||||
if (g_edit_index < 0)
|
||||
{
|
||||
g_edit_index = g_tx_vfo->channel.tx_power_user;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_tx_vfo->channel.tx_power_user = g_edit_index;
|
||||
g_request_save_channel = 1;
|
||||
|
||||
g_in_sub_menu = false;
|
||||
g_edit_index = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_menu_cursor == MENU_MEM_NAME)
|
||||
{
|
||||
if (g_edit_index < 0)
|
||||
@ -1736,7 +1747,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (g_edit_index >= 0 && g_edit_index < 10)
|
||||
{ // editing the channel name characters
|
||||
|
||||
@ -1747,7 +1758,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
if (memcmp(g_edit_original, g_edit, sizeof(g_edit_original)) == 0)
|
||||
{ // no change - drop it
|
||||
g_flag_accept_setting = false;
|
||||
g_in_sub_menu = false;
|
||||
g_in_sub_menu = false;
|
||||
g_ask_for_confirmation = 0;
|
||||
}
|
||||
else
|
||||
@ -1888,6 +1899,17 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
|
||||
uint8_t Channel;
|
||||
bool bCheckScanList;
|
||||
|
||||
if (g_menu_cursor == MENU_TX_POWER && g_in_sub_menu && g_sub_menu_selection == OUTPUT_POWER_USER && g_edit_index >= 0)
|
||||
{
|
||||
if (key_pressed)
|
||||
{
|
||||
g_edit_index += Direction;
|
||||
g_edit_index = (g_edit_index < 1) ? 1 : (g_edit_index > 15) ? 15 : g_edit_index;
|
||||
g_request_display_screen = DISPLAY_MENU;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_menu_cursor == MENU_MEM_NAME && g_in_sub_menu && g_edit_index >= 0)
|
||||
{ // change the character
|
||||
if (key_pressed && g_edit_index < 10 && Direction != 0)
|
||||
|
96
driver/i2c.c
96
driver/i2c.c
@ -44,9 +44,11 @@ void I2C_Stop(void)
|
||||
SYSTICK_Delay250ns(4);
|
||||
}
|
||||
|
||||
uint8_t I2C_Read_fast(bool bFinal)
|
||||
uint8_t I2C_Read(const bool end, const bool fast)
|
||||
{
|
||||
uint8_t i, Data;
|
||||
const unsigned int delay = fast ? 2 : 4;
|
||||
unsigned int i;
|
||||
uint8_t Data;
|
||||
|
||||
PORTCON_PORTA_IE |= PORTCON_PORTA_IE_A11_BITS_ENABLE;
|
||||
PORTCON_PORTA_OD &= ~PORTCON_PORTA_OD_A11_MASK;
|
||||
@ -56,72 +58,31 @@ uint8_t I2C_Read_fast(bool bFinal)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay250ns(2);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA))
|
||||
Data |= 1U;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
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;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
if (bFinal)
|
||||
SYSTICK_Delay250ns(delay);
|
||||
if (end)
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
else
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay250ns(2);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(2);
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
uint8_t I2C_Read(bool bFinal)
|
||||
{
|
||||
uint8_t i, Data;
|
||||
|
||||
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++)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay250ns(4);
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA))
|
||||
Data |= 1U;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
}
|
||||
|
||||
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
||||
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
||||
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
if (bFinal)
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
else
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay250ns(4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
SYSTICK_Delay250ns(delay);
|
||||
|
||||
return Data;
|
||||
}
|
||||
@ -133,12 +94,12 @@ int I2C_Write(uint8_t Data)
|
||||
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
for (i = 0; i < 8; i++) {
|
||||
if ((Data & 0x80) == 0) {
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if ((Data & 0x80) == 0)
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
} else {
|
||||
else
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
}
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay250ns(4);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
@ -155,8 +116,10 @@ int I2C_Write(uint8_t Data)
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(4);
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA) == 0) {
|
||||
for (i = 0; i < 255; i++)
|
||||
{
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA) == 0)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
@ -179,22 +142,13 @@ int I2C_ReadBuffer(void *pBuffer, const unsigned int Size, const bool fast)
|
||||
|
||||
if (Size == 1)
|
||||
{
|
||||
*pData = fast ? I2C_Read_fast(true) : I2C_Read(true);
|
||||
*pData = I2C_Read(true, fast);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fast)
|
||||
{
|
||||
for (i = 0; i < (Size - 1); i++)
|
||||
pData[i] = I2C_Read_fast(false);
|
||||
pData[i++] = I2C_Read_fast(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < (Size - 1); i++)
|
||||
pData[i] = I2C_Read(false);
|
||||
pData[i++] = I2C_Read(true);
|
||||
}
|
||||
for (i = 0; i < (Size - 1); i++)
|
||||
pData[i] = I2C_Read(false, fast);
|
||||
pData[i++] = I2C_Read(true, fast);
|
||||
|
||||
return Size;
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ enum {
|
||||
void I2C_Start(void);
|
||||
void I2C_Stop(void);
|
||||
|
||||
uint8_t I2C_Read(bool bFinal);
|
||||
uint8_t I2C_Read_fast(bool bFinal);
|
||||
uint8_t I2C_Read(const bool end, const bool fast);
|
||||
int I2C_Write(uint8_t Data);
|
||||
|
||||
int I2C_ReadBuffer(void *pBuffer, unsigned int Size, const bool fast);
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
36
ui/menu.c
36
ui/menu.c
@ -53,7 +53,6 @@ const t_menu_item g_menu_list[] =
|
||||
{"STEP", VOICE_ID_FREQUENCY_STEP, MENU_STEP },
|
||||
{"W/N", VOICE_ID_CHANNEL_BANDWIDTH, MENU_BANDWIDTH },
|
||||
{"Tx PWR", VOICE_ID_POWER, MENU_TX_POWER }, // was "TXP"
|
||||
{"TxPUSR", VOICE_ID_POWER, MENU_TX_POWER_USER },
|
||||
{"Rx DCS", VOICE_ID_DCS, MENU_RX_CDCSS }, // was "R_DCS"
|
||||
{"Rx CTS", VOICE_ID_CTCSS, MENU_RX_CTCSS }, // was "R_CTCS"
|
||||
{"Tx DCS", VOICE_ID_DCS, MENU_TX_CDCSS }, // was "T_DCS"
|
||||
@ -603,15 +602,14 @@ void UI_DisplayMenu(void)
|
||||
|
||||
case MENU_TX_POWER:
|
||||
strcpy(str, g_sub_menu_tx_power[g_sub_menu_selection]);
|
||||
channel_setting = true;
|
||||
break;
|
||||
|
||||
case MENU_TX_POWER_USER:
|
||||
// sprintf(str, "%u", 8 + (g_sub_menu_selection * 2));
|
||||
sprintf(str, "%u", g_sub_menu_selection);
|
||||
|
||||
// if (g_current_function == FUNCTION_TRANSMIT && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
// BK4819_SetupPowerAmplifier(8 + (g_sub_menu_selection * 2), g_current_vfo->p_tx->frequency);
|
||||
if (g_sub_menu_selection == OUTPUT_POWER_USER)
|
||||
{
|
||||
if (!g_in_sub_menu || g_edit_index < 0)
|
||||
sprintf(str + strlen(str), "\n%u", g_tx_vfo->channel.tx_power_user);
|
||||
else
|
||||
sprintf(str + strlen(str), "\n> %u", g_edit_index);
|
||||
}
|
||||
|
||||
channel_setting = true;
|
||||
break;
|
||||
@ -758,12 +756,12 @@ void UI_DisplayMenu(void)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
case MENU_AUTO_KEY_LOCK:
|
||||
if (g_sub_menu_selection == 0)
|
||||
strcpy(str, "OFF");
|
||||
else
|
||||
sprintf(str, "%u secs", key_lock_timeout_500ms / 2);
|
||||
break;
|
||||
case MENU_AUTO_KEY_LOCK:
|
||||
if (g_sub_menu_selection == 0)
|
||||
strcpy(str, "OFF");
|
||||
else
|
||||
sprintf(str, "%u secs", key_lock_timeout_500ms / 2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_COMPAND:
|
||||
@ -804,8 +802,8 @@ void UI_DisplayMenu(void)
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// case MENU_AM_FIX:
|
||||
strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
|
||||
break;
|
||||
// strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
|
||||
// break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SCAN_RANGES
|
||||
@ -1037,7 +1035,7 @@ void UI_DisplayMenu(void)
|
||||
break;
|
||||
|
||||
case MENU_DTMF_RSP:
|
||||
strcpy(str, "DTMF\nRESPONSE\n");
|
||||
strcpy(str, "DTMF\nRESP\n");
|
||||
strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]);
|
||||
channel_setting = true;
|
||||
break;
|
||||
@ -1066,7 +1064,7 @@ void UI_DisplayMenu(void)
|
||||
if (g_sub_menu_selection < DTMF_HOLD_MAX)
|
||||
sprintf(str + strlen(str), "%d sec", g_sub_menu_selection);
|
||||
else
|
||||
strcat(str, "STAY ON\nSCREEN"); // 60
|
||||
strcat(str, "STAY ON\nSCRN"); // 60
|
||||
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user