0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +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

@ -8,14 +8,15 @@ ENABLE_SWD := 0
ENABLE_OVERLAY := 0
ENABLE_LTO := 1
ENABLE_UART := 1
ENABLE_AIRCOPY := 0
ENABLE_UART_DEBUG := 0
ENABLE_AIRCOPY := 1
ENABLE_FMRADIO := 1
ENABLE_NOAA := 1
ENABLE_VOICE := 1
ENABLE_VOICE := 0
ENABLE_VOX := 1
ENABLE_ALARM := 1
ENABLE_TX1750 := 1
ENABLE_PWRON_PASSWORD := 1
ENABLE_PWRON_PASSWORD := 0
ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
@ -36,8 +37,8 @@ ENABLE_RSSI_BAR := 1
ENABLE_SHOW_TX_TIMEOUT := 1
ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_PANADAPTER := 1
#ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_PANADAPTER := 0
#ENABLE_SINGLE_VFO_CHAN := 0
#############################################################
@ -58,6 +59,10 @@ ifeq ($(ENABLE_SHOW_TX_TIMEOUT),1)
ENABLE_AUDIO_BAR := 0
endif
ifeq ($(ENABLE_UART_DEBUG),1)
ENABLE_UART := 1
endif
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
@ -234,6 +239,9 @@ endif
ifeq ($(ENABLE_UART),1)
CFLAGS += -DENABLE_UART
endif
ifeq ($(ENABLE_UART_DEBUG),1)
CFLAGS += -DENABLE_UART_DEBUG
endif
ifeq ($(ENABLE_BIG_FREQ),1)
CFLAGS += -DENABLE_BIG_FREQ
endif

View File

@ -34,14 +34,15 @@ ENABLE_CLANG := 0 **experimental, builds with clang instead
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this)
ENABLE_UART := 1 without this you can't configure radio via PC !
ENABLE_UART := 1 without this you can't configure radio via PC
ENABLE_UART_DEBUG := 0 just for code debugging, it sends debug info along the USB serial connection (programming lead)
ENABLE_AIRCOPY := 0 easier to just enter frequency with butts
ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA)
ENABLE_FMRADIO := 1 WBFM VHF broadcast band receiver
ENABLE_NOAA := 1 everything NOAA (only of any use in the USA)
ENABLE_VOICE := 0 want to hear voices ?
ENABLE_VOX := 0
ENABLE_ALARM := 0 TX alarms
ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access)
ENABLE_VOX := 1 voice operated transmission
ENABLE_ALARM := 1 TX alarms
ENABLE_1750HZ := 1 side key 1750Hz TX tone (older style repeater access)
ENABLE_PWRON_PASSWORD := 1 power-on password stuff
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
@ -58,13 +59,13 @@ ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan ti
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it)
ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves
ENABLE_FASTER_CHANNEL_SCAN := 0 increases the channel scan speed, but the squelch is also made more twitchy
ENABLE_FASTER_CHANNEL_SCAN := 1 increases the channel scan speed, but the squelch is also made more twitchy
ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols
ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing
ENABLE_SHOW_TX_TIMEOUT := 1 show the TX time left (TX timeout)
ENABLE_SHOW_TX_TIMEOUT := 1 show the TX time left when transmitting
ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO. Long press Menu key ('M')
#ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter
#ENABLE_BAND_SCOPE := 0 not yet implemented - spectrum/pan-adapter
#ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible
```
# New/modified function keys

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;

28
board.c
View File

@ -61,10 +61,10 @@ static const uint32_t gDefaultFrequencyTable[] =
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
FLASH_ConfigureTrimValues();
SYSTEM_ConfigureClocks();
overlay_FLASH_MainClock = 48000000;
overlay_FLASH_ClockMultiplier = 48;
FLASH_Init(FLASH_READ_MODE_2_CYCLE);
}
#endif
@ -644,7 +644,7 @@ void BOARD_EEPROM_Init(void)
memset(g_eeprom.ani_dtmf_id, 0, sizeof(g_eeprom.ani_dtmf_id));
strcpy(g_eeprom.ani_dtmf_id, "123");
}
// 0EE8..0EEF
EEPROM_ReadBuffer(0x0EE8, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8))
@ -654,7 +654,7 @@ void BOARD_EEPROM_Init(void)
memset(g_eeprom.kill_code, 0, sizeof(g_eeprom.kill_code));
strcpy(g_eeprom.kill_code, "ABCD9");
}
// 0EF0..0EF7
EEPROM_ReadBuffer(0x0EF0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8))
@ -664,7 +664,7 @@ void BOARD_EEPROM_Init(void)
memset(g_eeprom.revive_code, 0, sizeof(g_eeprom.revive_code));
strcpy(g_eeprom.revive_code, "9DCBA");
}
// 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16))
@ -674,7 +674,7 @@ void BOARD_EEPROM_Init(void)
memset(g_eeprom.dtmf_up_code, 0, sizeof(g_eeprom.dtmf_up_code));
strcpy(g_eeprom.dtmf_up_code, "12345");
}
// 0F08..0F17
EEPROM_ReadBuffer(0x0F08, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16))
@ -684,7 +684,7 @@ void BOARD_EEPROM_Init(void)
memset(g_eeprom.dtmf_down_code, 0, sizeof(g_eeprom.dtmf_down_code));
strcpy(g_eeprom.dtmf_down_code, "54321");
}
// 0F18..0F1F
EEPROM_ReadBuffer(0x0F18, Data, 8);
// g_eeprom.scan_list_default = (Data[0] < 2) ? Data[0] : false;
@ -706,7 +706,7 @@ void BOARD_EEPROM_Init(void)
g_setting_500_tx_enable = (Data[4] < 2) ? Data[4] : false;
g_setting_350_enable = (Data[5] < 2) ? Data[5] : true;
g_setting_scramble_enable = (Data[6] < 2) ? Data[6] : true;
g_Setting_tx_enable = (Data[7] & (1u << 0)) ? true : false;
g_setting_tx_enable = (Data[7] & (1u << 0)) ? true : false;
g_setting_live_dtmf_decoder = (Data[7] & (1u << 1)) ? true : false;
g_setting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2;
#ifdef ENABLE_AUDIO_BAR
@ -764,7 +764,7 @@ void BOARD_EEPROM_LoadMoreSettings(void)
EEPROM_ReadBuffer(0x1F50 + (g_eeprom.vox_level * 2), &g_eeprom.vox1_threshold, 2);
EEPROM_ReadBuffer(0x1F68 + (g_eeprom.vox_level * 2), &g_eeprom.vox0_threshold, 2);
#endif
//EEPROM_ReadBuffer(0x1F80 + g_eeprom.mic_sensitivity, &Mic, 1);
//g_eeprom.mic_sensitivity_tuning = (Mic < 32) ? Mic : 15;
g_eeprom.mic_sensitivity_tuning = g_mic_gain_dB_2[g_eeprom.mic_sensitivity];
@ -803,7 +803,7 @@ uint32_t BOARD_fetchChannelFrequency(const int channel)
} __attribute__((packed)) info;
EEPROM_ReadBuffer(channel * 16, &info, sizeof(info));
return info.frequency;
}
@ -813,9 +813,9 @@ void BOARD_fetchChannelName(char *s, const int channel)
if (s == NULL)
return;
memset(s, 0, 11); // 's' had better be large enough !
if (channel < 0)
return;
@ -872,10 +872,10 @@ void BOARD_FactoryReset(bool bIsAll)
// set the first few memory channels
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
{
const uint32_t Frequency = gDefaultFrequencyTable[i];
const uint32_t Frequency = gDefaultFrequencyTable[i];
g_rx_vfo->freq_config_rx.frequency = Frequency;
g_rx_vfo->freq_config_tx.frequency = Frequency;
g_rx_vfo->band = FREQUENCY_GetBand(Frequency);
g_rx_vfo->band = FREQUENCY_GetBand(Frequency);
SETTINGS_SaveChannel(USER_CHANNEL_FIRST + i, 0, g_rx_vfo, 2);
}
}

View File

@ -14,11 +14,14 @@
* limitations under the License.
*/
#include <string.h>
#include <stdbool.h>
#include "bsp/dp32g030/dma.h"
#include "bsp/dp32g030/syscon.h"
#include "bsp/dp32g030/uart.h"
#include "driver/uart.h"
#include "external/printf/printf.h"
static bool UART_IsLogEnabled;
uint8_t UART_DMA_Buffer[256];
@ -92,8 +95,36 @@ void UART_Send(const void *pBuffer, uint32_t Size)
}
}
void UART_SendText(const void *str)
{
if (str)
UART_Send(str, strlen(str));
}
void UART_LogSend(const void *pBuffer, uint32_t Size)
{
if (UART_IsLogEnabled)
UART_Send(pBuffer, Size);
}
void UART_LogSendText(const void *str)
{
if (UART_IsLogEnabled && str)
UART_Send(str, strlen(str));
}
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
void UART_printf(const char *str, ...)
{
char text[256];
int len;
va_list va;
va_start(va, str);
len = vsnprintf(text, sizeof(text), str, va);
va_end(va);
UART_Send(text, len);
//UART_Send(text, strlen(text));
}
#endif

View File

@ -24,7 +24,12 @@ extern uint8_t UART_DMA_Buffer[256];
void UART_Init(void);
void UART_Send(const void *pBuffer, uint32_t Size);
void UART_SendText(const void *str);
void UART_LogSend(const void *pBuffer, uint32_t Size);
void UART_LogSendText(const void *str);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
void UART_printf(const char *str, ...);
#endif
#endif

Binary file not shown.

Binary file not shown.

9
main.c
View File

@ -69,7 +69,9 @@ void Main(void)
g_boot_counter_10ms = 250; // 2.5 sec
UART_Send(UART_Version, strlen(UART_Version));
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText(UART_Version);
#endif
// Not implementing authentic device checks
@ -106,6 +108,11 @@ void Main(void)
g_f_lock = (BootMode == BOOT_MODE_F_LOCK); // flag to say include the hidden menu items
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
if (g_f_lock)
UART_SendText("boot_f_lock\r\n");
#endif
// sort the menu list
UI_SortMenu(!g_f_lock);

4
misc.c
View File

@ -84,7 +84,7 @@ bool g_setting_killed;
bool g_setting_200_tx_enable;
bool g_setting_500_tx_enable;
bool g_setting_350_enable;
bool g_Setting_tx_enable;
bool g_setting_tx_enable;
uint8_t g_setting_f_lock;
bool g_setting_scramble_enable;
@ -190,7 +190,7 @@ bool g_flag_refresh_menu;
bool g_flag_SaveVfo;
bool g_flag_SaveSettings;
bool g_flag_SaveChannel;
bool g_flag_save_channel;
#ifdef ENABLE_FMRADIO
bool g_flag_SaveFM;
#endif

4
misc.h
View File

@ -153,7 +153,7 @@ extern bool g_setting_killed;
extern bool g_setting_200_tx_enable;
extern bool g_setting_500_tx_enable;
extern bool g_setting_350_enable;
extern bool g_Setting_tx_enable;
extern bool g_setting_tx_enable;
extern uint8_t g_setting_f_lock;
extern bool g_setting_scramble_enable;
@ -260,7 +260,7 @@ extern bool g_flag_refresh_menu; // refresh menu display
extern bool g_flag_SaveVfo;
extern bool g_flag_SaveSettings;
extern bool g_flag_SaveChannel;
extern bool g_flag_save_channel;
#ifdef ENABLE_FMRADIO
extern bool g_flag_SaveFM;
#endif

View File

@ -325,7 +325,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
const uint8_t d4 = Data[4];
g_eeprom.vfo_info[VFO].frequency_reverse = ((d4 >> 0) & 1u) ? true : false;
g_eeprom.vfo_info[VFO].channel_bandwidth = ((d4 >> 1) & 1u) ? true : false;
g_eeprom.vfo_info[VFO].output_power = ((d4 >> 2) & 3u) ? true : false;
g_eeprom.vfo_info[VFO].output_power = (d4 >> 2) & 3u;
g_eeprom.vfo_info[VFO].busy_channel_lock = ((d4 >> 4) & 1u) ? true : false;
}
@ -976,7 +976,7 @@ void RADIO_PrepareTX(void)
}
else
#endif
if (!g_Setting_tx_enable || g_serial_config_count_down_500ms > 0)
if (!g_setting_tx_enable || g_serial_config_count_down_500ms > 0)
{ // TX is disabled or config upload/download in progress
State = VFO_STATE_TX_DISABLE;
}

View File

@ -180,7 +180,7 @@ void SETTINGS_SaveSettings(void)
State[4] = g_setting_500_tx_enable;
State[5] = g_setting_350_enable;
State[6] = g_setting_scramble_enable;
if (!g_Setting_tx_enable) State[7] &= ~(1u << 0);
if (!g_setting_tx_enable) State[7] &= ~(1u << 0);
if (!g_setting_live_dtmf_decoder) State[7] &= ~(1u << 1);
State[7] = (State[7] & ~(3u << 2)) | ((g_setting_battery_text & 3u) << 2);
#ifdef ENABLE_AUDIO_BAR
@ -196,118 +196,117 @@ void SETTINGS_SaveSettings(void)
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode)
{
const uint16_t OffsetMR = Channel * 16;
uint16_t OffsetVFO = OffsetMR;
uint8_t State[8];
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
if (IS_NOAA_CHANNEL(Channel))
return;
#endif
{
const uint16_t OffsetMR = Channel * 16;
uint16_t OffsetVFO = OffsetMR;
if (Channel > USER_CHANNEL_LAST)
{ // it's a VFO, not a channel
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
}
if (Mode >= 2 || Channel > USER_CHANNEL_LAST)
{ // copy VFO to a channel
uint8_t State[8];
((uint32_t *)State)[0] = pVFO->freq_config_rx.frequency;
((uint32_t *)State)[1] = pVFO->tx_offset_freq;
EEPROM_WriteBuffer(OffsetVFO + 0, State);
State[0] = pVFO->freq_config_rx.code;
State[1] = pVFO->freq_config_tx.code;
State[2] = (pVFO->freq_config_tx.code_type << 4) | pVFO->freq_config_rx.code_type;
State[3] = ((pVFO->am_mode & 1u) << 4) | pVFO->tx_offset_freq_dir;
State[4] = 0
| (pVFO->busy_channel_lock << 4)
| (pVFO->output_power << 2)
| (pVFO->channel_bandwidth << 1)
| (pVFO->frequency_reverse << 0);
State[5] = ((pVFO->dtmf_ptt_id_tx_mode & 7u) << 1) | ((pVFO->dtmf_decoding_enable & 1u) << 0);
State[6] = pVFO->step_setting;
State[7] = pVFO->scrambling_type;
EEPROM_WriteBuffer(OffsetVFO + 8, State);
SETTINGS_UpdateChannel(Channel, pVFO, true);
if (Channel <= USER_CHANNEL_LAST)
{ // it's a memory channel
#ifndef ENABLE_KEEP_MEM_NAME
// clear/reset the channel name
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
#else
if (Mode >= 3)
{ // save the channel name
memmove(State, pVFO->name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
//memset(State, 0xFF, sizeof(State));
memset(State, 0x00, sizeof(State)); // follow the QS way
memmove(State, pVFO->name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
#endif
}
}
if (IS_FREQ_CHANNEL(Channel))
{ // it's a VFO
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
}
if (Mode < 2 && Channel <= USER_CHANNEL_LAST)
return;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("sav_chan %u %u %u\r\n", Channel, VFO, Mode);
#endif
((uint32_t *)State)[0] = pVFO->freq_config_rx.frequency;
((uint32_t *)State)[1] = pVFO->tx_offset_freq;
EEPROM_WriteBuffer(OffsetVFO + 0, State);
State[0] = pVFO->freq_config_rx.code;
State[1] = pVFO->freq_config_tx.code;
State[2] = (pVFO->freq_config_tx.code_type << 4) | pVFO->freq_config_rx.code_type;
State[3] = ((pVFO->am_mode & 1u) << 4) | pVFO->tx_offset_freq_dir;
State[4] =
(pVFO->busy_channel_lock << 4)
| (pVFO->output_power << 2)
| (pVFO->channel_bandwidth << 1)
| (pVFO->frequency_reverse << 0);
State[5] = ((pVFO->dtmf_ptt_id_tx_mode & 7u) << 1) | ((pVFO->dtmf_decoding_enable & 1u) << 0);
State[6] = pVFO->step_setting;
State[7] = pVFO->scrambling_type;
EEPROM_WriteBuffer(OffsetVFO + 8, State);
SETTINGS_UpdateChannel(Channel, pVFO, true);
if (Channel > USER_CHANNEL_LAST)
return; // it's not a user channel
#ifndef ENABLE_KEEP_MEM_NAME
// clear/reset the channel name
memset(&State, 0x00, sizeof(State));
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
#else
if (Mode >= 3)
{ // save the channel name
memmove(State, pVFO->name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
memset(State, 0x00, sizeof(State));
memmove(State, pVFO->name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
#endif
}
void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep)
{
uint8_t State[8];
uint8_t Attributes = 0xFF; // default attributes
uint16_t Offset = 0x0D60 + (Channel & ~7u);
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
if (IS_NOAA_CHANNEL(Channel))
return;
#endif
Attributes &= (uint8_t)(~USER_CH_COMPAND); // default to '0' = compander disabled
EEPROM_ReadBuffer(Offset, State, sizeof(State));
if (keep)
{
uint8_t State[8];
uint8_t Attributes = 0xFF; // default attributes
uint16_t Offset = 0x0D60 + (Channel & ~7u);
Attributes &= (uint8_t)(~USER_CH_COMPAND); // default to '0' = compander disabled
EEPROM_ReadBuffer(Offset, State, sizeof(State));
if (keep)
{
Attributes = (pVFO->scanlist_1_participation << 7) | (pVFO->scanlist_2_participation << 6) | (pVFO->compander << 4) | (pVFO->band << 0);
if (State[Channel & 7u] == Attributes)
return; // no change in the attributes
}
State[Channel & 7u] = Attributes;
EEPROM_WriteBuffer(Offset, State);
g_user_channel_attributes[Channel] = Attributes;
// #ifndef ENABLE_KEEP_MEM_NAME
if (Channel <= USER_CHANNEL_LAST)
{ // it's a memory channel
const uint16_t OffsetMR = Channel * 16;
if (!keep)
{ // clear/reset the channel name
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
// else
// { // update the channel name
// memmove(State, pVFO->name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// //memset(State, 0xFF, sizeof(State));
// memset(State, 0x00, sizeof(State)); // follow the QS way
// memmove(State, pVFO->name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// }
}
// #endif
Attributes = (pVFO->scanlist_1_participation << 7) | (pVFO->scanlist_2_participation << 6) | (pVFO->compander << 4) | (pVFO->band << 0);
if (State[Channel & 7u] == Attributes)
return; // no change in the attributes
}
State[Channel & 7u] = Attributes;
EEPROM_WriteBuffer(Offset, State);
g_user_channel_attributes[Channel] = Attributes;
// #ifndef ENABLE_KEEP_MEM_NAME
if (Channel <= USER_CHANNEL_LAST)
{ // it's a memory channel
const uint16_t OffsetMR = Channel * 16;
if (!keep)
{ // clear/reset the channel name
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
// else
// { // update the channel name
// memmove(State, pVFO->name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// //memset(State, 0xFF, sizeof(State));
// memset(State, 0x00, sizeof(State)); // follow the QS way
// memmove(State, pVFO->name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// }
}
// #endif
}

View File

@ -50,7 +50,7 @@ center_line_t center_line = CENTER_LINE_NONE;
{
unsigned int timeout_secs = 0;
if (g_current_function != FUNCTION_TRANSMIT)
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
return false;
if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT)

View File

@ -871,9 +871,10 @@ void UI_DisplayMenu(void)
break;
case MENU_VOL:
sprintf(String, "%u.%02uV\n%u%%",
sprintf(String, "%u.%02uV\n%u%%\ncurr %u",
g_battery_voltage_average / 100, g_battery_voltage_average % 100,
BATTERY_VoltsToPercent(g_battery_voltage_average));
BATTERY_VoltsToPercent(g_battery_voltage_average),
g_battery_current);
break;
case MENU_SIDE1_SHORT: