Merge remote-tracking branch 'remotes/OneOfEleven/main'

This commit is contained in:
Krzysiek Egzmont
2023-10-05 15:01:31 +02:00
20 changed files with 960 additions and 785 deletions

View File

@@ -3,6 +3,7 @@
# 0 = disable # 0 = disable
# 1 = enable # 1 = enable
# #
ENABLE_CLANG := 0
ENABLE_SWD := 0 ENABLE_SWD := 0
ENABLE_OVERLAY := 0 ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
@@ -21,26 +22,30 @@ ENABLE_WIDE_RX := 1
ENABLE_TX_WHEN_AM := 0 ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0 ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_MAIN_KEY_HOLD := 1
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_CODE_SCAN_TIMEOUT := 0 ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_AM_FIX := 1 ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 0 ENABLE_AM_FIX_SHOW_DATA := 0
ENABLE_SQUELCH_LOWER := 0 ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_FASTER_CHANNEL_SCAN := 1 #ENABLE_FASTER_CHANNEL_SCAN := 0
ENABLE_RSSI_BAR := 1 ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 1 ENABLE_AUDIO_BAR := 1
ENABLE_COPY_CHAN_TO_VFO := 1 ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_SINGLE_VFO_CHAN := 1
ENABLE_SPECTRUM := 1 ENABLE_SPECTRUM := 1
#ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1 #ENABLE_BAND_SCOPE := 1
############################################################# #############################################################
TARGET = firmware TARGET = firmware
ifeq ($(ENABLE_CLANG),1)
# GCC's linker, ld, doesn't understand LLVM's generated bytecode
ENABLE_LTO := 0
endif
ifeq ($(ENABLE_LTO),1) ifeq ($(ENABLE_LTO),1)
# can't have LTO and OVERLAY enabled at same time # can't have LTO and OVERLAY enabled at same time
ENABLE_OVERLAY := 0 ENABLE_OVERLAY := 0
@@ -149,8 +154,20 @@ else
endif endif
AS = arm-none-eabi-gcc AS = arm-none-eabi-gcc
CC = arm-none-eabi-gcc
CC =
LD = arm-none-eabi-gcc LD = arm-none-eabi-gcc
ifeq ($(ENABLE_CLANG),0)
CC += arm-none-eabi-gcc
# Use GCC's linker to avoid undefined symbol errors
# LD += arm-none-eabi-gcc
else
# May need to adjust this to match your system
CC += clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
# Bloats binaries to 512MB
# LD = ld.lld
endif
OBJCOPY = arm-none-eabi-objcopy OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size SIZE = arm-none-eabi-size
@@ -166,13 +183,18 @@ ifeq ($(ENABLE_OVERLAY),1)
ASFLAGS += -DENABLE_OVERLAY ASFLAGS += -DENABLE_OVERLAY
endif endif
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD CFLAGS =
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD ifeq ($(ENABLE_CLANG),0)
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD # CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
else
# Oz needed to make it fit on flash
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
endif
ifeq ($(ENABLE_LTO),1) ifeq ($(ENABLE_LTO),1)
# CFLAGS += -flto
CFLAGS += -flto=2 CFLAGS += -flto=2
else else
# We get most of the space savings if LTO creates problems # We get most of the space savings if LTO creates problems
@@ -239,9 +261,6 @@ endif
ifeq ($(ENABLE_CTCSS_TAIL_PHASE_SHIFT),1) ifeq ($(ENABLE_CTCSS_TAIL_PHASE_SHIFT),1)
CFLAGS += -DENABLE_CTCSS_TAIL_PHASE_SHIFT CFLAGS += -DENABLE_CTCSS_TAIL_PHASE_SHIFT
endif endif
ifeq ($(ENABLE_MAIN_KEY_HOLD),1)
CFLAGS += -DENABLE_MAIN_KEY_HOLD
endif
ifeq ($(ENABLE_BOOT_BEEPS),1) ifeq ($(ENABLE_BOOT_BEEPS),1)
CFLAGS += -DENABLE_BOOT_BEEPS CFLAGS += -DENABLE_BOOT_BEEPS
endif endif
@@ -288,7 +307,13 @@ ifeq ($(ENABLE_BAND_SCOPE),1)
CFLAGS += -DENABLE_BAND_SCOPE CFLAGS += -DENABLE_BAND_SCOPE
endif endif
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld LDFLAGS =
ifeq ($(ENABLE_CLANG),0)
LDFLAGS += -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
else
# Fix warning about implied executable stack
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
endif
# Use newlib-nano instead of newlib # Use newlib-nano instead of newlib
LDFLAGS += --specs=nano.specs LDFLAGS += --specs=nano.specs

View File

@@ -50,6 +50,7 @@ You can customize the firmware by enabling/disabling various compile options.
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) .. You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
``` ```
ENABLE_CLANG := 0 experimental, builds with clang instead of gcc (LTO will be disabled if you enable this)
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)
@@ -68,7 +69,6 @@ ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method
ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead just hold down keys 0-9 to access the secondary butt functions
ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up
ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right) ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
@@ -76,7 +76,7 @@ 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 := 0 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves ENABLE_SQUELCH_MORE_SENSITIVE := 0 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 := 0 don't use (for now) .. 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_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')
@@ -86,9 +86,13 @@ ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO
# New/modified function keys # New/modified function keys
* Long-press 'M' = Copy selected channel into the same VFO, then switches to frequency mode * Long-press 'M' .. Copy selected channel into same VFO, then switch VFO to frequency mode
* Long-press '5' = Toggle a selected channels scanlist setting .. if NOAA is disable in Makefile *
* Long-press '*' = Toggles the scanlist number 1, 2 or ALL channels .. if in channel scan mode * Long-press '7' .. Toggle selected channel scanlist setting .. if VOX is disabled in Makefile
* or
* Long-press '5' .. Toggle selected channel scanlist setting .. if NOAA is disabled in Makefile
*
* Long-press '*' .. Start scanning, then toggles scanlist scan 1, 2 or ALL channel scanning
# Some changes made from the Quansheng firmware # Some changes made from the Quansheng firmware
@@ -109,6 +113,9 @@ arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on
Other versions may generate a flash file that is too big. Other versions may generate a flash file that is too big.
You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm
clang may be used but isn't fully supported. Resulting binaries may also be bigger.
You can get it from: https://releases.llvm.org/download.html
# Building # Building
To build the firmware, you need to fetch the submodules and then run make: To build the firmware, you need to fetch the submodules and then run make:
@@ -123,10 +130,10 @@ To compile directly in windows without the need of a linux virtual machine:
1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm 1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm
2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm 2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm
3. You may (or not) need to manualy add gcc path to you OS environment PATH. 3. You may need to (I didn't) manualy add gcc path to your OS environment PATH.
ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin
4. You may (or not) need to reboot your PC after installing the above 4. You may need to reboot your PC after installing the above
``` ```
Then you can run 'win_make.bat' from the directory you saved this source code too. Then you can run 'win_make.bat' from the directory you saved this source code too.

View File

@@ -206,7 +206,7 @@ void ACTION_Scan(bool bRestart)
#endif #endif
// clear the other vfo's rssi level (to hide the antenna symbol) // clear the other vfo's rssi level (to hide the antenna symbol)
gVFO_RSSI_bar_level[(gEeprom.RX_CHANNEL + 1) & 1u] = 0; gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1u] = 0;
// let the user see DW is not active // let the user see DW is not active
gDualWatchActive = false; gDualWatchActive = false;

View File

@@ -122,7 +122,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true; //gUpdateDisplay = true;
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true; gUpdateRSSI = true;
} }
@@ -138,7 +138,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true; //gUpdateDisplay = true;
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true; gUpdateRSSI = true;
} }
return; return;
@@ -152,7 +152,7 @@ static void APP_CheckForIncoming(void)
gUpdateStatus = true; gUpdateStatus = true;
} }
else else
{ { // RF scanning
if (gRxReceptionMode != RX_MODE_NONE) if (gRxReceptionMode != RX_MODE_NONE)
{ {
if (gCurrentFunction != FUNCTION_INCOMING) if (gCurrentFunction != FUNCTION_INCOMING)
@@ -160,10 +160,9 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true; //gUpdateDisplay = true;
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true; gUpdateRSSI = true;
} }
return; return;
} }
@@ -178,7 +177,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true; //gUpdateDisplay = true;
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true; gUpdateRSSI = true;
} }
} }
@@ -468,7 +467,7 @@ static void APP_HandleFunction(void)
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
{ {
const unsigned int chan = gEeprom.RX_CHANNEL; const unsigned int chan = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE; // const unsigned int chan = gRxVfo->CHANNEL_SAVE;
if (gSetting_KILLED) if (gSetting_KILLED)
@@ -639,12 +638,12 @@ static void FREQ_NextChannel(void)
static void MR_NextChannel(void) static void MR_NextChannel(void)
{ {
static int prev_mr_chan = 0; static unsigned int prev_mr_chan = 0;
const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true; const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1; const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1; const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int prev_chan = gNextMrChannel; const unsigned int prev_chan = gNextMrChannel;
int chan = 0; unsigned int chan = 0;
if (enabled) if (enabled)
{ {
@@ -657,7 +656,7 @@ static void MR_NextChannel(void)
{ {
if (RADIO_CheckValidChannel(chan1, false, 0)) if (RADIO_CheckValidChannel(chan1, false, 0))
{ {
//gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1; gNextMrChannel = chan1;
break; break;
} }
@@ -674,31 +673,31 @@ static void MR_NextChannel(void)
} }
} }
// this bit doesn't work at all - yet :( // this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH: case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) // if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ // {
// chan = (gEeprom.RX_CHANNEL + 1) & 1u; // chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan]; // chan = gEeprom.ScreenChannel[chan];
// chan = 14; // if (IS_MR_CHANNEL(chan))
// if (RADIO_CheckValidChannel(chan, false, 0))
// { // {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH; // gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan; // gNextMrChannel = chan;
// break; // break;
// } // }
} // }
default: default:
case SCAN_NEXT_CHAN_MR: case SCAN_NEXT_CHAN_MR:
gCurrentScanList = SCAN_NEXT_CHAN_MR; gCurrentScanList = SCAN_NEXT_CHAN_MR;
gNextMrChannel = prev_mr_chan; gNextMrChannel = prev_mr_chan;
chan = 0xffffffff; chan = 0xff;
break; break;
} }
} }
if (!enabled || chan == 0xffffffff) if (!enabled || chan == 0xff)
{ {
chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT); chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF) if (chan == 0xFF)
@@ -711,12 +710,12 @@ static void MR_NextChannel(void)
gNextMrChannel = chan; gNextMrChannel = chan;
} }
if (prev_chan != gNextMrChannel) if (gNextMrChannel != prev_chan)
{ {
gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
gUpdateDisplay = true; gUpdateDisplay = true;
@@ -749,11 +748,11 @@ static void DUALWATCH_Alternate(void)
if (gIsNoaaMode) if (gIsNoaaMode)
{ {
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL + 1) & 1; gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1;
else else
gEeprom.RX_CHANNEL = 0; gEeprom.RX_VFO = 0;
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL]; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];
if (gEeprom.VfoInfo[0].CHANNEL_SAVE >= NOAA_CHANNEL_FIRST) if (gEeprom.VfoInfo[0].CHANNEL_SAVE >= NOAA_CHANNEL_FIRST)
NOAA_IncreaseChannel(); NOAA_IncreaseChannel();
@@ -761,8 +760,8 @@ static void DUALWATCH_Alternate(void)
else else
#endif #endif
{ // toggle between VFO's { // toggle between VFO's
gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL + 1) & 1; gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1;
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL]; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];
if (!gDualWatchActive) if (!gDualWatchActive)
{ // let the user see DW is active { // let the user see DW is active
@@ -1068,7 +1067,8 @@ void APP_Update(void)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
#endif #endif
{ { // scanning
if (IS_FREQ_CHANNEL(gNextMrChannel)) if (IS_FREQ_CHANNEL(gNextMrChannel))
{ {
if (gCurrentFunction == FUNCTION_INCOMING) if (gCurrentFunction == FUNCTION_INCOMING)
@@ -1250,7 +1250,7 @@ void APP_Update(void)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI)
{ // dual watch mode, go back to sleep { // dual watch mode, go back to sleep
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
// go back to sleep // go back to sleep
@@ -1370,11 +1370,8 @@ void APP_CheckKeys(void)
Key == KEY_UP || Key == KEY_UP ||
Key == KEY_DOWN || Key == KEY_DOWN ||
Key == KEY_EXIT || Key == KEY_EXIT ||
Key == KEY_MENU Key == KEY_MENU ||
#ifdef ENABLE_MAIN_KEY_HOLD Key <= KEY_9) // keys 0-9 can be held down to bypass pressing the F-Key
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
#endif
)
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true); APP_ProcessKey(Key, true, true);
@@ -1410,9 +1407,9 @@ void APP_TimeSlice10ms(void)
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix) // if (gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix)
if (gRxVfo->AM_mode && gSetting_AM_fix) if (gRxVfo->AM_mode && gSetting_AM_fix)
AM_fix_10ms(gEeprom.RX_CHANNEL); AM_fix_10ms(gEeprom.RX_VFO);
#endif #endif
if (UART_IsCommandAvailable()) if (UART_IsCommandAvailable())
@@ -1800,7 +1797,7 @@ void APP_TimeSlice500ms(void)
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_TRANSMIT)
{ {
if (gCurrentFunction != FUNCTION_POWER_SAVE) if (gCurrentFunction != FUNCTION_POWER_SAVE)
updateRSSI(gEeprom.RX_CHANNEL); updateRSSI(gEeprom.RX_VFO);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF) if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
@@ -2110,10 +2107,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gFlagSaveChannel) if (gFlagSaveChannel)
{ {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gFlagSaveChannel); SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gFlagSaveChannel);
gFlagSaveChannel = false; gFlagSaveChannel = false;
RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, VFO_CONFIGURE); RADIO_ConfigureChannel(gEeprom.TX_VFO, VFO_CONFIGURE);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
@@ -2163,8 +2160,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
if (!bKeyHeld) if (!bKeyHeld)
{ { // keypad is locked, tell the user
// keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4; // 2 seconds gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true; gUpdateDisplay = true;
@@ -2327,9 +2323,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case DISPLAY_MAIN: case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
#ifdef ENABLE_MAIN_KEY_HOLD
bKeyHeld = false; // allow the channel setting to be saved bKeyHeld = false; // allow the channel setting to be saved
#endif
break; break;
@@ -2435,7 +2429,7 @@ Skip:
{ {
if (!bKeyHeld) if (!bKeyHeld)
{ {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gRequestSaveChannel); SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel);
if (gScreenToDisplay != DISPLAY_SCANNER) if (gScreenToDisplay != DISPLAY_SCANNER)
if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere
@@ -2460,7 +2454,7 @@ Skip:
RADIO_ConfigureChannel(1, gVfoConfigureMode); RADIO_ConfigureChannel(1, gVfoConfigureMode);
} }
else else
RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, gVfoConfigureMode); RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode);
if (gRequestDisplayScreen == DISPLAY_INVALID) if (gRequestDisplayScreen == DISPLAY_INVALID)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;

View File

@@ -52,13 +52,23 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
if (!bKeyPressed) if (!bKeyPressed)
return; return;
if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK; gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif #endif
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK; gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
}
else else
{ {
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO

View File

@@ -38,10 +38,40 @@
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/ui.h" #include "ui/ui.h"
void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting
if (gScreenToDisplay == DISPLAY_SCANNER || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
return;
if (gTxVfo->SCANLIST1_PARTICIPATION)
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST1_PARTICIPATION = 0;
else
gTxVfo->SCANLIST2_PARTICIPATION = 1;
}
else
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST2_PARTICIPATION = 0;
else
gTxVfo->SCANLIST1_PARTICIPATION = 1;
}
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
}
static void processFKeyFunction(const KEY_Code_t Key, const bool beep) static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{ {
uint8_t Band; uint8_t Band;
uint8_t Vfo = gEeprom.TX_CHANNEL; uint8_t Vfo = gEeprom.TX_VFO;
if (gScreenToDisplay == DISPLAY_MENU)
return;
switch (Key) switch (Key)
{ {
@@ -102,7 +132,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A; gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A;
else else
gEeprom.TX_CHANNEL = (Vfo + 1) & 1u; gEeprom.TX_VFO = (Vfo + 1) & 1u;
gRequestSaveSettings = 1; gRequestSaveSettings = 1;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
@@ -125,7 +155,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // swap to frequency mode { // swap to frequency mode
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL]; gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif #endif
@@ -134,7 +164,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
} }
Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_CHANNEL], 1, false, 0); Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 0);
if (Channel != 0xFF) if (Channel != 0xFF)
{ // swap to channel mode { // swap to channel mode
gEeprom.ScreenChannel[Vfo] = Channel; gEeprom.ScreenChannel[Vfo] = Channel;
@@ -173,11 +203,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ {
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_CHANNEL]; gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
} }
else else
{ {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL]; gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif #endif
@@ -190,32 +220,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#endif #endif
} }
else { else {
// toggle the selected channels scanlist setting #ifdef ENABLE_VOX
toggle_chan_scanlist();
#endif
}
if (gScreenToDisplay != DISPLAY_SCANNER)
{
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
if (gTxVfo->SCANLIST1_PARTICIPATION)
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST1_PARTICIPATION = 0;
else
gTxVfo->SCANLIST2_PARTICIPATION = 1;
}
else
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST2_PARTICIPATION = 0;
else
gTxVfo->SCANLIST1_PARTICIPATION = 1;
}
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
}
}
}
break; break;
case KEY_6: case KEY_6:
@@ -226,11 +235,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
ACTION_Vox(); ACTION_Vox();
#else #else
toggle_chan_scanlist();
// TODO: make use of this function key
#endif #endif
break; break;
@@ -273,7 +278,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (bKeyHeld) if (bKeyHeld)
{ // key held down { // key held down
#ifdef ENABLE_MAIN_KEY_HOLD
if (bKeyPressed) if (bKeyPressed)
{ {
if (gScreenToDisplay == DISPLAY_MAIN) if (gScreenToDisplay == DISPLAY_MAIN)
@@ -290,28 +294,20 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
processFKeyFunction(Key, false); processFKeyFunction(Key, false);
} }
} }
#endif
return; return;
} }
#ifdef ENABLE_MAIN_KEY_HOLD
if (bKeyPressed) if (bKeyPressed)
{ // key is pressed { // key is pressed
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed
return; // don't use the key till it's released return; // don't use the key till it's released
} }
#else
if (!bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
#endif
if (!gWasFKeyPressed) if (!gWasFKeyPressed)
{ // F-key wasn't pressed { // F-key wasn't pressed
const uint8_t Vfo = gEeprom.TX_CHANNEL; const uint8_t Vfo = gEeprom.TX_VFO;
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
@@ -560,71 +556,50 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gUpdateStatus = true; gUpdateStatus = true;
#ifdef ENABLE_COPY_CHAN_TO_VFO #ifdef ENABLE_COPY_CHAN_TO_VFO
if (gEeprom.VFO_OPEN &&
gEeprom.DUAL_WATCH == DUAL_WATCH_OFF &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // copy channel to VFO
int channel = -1; if (gEeprom.VFO_OPEN && gCssScanMode == CSS_SCAN_MODE_OFF)
int vfo = -1;
#if 0
// copy channel to opposite VFO
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[1]))
{ {
channel = gEeprom.ScreenChannel[1];
vfo = 0; if (gScanState != SCAN_OFF)
}
else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) &&
IS_MR_CHANNEL(gEeprom.ScreenChannel[0]))
{ {
channel = gEeprom.ScreenChannel[0]; if (gCurrentFunction != FUNCTION_INCOMING ||
vfo = 1; gRxReceptionMode == RX_MODE_NONE ||
ScanPauseDelayIn_10ms == 0)
{ // scan is running (not paused)
return;
} }
#else
// copy channel to same VFO
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[gEeprom.RX_CHANNEL]))
{
channel = gEeprom.ScreenChannel[gEeprom.RX_CHANNEL];
vfo = gEeprom.RX_CHANNEL;
} }
#endif
if (channel >= 0 && vfo >= 0) const unsigned int vfo = get_rx_VFO();
{ // copy the channel into the VFO
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
{ // copy channel to VFO, then swap to the VFO
gEeprom.MrChannel[vfo] = channel; const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
gEeprom.ScreenChannel[vfo] = channel;
RADIO_ConfigureChannel(vfo, VFO_CONFIGURE_RELOAD);
channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
gEeprom.MrChannel[vfo] = channel;
gEeprom.ScreenChannel[vfo] = channel; gEeprom.ScreenChannel[vfo] = channel;
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel; gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
gEeprom.TX_VFO = vfo;
// swap to the VFO
gEeprom.TX_CHANNEL = vfo;
gEeprom.RX_CHANNEL = vfo;
RADIO_SelectVfos(); RADIO_SelectVfos();
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
// SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_CHANNEL, gRxVfo, 1); //SETTINGS_SaveChannel(channel, gEeprom.RX_VFO, gRxVfo, 1);
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gUpdateStatus = true; gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
} }
} }
#endif else
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}
#endif
} }
} }
@@ -731,7 +706,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{ {
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_CHANNEL]; uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (bKeyHeld || !bKeyPressed) if (bKeyHeld || !bKeyPressed)
{ {
@@ -796,8 +771,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (Channel == Next) if (Channel == Next)
return; return;
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = Next; gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Next; gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next;
if (!bKeyHeld) if (!bKeyHeld)
{ {
@@ -810,9 +785,9 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] - NOAA_CHANNEL_FIRST, Direction, 0, 9); Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_CHANNEL] = Channel; gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Channel; gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
} }
#endif #endif

View File

@@ -472,7 +472,7 @@ void MENU_AcceptSetting(void)
#if 0 #if 0
gEeprom.MrChannel[0] = gSubMenuSelection; gEeprom.MrChannel[0] = gSubMenuSelection;
#else #else
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = gSubMenuSelection; gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection;
#endif #endif
gRequestSaveChannel = 2; gRequestSaveChannel = 2;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@@ -492,7 +492,7 @@ void MENU_AcceptSetting(void)
// save the channel name // save the channel name
memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name)); memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name));
memmove(gTxVfo->Name, edit, 10); memmove(gTxVfo->Name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_CHANNEL, gTxVfo, 3); SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_VFO, gTxVfo, 3);
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
return; return;
@@ -921,12 +921,12 @@ void MENU_ShowCurrentSetting(void)
#if 0 #if 0
gSubMenuSelection = gEeprom.MrChannel[0]; gSubMenuSelection = gEeprom.MrChannel[0];
#else #else
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL]; gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO];
#endif #endif
break; break;
case MENU_MEM_NAME: case MENU_MEM_NAME:
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL]; gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO];
break; break;
case MENU_SAVE: case MENU_SAVE:
@@ -1106,7 +1106,7 @@ void MENU_ShowCurrentSetting(void)
#if 0 #if 0
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1); gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1);
#else #else
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_CHANNEL], 1, false, 1); gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 1);
#endif #endif
break; break;

View File

