0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 08:21: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_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_AIRCOPY := 0 ENABLE_UART_DEBUG := 0
ENABLE_AIRCOPY := 1
ENABLE_FMRADIO := 1 ENABLE_FMRADIO := 1
ENABLE_NOAA := 1 ENABLE_NOAA := 1
ENABLE_VOICE := 1 ENABLE_VOICE := 0
ENABLE_VOX := 1 ENABLE_VOX := 1
ENABLE_ALARM := 1 ENABLE_ALARM := 1
ENABLE_TX1750 := 1 ENABLE_TX1750 := 1
ENABLE_PWRON_PASSWORD := 1 ENABLE_PWRON_PASSWORD := 0
ENABLE_BIG_FREQ := 0 ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1 ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
@ -36,8 +37,8 @@ ENABLE_RSSI_BAR := 1
ENABLE_SHOW_TX_TIMEOUT := 1 ENABLE_SHOW_TX_TIMEOUT := 1
ENABLE_AUDIO_BAR := 0 ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1 ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_PANADAPTER := 1 #ENABLE_PANADAPTER := 0
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 0
############################################################# #############################################################
@ -58,6 +59,10 @@ ifeq ($(ENABLE_SHOW_TX_TIMEOUT),1)
ENABLE_AUDIO_BAR := 0 ENABLE_AUDIO_BAR := 0
endif endif
ifeq ($(ENABLE_UART_DEBUG),1)
ENABLE_UART := 1
endif
BSP_DEFINITIONS := $(wildcard hardware/*/*.def) BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS)) BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS)) BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
@ -234,6 +239,9 @@ endif
ifeq ($(ENABLE_UART),1) ifeq ($(ENABLE_UART),1)
CFLAGS += -DENABLE_UART CFLAGS += -DENABLE_UART
endif endif
ifeq ($(ENABLE_UART_DEBUG),1)
CFLAGS += -DENABLE_UART_DEBUG
endif
ifeq ($(ENABLE_BIG_FREQ),1) ifeq ($(ENABLE_BIG_FREQ),1)
CFLAGS += -DENABLE_BIG_FREQ CFLAGS += -DENABLE_BIG_FREQ
endif 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_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed 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_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_AIRCOPY := 0 easier to just enter frequency with butts
ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver ENABLE_FMRADIO := 1 WBFM VHF broadcast band receiver
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA) ENABLE_NOAA := 1 everything NOAA (only of any use in the USA)
ENABLE_VOICE := 0 want to hear voices ? ENABLE_VOICE := 0 want to hear voices ?
ENABLE_VOX := 0 ENABLE_VOX := 1 voice operated transmission
ENABLE_ALARM := 0 TX alarms ENABLE_ALARM := 1 TX alarms
ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access) ENABLE_1750HZ := 1 side key 1750Hz TX tone (older style repeater access)
ENABLE_PWRON_PASSWORD := 1 power-on password stuff ENABLE_PWRON_PASSWORD := 1 power-on password stuff
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware) 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) 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 := 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_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_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_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_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_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 := 0 not yet implemented - spectrum/pan-adapter
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter #ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible
``` ```
# New/modified function keys # New/modified function keys

View File

@ -30,6 +30,7 @@
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/uart.h"
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
@ -58,8 +59,11 @@ void ACTION_Power(void)
if (++g_tx_vfo->output_power > OUTPUT_POWER_HIGH) if (++g_tx_vfo->output_power > OUTPUT_POWER_HIGH)
g_tx_vfo->output_power = OUTPUT_POWER_LOW; 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 = 1;
//g_request_save_channel = 2; // auto save the channel
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_POWER; g_another_voice_id = VOICE_ID_POWER;

View File

@ -44,6 +44,7 @@
#include "driver/keyboard.h" #include "driver/keyboard.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/uart.h"
#include "am_fix.h" #include "am_fix.h"
#include "dtmf.h" #include "dtmf.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
@ -1301,7 +1302,7 @@ void APP_CheckKeys(void)
if (g_ptt_is_pressed) 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 { // PTT released or serial comms config in progress
if (++g_ptt_debounce_counter >= 3 || g_serial_config_count_down_500ms > 0) // 30ms if (++g_ptt_debounce_counter >= 3 || g_serial_config_count_down_500ms > 0) // 30ms
{ // stop transmitting { // stop transmitting
@ -1315,7 +1316,7 @@ void APP_CheckKeys(void)
g_ptt_debounce_counter = 0; g_ptt_debounce_counter = 0;
} }
else 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 { // PTT pressed
if (++g_ptt_debounce_counter >= 3) // 30ms if (++g_ptt_debounce_counter >= 3) // 30ms
{ // start transmitting { // start transmitting
@ -2108,8 +2109,9 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
// if (Key == KEY_INVALID) // if (Key == KEY_INVALID)
// return; // return;
// reset the state so as to remove it from the screen
if (Key != KEY_INVALID && Key != KEY_PTT) 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); 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 #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); SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel);
g_flag_SaveChannel = false; g_flag_save_channel = false;
RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE); RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
@ -2464,7 +2466,7 @@ Skip:
} }
else else
{ {
g_flag_SaveChannel = g_request_save_channel; g_flag_save_channel = g_request_save_channel;
if (g_request_display_screen == DISPLAY_INVALID) if (g_request_display_screen == DISPLAY_INVALID)
g_request_display_screen = DISPLAY_MAIN; g_request_display_screen = DISPLAY_MAIN;

View File

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

View File

@ -706,7 +706,7 @@ void BOARD_EEPROM_Init(void)
g_setting_500_tx_enable = (Data[4] < 2) ? Data[4] : false; g_setting_500_tx_enable = (Data[4] < 2) ? Data[4] : false;
g_setting_350_enable = (Data[5] < 2) ? Data[5] : true; g_setting_350_enable = (Data[5] < 2) ? Data[5] : true;
g_setting_scramble_enable = (Data[6] < 2) ? Data[6] : 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_live_dtmf_decoder = (Data[7] & (1u << 1)) ? true : false;
g_setting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; g_setting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2;
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR

View File

@ -14,11 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include "bsp/dp32g030/dma.h" #include "bsp/dp32g030/dma.h"
#include "bsp/dp32g030/syscon.h" #include "bsp/dp32g030/syscon.h"
#include "bsp/dp32g030/uart.h" #include "bsp/dp32g030/uart.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "external/printf/printf.h"
static bool UART_IsLogEnabled; static bool UART_IsLogEnabled;
uint8_t UART_DMA_Buffer[256]; 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) void UART_LogSend(const void *pBuffer, uint32_t Size)
{ {
if (UART_IsLogEnabled) if (UART_IsLogEnabled)
UART_Send(pBuffer, Size); 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_Init(void);
void UART_Send(const void *pBuffer, uint32_t Size); 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_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 #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 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 // 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 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 // sort the menu list
UI_SortMenu(!g_f_lock); 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_200_tx_enable;
bool g_setting_500_tx_enable; bool g_setting_500_tx_enable;
bool g_setting_350_enable; bool g_setting_350_enable;
bool g_Setting_tx_enable; bool g_setting_tx_enable;
uint8_t g_setting_f_lock; uint8_t g_setting_f_lock;
bool g_setting_scramble_enable; bool g_setting_scramble_enable;
@ -190,7 +190,7 @@ bool g_flag_refresh_menu;
bool g_flag_SaveVfo; bool g_flag_SaveVfo;
bool g_flag_SaveSettings; bool g_flag_SaveSettings;
bool g_flag_SaveChannel; bool g_flag_save_channel;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
bool g_flag_SaveFM; bool g_flag_SaveFM;
#endif #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_200_tx_enable;
extern bool g_setting_500_tx_enable; extern bool g_setting_500_tx_enable;
extern bool g_setting_350_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 uint8_t g_setting_f_lock;
extern bool g_setting_scramble_enable; 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_SaveVfo;
extern bool g_flag_SaveSettings; extern bool g_flag_SaveSettings;
extern bool g_flag_SaveChannel; extern bool g_flag_save_channel;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
extern bool g_flag_SaveFM; extern bool g_flag_SaveFM;
#endif #endif

View File

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

View File

@ -180,7 +180,7 @@ void SETTINGS_SaveSettings(void)
State[4] = g_setting_500_tx_enable; State[4] = g_setting_500_tx_enable;
State[5] = g_setting_350_enable; State[5] = g_setting_350_enable;
State[6] = g_setting_scramble_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); if (!g_setting_live_dtmf_decoder) State[7] &= ~(1u << 1);
State[7] = (State[7] & ~(3u << 2)) | ((g_setting_battery_text & 3u) << 2); State[7] = (State[7] & ~(3u << 2)) | ((g_setting_battery_text & 3u) << 2);
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
@ -196,23 +196,27 @@ void SETTINGS_SaveSettings(void)
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode) void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode)
{ {
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
#endif
{
const uint16_t OffsetMR = Channel * 16; const uint16_t OffsetMR = Channel * 16;
uint16_t OffsetVFO = OffsetMR; uint16_t OffsetVFO = OffsetMR;
uint8_t State[8];
if (Channel > USER_CHANNEL_LAST) #ifdef ENABLE_NOAA
{ // it's a VFO, not a channel if (IS_NOAA_CHANNEL(Channel))
return;
#endif
if (IS_FREQ_CHANNEL(Channel))
{ // it's a VFO
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90; OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32; OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
} }
if (Mode >= 2 || Channel > USER_CHANNEL_LAST) if (Mode < 2 && Channel <= USER_CHANNEL_LAST)
{ // copy VFO to a channel return;
uint8_t State[8]; #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)[0] = pVFO->freq_config_rx.frequency;
((uint32_t *)State)[1] = pVFO->tx_offset_freq; ((uint32_t *)State)[1] = pVFO->tx_offset_freq;
@ -222,8 +226,8 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO,
State[1] = pVFO->freq_config_tx.code; State[1] = pVFO->freq_config_tx.code;
State[2] = (pVFO->freq_config_tx.code_type << 4) | pVFO->freq_config_rx.code_type; 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[3] = ((pVFO->am_mode & 1u) << 4) | pVFO->tx_offset_freq_dir;
State[4] = 0 State[4] =
| (pVFO->busy_channel_lock << 4) (pVFO->busy_channel_lock << 4)
| (pVFO->output_power << 2) | (pVFO->output_power << 2)
| (pVFO->channel_bandwidth << 1) | (pVFO->channel_bandwidth << 1)
| (pVFO->frequency_reverse << 0); | (pVFO->frequency_reverse << 0);
@ -234,13 +238,12 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO,
SETTINGS_UpdateChannel(Channel, pVFO, true); SETTINGS_UpdateChannel(Channel, pVFO, true);
if (Channel <= USER_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
{ // it's a memory channel return; // it's not a user channel
#ifndef ENABLE_KEEP_MEM_NAME #ifndef ENABLE_KEEP_MEM_NAME
// clear/reset the channel name // clear/reset the channel name
//memset(&State, 0xFF, sizeof(State)); memset(&State, 0x00, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
#else #else
@ -248,27 +251,24 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO,
{ // save the channel name { // save the channel name
memmove(State, pVFO->name + 0, 8); memmove(State, pVFO->name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
//memset(State, 0xFF, sizeof(State)); memset(State, 0x00, sizeof(State));
memset(State, 0x00, sizeof(State)); // follow the QS way
memmove(State, pVFO->name + 8, 2); memmove(State, pVFO->name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
} }
#endif #endif
}
}
}
} }
void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep) void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep)
{ {
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
#endif
{
uint8_t State[8]; uint8_t State[8];
uint8_t Attributes = 0xFF; // default attributes uint8_t Attributes = 0xFF; // default attributes
uint16_t Offset = 0x0D60 + (Channel & ~7u); uint16_t Offset = 0x0D60 + (Channel & ~7u);
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(Channel))
return;
#endif
Attributes &= (uint8_t)(~USER_CH_COMPAND); // default to '0' = compander disabled Attributes &= (uint8_t)(~USER_CH_COMPAND); // default to '0' = compander disabled
EEPROM_ReadBuffer(Offset, State, sizeof(State)); EEPROM_ReadBuffer(Offset, State, sizeof(State));
@ -309,5 +309,4 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep)
// } // }
} }
// #endif // #endif
}
} }

View File

@ -50,7 +50,7 @@ center_line_t center_line = CENTER_LINE_NONE;
{ {
unsigned int timeout_secs = 0; 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; return false;
if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT) if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT)

View File

@ -871,9 +871,10 @@ void UI_DisplayMenu(void)
break; break;
case MENU_VOL: 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, 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; break;
case MENU_SIDE1_SHORT: case MENU_SIDE1_SHORT: