0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Fix TX power setting (I broke it previous commit)

This commit is contained in:
OneOfEleven
2023-10-08 23:08:18 +01:00
parent 0bb34d230c
commit 16d51300d9
18 changed files with 215 additions and 157 deletions

View File

@ -30,6 +30,7 @@
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/uart.h"
#include "functions.h"
#include "misc.h"
#include "settings.h"
@ -58,11 +59,14 @@ void ACTION_Power(void)
if (++g_tx_vfo->output_power > OUTPUT_POWER_HIGH)
g_tx_vfo->output_power = OUTPUT_POWER_LOW;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("act_pwr %u\r\n", g_tx_vfo->output_power);
#endif
g_request_save_channel = 1;
//g_request_save_channel = 2; // auto save the channel
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_POWER;
g_another_voice_id = VOICE_ID_POWER;
#endif
g_request_display_screen = g_screen_to_display;

View File

@ -44,6 +44,7 @@
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "driver/system.h"
#include "driver/uart.h"
#include "am_fix.h"
#include "dtmf.h"
#include "external/printf/printf.h"
@ -1301,7 +1302,7 @@ void APP_CheckKeys(void)
if (g_ptt_is_pressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || g_serial_config_count_down_500ms > 0)
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || g_serial_config_count_down_500ms > 0 || !g_setting_tx_enable)
{ // PTT released or serial comms config in progress
if (++g_ptt_debounce_counter >= 3 || g_serial_config_count_down_500ms > 0) // 30ms
{ // stop transmitting
@ -1315,11 +1316,11 @@ void APP_CheckKeys(void)
g_ptt_debounce_counter = 0;
}
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && g_serial_config_count_down_500ms == 0)
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && g_serial_config_count_down_500ms == 0 && g_setting_tx_enable)
{ // PTT pressed
if (++g_ptt_debounce_counter >= 3) // 30ms
{ // start transmitting
g_boot_counter_10ms = 0; // cancel the boot-up screen
g_boot_counter_10ms = 0; // cancel the boot-up screen
g_ptt_debounce_counter = 0;
g_ptt_is_pressed = true;
APP_ProcessKey(KEY_PTT, true, false);
@ -1350,7 +1351,7 @@ void APP_CheckKeys(void)
if (g_key_reading_0 != KEY_INVALID && Key != KEY_INVALID)
APP_ProcessKey(g_key_reading_1, false, g_key_being_held); // key pressed without releasing previous key
g_key_reading_0 = Key;
g_key_reading_0 = Key;
g_debounce_counter = 0;
return;
}
@ -2108,8 +2109,9 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
// if (Key == KEY_INVALID)
// return;
// reset the state so as to remove it from the screen
if (Key != KEY_INVALID && Key != KEY_PTT)
RADIO_Setg_vfo_state(VFO_STATE_NORMAL); // reset the state
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
@ -2150,10 +2152,10 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
}
#endif
if (g_flag_SaveChannel)
if (g_flag_save_channel)
{
SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_SaveChannel);
g_flag_SaveChannel = false;
SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel);
g_flag_save_channel = false;
RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE);
RADIO_SetupRegisters(true);
@ -2464,7 +2466,7 @@ Skip:
}
else
{
g_flag_SaveChannel = g_request_save_channel;
g_flag_save_channel = g_request_save_channel;
if (g_request_display_screen == DISPLAY_INVALID)
g_request_display_screen = DISPLAY_MAIN;

View File

@ -781,7 +781,7 @@ void MENU_AcceptSetting(void)
break;
case MENU_TX_EN:
g_Setting_tx_enable = g_sub_menu_selection;
g_setting_tx_enable = g_sub_menu_selection;
break;
#ifdef ENABLE_F_CAL_MENU
@ -1208,7 +1208,7 @@ void MENU_ShowCurrentSetting(void)
break;
case MENU_TX_EN:
g_sub_menu_selection = g_Setting_tx_enable;
g_sub_menu_selection = g_setting_tx_enable;
break;
#ifdef ENABLE_F_CAL_MENU

View File

@ -308,9 +308,9 @@ static void SCANNER_Key_MENU(bool key_pressed, bool key_held)
g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel;
}
g_tx_vfo->channel_save = Channel;
g_tx_vfo->channel_save = Channel;
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
g_request_save_channel = 2;
g_request_save_channel = 2;
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_CONFIRM;