@@ -250,16 +250,16 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ {
Channel = gScanChannel; Channel = gScanChannel;
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = Channel; gEeprom.MrChannel[gEeprom.TX_VFO] = Channel;
} }
else else
{ {
Channel = gTxVfo->Band + FREQ_CHANNEL_FIRST; Channel = gTxVfo->Band + FREQ_CHANNEL_FIRST;
gEeprom.FreqChannel[gEeprom.TX_CHANNEL] = Channel; gEeprom.FreqChannel[gEeprom.TX_VFO] = Channel;
} }
gTxVfo->CHANNEL_SAVE = Channel; gTxVfo->CHANNEL_SAVE = Channel;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Channel; gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CONFIRM; gAnotherVoiceID = VOICE_ID_CONFIRM;
#endif #endif
@@ -430,10 +430,10 @@ void SCANNER_Stop(void)
{ {
if (IS_MR_CHANNEL(gNextMrChannel)) if (IS_MR_CHANNEL(gNextMrChannel))
{ {
gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gRestoreMrChannel; gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = Previous; gEeprom.ScreenChannel[gEeprom.RX_VFO] = Previous;
RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
} }
else else
{ {
@@ -450,7 +450,7 @@ void SCANNER_Stop(void)
{ {
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_CHANNEL, gRxVfo, 1); SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_VFO, gRxVfo, 1);
return; return;
} }

View File

@@ -385,7 +385,7 @@ static void CMD_052F(const uint8_t *pBuffer)
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF; gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gEeprom.RX_CHANNEL = 0; gEeprom.RX_VFO = 0;
gEeprom.DTMF_SIDE_TONE = false; gEeprom.DTMF_SIDE_TONE = false;
gEeprom.VfoInfo[0].FrequencyReverse = false; gEeprom.VfoInfo[0].FrequencyReverse = false;
gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX; gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX;

View File

@@ -509,7 +509,7 @@ void BOARD_Init(void)
BOARD_PORTCON_Init(); BOARD_PORTCON_Init();
BOARD_GPIO_Init(); BOARD_GPIO_Init();
BOARD_ADC_Init(); BOARD_ADC_Init();
ST7565_Init(); ST7565_Init(true);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif
@@ -616,7 +616,7 @@ void BOARD_EEPROM_Init(void)
#endif #endif
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0; gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0;
gEeprom.TX_CHANNEL = (Data[3] < 2) ? Data[3] : 0; gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0;
// 0ED0..0ED7 // 0ED0..0ED7
EEPROM_ReadBuffer(0x0ED0, Data, 8); EEPROM_ReadBuffer(0x0ED0, Data, 8);

View File

@@ -58,21 +58,21 @@ void BK4819_Init(void)
BK4819_WriteRegister(BK4819_REG_7D, 0xE940); BK4819_WriteRegister(BK4819_REG_7D, 0xE940);
// RX AF level // REG_48 .. RX AF level
// //
// REG_48 <15:12> 11 ??? 0 to 15 // <15:12> 11 ??? 0 to 15
// //
// REG_48 <11:10> 0 AF Rx Gain-1 // <11:10> 0 AF Rx Gain-1
// 0 = 0dB // 0 = 0dB
// 1 = -6dB // 1 = -6dB
// 2 = -12dB // 2 = -12dB
// 3 = -18dB // 3 = -18dB
// //
// REG_48 <9:4> 60 AF Rx Gain-2 -26dB ~ 5.5dB 0.5dB/step // <9:4> 60 AF Rx Gain-2 -26dB ~ 5.5dB 0.5dB/step
// 63 = max // 63 = max
// 0 = mute // 0 = mute
// //
// REG_48 <3:0> 15 AF DAC Gain (after Gain-1 and Gain-2) approx 2dB/step // <3:0> 15 AF DAC Gain (after Gain-1 and Gain-2) approx 2dB/step
// 15 = max // 15 = max
// 0 = min // 0 = min
// //
@@ -236,33 +236,37 @@ void BK4819_SetAGC(uint8_t Value)
{ {
if (Value == 0) if (Value == 0)
{ {
// REG_10 <15:0> 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) // REG_10
// //
// <9:8> = LNA Gain Short // 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1)
// 3 = 0dB //
// <15:10> ???
//
// <9:8> LNA Gain Short
// 3 = 0dB <<<
// 2 = -24dB // was -11 // 2 = -24dB // was -11
// 1 = -30dB // was -16 // 1 = -30dB // was -16
// 0 = -33dB // was -19 // 0 = -33dB // was -19
// //
// <7:5> = LNA Gain // <7:5> LNA Gain
// 7 = 0dB // 7 = 0dB
// 6 = -2dB // 6 = -2dB
// 5 = -4dB // 5 = -4dB
// 4 = -6dB // 4 = -6dB
// 3 = -9dB // 3 = -9dB
// 2 = -14dB // 2 = -14dB <<<
// 1 = -19dB // 1 = -19dB
// 0 = -24dB // 0 = -24dB
// //
// <4:3> = MIXER Gain // <4:3> MIXER Gain
// 3 = 0dB // 3 = 0dB <<<
// 2 = -3dB // 2 = -3dB
// 1 = -6dB // 1 = -6dB
// 0 = -8dB // 0 = -8dB
// //
// <2:0> = PGA Gain // <2:0> PGA Gain
// 7 = 0dB // 7 = 0dB
// 6 = -3dB // 6 = -3dB <<<
// 5 = -6dB // 5 = -6dB
// 4 = -9dB // 4 = -9dB
// 3 = -15dB // 3 = -15dB
@@ -270,11 +274,6 @@ void BK4819_SetAGC(uint8_t Value)
// 1 = -27dB // 1 = -27dB
// 0 = -33dB // 0 = -33dB
// //
// LNA_SHORT .. 0dB
// LNA ........ 14dB
// MIXER ...... 0dB
// PGA ........ -3dB
//
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110
BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011 BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011
@@ -287,20 +286,23 @@ void BK4819_SetAGC(uint8_t Value)
} }
else else
if (Value == 1) if (Value == 1)
{ // what does this do ????????? { // what does this do ???
unsigned int i; unsigned int i;
// REG_10 // REG_10
// <15:0> 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1)
// //
// <9:8> = LNA Gain Short // 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1)
//
// (15:10> ???
//
// <9:8> LNA Gain Short
// 3 = 0dB << original // 3 = 0dB << original
// 2 = -24dB // was -11 // 2 = -24dB // was -11
// 1 = -30dB // was -16 // 1 = -30dB // was -16
// 0 = -33dB // was -19 // 0 = -33dB // was -19
// //
// <7:5> = LNA Gain // <7:5> LNA Gain
// 7 = 0dB // 7 = 0dB
// 6 = -2dB // 6 = -2dB
// 5 = -4dB // 5 = -4dB
@@ -310,13 +312,13 @@ void BK4819_SetAGC(uint8_t Value)
// 1 = -19dB // 1 = -19dB
// 0 = -24dB // 0 = -24dB
// //
// <4:3> = MIXER Gain // <4:3> MIXER Gain
// 3 = 0dB << original // 3 = 0dB << original
// 2 = -3dB // 2 = -3dB
// 1 = -6dB // 1 = -6dB
// 0 = -8dB // 0 = -8dB
// //
// <2:0> = PGA Gain // <2:0> PGA Gain
// 7 = 0dB // 7 = 0dB
// 6 = -3dB << original // 6 = -3dB << original
// 5 = -6dB // 5 = -6dB
@@ -357,15 +359,42 @@ void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet)
void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
{ {
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable // REG_51
// REG_51 <14> 0 1 = GPIO0Input for CDCSS 0 = Normal Mode.(for BK4819v3) //
// REG_51 <13> 0 1 = Transmit negative CDCSS code 0 = Transmit positive CDCSScode // <15> 0
// REG_51 <12> 0 CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS // 1 = Enable TxCTCSS/CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection 1 = 24bit 0 = 23bit // 0 = Disable
// REG_51 <10> 0 1050HzDetectionMode 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz //
// REG_51 <9> 0 Auto CDCSS Bw Mode 1 = Disable 0 = Enable. // <14> 0
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable // 1 = GPIO0Input for CDCSS
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max // 0 = Normal Mode (for BK4819 v3)
//
// <13> 0
// 1 = Transmit negative CDCSS code
// 0 = Transmit positive CDCSS code
//
// <12> 0 CTCSS/CDCSS mode selection
// 1 = CTCSS
// 0 = CDCSS
//
// <11> 0 CDCSS 24/23bit selection
// 1 = 24bit
// 0 = 23bit
//
// <10> 0 1050HzDetectionMode
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
//
// <9> 0 Auto CDCSS Bw Mode
// 1 = Disable
// 0 = Enable
//
// <8> 0 Auto CTCSS Bw Mode
// 0 = Enable
// 1 = Disable
//
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
// 0 = min
// 127 = max
// Enable CDCSS // Enable CDCSS
// Transmit positive CDCSS code // Transmit positive CDCSS code
@@ -376,15 +405,15 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
// CTCSS/CDCSS Tx Gain1 Tuning = 51 // CTCSS/CDCSS Tx Gain1 Tuning = 51
// //
BK4819_WriteRegister(BK4819_REG_51, BK4819_WriteRegister(BK4819_REG_51,
BK4819_REG_51_ENABLE_CxCSS BK4819_REG_51_ENABLE_CxCSS |
| BK4819_REG_51_GPIO6_PIN2_NORMAL BK4819_REG_51_GPIO6_PIN2_NORMAL |
| BK4819_REG_51_TX_CDCSS_POSITIVE BK4819_REG_51_TX_CDCSS_POSITIVE |
| BK4819_REG_51_MODE_CDCSS BK4819_REG_51_MODE_CDCSS |
| BK4819_REG_51_CDCSS_23_BIT BK4819_REG_51_CDCSS_23_BIT |
| BK4819_REG_51_1050HZ_NO_DETECTION BK4819_REG_51_1050HZ_NO_DETECTION |
| BK4819_REG_51_AUTO_CDCSS_BW_ENABLE BK4819_REG_51_AUTO_CDCSS_BW_ENABLE |
| BK4819_REG_51_AUTO_CTCSS_BW_ENABLE BK4819_REG_51_AUTO_CTCSS_BW_ENABLE |
| (51u << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1)); (51u << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1));
// REG_07 <15:0> // REG_07 <15:0>
// //
@@ -515,7 +544,10 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different) void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different)
{ {
// REG_43 <14:12> 4 RF filter bandwidth // REG_43
// <15> 0 ???
//
// <14:12> 4 RF filter bandwidth
// 0 = 1.7 kHz // 0 = 1.7 kHz
// 1 = 2.0 kHz // 1 = 2.0 kHz
// 2 = 2.5 kHz // 2 = 2.5 kHz
@@ -524,9 +556,9 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
// 5 = 4.0 kHz // 5 = 4.0 kHz
// 6 = 4.25 kHz // 6 = 4.25 kHz
// 7 = 4.5 kHz // 7 = 4.5 kHz
// if REG_43 <5> == 1 RF filter bandwidth * 2 // if <5> == 1, RF filter bandwidth * 2
// //
// REG_43 <11:9> 0 RF filter bandwidth when signal is weak // <11:9> 0 RF filter bandwidth when signal is weak
// 0 = 1.7 kHz // 0 = 1.7 kHz
// 1 = 2.0 kHz // 1 = 2.0 kHz
// 2 = 2.5 kHz // 2 = 2.5 kHz
@@ -535,9 +567,9 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
// 5 = 4.0 kHz // 5 = 4.0 kHz
// 6 = 4.25 kHz // 6 = 4.25 kHz
// 7 = 4.5 kHz // 7 = 4.5 kHz
// if REG_43 <5> == 1 RF filter bandwidth * 2 // if <5> == 1, RF filter bandwidth * 2
// //
// REG_43 <8:6> 1 AFTxLPF2 filter Band Width // <8:6> 1 AFTxLPF2 filter Band Width
// 1 = 2.5 kHz (for 12.5k channel space) // 1 = 2.5 kHz (for 12.5k channel space)
// 2 = 2.75 kHz // 2 = 2.75 kHz
// 0 = 3.0 kHz (for 25k channel space) // 0 = 3.0 kHz (for 25k channel space)
@@ -547,99 +579,107 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
// 6 = 4.0 kHz // 6 = 4.0 kHz
// 7 = 3.75 kHz // 7 = 3.75 kHz
// //
// REG_43 <5:4> 0 BW Mode Selection // <5:4> 0 BW Mode Selection
// 1 = 6.25k
// 0 = 12.5k // 0 = 12.5k
// 1 = 6.25k
// 2 = 25k/20k // 2 = 25k/20k
// //
// REG_43 <2> 0 Gain after FM Demodulation // <3> 1 ???
//
// <2> 0 Gain after FM Demodulation
// 0 = 0dB // 0 = 0dB
// 1 = 6dB // 1 = 6dB
//
// <1:0> 0 ???
if (Bandwidth == BK4819_FILTER_BW_WIDE) uint16_t val;
{ // 25kHz
switch (Bandwidth)
{
default:
case BK4819_FILTER_BW_WIDE: // 25kHz
if (weak_no_different) if (weak_no_different)
{ // make the RX bandwidth the same with weak signals (sounds better) { // make the RX bandwidth the same with weak signals
val =
BK4819_WriteRegister(BK4819_REG_43,
(0u << 15) | // 0 (0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth (5u << 12) | // *3 RF filter bandwidth
(3u << 9) | // *0 RF filter bandwidth when signal is weak (5u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width (6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection (2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation (0u << 2) | // 0 Gain after FM Demodulation
(0u << 0)); // 0 (0u << 0); // 0
} }
else else
{ // with weak RX signals the RX bandwidth is reduced { // with weak RX signals the RX bandwidth is reduced
BK4819_WriteRegister(BK4819_REG_43, // 0x3028); // 0 011 000 000 10 1 0 00 val = // 0x3028); // 0 011 000 000 10 1 0 00
(0u << 15) | // 0 (0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth (5u << 12) | // *3 RF filter bandwidth
(0u << 9) | // *0 RF filter bandwidth when signal is weak (2u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width (6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection (2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation (0u << 2) | // 0 Gain after FM Demodulation
(0u << 0)); // 0 (0u << 0); // 0
} }
} break;
else
if (Bandwidth == BK4819_FILTER_BW_NARROW) case BK4819_FILTER_BW_NARROW: // 12.5kHz
{ // 12.5kHz
if (weak_no_different) if (weak_no_different)
{ {
BK4819_WriteRegister(BK4819_REG_43, // 0x4048); // 0 100 000 001 00 1 0 00 val =
(0u << 15) | // 0 (0u << 15) | // 0
(3u << 12) | // 4 RF filter bandwidth (5u << 12) | // *4 RF filter bandwidth
(5u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
else
{
val = // 0x4048); // 0 100 000 001 00 1 0 00
(0u << 15) | // 0
(5u << 12) | // *4 RF filter bandwidth
(2u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0); // 0
}
break;
case BK4819_FILTER_BW_NARROWER: // 6.25kHz
if (weak_no_different)
{
val =
(0u << 15) | // 0
(3u << 12) | // 3 RF filter bandwidth
(3u << 9) | // *0 RF filter bandwidth when signal is weak (3u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0)); // 0
}
else
{
BK4819_WriteRegister(BK4819_REG_43, // 0x4048); // 0 100 000 001 00 1 0 00
(0u << 15) | // 0
(3u << 12) | // 4 RF filter bandwidth
(0u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation
(0u << 0)); // 0
}
}
else
if (Bandwidth == BK4819_FILTER_BW_NARROWER)
{ // 6.25kHz
if (weak_no_different)
{
BK4819_WriteRegister(BK4819_REG_43,
(0u << 15) | // 0
(2u << 12) | // 4 RF filter bandwidth
(2u << 9) | // 0 RF filter bandwidth when signal is weak
(1u << 6) | // 1 AFTxLPF2 filter Band Width (1u << 6) | // 1 AFTxLPF2 filter Band Width
(1u << 4) | // 1 BW Mode Selection (1u << 4) | // 1 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation (0u << 2) | // 0 Gain after FM Demodulation
(0u << 0)); // 0 (0u << 0); // 0
} }
else else
{ {
BK4819_WriteRegister(BK4819_REG_43, val =
(0u << 15) | // 0 (0u << 15) | // 0
(2u << 12) | // 4 RF filter bandwidth (3u << 12) | // 3 RF filter bandwidth
(0u << 9) | // 0 RF filter bandwidth when signal is weak (0u << 9) | // 0 RF filter bandwidth when signal is weak
(1u << 6) | // 1 AFTxLPF2 filter Band Width (1u << 6) | // 1 AFTxLPF2 filter Band Width
(1u << 4) | // 1 BW Mode Selection (1u << 4) | // 1 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
(0u << 2) | // 0 Gain after FM Demodulation (0u << 2) | // 1 Gain after FM Demodulation
(0u << 0)); // 0 (0u << 0); // 0
} }
break;
} }
BK4819_WriteRegister(BK4819_REG_43, val);
} }
void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency) void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency)
@@ -680,18 +720,20 @@ void BK4819_SetupSquelch(
uint8_t SquelchCloseGlitchThresh, uint8_t SquelchCloseGlitchThresh,
uint8_t SquelchOpenGlitchThresh) uint8_t SquelchOpenGlitchThresh)
{ {
// REG_70 <15> 0 Enable TONE1 // REG_70
//
// <15> 0 Enable TONE1
// 1 = Enable // 1 = Enable
// 0 = Disable // 0 = Disable
// //
// REG_70 <14:8> 0 TONE1 tuning gain // <14:8> 0 TONE1 tuning gain
// 0 ~ 127 // 0 ~ 127
// //
// REG_70 <7> 0 Enable TONE2 // <7> 0 Enable TONE2
// 1 = Enable // 1 = Enable
// 0 = Disable // 0 = Disable
// //
// REG_70 <6:0> 0 TONE2/FSK tuning gain // <6:0> 0 TONE2/FSK tuning gain
// 0 ~ 127 // 0 ~ 127
// //
BK4819_WriteRegister(BK4819_REG_70, 0); BK4819_WriteRegister(BK4819_REG_70, 0);
@@ -702,43 +744,51 @@ void BK4819_SetupSquelch(
// //
BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh);
// REG_4E <15:14> 1 ??? // REG_4E
// //
// REG_4E <13:11> 5 Squelch = 1 Delay Setting // <15:14> 1 ???
//
// <13:11> 5 Squelch = 1 Delay Setting
// 0 ~ 7 // 0 ~ 7
// //
// REG_4E <10: 9> 7 Squelch = 0 Delay Setting // <10:9> 7 Squelch = 0 Delay Setting
// 0 ~ 3 // 0 ~ 3
// //
// REG_4E < 8> 0 ??? // <8> 0 ???
// //
// REG_4E < 7: 0> 8 Glitch threshold for Squelch = 1 // <7:0> 8 Glitch threshold for Squelch = 1
// 0 ~ 255 // 0 ~ 255
// //
BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000 BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000
#ifndef ENABLE_FASTER_CHANNEL_SCAN #ifndef ENABLE_FASTER_CHANNEL_SCAN
// original // original
(1u << 14) // 1 ??? (1u << 14) | // 1 ???
| (5u << 11) // 5 squelch = 1 delay .. 0 ~ 7 (5u << 11) | // 5 squelch = 1 delay .. 0 ~ 7
| (3u << 9) // 3 squelch = 0 delay .. 0 ~ 3 (3u << 9) | // 3 squelch = 0 delay .. 0 ~ 3
| SquelchOpenGlitchThresh); // 0 ~ 255 SquelchOpenGlitchThresh); // 0 ~ 255
#else #else
// faster (but twitchier) // faster (but twitchier)
(1u << 14) // 1 ??? (1u << 14) | // 1 ???
| SquelchOpenGlitchThresh); // 0 ~ 255 SquelchOpenGlitchThresh); // 0 ~ 255
#endif #endif
// REG_4F <14:8> 47 Ex-noise threshold for Squelch = 0 // REG_4F
//
// <14:8> 47 Ex-noise threshold for Squelch = 0
// 0 ~ 127 // 0 ~ 127
// //
// REG_4F < 7> ??? // <7> ???
// //
// REG_4F < 6:0> 46 Ex-noise threshold for Squelch = 1 // <6:0> 46 Ex-noise threshold for Squelch = 1
// 0 ~ 127 // 0 ~ 127
//
BK4819_WriteRegister(BK4819_REG_4F, ((uint16_t)SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh); BK4819_WriteRegister(BK4819_REG_4F, ((uint16_t)SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh);
// REG_78 <15:8> 72 RSSI threshold for Squelch = 1 0.5dB/step // REG_78
// REG_78 < 7:0> 70 RSSI threshold for Squelch = 0 0.5dB/step //
// <15:8> 72 RSSI threshold for Squelch = 1 0.5dB/step
//
// <7:0> 70 RSSI threshold for Squelch = 0 0.5dB/step
// //
BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh); BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh);
@@ -751,6 +801,7 @@ void BK4819_SetAF(BK4819_AF_Type_t AF)
{ {
// AF Output Inverse Mode = Inverse // AF Output Inverse Mode = Inverse
// Undocumented bits 0x2040 // Undocumented bits 0x2040
//
BK4819_WriteRegister(BK4819_REG_47, 0x6040 | (AF << 8)); BK4819_WriteRegister(BK4819_REG_47, 0x6040 | (AF << 8));
} }
@@ -769,6 +820,7 @@ void BK4819_RX_TurnOn(void)
// Enable DSP // Enable DSP
// Enable XTAL // Enable XTAL
// Enable Band Gap // Enable Band Gap
//
BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001111100001111 BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001111100001111
// Turn off everything // Turn off everything
@@ -782,6 +834,7 @@ void BK4819_RX_TurnOn(void)
// Disable MIC ADC // Disable MIC ADC
// Disable TX DSP // Disable TX DSP
// Enable RX DSP // Enable RX DSP
//
BK4819_WriteRegister(BK4819_REG_30, 0b1011111111110001); // 1 0 1111 1 1 1111 0 0 0 1 BK4819_WriteRegister(BK4819_REG_30, 0b1011111111110001); // 1 0 1111 1 1 1111 0 0 0 1
} }
@@ -821,7 +874,7 @@ void BK4819_EnableScramble(uint8_t Type)
bool BK4819_CompanderEnabled(void) bool BK4819_CompanderEnabled(void)
{ {
return (BK4819_ReadRegister(BK4819_REG_31) & (1u < 3)) ? true : false; return (BK4819_ReadRegister(BK4819_REG_31) & (1u << 3)) ? true : false;
} }
void BK4819_SetCompander(const unsigned int mode) void BK4819_SetCompander(const unsigned int mode)
@@ -839,47 +892,47 @@ void BK4819_SetCompander(const unsigned int mode)
return; return;
} }
// set the compressor ratio // REG_29
// //
// REG_29 <15:14> 10 Compress (AF Tx) Ratio // <15:14> 10 Compress (AF Tx) Ratio
// 00 = Disable // 00 = Disable
// 01 = 1.333:1 // 01 = 1.333:1
// 10 = 2:1 // 10 = 2:1
// 11 = 4:1 // 11 = 4:1
// //
// REG_29 <13:7> 86 Compress (AF Tx) 0 dB point (dB) // <13:7> 86 Compress (AF Tx) 0 dB point (dB)
// //
// REG_29 <6:0> 64 Compress (AF Tx) noise point (dB) // <6:0> 64 Compress (AF Tx) noise point (dB)
// //
const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 2 : 0; // 2:1 const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 2 : 0; // 2:1
const uint16_t compress_0dB = 86; const uint16_t compress_0dB = 86;
const uint16_t compress_noise_dB = 64; const uint16_t compress_noise_dB = 64;
// AB40 10 1010110 1000000 // AB40 10 1010110 1000000
BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u << 14)) | (compress_ratio << 14));
(compress_ratio << 14) (compress_ratio << 14) |
| (compress_0dB << 7) (compress_0dB << 7) |
| (compress_noise_dB << 0)); (compress_noise_dB << 0));
// set the expander ratio // REG_28
// //
// REG_28 <15:14> 01 Expander (AF Rx) Ratio // <15:14> 01 Expander (AF Rx) Ratio
// 00 = Disable // 00 = Disable
// 01 = 1:2 // 01 = 1:2
// 10 = 1:3 // 10 = 1:3
// 11 = 1:4 // 11 = 1:4
// //
// REG_28 <13:7> 86 Expander (AF Rx) 0 dB point (dB) // <13:7> 86 Expander (AF Rx) 0 dB point (dB)
// //
// REG_28 <6:0> 56 Expander (AF Rx) noise point (dB) // <6:0> 56 Expander (AF Rx) noise point (dB)
// //
const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2 const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2
const uint16_t expand_0dB = 86; const uint16_t expand_0dB = 86;
const uint16_t expand_noise_dB = 56; const uint16_t expand_noise_dB = 56;
// 6B38 01 1010110 0111000 // 6B38 01 1010110 0111000
BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u << 14)) | (expand_ratio << 14));
(expand_ratio << 14) (expand_ratio << 14) |
| (expand_0dB << 7) (expand_0dB << 7) |
| (expand_noise_dB << 0)); (expand_noise_dB << 0));
// enable // enable
BK4819_WriteRegister(BK4819_REG_31, r31 | (1u << 3)); BK4819_WriteRegister(BK4819_REG_31, r31 | (1u << 3));
@@ -898,29 +951,36 @@ void BK4819_DisableDTMF(void)
void BK4819_EnableDTMF(void) void BK4819_EnableDTMF(void)
{ {
// no idea what this register does // no idea what this does
BK4819_WriteRegister(BK4819_REG_21, 0x06D8); // 0000 0110 1101 1000 BK4819_WriteRegister(BK4819_REG_21, 0x06D8); // 0000 0110 1101 1000
// REG_24 <15> 1 ??? // REG_24
// REG_24 <14:7> 24 Threshold //
// REG_24 <6> 1 ??? // <15> 1 ???
// REG_24 <5> 0 DTMF/SelCall enable //
// <14:7> 24 Threshold
//
// <6> 1 ???
//
// <5> 0 DTMF/SelCall enable
// 1 = Enable // 1 = Enable
// 0 = Disable // 0 = Disable
// REG_24 <4> 1 DTMF or SelCall detection mode //
// <4> 1 DTMF or SelCall detection mode
// 1 = for DTMF // 1 = for DTMF
// 0 = for SelCall // 0 = for SelCall
// REG_24 <3:0> 14 Max symbol number for SelCall detection //
// <3:0> 14 Max symbol number for SelCall detection
// const uint16_t threshold = 24; // doesn't decode non-QS radios //
// const uint16_t threshold = 24; // default, but doesn't decode non-QS radios
const uint16_t threshold = 160; // but 128 ~ 247 does const uint16_t threshold = 160; // but 128 ~ 247 does
BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110 BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110
(1u << BK4819_REG_24_SHIFT_UNKNOWN_15) (1u << BK4819_REG_24_SHIFT_UNKNOWN_15) |
| (threshold << BK4819_REG_24_SHIFT_THRESHOLD) // 0 ~ 255 (threshold << BK4819_REG_24_SHIFT_THRESHOLD) | // 0 ~ 255
| (1u << BK4819_REG_24_SHIFT_UNKNOWN_6) (1u << BK4819_REG_24_SHIFT_UNKNOWN_6) |
| BK4819_REG_24_ENABLE BK4819_REG_24_ENABLE |
| BK4819_REG_24_SELECT_DTMF BK4819_REG_24_SELECT_DTMF |
| (14u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15 (14u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15
} }
void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch) void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch)
@@ -967,13 +1027,12 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
BK4819_WriteRegister(BK4819_REG_30, 0); BK4819_WriteRegister(BK4819_REG_30, 0);
BK4819_WriteRegister(BK4819_REG_30, BK4819_WriteRegister(BK4819_REG_30,
0 BK4819_REG_30_ENABLE_VCO_CALIB |
| BK4819_REG_30_ENABLE_VCO_CALIB BK4819_REG_30_ENABLE_RX_LINK |
| BK4819_REG_30_ENABLE_RX_LINK BK4819_REG_30_ENABLE_AF_DAC |
| BK4819_REG_30_ENABLE_AF_DAC BK4819_REG_30_ENABLE_DISC_MODE |
| BK4819_REG_30_ENABLE_DISC_MODE BK4819_REG_30_ENABLE_PLL_VCO |
| BK4819_REG_30_ENABLE_PLL_VCO BK4819_REG_30_ENABLE_RX_DSP);
| BK4819_REG_30_ENABLE_RX_DSP);
} }
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
@@ -1034,10 +1093,10 @@ void BK4819_ExitBypass(void)
// 0 = bypass DC filter // 0 = bypass DC filter
// //
BK4819_WriteRegister(BK4819_REG_7E, // 0x302E); // 0 011 000000 101 110 BK4819_WriteRegister(BK4819_REG_7E, // 0x302E); // 0 011 000000 101 110
(0u << 15) // 0 AGC fix mode (0u << 15) | // 0 AGC fix mode
| (3u << 12) // 3 AGC fix index (3u << 12) | // 3 AGC fix index
| (5u << 3) // 5 DC Filter band width for Tx (MIC In) (5u << 3) | // 5 DC Filter band width for Tx (MIC In)
| (6u << 0)); // 6 DC Filter band width for Rx (I.F In) (6u << 0)); // 6 DC Filter band width for Rx (I.F In)
} }
void BK4819_PrepareTransmit(void) void BK4819_PrepareTransmit(void)
@@ -1057,15 +1116,42 @@ void BK4819_TxOn_Beep(void)
void BK4819_ExitSubAu(void) void BK4819_ExitSubAu(void)
{ {
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable // REG_51
// REG_51 <14> 0 1 = GPIO0Input for CDCSS 0 = Normal Mode.(for BK4819v3) //
// REG_51 <13> 0 1 = Transmit negative CDCSS code 0 = Transmit positive CDCSScode // <15> 0
// REG_51 <12> 0 CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS // 1 = Enable TxCTCSS/CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection 1 = 24bit 0 = 23bit // 0 = Disable
// REG_51 <10> 0 1050HzDetectionMode 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz //
// REG_51 <9> 0 Auto CDCSS Bw Mode 1 = Disable 0 = Enable. // <14> 0
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable // 1 = GPIO0Input for CDCSS
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max // 0 = Normal Mode (for BK4819 v3)
//
// <13> 0
// 1 = Transmit negative CDCSS code
// 0 = Transmit positive CDCSS code
//
// <12> 0 CTCSS/CDCSS mode selection
// 1 = CTCSS
// 0 = CDCSS
//
// <11> 0 CDCSS 24/23bit selection
// 1 = 24bit
// 0 = 23bit
//
// <10> 0 1050HzDetectionMode
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
//
// <9> 0 Auto CDCSS Bw Mode
// 1 = Disable
// 0 = Enable
//
// <8> 0 Auto CTCSS Bw Mode
// 0 = Enable
// 1 = Disable
//
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
// 0 = min
// 127 = max
// //
BK4819_WriteRegister(BK4819_REG_51, 0x0000); BK4819_WriteRegister(BK4819_REG_51, 0x0000);
} }
@@ -1086,11 +1172,10 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback)
BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE);
BK4819_WriteRegister(BK4819_REG_70, BK4819_WriteRegister(BK4819_REG_70,
0 BK4819_REG_70_MASK_ENABLE_TONE1 |
| BK4819_REG_70_MASK_ENABLE_TONE1 (83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) |
| (83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) BK4819_REG_70_MASK_ENABLE_TONE2 |
| BK4819_REG_70_MASK_ENABLE_TONE2 (83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
| (83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
BK4819_EnableTXLink(); BK4819_EnableTXLink();
} }
@@ -1109,17 +1194,16 @@ void BK4819_ExitDTMF_TX(bool bKeep)
void BK4819_EnableTXLink(void) void BK4819_EnableTXLink(void)
{ {
BK4819_WriteRegister(BK4819_REG_30, BK4819_WriteRegister(BK4819_REG_30,
0 BK4819_REG_30_ENABLE_VCO_CALIB |
| BK4819_REG_30_ENABLE_VCO_CALIB BK4819_REG_30_ENABLE_UNKNOWN |
| BK4819_REG_30_ENABLE_UNKNOWN BK4819_REG_30_DISABLE_RX_LINK |
| BK4819_REG_30_DISABLE_RX_LINK BK4819_REG_30_ENABLE_AF_DAC |
| BK4819_REG_30_ENABLE_AF_DAC BK4819_REG_30_ENABLE_DISC_MODE |
| BK4819_REG_30_ENABLE_DISC_MODE BK4819_REG_30_ENABLE_PLL_VCO |
| BK4819_REG_30_ENABLE_PLL_VCO BK4819_REG_30_ENABLE_PA_GAIN |
| BK4819_REG_30_ENABLE_PA_GAIN BK4819_REG_30_DISABLE_MIC_ADC |
| BK4819_REG_30_DISABLE_MIC_ADC BK4819_REG_30_ENABLE_TX_DSP |
| BK4819_REG_30_ENABLE_TX_DSP BK4819_REG_30_DISABLE_RX_DSP);
| BK4819_REG_30_DISABLE_RX_DSP);
} }
void BK4819_PlayDTMF(char Code) void BK4819_PlayDTMF(char Code)
@@ -1127,32 +1211,31 @@ void BK4819_PlayDTMF(char Code)
uint16_t tone1 = 0; uint16_t tone1 = 0;
uint16_t tone2 = 0; uint16_t tone2 = 0;
switch (Code) switch (Code) // Hz Hz
{ { //
case '0': tone1 = 9715; tone2 = 13793; break; // 941Hz 1336Hz case '0': tone1 = 9715; tone2 = 13793; break; // 941 1336
case '1': tone1 = 7196; tone2 = 12482; break; // 679Hz 1209Hz case '1': tone1 = 7196; tone2 = 12482; break; // 679 1209
case '2': tone1 = 7196; tone2 = 13793; break; // 697Hz 1336Hz case '2': tone1 = 7196; tone2 = 13793; break; // 697 1336
case '3': tone1 = 7196; tone2 = 15249; break; // 679Hz 1477Hz case '3': tone1 = 7196; tone2 = 15249; break; // 679 1477
case '4': tone1 = 7950; tone2 = 12482; break; // 770Hz 1209Hz case '4': tone1 = 7950; tone2 = 12482; break; // 770 1209
case '5': tone1 = 7950; tone2 = 13793; break; // 770Hz 1336Hz case '5': tone1 = 7950; tone2 = 13793; break; // 770 1336
case '6': tone1 = 7950; tone2 = 15249; break; // 770Hz 1477Hz case '6': tone1 = 7950; tone2 = 15249; break; // 770 1477
case '7': tone1 = 8796; tone2 = 12482; break; // 852Hz 1209Hz case '7': tone1 = 8796; tone2 = 12482; break; // 852 1209
case '8': tone1 = 8796; tone2 = 13793; break; // 852Hz 1336Hz case '8': tone1 = 8796; tone2 = 13793; break; // 852 1336
case '9': tone1 = 8796; tone2 = 15249; break; // 852Hz 1477Hz case '9': tone1 = 8796; tone2 = 15249; break; // 852 1477
case 'A': tone1 = 7196; tone2 = 16860; break; // 679Hz 1633Hz case 'A': tone1 = 7196; tone2 = 16860; break; // 679 1633
case 'B': tone1 = 7950; tone2 = 16860; break; // 770Hz 1633Hz case 'B': tone1 = 7950; tone2 = 16860; break; // 770 1633
case 'C': tone1 = 8796; tone2 = 16860; break; // 852Hz 1633Hz case 'C': tone1 = 8796; tone2 = 16860; break; // 852 1633
case 'D': tone1 = 9715; tone2 = 16860; break; // 941Hz 1633Hz case 'D': tone1 = 9715; tone2 = 16860; break; // 941 1633
case '*': tone1 = 9715; tone2 = 12482; break; // 941Hz 1209Hz case '*': tone1 = 9715; tone2 = 12482; break; // 941 1209
case '#': tone1 = 9715; tone2 = 15249; break; // 941Hz 1477Hz case '#': tone1 = 9715; tone2 = 15249; break; // 941 1477
} }
if (tone1 > 0 && tone2 > 0) if (tone1 > 0)
{
BK4819_WriteRegister(BK4819_REG_71, tone1); BK4819_WriteRegister(BK4819_REG_71, tone1);
if (tone2 > 0)
BK4819_WriteRegister(BK4819_REG_72, tone2); BK4819_WriteRegister(BK4819_REG_72, tone2);
} }
}
void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime) void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime)
{ {
@@ -1183,18 +1266,20 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
{ {
BK4819_EnterTxMute(); BK4819_EnterTxMute();
// REG_70 <15> 0 Enable TONE1 // REG_70
//
// <15> 0 Enable TONE1
// 1 = Enable // 1 = Enable
// 0 = Disable // 0 = Disable
// //
// REG_70 <14:8> 0 TONE1 tuning gain // <14:8> 0 TONE1 tuning gain
// 0 ~ 127 // 0 ~ 127
// //
// REG_70 <7> 0 Enable TONE2 // <7> 0 Enable TONE2
// 1 = Enable // 1 = Enable
// 0 = Disable // 0 = Disable
// //
// REG_70 <6:0> 0 TONE2/FSK tuning gain // <6:0> 0 TONE2/FSK amplitude
// 0 ~ 127 // 0 ~ 127
// //
// set the tone amplitude // set the tone amplitude
@@ -1215,19 +1300,25 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
void BK4819_GenTail(uint8_t Tail) void BK4819_GenTail(uint8_t Tail)
{ {
// REG_52 <15> 0 Enable 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode // REG_52
//
// <15> 0 Enable 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode
// 0 = Normal // 0 = Normal
// 1 = Enable // 1 = Enable
// REG_52 <14:13> 0 CTCSS tail mode selection (only valid when REG_52 <15> = 1) //
// <14:13> 0 CTCSS tail mode selection (only valid when REG_52 <15> = 1)
// 00 = for 134.4Hz CTCSS Tail when CDCSS mode // 00 = for 134.4Hz CTCSS Tail when CDCSS mode
// 01 = CTCSS0 120° phase shift // 01 = CTCSS0 120° phase shift
// 10 = CTCSS0 180° phase shift // 10 = CTCSS0 180° phase shift
// 11 = CTCSS0 240° phase shift // 11 = CTCSS0 240° phase shift
// REG_52 <12> 0 CTCSSDetectionThreshold Mode //
// <12> 0 CTCSSDetectionThreshold Mode
// 1 = ~0.1% // 1 = ~0.1%
// 0 = 0.1 Hz // 0 = 0.1 Hz
// REG_52 <11:6> 0x0A CTCSS found detect threshold //
// REG_52 <5:0> 0x0F CTCSS lost detect threshold // <11:6> 0x0A CTCSS found detect threshold
//
// <5:0> 0x0F CTCSS lost detect threshold
// REG_07 <15:0> // REG_07 <15:0>
// //
@@ -1282,30 +1373,40 @@ void BK4819_EnableCTCSS(void)
BK4819_GenTail(4); // 55Hz tone freq BK4819_GenTail(4); // 55Hz tone freq
#endif #endif
// REG_51 <15> 0 // REG_51
//
// <15> 0
// 1 = Enable TxCTCSS/CDCSS // 1 = Enable TxCTCSS/CDCSS
// 0 = Disable // 0 = Disable
// REG_51 <14> 0 //
// <14> 0
// 1 = GPIO0Input for CDCSS // 1 = GPIO0Input for CDCSS
// 0 = Normal Mode (for BK4819 v3) // 0 = Normal Mode (for BK4819 v3)
// REG_51 <13> 0 //
// <13> 0
// 1 = Transmit negative CDCSS code // 1 = Transmit negative CDCSS code
// 0 = Transmit positive CDCSS code // 0 = Transmit positive CDCSS code
// REG_51 <12> 0 CTCSS/CDCSS mode selection //
// <12> 0 CTCSS/CDCSS mode selection
// 1 = CTCSS // 1 = CTCSS
// 0 = CDCSS // 0 = CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection //
// <11> 0 CDCSS 24/23bit selection
// 1 = 24bit // 1 = 24bit
// 0 = 23bit // 0 = 23bit
// REG_51 <10> 0 1050HzDetectionMode //
// <10> 0 1050HzDetectionMode
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz // 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
// REG_51 <9> 0 Auto CDCSS Bw Mode //
// <9> 0 Auto CDCSS Bw Mode
// 1 = Disable // 1 = Disable
// 0 = Enable // 0 = Enable
// REG_51 <8> 0 Auto CTCSS Bw Mode //
// <8> 0 Auto CTCSS Bw Mode
// 0 = Enable // 0 = Enable
// 1 = Disable // 1 = Disable
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning //
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
// 0 = min // 0 = min
// 127 = max // 127 = max
@@ -1386,25 +1487,52 @@ void BK4819_SetScanFrequency(uint32_t Frequency)
{ {
BK4819_SetFrequency(Frequency); BK4819_SetFrequency(Frequency);
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable // REG_51
// REG_51 <14> 0 1 = GPIO0 Input for CDCSS 0 = Normal Mode.(for BK4819v3) //
// REG_51 <13> 0 1 = Transmit negative CDCSS code 0 = Transmit positive CDCSScode // <15> 0
// REG_51 <12> 0 CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS // 1 = Enable TxCTCSS/CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection 1 = 24bit 0 = 23bit // 0 = Disable
// REG_51 <10> 0 1050HzDetectionMode 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz //
// REG_51 <9> 0 Auto CDCSS Bw Mode 1 = Disable 0 = Enable. // <14> 0
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable // 1 = GPIO0Input for CDCSS
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max // 0 = Normal Mode (for BK4819 v3)
//
BK4819_WriteRegister(BK4819_REG_51, 0 // <13> 0
| BK4819_REG_51_DISABLE_CxCSS // 1 = Transmit negative CDCSS code
| BK4819_REG_51_GPIO6_PIN2_NORMAL // 0 = Transmit positive CDCSS code
| BK4819_REG_51_TX_CDCSS_POSITIVE //
| BK4819_REG_51_MODE_CDCSS // <12> 0 CTCSS/CDCSS mode selection
| BK4819_REG_51_CDCSS_23_BIT // 1 = CTCSS
| BK4819_REG_51_1050HZ_NO_DETECTION // 0 = CDCSS
| BK4819_REG_51_AUTO_CDCSS_BW_DISABLE //
| BK4819_REG_51_AUTO_CTCSS_BW_DISABLE); // <11> 0 CDCSS 24/23bit selection
// 1 = 24bit
// 0 = 23bit
//
// <10> 0 1050HzDetectionMode
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
//
// <9> 0 Auto CDCSS Bw Mode
// 1 = Disable
// 0 = Enable
//
// <8> 0 Auto CTCSS Bw Mode
// 0 = Enable
// 1 = Disable
//
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
// 0 = min
// 127 = max
//
BK4819_WriteRegister(BK4819_REG_51,
BK4819_REG_51_DISABLE_CxCSS |
BK4819_REG_51_GPIO6_PIN2_NORMAL |
BK4819_REG_51_TX_CDCSS_POSITIVE |
BK4819_REG_51_MODE_CDCSS |
BK4819_REG_51_CDCSS_23_BIT |
BK4819_REG_51_1050HZ_NO_DETECTION |
BK4819_REG_51_AUTO_CDCSS_BW_DISABLE |
BK4819_REG_51_AUTO_CTCSS_BW_DISABLE);
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
} }

View File

@@ -82,10 +82,10 @@ void ST7565_BlitFullScreen(void)
} }
#if 0 #if 0
// whats the delay for I wonder ? .. it slows down scanning :( // whats the delay for I wonder, it holds things up :(
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
#else #else
SYSTEM_DelayMs(1); // SYSTEM_DelayMs(1);
#endif #endif
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
@@ -119,6 +119,9 @@ void ST7565_FillScreen(uint8_t Value)
{ {
unsigned int i; unsigned int i;
// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display
ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
@@ -135,7 +138,9 @@ void ST7565_FillScreen(uint8_t Value)
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_Init(void) void ST7565_Init(const bool full)
{
if (full)
{ {
SPI0_Init(); SPI0_Init();
@@ -146,6 +151,7 @@ void ST7565_Init(void)
ST7565_WriteByte(0xE2); // internal reset ST7565_WriteByte(0xE2); // internal reset
SYSTEM_DelayMs(120); SYSTEM_DelayMs(120);
}
ST7565_WriteByte(0xA2); // bias 9 ST7565_WriteByte(0xA2); // bias 9
ST7565_WriteByte(0xC0); // com normal ST7565_WriteByte(0xC0); // com normal
@@ -157,6 +163,9 @@ void ST7565_Init(void)
ST7565_WriteByte(0xA4); // all points normal ST7565_WriteByte(0xA4); // all points normal
ST7565_WriteByte(0x24); // ST7565_WriteByte(0x24); //
ST7565_WriteByte(0x81); // volume first ? ST7565_WriteByte(0x81); // volume first ?
if (full)
{
ST7565_WriteByte(0x1f); // contrast ? ST7565_WriteByte(0x1f); // contrast ?
ST7565_WriteByte(0x2B); // power control ? ST7565_WriteByte(0x2B); // power control ?
@@ -175,11 +184,13 @@ void ST7565_Init(void)
ST7565_WriteByte(0x40); // start line ? ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ? ST7565_WriteByte(0xAF); // display on ?
}
SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_WaitForUndocumentedTxFifoStatusBit();
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
if (full)
ST7565_FillScreen(0x00); ST7565_FillScreen(0x00);
} }

View File

@@ -30,7 +30,7 @@ void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const u
void ST7565_BlitFullScreen(void); void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void); void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value); void ST7565_FillScreen(uint8_t Value);
void ST7565_Init(void); void ST7565_Init(const bool full);
void ST7565_Configure_GPIO_B11(void); void ST7565_Configure_GPIO_B11(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value); void ST7565_WriteByte(uint8_t Value);

2
main.c
View File

@@ -193,7 +193,7 @@ void Main(void)
AUDIO_SetVoiceID(0, VOICE_ID_WELCOME); AUDIO_SetVoiceID(0, VOICE_ID_WELCOME);
Channel = gEeprom.ScreenChannel[gEeprom.TX_CHANNEL]; Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (IS_MR_CHANNEL(Channel)) if (IS_MR_CHANNEL(Channel))
{ {
AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE);

35
misc.c
View File

@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include "misc.h" #include "misc.h"
#include "settings.h"
const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
@@ -259,7 +260,39 @@ int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
uint8_t gIsLocked = 0xFF; uint8_t gIsLocked = 0xFF;
// -------- unsigned int get_rx_VFO(void)
{
unsigned int rx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
rx_vfo = 0;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
rx_vfo = 0;
return rx_vfo;
}
unsigned int get_tx_VFO(void)
{
unsigned int tx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
tx_vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
tx_vfo = 0;
return tx_vfo;
}
void NUMBER_Get(char *pDigits, uint32_t *pInteger) void NUMBER_Get(char *pDigits, uint32_t *pInteger)
{ {

3
misc.h
View File

@@ -322,6 +322,9 @@ extern int16_t gCurrentRSSI[2]; // now one per VFO
extern uint8_t gIsLocked; extern uint8_t gIsLocked;
extern volatile uint8_t boot_counter_10ms; extern volatile uint8_t boot_counter_10ms;
unsigned int get_tx_VFO(void);
unsigned int get_rx_VFO(void);
void NUMBER_Get(char *pDigits, uint32_t *pInteger); void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits); void NUMBER_ToDigits(uint32_t Value, char *pDigits);
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);

43
radio.c
View File

@@ -517,30 +517,16 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
static void RADIO_SelectCurrentVfo(void) static void RADIO_SelectCurrentVfo(void)
{ {
gCurrentVfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gRxVfo : &gEeprom.VfoInfo[gEeprom.TX_CHANNEL]; gCurrentVfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gRxVfo : &gEeprom.VfoInfo[gEeprom.TX_VFO];
} }
void RADIO_SelectVfos(void) void RADIO_SelectVfos(void)
{ {
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) gEeprom.TX_VFO = get_tx_VFO();
gEeprom.TX_CHANNEL = 1; gEeprom.RX_VFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : (gEeprom.TX_VFO + 1) & 1u;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
gEeprom.TX_CHANNEL = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.TX_CHANNEL = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
gEeprom.TX_CHANNEL = 0;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
gEeprom.RX_CHANNEL = gEeprom.TX_CHANNEL; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];
else
gEeprom.RX_CHANNEL = (gEeprom.TX_CHANNEL == 0) ? 1 : 0;
gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_CHANNEL];
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL];
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
} }
@@ -877,10 +863,9 @@ void RADIO_SetVfoState(VfoState_t State)
VfoState[1] = VFO_STATE_TX_DISABLE; VfoState[1] = VFO_STATE_TX_DISABLE;
} }
else else
{ { // 1of11
unsigned int chan = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) ? (gEeprom.RX_CHANNEL + 1) & 1 : gEeprom.RX_CHANNEL; // 1of11 const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
chan = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_CHANNEL : chan; VfoState[vfo] = State;
VfoState[chan] = State;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@@ -901,11 +886,11 @@ void RADIO_PrepareTX(void)
gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
if (!gRxVfoIsActive) if (gRxVfoIsActive)
{ // use the TX vfo { // use the TX vfo
gEeprom.RX_CHANNEL = gEeprom.TX_CHANNEL; gEeprom.RX_VFO = gEeprom.TX_VFO;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_CHANNEL]; gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
gRxVfoIsActive = true; // gRxVfoIsActive = true;
} }
// let the user see that DW is not active // let the user see that DW is not active
@@ -939,7 +924,6 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else
//if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0 || gCurrentVfo->CHANNEL_SAVE <= FREQ_CHANNEL_LAST)
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0)
{ // TX frequency is allowed { // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
@@ -958,10 +942,13 @@ void RADIO_PrepareTX(void)
if (State != VFO_STATE_NORMAL) if (State != VFO_STATE_NORMAL)
{ // TX not allowed { // TX not allowed
RADIO_SetVfoState(State); RADIO_SetVfoState(State);
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
gAlarmState = ALARM_STATE_OFF; gAlarmState = ALARM_STATE_OFF;
#endif #endif
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return; return;
} }

View File

@@ -133,7 +133,7 @@ void SETTINGS_SaveSettings(void)
#endif #endif
State[1] = gEeprom.ROGER; State[1] = gEeprom.ROGER;
State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION;
State[3] = gEeprom.TX_CHANNEL; State[3] = gEeprom.TX_VFO;
EEPROM_WriteBuffer(0x0EA8, State); EEPROM_WriteBuffer(0x0EA8, State);
State[0] = gEeprom.DTMF_SIDE_TONE; State[0] = gEeprom.DTMF_SIDE_TONE;

View File

@@ -121,8 +121,8 @@ typedef struct {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
uint8_t NoaaChannel[2]; uint8_t NoaaChannel[2];
#endif #endif
uint8_t RX_CHANNEL; uint8_t RX_VFO;
uint8_t TX_CHANNEL; uint8_t TX_VFO;
uint8_t field7_0xa; uint8_t field7_0xa;
uint8_t field8_0xb; uint8_t field8_0xb;

View File

@@ -85,22 +85,22 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
const unsigned int bar_width = LCD_WIDTH - 2 - bar_x; const unsigned int bar_width = LCD_WIDTH - 2 - bar_x;
unsigned int i; unsigned int i;
if (gScreenToDisplay != DISPLAY_MAIN)
return;
#if 1
// TX audio level
if (gCurrentFunction != FUNCTION_TRANSMIT || if (gCurrentFunction != FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
{
return; // screen is in use return; // screen is in use
}
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState != ALARM_STATE_OFF) if (gAlarmState != ALARM_STATE_OFF)
return; return;
#endif #endif
{
#if 1
// TX audio level
const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0 const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0
// const unsigned int max = 65535; // const unsigned int max = 65535;
@@ -140,6 +140,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
} }
} }
}
#endif #endif
#if defined(ENABLE_RSSI_BAR) #if defined(ENABLE_RSSI_BAR)
@@ -172,6 +173,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || if (gCurrentFunction == FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
@@ -331,8 +333,8 @@ void UI_DisplayMain(void)
for (vfo_num = 0; vfo_num < 2; vfo_num++) for (vfo_num = 0; vfo_num < 2; vfo_num++)
{ {
const unsigned int line = (vfo_num == 0) ? line0 : line1; const unsigned int line = (vfo_num == 0) ? line0 : line1;
uint8_t channel = gEeprom.TX_CHANNEL; uint8_t channel = gEeprom.TX_VFO;
// uint8_t tx_channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; // uint8_t tx_channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
const bool same_vfo = (channel == vfo_num) ? true : false; const bool same_vfo = (channel == vfo_num) ? true : false;
uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1]; uint8_t *p_line1 = gFrameBuffer[line + 1];
@@ -349,7 +351,7 @@ void UI_DisplayMain(void)
} }
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive)
channel = gEeprom.RX_CHANNEL; // we're currently monitoring the other VFO channel = gEeprom.RX_VFO; // we're currently monitoring the other VFO
if (channel != vfo_num) if (channel != vfo_num)
{ {
@@ -427,7 +429,7 @@ void UI_DisplayMain(void)
else else
#endif #endif
{ {
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (channel == vfo_num)
{ // show the TX symbol { // show the TX symbol
mode = 1; mode = 1;
@@ -445,7 +447,7 @@ void UI_DisplayMain(void)
if ((gCurrentFunction == FUNCTION_RECEIVE || if ((gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) && gCurrentFunction == FUNCTION_INCOMING) &&
gEeprom.RX_CHANNEL == vfo_num) gEeprom.RX_VFO == vfo_num)
{ {
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold("RX", 14, 0, line); UI_PrintStringSmallBold("RX", 14, 0, line);
@@ -458,7 +460,7 @@ void UI_DisplayMain(void)
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // channel mode { // channel mode
const unsigned int x = 2; const unsigned int x = 2;
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) ? false : true; const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
if (!inputting) if (!inputting)
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number
else else
@@ -478,7 +480,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) if (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num)
{ // channel number { // channel number
sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST); sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST);
} }
@@ -497,7 +499,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM)
{ {
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (channel == vfo_num)
state = VFO_STATE_ALARM; state = VFO_STATE_ALARM;
} }
@@ -510,7 +512,7 @@ void UI_DisplayMain(void)
UI_PrintString(state_list[state], 31, 0, line, 8); UI_PrintString(state_list[state], 31, 0, line, 8);
} }
else else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
{ // user entering a frequency { // user entering a frequency
UI_DisplayFrequency(gInputBox, 32, line, true, false); UI_DisplayFrequency(gInputBox, 32, line, true, false);
@@ -521,7 +523,7 @@ void UI_DisplayMain(void)
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (channel == vfo_num)
frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
} }
@@ -721,14 +723,14 @@ void UI_DisplayMain(void)
#endif #endif
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (rx && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix) if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix)
{ {
if (gScreenToDisplay != DISPLAY_MAIN || if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; return;
center_line = CENTER_LINE_AM_FIX_DATA; center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(gEeprom.RX_CHANNEL, String); AM_fix_print_data(gEeprom.RX_VFO, String);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(String, 2, 0, 3);
} }
else else
@@ -738,7 +740,7 @@ void UI_DisplayMain(void)
if (rx) if (rx)
{ {
center_line = CENTER_LINE_RSSI; center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_CHANNEL], false); UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false);
} }
else else
#endif #endif