0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 22:01:26 +03:00

Tidy ups and makefile update

This commit is contained in:
OneOfEleven 2023-09-14 09:56:30 +01:00
parent fe212140dd
commit 54711a5971
53 changed files with 1092 additions and 687 deletions

135
Makefile
View File

@ -1,5 +1,20 @@
TARGET = firmware
ENABLE_AIRCOPY := 0
ENABLE_FMRADIO := 0
ENABLE_OVERLAY := 1
ENABLE_UART := 1
ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_ALARM := 0
ENABLE_BIG_FREQ := 0
ENABLE_KEEP_MEM_NAME := 1
ENABLE_CHAN_NAME_FREQ := 1
ENABLE_WIDE_RX := 1
ENABLE_TX_WHEN_AM := 0
#ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
@ -8,18 +23,28 @@ OBJS =
# Startup files
OBJS += start.o
OBJS += init.o
OBJS += sram-overlay.o
ifeq ($(ENABLE_OVERLAY),1)
OBJS += sram-overlay.o
endif
OBJS += external/printf/printf.o
# Drivers
OBJS += driver/adc.o
OBJS += driver/aes.o
ifeq ($(ENABLE_UART),1)
OBJS += driver/aes.o
endif
OBJS += driver/backlight.o
OBJS += driver/bk1080.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += driver/bk1080.o
endif
OBJS += driver/bk4819.o
OBJS += driver/crc.o
ifeq ($(filter $(ENABLE_AIRCOPY) $(ENABLE_UART),1),1)
OBJS += driver/crc.o
endif
OBJS += driver/eeprom.o
ifeq ($(ENABLE_OVERLAY),1)
OBJS += driver/flash.o
endif
OBJS += driver/gpio.o
OBJS += driver/i2c.o
OBJS += driver/keyboard.o
@ -27,19 +52,27 @@ OBJS += driver/spi.o
OBJS += driver/st7565.o
OBJS += driver/system.o
OBJS += driver/systick.o
OBJS += driver/uart.o
ifeq ($(ENABLE_UART),1)
OBJS += driver/uart.o
endif
# Main
OBJS += app/action.o
OBJS += app/aircopy.o
ifeq ($(ENABLE_AIRCOPY),1)
OBJS += app/aircopy.o
endif
OBJS += app/app.o
OBJS += app/dtmf.o
OBJS += app/fm.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += app/fm.o
endif
OBJS += app/generic.o
OBJS += app/main.o
OBJS += app/menu.o
OBJS += app/scanner.o
OBJS += app/uart.o
ifeq ($(ENABLE_UART),1)
OBJS += app/uart.o
endif
OBJS += audio.o
OBJS += bitmaps.o
OBJS += board.o
@ -53,9 +86,13 @@ OBJS += misc.o
OBJS += radio.o
OBJS += scheduler.o
OBJS += settings.o
OBJS += ui/aircopy.o
ifeq ($(ENABLE_AIRCOPY),1)
OBJS += ui/aircopy.o
endif
OBJS += ui/battery.o
OBJS += ui/fmradio.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += ui/fmradio.o
endif
OBJS += ui/helper.o
OBJS += ui/inputbox.o
OBJS += ui/lock.o
@ -76,38 +113,69 @@ else
TOP := $(shell pwd)
endif
AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
AS = arm-none-eabi-gcc
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
SIZE = arm-none-eabi-size
#GIT_HASH := $(shell git rev-parse --short HEAD)
GIT_HASH := $(shell git rev-parse --short HEAD)
ASFLAGS = -mcpu=cortex-m0
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD -fdata-sections -ffunction-sections
ASFLAGS = -c -mcpu=cortex-m0
ifeq ($(ENABLE_OVERLAY),1)
ASFLAGS += -DENABLE_OVERLAY
endif
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
#CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
ifeq ($(ENABLE_AIRCOPY),1)
CFLAGS += -DENABLE_AIRCOPY
endif
ifeq ($(ENABLE_FMRADIO),1)
CFLAGS += -DENABLE_FMRADIO
endif
ifeq ($(ENABLE_OVERLAY),1)
CFLAGS += -DENABLE_OVERLAY
endif
ifeq ($(ENABLE_UART),1)
CFLAGS += -DENABLE_UART
endif
ifeq ($(ENABLE_BIG_FREQ),1)
CFLAGS += -DENABLE_BIG_FREQ
endif
ifeq ($(ENABLE_NOAA),1)
CFLAGS += -DENABLE_NOAA
endif
ifeq ($(ENABLE_VOICE),1)
CFLAGS += -DENABLE_VOICE
endif
ifeq ($(ENABLE_ALARM),1)
CFLAGS += -DENABLE_ALARM
endif
ifeq ($(ENABLE_KEEP_MEM_NAME),1)
CFLAGS += -DKEEP_MEM_NAME
endif
ifeq ($(ENABLE_CHAN_NAME_FREQ),1)
CFLAGS += -DENABLE_CHAN_NAME_FREQ
endif
ifeq ($(ENABLE_WIDE_RX),1)
CFLAGS += -DENABLE_WIDE_RX
endif
ifeq ($(ENABLE_TX_WHEN_AM),1)
CFLAGS += -DENABLE_TX_WHEN_AM
endif
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
CFLAGS += -DENABLE_SINGLE_VFO_CHAN
endif
ifeq ($(ENABLE_BAND_SCOPE),1)
CFLAGS += -DENABLE_BAND_SCOPE
endif
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
#LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-gc-sections,-T,firmware.ld
# compilation options
CFLAGS += -DDISABLE_BIG_FREQ
CFLAGS += -DDISABLE_NOAA
CFLAGS += -DDISABLE_VOICE
CFLAGS += -DDISABLE_AIRCOPY
CFLAGS += -DDISABLE_ALARM
CFLAGS += -DKEEP_MEM_NAME
CFLAGS += -DCHAN_NAME_FREQ
CFLAGS += -DRX_ANY_FREQ
#CFLAGS += -DENABLE_TX_WHEN_AM
#CFLAGS += -DSINGLE_VFO_CHAN
#CFLAGS += -DBAND_SCOPE
ifeq ($(DEBUG),1)
ASFLAGS += -g
CFLAGS += -g
CFLAGS += -g
LDFLAGS += -g
endif
@ -151,4 +219,3 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def
clean:
rm -f $(TARGET).bin $(TARGET) $(OBJS) $(DEPS)

View File

@ -9,21 +9,24 @@ Am amazing achievement if you ask me !
# User customization
This version you can customize at compile time by making various changes to the makefile.
You can edit those changes by (currently) editing the MakeFile, look for these lines ..
You can edit those changes by (currently) editing the MakeFile, look for these lines near the top of the file ..
* CFLAGS += -DDISABLE_BIG_FREQ .. show frequencies using smaller font
* CFLAGS += -DDISABLE_NOAA .. remove NOAA channels option from the firmware
* CFLAGS += -DDISABLE_VOICE .. remove spoken VOICES option from the firmware
* CFLAGS += -DDISABLE_AIRCOPY .. remove AIRCOPY option
* CFLAGS += -DDISABLE_ALARM .. remove the ALARM transmit option from the firmware
* CFLAGS += -DKEEP_MEM_NAME .. keep the memory channels name when re-saving a channel
* CFLAGS += -DCHAN_NAME_FREQ .. show the channel frequency (as well as channel number/name)
* CFLAGS += -DRX_ANY_FREQ .. allow RX on any frequency from 18MHz to 1300MHz
* #CFLAGS += -DENABLE_TX_WHEN_AM .. enable TX when radio set to AM (radio does NOT do AM, the adverts are false)
* #CFLAGS += -DSINGLE_VFO_CHAN .. (not yet implemented) show a single VFO/CHANNEL if dual-watch/cross-band are disabled
* #CFLAGS += -DBAND_SCOPE .. (not yet implemented) add a band scope/spectrum/panadapter option
* ENABLE_AIRCOPY := 0 aircopy
* ENABLE_FMRADIO := 0 FM band 2 radio
* ENABLE_OVERLAY := 1
* ENABLE_UART := 1 serial port
* ENABLE_NOAA := 0 NOAA channels
* ENABLE_VOICE := 0 voices
* ENABLE_ALARM := 0 TX alarms
* ENABLE_BIG_FREQ := 0 big font for the frequencies
* ENABLE_KEEP_MEM_NAME := 1 maintain the channels name when saving over it
* ENABLE_CHAN_NAME_FREQ := 1 show the channels frequency below the channels name/number
* ENABLE_WIDE_RX := 1 enable the RX in the full 18MHz to 1300MHz range
* ENABLE_TX_WHEN_AM := 0 allow TX when RX set to AM
* #ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented
* #ENABLE_BAND_SCOPE := 1 not yet implemented
To enable the custom option just uncomment the line by removing the starting '#'.
To enable the custom option, set the above option to '1'
# Other changes made

View File

@ -17,11 +17,15 @@
#include "app/action.h"
#include "app/app.h"
#include "app/dtmf.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk1080.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "functions.h"
@ -54,7 +58,7 @@ void ACTION_Power(void)
gRequestSaveChannel = 1;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_POWER;
#endif
@ -67,7 +71,7 @@ static void ACTION_Monitor(void)
{
RADIO_SelectVfos();
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
#endif
@ -85,7 +89,7 @@ static void ACTION_Monitor(void)
gScanPauseMode = true;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode)
{
gNOAA_Countdown = 500;
@ -95,64 +99,69 @@ static void ACTION_Monitor(void)
RADIO_SetupRegisters(true);
if (gFmRadioMode)
{
FM_Start();
gRequestDisplayScreen = DISPLAY_FM;
}
else
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
{
FM_Start();
gRequestDisplayScreen = DISPLAY_FM;
}
else
#endif
gRequestDisplayScreen = gScreenToDisplay;
}
void ACTION_Scan(bool bRestart)
{
if (gFmRadioMode)
{
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
{
GUI_SelectNextDisplay(DISPLAY_FM);
if (gFM_ScanState != FM_SCAN_OFF)
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
{
FM_PlayAndUpdate();
#ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
else
{
uint16_t Frequency;
if (bRestart)
GUI_SelectNextDisplay(DISPLAY_FM);
if (gFM_ScanState != FM_SCAN_OFF)
{
gFM_AutoScan = true;
gFM_ChannelPosition = 0;
FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit;
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
else
{
gFM_AutoScan = false;
gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying;
uint16_t Frequency;
if (bRestart)
{
gFM_AutoScan = true;
gFM_ChannelPosition = 0;
FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit;
}
else
{
gFM_AutoScan = false;
gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying;
}
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
#endif
}
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
#ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
#endif
}
return;
}
}
else
#endif
if (gScreenToDisplay != DISPLAY_SCANNER)
{
RADIO_SelectVfos();
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
@ -162,7 +171,7 @@ void ACTION_Scan(bool bRestart)
{
SCANNER_Stop();
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
@ -170,7 +179,7 @@ void ACTION_Scan(bool bRestart)
{
CHANNEL_Next(true, 1);
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(true);
#endif
@ -184,13 +193,13 @@ void ACTION_Vox(void)
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
gRequestSaveSettings = true;
gFlagReconfigureVfos = true;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_VOX;
#endif
gUpdateStatus = true;
}
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
static void ACTION_AlarmOr1750(bool b1750)
{
gInputBoxIndex = 0;
@ -201,30 +210,32 @@ void ACTION_Vox(void)
}
#endif
void ACTION_FM(void)
{
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
#ifdef ENABLE_FMRADIO
void ACTION_FM(void)
{
if (gFmRadioMode)
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR)
{
FM_TurnOff();
if (gFmRadioMode)
{
FM_TurnOff();
gInputBoxIndex = 0;
gVoxResumeCountdown = 80;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
RADIO_SelectVfos();
RADIO_SetupRegisters(true);
FM_Start();
gInputBoxIndex = 0;
gVoxResumeCountdown = 80;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
gRequestDisplayScreen = DISPLAY_FM;
}
RADIO_SelectVfos();
RADIO_SetupRegisters(true);
FM_Start();
gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_FM;
}
}
#endif
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
@ -247,7 +258,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
@ -309,15 +320,17 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
ACTION_Vox();
break;
case ACTION_OPT_ALARM:
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
ACTION_AlarmOr1750(false);
#endif
break;
case ACTION_OPT_FM:
ACTION_FM();
break;
#ifdef ENABLE_FMRADIO
case ACTION_OPT_FM:
ACTION_FM();
break;
#endif
case ACTION_OPT_1750:
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
ACTION_AlarmOr1750(true);
#endif
break;

View File

@ -24,10 +24,12 @@ void ACTION_Power(void);
//static void ACTION_Monitor(void)
void ACTION_Scan(bool bFlag);
void ACTION_Vox(void);
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
//static void ACTION_AlarmOr1750(bool b1750)
#endif
void ACTION_FM(void);
#ifdef ENABLE_FMRADIO
void ACTION_FM(void);
#endif
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include "app/aircopy.h"
#include "audio.h"
@ -124,7 +124,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_AIRCOPY;
if (gInputBoxIndex < 6)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
return;
@ -138,7 +138,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRxVfo->Band = i;

View File

@ -17,7 +17,7 @@
#ifndef APP_AIRCOPY_H
#define APP_AIRCOPY_H
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include "driver/keyboard.h"

304
app/app.c
View File

@ -17,12 +17,14 @@
#include <string.h>
#include "app/action.h"
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include "app/aircopy.h"
#endif
#include "app/app.h"
#include "app/dtmf.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/main.h"
#include "app/menu.h"
@ -33,7 +35,9 @@
#include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/backlight.h"
#include "driver/bk1080.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/keyboard.h"
@ -73,7 +77,7 @@ static void APP_CheckForIncoming(void)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gIsNoaaMode)
{
gNOAA_Countdown = 20;
@ -124,7 +128,7 @@ static void APP_HandleIncoming(void)
bFlag = (gScanState == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gSystickCountdown2)
{
bFlag = true;
@ -221,7 +225,7 @@ static void APP_HandleReceive(void)
if (g_SquelchLost)
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (!gEndOfRxDetectedMaybe && IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#else
if (!gEndOfRxDetectedMaybe)
@ -306,7 +310,7 @@ Skip:
case END_OF_RX_MODE_END:
RADIO_SetupRegisters(true);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
gSystickCountdown2 = 300;
#endif
@ -380,9 +384,11 @@ void APP_StartListening(FUNCTION_Type_t Function)
{
if (!gSetting_KILLED)
{
if (gFmRadioMode)
BK1080_Init(0, false);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Init(0, false);
#endif
gVFO_RSSI_Level[gEeprom.RX_CHANNEL == 0] = 0;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
@ -414,7 +420,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
bScanKeepFrequency = true;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gIsNoaaMode)
{
gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST;
@ -445,14 +451,18 @@ void APP_StartListening(FUNCTION_Type_t Function)
else
BK4819_WriteRegister(BK4819_REG_48, 0xB000 | (gEeprom.VOLUME_GAIN << 4) | (gEeprom.DAC_GAIN << 0));
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0)
#endif
BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN);
FUNCTION_Select(Function);
if (Function == FUNCTION_MONITOR || gFmRadioMode)
#ifdef ENABLE_FMRADIO
if (Function == FUNCTION_MONITOR || gFmRadioMode)
#else
if (Function == FUNCTION_MONITOR)
#endif
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
@ -548,7 +558,7 @@ Skip:
gCurrentScanList = 0;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
static void NOAA_IncreaseChannel(void)
{
if (++gNoaaChannel > 9)
@ -558,7 +568,7 @@ Skip:
static void DUALWATCH_Alternate(void)
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gIsNoaaMode)
{
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
@ -580,7 +590,7 @@ static void DUALWATCH_Alternate(void)
RADIO_SetupRegisters(false);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
gDualWatchCountdown = gIsNoaaMode ? dual_watch_count_noaa : dual_watch_count_toggle;
#else
gDualWatchCountdown = dual_watch_count_toggle;
@ -679,7 +689,7 @@ void APP_CheckRadioInterrupts(void)
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false);
}
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (interrupt_status_bits & BK4819_REG_02_FSK_FIFO_ALMOST_FULL &&
gScreenToDisplay == DISPLAY_AIRCOPY &&
gAircopyState == AIRCOPY_TRANSFER &&
@ -737,8 +747,11 @@ static void APP_HandleVox(void)
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF &&
!gFmRadioMode)
gCssScanMode == CSS_SCAN_MODE_OFF
#ifdef ENABLE_FMRADIO
&& !gFmRadioMode
#endif
)
{
if (gVOX_NoiseDetected)
{
@ -793,7 +806,7 @@ static void APP_HandleVox(void)
void APP_Update(void)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gFlagPlayQueuedVoice)
{
AUDIO_PlayQueuedVoice();
@ -821,10 +834,12 @@ void APP_Update(void)
if (gCurrentFunction != FUNCTION_TRANSMIT)
APP_HandleFunction();
if (gFmRadioCountdown)
return;
#ifdef ENABLE_FMRADIO
if (gFmRadioCountdown)
return;
#endif
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
#else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
@ -850,7 +865,7 @@ void APP_Update(void)
gScheduleScanListen = false;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0)
#else
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen)
@ -860,8 +875,8 @@ void APP_Update(void)
gScheduleScanListen = false;
}
#ifndef DISABLE_NOAA
#ifndef DISABLE_VOICE
#ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0)
#else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA)
@ -877,7 +892,7 @@ void APP_Update(void)
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0)
#else
if (gScheduleDualWatch)
@ -885,7 +900,11 @@ void APP_Update(void)
{
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (!gPttIsPressed && !gFmRadioMode && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE)
#ifdef ENABLE_FMRADIO
if (!gPttIsPressed && !gFmRadioMode && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE)
#else
if (!gPttIsPressed && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE)
#endif
{
gScheduleDualWatch = false;
@ -902,24 +921,29 @@ void APP_Update(void)
}
}
if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
FM_Play();
gScheduleFM = false;
}
#ifdef ENABLE_FMRADIO
if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
FM_Play();
gScheduleFM = false;
}
#endif
if (gEeprom.VOX_SWITCH)
APP_HandleVox();
if (gSchedulePowerSave)
{
#ifndef DISABLE_NOAA
if (gFmRadioMode ||
gPttIsPressed ||
#ifdef ENABLE_NOAA
if (
#ifdef ENABLE_FMRADIO
gFmRadioMode ||
#endif
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
@ -933,8 +957,11 @@ void APP_Update(void)
else
gBatterySaveCountdown = battery_save_count;
#else
if (gFmRadioMode ||
gPttIsPressed ||
if (
#ifdef ENABLE_FMRADIO
gFmRadioMode ||
#endif
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
@ -949,7 +976,7 @@ void APP_Update(void)
gSchedulePowerSave = false;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gBatterySaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0)
#else
if (gBatterySaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE)
@ -1007,7 +1034,7 @@ void APP_CheckKeys(void)
const uint16_t key_repeat_delay = 60; // 600ms
KEY_Code_t Key;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
#else
@ -1148,7 +1175,7 @@ void APP_TimeSlice10ms(void)
{
if (gUpdateStatus)
{
UI_DisplayStatus();
UI_DisplayStatus(false);
gUpdateStatus = false;
}
@ -1161,21 +1188,23 @@ void APP_TimeSlice10ms(void)
// Skipping authentic device checks
if (gFmRadioCountdown)
return;
#ifdef ENABLE_FMRADIO
if (gFmRadioCountdown > 0)
return;
#endif
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0)
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
if (gVoxResumeCountdown)
if (gVoxResumeCountdown > 0)
gVoxResumeCountdown--;
if (gVoxPauseCountdown)
if (gVoxPauseCountdown > 0)
gVoxPauseCountdown--;
if (gCurrentFunction == FUNCTION_TRANSMIT)
{
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_ALARM)
{
uint16_t Tone;
@ -1233,15 +1262,17 @@ void APP_TimeSlice10ms(void)
}
}
if (gFmRadioMode && gFM_RestoreCountdown)
{
if (--gFM_RestoreCountdown == 0)
#ifdef ENABLE_FMRADIO
if (gFmRadioMode && gFM_RestoreCountdown > 0)
{
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
if (--gFM_RestoreCountdown == 0)
{
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
}
#endif
if (gScreenToDisplay == DISPLAY_SCANNER)
{
uint32_t Result;
@ -1311,10 +1342,10 @@ void APP_TimeSlice10ms(void)
const uint8_t Code = DCS_GetCdcssCode(Result);
if (Code != 0xFF)
{
gScanCssResultCode = Code;
gScanCssResultType = CODE_TYPE_DIGITAL;
gScanCssState = SCAN_CSS_STATE_FOUND;
gScanUseCssResult = true;
gScanCssResultCode = Code;
gScanCssResultType = CODE_TYPE_DIGITAL;
gScanCssState = SCAN_CSS_STATE_FOUND;
gScanUseCssResult = true;
}
}
else
@ -1354,10 +1385,10 @@ void APP_TimeSlice10ms(void)
}
}
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
{
if (gAircopySendCountdown)
if (gAircopySendCountdown > 0)
{
if (--gAircopySendCountdown == 0)
{
@ -1382,12 +1413,14 @@ void APP_TimeSlice500ms(void)
// Skipped authentic device check
if (gFmRadioCountdown > 0)
{
gFmRadioCountdown--;
return;
}
#ifdef ENABLE_FMRADIO
if (gFmRadioCountdown > 0)
{
gFmRadioCountdown--;
return;
}
#endif
if (gReducedService)
{
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
@ -1418,7 +1451,11 @@ void APP_TimeSlice500ms(void)
UI_UpdateRSSI(gCurrentRSSI);
}
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
#ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
#else
if (gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
#endif
{
if (gBacklightCountdown > 0)
@ -1426,7 +1463,7 @@ void APP_TimeSlice500ms(void)
if (gEeprom.BACKLIGHT < 5)
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (gScanState == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#else
if (gScanState == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
@ -1465,9 +1502,11 @@ void APP_TimeSlice500ms(void)
gAskToSave = false;
gAskToDelete = false;
if (gFmRadioMode && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
GUI_SelectNextDisplay(DISPLAY_FM);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
GUI_SelectNextDisplay(DISPLAY_FM);
else
#endif
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
}
@ -1476,19 +1515,21 @@ void APP_TimeSlice500ms(void)
}
if (!gPttIsPressed && gFM_ResumeCountdown)
{
if (--gFM_ResumeCountdown == 0)
#ifdef ENABLE_FMRADIO
if (!gPttIsPressed && gFM_ResumeCountdown > 0)
{
RADIO_SetVfoState(VFO_STATE_NORMAL);
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode)
if (--gFM_ResumeCountdown == 0)
{
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
RADIO_SetVfoState(VFO_STATE_NORMAL);
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode)
{
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
}
}
#endif
if (gLowBattery)
{
gLowBatteryBlink = ++gLowBatteryCountdown & 1;
@ -1510,24 +1551,26 @@ void APP_TimeSlice500ms(void)
{
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
#endif
if (gBatteryDisplayLevel == 0)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_PlaySingleVoice(true);
#endif
gReducedService = true;
FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_Configure_GPIO_B11();
//if (gEeprom.BACKLIGHT < 5)
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
else
AUDIO_PlaySingleVoice(false);
#endif
@ -1550,7 +1593,7 @@ void APP_TimeSlice500ms(void)
if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
{
if (gDTMF_AUTO_RESET_TIME)
if (gDTMF_AUTO_RESET_TIME > 0)
{
if (--gDTMF_AUTO_RESET_TIME == 0)
{
@ -1559,7 +1602,7 @@ void APP_TimeSlice500ms(void)
}
}
if (gDTMF_DecodeRing && gDTMF_DecodeRingCountdown)
if (gDTMF_DecodeRing && gDTMF_DecodeRingCountdown > 0)
{
if ((--gDTMF_DecodeRingCountdown % 3) == 0)
AUDIO_PlayBeep(BEEP_440HZ_500MS);
@ -1569,7 +1612,7 @@ void APP_TimeSlice500ms(void)
}
}
if (gDTMF_IsTx && gDTMF_TxStopCountdown)
if (gDTMF_IsTx && gDTMF_TxStopCountdown > 0)
{
if (--gDTMF_TxStopCountdown == 0)
{
@ -1578,7 +1621,7 @@ void APP_TimeSlice500ms(void)
}
}
if (gDTMF_RecvTimeout)
if (gDTMF_RecvTimeout > 0)
{
if (--gDTMF_RecvTimeout == 0)
{
@ -1588,7 +1631,7 @@ void APP_TimeSlice500ms(void)
}
}
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
static void ALARM_Off(void)
{
gAlarmState = ALARM_STATE_OFF;
@ -1664,12 +1707,14 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gFlagSaveSettings = false;
}
if (gFlagSaveFM)
{
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
#ifdef ENABLE_FMRADIO
if (gFlagSaveFM)
{
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
#endif
if (gFlagSaveChannel)
{
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gFlagSaveChannel);
@ -1711,7 +1756,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
// keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4;
gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true;
return;
}
@ -1724,7 +1769,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4;
gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true;
return;
}
@ -1735,7 +1780,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Key != KEY_UP &&
Key != KEY_DOWN &&
Key != KEY_EXIT &&
Key != KEY_STAR) ||
Key != KEY_STAR)
||
(gCssScanMode != CSS_SCAN_MODE_OFF &&
Key != KEY_PTT &&
Key != KEY_UP &&
@ -1787,8 +1833,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!bFlag)
{
if (gCurrentFunction == FUNCTION_TRANSMIT)
{
#ifndef DISABLE_ALARM
{ // transmitting
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_OFF)
#endif
{
@ -1811,7 +1858,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
goto Skip;
}
if (bKeyHeld || !bKeyPressed)
if (!bKeyPressed || bKeyHeld)
{
if (!bKeyPressed)
{
@ -1844,7 +1891,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
}
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
else
if (!bKeyHeld && bKeyPressed)
{
@ -1870,31 +1917,36 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
case DISPLAY_FM:
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#ifdef ENABLE_FMRADIO
case DISPLAY_FM:
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#endif
case DISPLAY_MENU:
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
case DISPLAY_SCANNER:
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
case DISPLAY_AIRCOPY:
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#endif
case DISPLAY_INVALID:
default:
break;
}
}
else
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
{
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
}
else
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -1926,21 +1978,21 @@ Skip:
SETTINGS_SaveSettings();
else
gFlagSaveSettings = 1;
gRequestSaveSettings = false;
gUpdateStatus = true;
}
if (gRequestSaveFM)
{
if (!bKeyHeld)
SETTINGS_SaveFM();
else
gFlagSaveFM = true;
gRequestSaveFM = false;
}
#ifdef ENABLE_FMRADIO
if (gRequestSaveFM)
{
if (!bKeyHeld)
SETTINGS_SaveFM();
else
gFlagSaveFM = true;
gRequestSaveFM = false;
}
#endif
if (gRequestSaveVFO)
{
if (!bKeyHeld)
@ -1977,9 +2029,7 @@ Skip:
RADIO_ConfigureChannel(1, gVfoConfigureMode);
}
else
{
RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, gVfoConfigureMode);
}
if (gRequestDisplayScreen == DISPLAY_INVALID)
gRequestDisplayScreen = DISPLAY_MAIN;
@ -1992,9 +2042,11 @@ Skip:
if (gFlagReconfigureVfos)
{
RADIO_SelectVfos();
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
RADIO_ConfigureNOAA();
#endif
RADIO_SetupRegisters(true);
gDTMF_AUTO_RESET_TIME = 0;
@ -2016,7 +2068,7 @@ Skip:
if (gFlagStartScan)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(true);
#endif
@ -2033,7 +2085,7 @@ Skip:
gFlagPrepareTX = false;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gAnotherVoiceID != VOICE_ID_INVALID)
{
if (gAnotherVoiceID < 76)

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk4819.h"
@ -213,11 +215,14 @@ void DTMF_HandleRequest(void)
gSetting_KILLED = true;
SETTINGS_SaveSettings();
gDTMF_ReplyState = DTMF_REPLY_AB;
if (gFmRadioMode)
{
FM_TurnOff();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
{
FM_TurnOff();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#endif
}
else
{

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#ifdef ENABLE_FMRADIO
#include <string.h>
#include "app/action.h"
@ -284,7 +286,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -306,7 +308,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (FM_CheckValidChannel(Channel))
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gEeprom.FM_SelectedChannel = Channel;
@ -319,7 +321,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
else
if (Channel < 20)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_FM;
@ -332,7 +334,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -422,14 +424,14 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
else
{
FM_PlayAndUpdate();
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
@ -660,3 +662,5 @@ void FM_Start(void)
gEnableSpeaker = true;
gUpdateStatus = true;
}
#endif

View File

@ -17,6 +17,8 @@
#ifndef APP_FM_H
#define APP_FM_H
#ifdef ENABLE_FMRADIO
#include "driver/keyboard.h"
#define FM_CHANNEL_UP 0x01
@ -57,3 +59,5 @@ void FM_Start(void);
#endif
#endif

View File

@ -17,7 +17,9 @@
#include <string.h>
#include "app/app.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/menu.h"
#include "app/scanner.h"
@ -50,7 +52,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
if (!bKeyPressed)
return;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif
@ -59,12 +61,17 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
}
else
{
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
return;
#ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
return;
#else
if (gScreenToDisplay != DISPLAY_MAIN)
return;
#endif
gWasFKeyPressed = !gWasFKeyPressed;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (!gWasFKeyPressed)
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
@ -79,12 +86,14 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
if (gFM_ScanState == FM_SCAN_OFF)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
#ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
#endif
gBeepToPlay = BEEP_440HZ_500MS;
gPttWasReleased = true;
@ -139,11 +148,17 @@ void GENERIC_Key_PTT(bool bKeyPressed)
return;
}
if (gFM_ScanState == FM_SCAN_OFF)
#ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF)
#endif
{
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (gScreenToDisplay == DISPLAY_MENU || gScreenToDisplay == DISPLAY_FM)
#ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_MENU || gScreenToDisplay == DISPLAY_FM)
#else
if (gScreenToDisplay == DISPLAY_MENU)
#endif
{
gRequestDisplayScreen = DISPLAY_MAIN;
gInputBoxIndex = 0;
@ -210,13 +225,15 @@ void GENERIC_Key_PTT(bool bKeyPressed)
gRequestDisplayScreen = DISPLAY_MENU;
}
}
else
{
FM_PlayAndUpdate();
gRequestDisplayScreen = DISPLAY_FM;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_FMRADIO
else
{
FM_PlayAndUpdate();
gRequestDisplayScreen = DISPLAY_FM;
}
#endif
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif

View File

@ -18,7 +18,9 @@
#include "app/action.h"
#include "app/app.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/main.h"
#include "app/scanner.h"
@ -31,6 +33,10 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
//#ifndef ARRAY_SIZE
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
//#endif
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
uint8_t Band;
@ -55,7 +61,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex != 3)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
@ -71,7 +77,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gEeprom.MrChannel[Vfo] = (uint8_t)Channel;
@ -81,7 +87,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#endif
{
@ -89,7 +95,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 6)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
return;
@ -106,7 +112,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -132,14 +138,14 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
else
{
uint8_t Channel;
if (gInputBoxIndex != 2)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
@ -152,7 +158,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Channel >= 1 && Channel <= 10)
{
Channel += NOAA_CHANNEL_FIRST;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gEeprom.NoaaChannel[Vfo] = Channel;
@ -175,7 +181,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
switch (Key)
{
case KEY_0:
ACTION_FM();
#ifdef ENABLE_FMRADIO
ACTION_FM();
#endif
break;
case KEY_1:
@ -227,7 +235,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
break;
case KEY_3:
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gEeprom.VFO_OPEN && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else
if (gEeprom.VFO_OPEN)
@ -238,7 +246,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
gRequestSaveVFO = true;
@ -250,7 +258,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Channel != 0xFF)
{
gEeprom.ScreenChannel[Vfo] = Channel;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, Channel + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
@ -276,7 +284,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_5:
// TODO: something wrong here !!
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_CHANNEL];
@ -284,14 +292,14 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
else
{
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
}
#else
//gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_CHANNEL];
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
#endif
@ -318,7 +326,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
@ -345,7 +353,9 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!gFmRadioMode)
#ifdef ENABLE_FMRADIO
if (!gFmRadioMode)
#endif
{
if (gScanState == SCAN_OFF)
{
@ -353,7 +363,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
return;
gInputBox[--gInputBoxIndex] = 10;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gInputBoxIndex == 0)
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
@ -362,7 +372,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
SCANNER_Stop();
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
@ -371,7 +381,9 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
return;
}
ACTION_FM();
#ifdef ENABLE_FMRADIO
ACTION_FM();
#endif
}
}
@ -388,7 +400,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
{
gFlagRefreshSetting = true;
gRequestDisplayScreen = DISPLAY_MENU;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MENU;
#endif
}
@ -422,7 +434,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gScanState == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else
if (gScanState == SCAN_OFF)
@ -447,7 +459,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
gWasFKeyPressed = false;
gUpdateStatus = true;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gFlagStartScan = true;
@ -487,7 +499,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (IS_FREQ_CHANNEL(Channel))
return;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
@ -507,7 +519,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gScanState == SCAN_OFF)
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
#endif
{
@ -532,13 +544,13 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (!bKeyHeld)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, Next + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
}
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
else
{
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
@ -559,12 +571,14 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT)
{
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
#ifdef ENABLE_FMRADIO
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT)
{
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
#endif
if (gDTMF_InputMode && !bKeyHeld && bKeyPressed)
{

View File

@ -34,7 +34,7 @@
#include "ui/menu.h"
#include "ui/ui.h"
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
static const VOICE_ID_t MenuVoices[] =
{
VOICE_ID_SQUELCH,
@ -57,7 +57,7 @@
VOICE_ID_INVALID,
VOICE_ID_BEEP_PROMPT,
VOICE_ID_TRANSMIT_OVER_TIME,
// #ifndef DISABLE_VOICE
// #ifdef ENABLE_VOICE
VOICE_ID_VOICE_PROMPT,
// #endif
VOICE_ID_INVALID,
@ -72,7 +72,7 @@
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID,
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
VOICE_ID_INVALID,
#endif
VOICE_ID_ANI_CODE,
@ -89,7 +89,7 @@
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID,
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
VOICE_ID_INVALID,
#endif
VOICE_ID_DELETE_CHANNEL,
@ -149,7 +149,7 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
break;
case MENU_MDF:
#ifdef CHAN_NAME_FREQ
#ifdef ENABLE_CHAN_NAME_FREQ
*pMin = 0;
*pMax = 3;
break;
@ -161,7 +161,7 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
case MENU_SFT_D:
case MENU_TDR:
case MENU_XB:
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
case MENU_VOICE:
#endif
case MENU_SC_REV:
@ -190,13 +190,13 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_STE:
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
#endif
case MENU_D_ST:
case MENU_D_DCD:
case MENU_AM:
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
#endif
case MENU_RESET:
@ -420,7 +420,7 @@ void MENU_AcceptSetting(void)
return;
case MENU_XB:
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]))
return;
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
@ -441,7 +441,7 @@ void MENU_AcceptSetting(void)
gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection;
break;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
case MENU_VOICE:
gEeprom.VOICE_PROMPT = gSubMenuSelection;
gRequestSaveSettings = true;
@ -499,7 +499,7 @@ void MENU_AcceptSetting(void)
gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection - 1;
break;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
gEeprom.ALARM_MODE = gSubMenuSelection;
break;
@ -556,7 +556,7 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 2;
return;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection;
gRequestSaveSettings = true;
@ -779,7 +779,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gEeprom.TX_TIMEOUT_TIMER;
break;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
case MENU_VOICE:
gSubMenuSelection = gEeprom.VOICE_PROMPT;
break;
@ -833,7 +833,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 1);
break;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
gSubMenuSelection = gEeprom.ALARM_MODE;
break;
@ -879,7 +879,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gTxVfo->AM_CHANNEL_MODE;
break;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN;
break;
@ -971,7 +971,7 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 6)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
return;
@ -980,7 +980,7 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency);
Frequency += 75;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, 0);
@ -991,7 +991,7 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (gInputBoxIndex < 3)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
@ -1004,7 +1004,7 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (IS_MR_CHANNEL(Value))
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = Value;
@ -1066,7 +1066,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
@ -1077,7 +1077,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
return;
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
@ -1085,7 +1085,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
else
{
MENU_StopCssScan();
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
@ -1104,7 +1104,7 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (!gIsInSubMenu)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR)
gAnotherVoiceID = MenuVoices[gMenuCursor];
#endif
@ -1128,7 +1128,7 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (gMenuCursor == MENU_RESET)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
#endif
@ -1149,7 +1149,7 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gCssScanMode = CSS_SCAN_MODE_OFF;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else
@ -1169,7 +1169,7 @@ static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
RADIO_SelectVfos();
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && !gRxVfo->IsAM)
#else
if (!gRxVfo->IsAM)
@ -1181,7 +1181,7 @@ static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{
MENU_StartCssScan(1);
gRequestDisplayScreen = DISPLAY_MENU;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(1);
#endif
@ -1190,7 +1190,7 @@ static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{
MENU_StopCssScan();
gRequestDisplayScreen = DISPLAY_MENU;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}

View File

@ -57,7 +57,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 3)
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
return;
@ -68,7 +68,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (IS_MR_CHANNEL(Channel))
{
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0);
@ -96,7 +96,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
break;
@ -113,7 +113,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
case 2:
gScannerEditState = 0;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_SCANNER;
@ -203,7 +203,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
}
gScanCssState = SCAN_CSS_STATE_FOUND;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MEMORY_CHANNEL;
#endif
gRequestDisplayScreen = DISPLAY_SCANNER;
@ -256,7 +256,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gTxVfo->CHANNEL_SAVE = Channel;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Channel;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CONFIRM;
#endif
gRequestDisplayScreen = DISPLAY_SCANNER;
@ -356,9 +356,9 @@ void SCANNER_Start(void)
RADIO_SelectVfos();
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + 5;
gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz;
#endif
BackupStep = gRxVfo->STEP_SETTING;
@ -371,7 +371,7 @@ void SCANNER_Start(void)
RADIO_SetupRegisters(true);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
gIsNoaaMode = false;
#endif

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/uart.h"
#include "board.h"
#include "bsp/dp32g030/dma.h"
@ -215,7 +217,9 @@ static void CMD_0514(const uint8_t *pBuffer)
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;
Timestamp = pCmd->Timestamp;
gFmRadioCountdown = 4;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown = 4;
#endif
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
SendVersion();
}
@ -230,7 +234,9 @@ static void CMD_051B(const uint8_t *pBuffer)
return;
}
gFmRadioCountdown = 4;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown = 4;
#endif
memset(&Reply, 0, sizeof(Reply));
Reply.Header.ID = 0x051C;
Reply.Header.Size = pCmd->Size + 4;
@ -261,7 +267,9 @@ static void CMD_051D(const uint8_t *pBuffer)
bReloadEeprom = false;
gFmRadioCountdown = 4;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown = 4;
#endif
Reply.Header.ID = 0x051E;
Reply.Header.Size = sizeof(Reply.Data);
Reply.Data.Offset = pCmd->Offset;
@ -326,7 +334,9 @@ static void CMD_052D(const uint8_t *pBuffer)
REPLY_052D_t Reply;
bool bIsLocked;
gFmRadioCountdown = 4;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown = 4;
#endif
Reply.Header.ID = 0x052E;
Reply.Header.Size = sizeof(Reply.Data);
@ -369,7 +379,7 @@ static void CMD_052F(const uint8_t *pBuffer)
gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF;
gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
gIsNoaaMode = false;
#endif

54
audio.c
View File

@ -14,10 +14,14 @@
* limitations under the License.
*/
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk1080.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/system.h"
@ -27,7 +31,7 @@
#include "settings.h"
#include "ui/ui.h"
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
static const uint8_t VoiceClipLengthChinese[58] =
{
@ -75,7 +79,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL)
return;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY)
return;
#endif
@ -93,9 +97,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
BK4819_RX_TurnOn();
if (gFmRadioMode)
BK1080_Mute(true);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Mute(true);
#endif
SYSTEM_DelayMs(20);
switch (Beep)
@ -155,14 +161,16 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gEnableSpeaker)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
if (gFmRadioMode)
BK1080_Mute(false);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Mute(false);
#endif
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
BK4819_Sleep();
}
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
void AUDIO_PlayVoice(uint8_t VoiceID)
{
@ -217,9 +225,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
BK4819_SetAF(BK4819_AF_MUTE);
if (gFmRadioMode)
BK1080_Mute(true);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Mute(true);
#endif
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gVoxResumeCountdown = 2000;
SYSTEM_DelayMs(5);
@ -240,9 +250,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
BK4819_SetAF(BK4819_AF_OPEN);
}
if (gFmRadioMode)
BK1080_Mute(false);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Mute(false);
#endif
if (!gEnableSpeaker)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
@ -375,9 +387,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
BK4819_SetAF(BK4819_AF_OPEN);
}
if (gFmRadioMode)
BK1080_Mute(false);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
BK1080_Mute(false);
#endif
if (!gEnableSpeaker)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

View File

@ -35,7 +35,7 @@ extern BEEP_Type_t gBeepToPlay;
void AUDIO_PlayBeep(BEEP_Type_t Beep);
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
enum
{

View File

@ -244,7 +244,7 @@ const uint8_t BITMAP_TDR[] =
0b01111111
};
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
const uint8_t BITMAP_VoicePrompt[] =
{
0b00000000,
@ -259,24 +259,26 @@ const uint8_t BITMAP_TDR[] =
};
#endif
const uint8_t BITMAP_FM[] =
{
0b00000000,
0b01111111,
0b00001001,
0b00001001,
0b00001001,
0b00000001,
#ifdef ENABLE_FMRADIO
const uint8_t BITMAP_FM[] =
{
0b00000000,
0b01111111,
0b00001001,
0b00001001,
0b00001001,
0b00000001,
0b00000000,
0b01111111,
0b00000010,
0b00001100,
0b00000010,
0b01111111
};
#endif
0b00000000,
0b01111111,
0b00000010,
0b00001100,
0b00000010,
0b01111111
};
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
const uint8_t BITMAP_NOAA[] =
{
0b00000000,

View File

@ -28,13 +28,15 @@ extern const uint8_t BITMAP_VOX[18];
extern const uint8_t BITMAP_TDR[12];
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
extern const uint8_t BITMAP_VoicePrompt[9];
#endif
extern const uint8_t BITMAP_FM[12];
#ifdef ENABLE_FMRADIO
extern const uint8_t BITMAP_FM[12];
#endif
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
extern const uint8_t BITMAP_NOAA[12];
#endif

56
board.c
View File

@ -18,14 +18,18 @@
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "bsp/dp32g030/portcon.h"
#include "bsp/dp32g030/saradc.h"
#include "bsp/dp32g030/syscon.h"
#include "driver/adc.h"
#include "driver/bk1080.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/crc.h"
#include "driver/eeprom.h"
@ -300,9 +304,7 @@ void BOARD_ADC_Init(void)
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent)
{
ADC_Start();
while (!ADC_CheckEndOfConversion(ADC_CH9)) {}
*pVoltage = ADC_GetValue(ADC_CH4);
*pCurrent = ADC_GetValue(ADC_CH9);
}
@ -313,7 +315,9 @@ void BOARD_Init(void)
BOARD_GPIO_Init();
BOARD_ADC_Init();
ST7565_Init();
BK1080_Init(0, false);
#ifdef ENABLE_FMRADIO
BK1080_Init(0, false);
#endif
CRC_Init();
}
@ -329,7 +333,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST;
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
#endif
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false;
@ -339,7 +343,7 @@ void BOARD_EEPROM_Init(void)
// 0E78..0E7F
EEPROM_ReadBuffer(0x0E78, Data, 8);
#ifndef CHAN_NAME_FREQ
#ifndef ENABLE_CHAN_NAME_FREQ
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 3) ? Data[1] : MDF_FREQUENCY;
#else
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY;
@ -353,17 +357,18 @@ void BOARD_EEPROM_Init(void)
// 0E80..0E87
EEPROM_ReadBuffer(0x0E80, Data, 8);
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + 5);
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + 5);
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST;
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST;
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + 5);
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + 5);
#ifndef DISABLE_NOAA
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
#ifdef ENABLE_NOAA
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
#endif
#ifdef ENABLE_FMRADIO
{ // 0E88..0E8F
struct
{
@ -388,31 +393,35 @@ void BOARD_EEPROM_Init(void)
// 0E40..0E67
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
FM_ConfigureChannelState();
#endif
// 0E90..0E97
EEPROM_ReadBuffer(0x0E90, Data, 8);
gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true;
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_FM;
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 3) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true;
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
#ifdef ENABLE_FMRADIO
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
#else
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
#endif
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 3) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
// 0E98..0E9F
EEPROM_ReadBuffer(0x0E98, Data, 8);
memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4);
// 0EA0..0EA7
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
EEPROM_ReadBuffer(0x0EA0, Data, 8);
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
#endif
// 0EA8..0EAF
EEPROM_ReadBuffer(0x0EA8, Data, 8);
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true;
#endif
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
@ -588,7 +597,8 @@ void BOARD_FactoryReset(bool bIsAll)
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
!(i >= 0x0E88 && i < 0x0E90))) // FM settings
!(i >= 0x0E88 && i < 0x0E90) // FM settings
))
) {
EEPROM_WriteBuffer(i, Template);
}

View File

@ -231,6 +231,16 @@ void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet)
void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
{
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable
// 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
// REG_51 <12> 0 CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
// 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.
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max
// Enable CDCSS
// Transmit positive CDCSS code
// CDCSS Mode
@ -238,6 +248,7 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
// Enable Auto CDCSS Bw Mode
// Enable Auto CTCSS Bw Mode
// CTCSS/CDCSS Tx Gain1 Tuning = 51
//
BK4819_WriteRegister(BK4819_REG_51,
BK4819_REG_51_ENABLE_CxCSS
| BK4819_REG_51_GPIO6_PIN2_NORMAL
@ -249,18 +260,35 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
| BK4819_REG_51_AUTO_CTCSS_BW_ENABLE
| (51u << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1));
// CTC1 Frequency Control Word = 2775
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | (2775u << BK4819_REG_07_SHIFT_FREQUENCY));
// REG_07 <15:0>
//
// When <13> = 0 for CTC1
// <12:0> = CTC1 frequency control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 1 for CTC2 (Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequency control word =
// 25391 / freq(Hz) for XTAL 13M/26M or
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 2 for CDCSS 134.4Hz
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// Set the code word
BK4819_WriteRegister(BK4819_REG_08, 0x0000 | ((CodeWord >> 0) & 0x0FFF));
BK4819_WriteRegister(BK4819_REG_08, 0x8000 | ((CodeWord >> 12) & 0x0FFF));
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | 2775u);
// REG_08 <15:0> <15> = 1 for CDCSS high 12bit
// <15> = 0 for CDCSS low 12bit
// <11:0> = CDCSShigh/low 12bit code
BK4819_WriteRegister(BK4819_REG_08, (0u << 15) | ((CodeWord >> 0) & 0x0FFF)); // LS 12-bits
BK4819_WriteRegister(BK4819_REG_08, (1u << 15) | ((CodeWord >> 12) & 0x0FFF)); // MS 12-bits
}
void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
{
uint16_t Config;
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable
// 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
@ -271,6 +299,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max
uint16_t Config;
if (FreqControlWord == 2625)
{ // Enables 1050Hz detection mode
// Enable TxCTCSS
@ -279,6 +308,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
// Enable Auto CDCSS Bw Mode
// Enable Auto CTCSS Bw Mode
// CTCSS/CDCSS Tx Gain1 Tuning = 74
//
Config = 0x944A; // 1 0 0 1 0 1 0 0 0 1001010
}
else
@ -287,6 +317,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
// Enable Auto CDCSS Bw Mode
// Enable Auto CTCSS Bw Mode
// CTCSS/CDCSS Tx Gain1 Tuning = 74
//
Config = 0x904A; // 1 0 0 1 0 0 0 0 0 1001010
}
BK4819_WriteRegister(BK4819_REG_51, Config);
@ -294,16 +325,21 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
// REG_07 <15:0>
//
// When <13> = 0 for CTC1
// <12:0> = CTC1 frequencycontrolword = freq(Hz)*20.64888 for XTAL 13M/26M or = freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// <12:0> = CTC1 frequency control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 1 for CTC2(Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequencycontrolword = 25391/freq(Hz) for XTAL 13M/26M or = 25000/freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
// When <13> = 1 for CTC2 (Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequency control word =
// 25391 / freq(Hz) for XTAL 13M/26M or
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 2 for CDCSS 134.4Hz
// <12:0> = CDCSS baud rate frequency (134.4Hz) controlword = freq(Hz)*20.64888 for XTAL 13M/26M or = freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// CTC1 Frequency Control Word
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | ((FreqControlWord * 2065) / 1000) << BK4819_REG_07_SHIFT_FREQUENCY);
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | ((FreqControlWord * 2065u) / 1000u));
}
void BK4819_Set55HzTailDetection(void)
@ -311,17 +347,23 @@ void BK4819_Set55HzTailDetection(void)
// REG_07 <15:0>
//
// When <13> = 0 for CTC1
// <12:0> = CTC1 frequencycontrolword = freq(Hz)*20.64888 for XTAL 13M/26M or = freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// <12:0> = CTC1 frequency control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 1 for CTC2(Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequencycontrolword = 25391/freq(Hz) for XTAL 13M/26M or = 25000/freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
// When <13> = 1 for CTC2 (Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequency control word =
// 25391 / freq(Hz) for XTAL 13M/26M or
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 2 for CDCSS 134.4Hz
// <12:0> = CDCSS baud rate frequency (134.4Hz) controlword = freq(Hz)*20.64888 for XTAL 13M/26M or = freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
// CTC2 Frequency Control Word = round_nearest(25391 / 55) = 462
const unsigned int ctcss_Hz = 55;
BK4819_WriteRegister(BK4819_REG_07, (1u << 13) | ((25391 + (ctcss_Hz / 2)) / ctcss_Hz)); // with rounding
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC2 | ((25391 + (ctcss_Hz / 2)) / ctcss_Hz)); // with rounding
}
void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
@ -554,7 +596,7 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
| BK4819_REG_30_ENABLE_RX_DSP);
}
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
void BK4819_SetupAircopy(void)
{
BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48
@ -778,36 +820,98 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
void BK4819_GenTail(uint8_t Tail)
{
// REG_52 <15> 0 Enable 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode
// 0 = Normal
// 1 = Enable
// REG_52 <14:13> 0 CTCSS tail mode selection (only valid when REG_52 <15> = 1)
// 00 = for 134.4Hz CTCSS Tail when CDCSS mode
// 01 = CTCSS0 120° phase shift
// 10 = CTCSS0 180° phase shift
// 11 = CTCSS0 240° phase shift
// REG_52 <12> 0 CTCSSDetectionThreshold Mode
// 1 = ~0.1%
// 0 = 0.1 Hz
// REG_52 <11:6> 0x0A CTCSS found detect threshold
// REG_52 <5:0> 0x0F CTCSS lost detect threshold
// REG_07 <15:0>
//
// When <13> = 0 for CTC1
// <12:0> = CTC1 frequency control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 1 for CTC2 (Tail 55Hz Rx detection)
// <12:0> = CTC2 (should below 100Hz) frequency control word =
// 25391 / freq(Hz) for XTAL 13M/26M or
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
//
// When <13> = 2 for CDCSS 134.4Hz
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz)*20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
switch (Tail)
{
case 0: // CTC134
BK4819_WriteRegister(BK4819_REG_52, 0x828F);
case 0: // 134.4Hz CTCSS Tail
BK4819_WriteRegister(BK4819_REG_52, 0x828F); // 1 00 0 001010 001111
break;
case 1: // CTC120
BK4819_WriteRegister(BK4819_REG_52, 0xA28F);
case 1: // 120° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xA28F); // 1 01 0 001010 001111
break;
case 2: // CTC180
BK4819_WriteRegister(BK4819_REG_52, 0xC28F);
case 2: // 180° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xC28F); // 1 10 0 001010 001111
break;
case 3: // CTC240
BK4819_WriteRegister(BK4819_REG_52, 0xE28F);
case 3: // 240° phase shift
BK4819_WriteRegister(BK4819_REG_52, 0xE28F); // 1 11 0 001010 001111
break;
case 4: // CTC55
BK4819_WriteRegister(BK4819_REG_07, 0x046f);
case 4: // 55Hz tone freq
BK4819_WriteRegister(BK4819_REG_07, 0x046f); // 0 00 0 010001 101111
break;
}
}
void BK4819_EnableCDCSS(void)
{
BK4819_GenTail(0); // CTC134
BK4819_GenTail(0); // CTC134
BK4819_WriteRegister(BK4819_REG_51, 0x804A);
}
void BK4819_EnableCTCSS(void)
{
BK4819_GenTail(4); // CTC55
BK4819_WriteRegister(BK4819_REG_51, 0x904A);
// BK4819_GenTail(1); // 120° phase shift
BK4819_GenTail(2); // 180° phase shift
// BK4819_GenTail(3); // 240° phase shift
// BK4819_GenTail(4); // 55Hz tone freq
// REG_51 <15> 0
// 1 = Enable TxCTCSS/CDCSS
// 0 = Disable
// REG_51 <14> 0
// 1 = GPIO0Input for CDCSS
// 0 = Normal Mode (for BK4819 v3)
// REG_51 <13> 0
// 1 = Transmit negative CDCSS code
// 0 = Transmit positive CDCSS code
// REG_51 <12> 0 CTCSS/CDCSS mode selection
// 1 = CTCSS
// 0 = CDCSS
// REG_51 <11> 0 CDCSS 24/23bit selection
// 1 = 24bit
// 0 = 23bit
// 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
// REG_51 <8> 0 Auto CTCSS Bw Mode
// 0 = Enable
// 1 = Disable
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
// 0 = min
// 127 = max
BK4819_WriteRegister(BK4819_REG_51, 0x904A); // 1 0 0 1 0 0 0 0 0 1001010
}
uint16_t BK4819_GetRSSI(void)

View File

@ -92,7 +92,7 @@ void BK4819_EnterTxMute(void);
void BK4819_ExitTxMute(void);
void BK4819_Sleep(void);
void BK4819_TurnsOffTones_TurnsOnRX(void);
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
void BK4819_SetupAircopy(void);
#endif
void BK4819_ResetFSK(void);

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,7 +23,7 @@ const uint32_t bx_max_Hz = 130000000; // 1300MHz
const uint32_t LowerLimitFrequencyBandTable[7] =
{
#ifndef RX_ANY_FREQ
#ifndef ENABLE_WIDE_RX
5000000,
#else
1800000,
@ -55,14 +55,14 @@ const uint32_t UpperLimitFrequencyBandTable[7] =
34999990,
39999990,
46999990,
#ifndef RX_ANY_FREQ
#ifndef ENABLE_WIDE_RX
60000000
#else
130000000
#endif
};
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
const uint32_t NoaaFrequencyTable[10] =
{
16255000,
@ -154,7 +154,7 @@ int FREQUENCY_Check(VFO_Info_t *pInfo)
{
const uint32_t Frequency = pInfo->pTX->Frequency;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (pInfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST)
return -1;
#endif

View File

@ -41,7 +41,7 @@ extern const uint32_t LowerLimitFrequencyBandTable[7];
extern const uint32_t MiddleFrequencyBandTable[7];
extern const uint32_t UpperLimitFrequencyBandTable[7];
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
extern const uint32_t NoaaFrequencyTable[10];
#endif

View File

@ -17,10 +17,14 @@
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
#include "driver/bk1080.h"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/system.h"
@ -36,7 +40,7 @@ FUNCTION_Type_t gCurrentFunction;
void FUNCTION_Init(void)
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
@ -44,11 +48,11 @@ void FUNCTION_Init(void)
if (gCssScanMode == CSS_SCAN_MODE_OFF)
gCurrentCodeType = gRxVfo->IsAM ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
else
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
#endif
gDTMF_RequestPending = false;
gDTMF_WriteIndex = 0;
@ -73,7 +77,6 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
{
FUNCTION_Type_t PreviousFunction;
bool bWasPowerSave;
uint16_t Countdown = 0;
PreviousFunction = gCurrentFunction;
bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);
@ -85,7 +88,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
{
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
gRxIdleMode = false;
UI_DisplayStatus();
UI_DisplayStatus(false);
}
}
@ -94,21 +97,23 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
case FUNCTION_FOREGROUND:
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
RADIO_PrepareCssTX();
if (PreviousFunction == FUNCTION_TRANSMIT)
{
gVFO_RSSI_Level[0] = 0;
gVFO_RSSI_Level[1] = 0;
}
else
if (PreviousFunction == FUNCTION_RECEIVE)
{
if (PreviousFunction != FUNCTION_RECEIVE)
break;
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode)
Countdown = 500;
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED)
gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2);
}
gFM_RestoreCountdown = 500;
#endif
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED)
gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2);
return;
@ -120,22 +125,21 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
case FUNCTION_POWER_SAVE:
gBatterySave = gEeprom.BATTERY_SAVE * 10;
gRxIdleMode = true;
BK4819_DisableVox();
BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
gBatterySaveCountdownExpired = false;
gUpdateStatus = true;
gUpdateStatus = true;
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
case FUNCTION_TRANSMIT:
if (gFmRadioMode)
BK1080_Init(0, false);
#ifndef DISABLE_ALARM
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode)
BK1080_Init(0, false);
#endif
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE)
{
gAlarmState = ALARM_STATE_ALARM;
@ -154,22 +158,17 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
#endif
GUI_DisplayScreen();
RADIO_SetTxParameters();
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true);
DTMF_Reply();
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
if (gAlarmState != ALARM_STATE_OFF)
{
BK4819_TransmitTone(true, (gAlarmState == ALARM_STATE_TX1750) ? 1750 : 500);
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gAlarmToneCounter = 0;
gEnableSpeaker = true;
break;
@ -180,12 +179,13 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U);
else
BK4819_DisableScramble();
break;
}
gBatterySaveCountdown = battery_save_count;
gSchedulePowerSave = false;
gFM_RestoreCountdown = Countdown;
#if defined(ENABLE_FMRADIO)
gFM_RestoreCountdown = 0;
#endif
}

View File

@ -30,8 +30,8 @@ uint8_t gBatteryDisplayLevel;
bool gChargingWithTypeC;
bool gLowBattery;
bool gLowBatteryBlink;
volatile uint16_t gBatterySave;
uint16_t gBatteryCheckCounter;
volatile uint16_t gBatterySave;
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
{

View File

@ -20,22 +20,18 @@
#include <stdbool.h>
#include <stdint.h>
extern uint16_t gBatteryCalibration[6];
extern uint16_t gBatteryCurrentVoltage;
extern uint16_t gBatteryCurrent;
extern uint16_t gBatteryVoltages[4];
extern uint16_t gBatteryVoltageAverage;
extern uint8_t gBatteryDisplayLevel;
extern bool gChargingWithTypeC;
extern bool gLowBattery;
extern bool gLowBatteryBlink;
extern uint16_t gBatteryCalibration[6];
extern uint16_t gBatteryCurrentVoltage;
extern uint16_t gBatteryCurrent;
extern uint16_t gBatteryVoltages[4];
extern uint16_t gBatteryVoltageAverage;
extern uint8_t gBatteryDisplayLevel;
extern bool gChargingWithTypeC;
extern bool gLowBattery;
extern bool gLowBatteryBlink;
extern uint16_t gBatteryCheckCounter;
extern volatile uint16_t gBatterySave;
extern uint16_t gBatteryCheckCounter;
void BATTERY_GetReadings(bool bDisplayBatteryLevel);
#endif

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include "app/aircopy.h"
#endif
#include "bsp/dp32g030/gpio.h"
@ -53,7 +53,7 @@ BOOT_Mode_t BOOT_GetMode(void)
if (Keys[0] == KEY_SIDE1)
return BOOT_MODE_F_LOCK;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
if (Keys[0] == KEY_SIDE2)
return BOOT_MODE_AIRCOPY;
#endif
@ -71,17 +71,17 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
GUI_SelectNextDisplay(DISPLAY_MENU);
gF_LOCK = true;
gMenuListCount = 57;
#ifdef DISABLE_VOICE
#ifndef ENABLE_VOICE
gMenuListCount--;
#endif
#ifdef DISABLE_ALARM
#ifndef ENABLE_ALARM
gMenuListCount--;
#endif
#ifdef DISABLE_NOAA
#ifndef ENABLE_NOAA
gMenuListCount--;
#endif
}
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
else
if (Mode == BOOT_MODE_AIRCOPY)
{

View File

@ -24,7 +24,7 @@ enum BOOT_Mode_t
{
BOOT_MODE_NORMAL = 0,
BOOT_MODE_F_LOCK,
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
BOOT_MODE_AIRCOPY
#endif
};

16
main.c
View File

@ -37,6 +37,10 @@
#include "ui/welcome.h"
#include "version.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
void _putchar(char c)
{
UART_Send((uint8_t *)&c, 1);
@ -85,7 +89,7 @@ void Main(void)
{
unsigned int i;
for (i = 0; i < 4; i++)
for (i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++)
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
}
@ -113,13 +117,13 @@ void Main(void)
SYSTEM_DelayMs(2000);
gMenuListCount = 51;
#ifdef DISABLE_ALARM
#ifndef ENABLE_ALARM
gMenuListCount--;
#endif
#ifdef DISABLE_VOICE
#ifndef ENABLE_VOICE
gMenuListCount--;
#endif
#ifdef DISABLE_NOAA
#ifndef ENABLE_NOAA
gMenuListCount--;
#endif
@ -138,7 +142,7 @@ void Main(void)
gUpdateStatus = true;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
{
uint8_t Channel;
@ -158,7 +162,7 @@ void Main(void)
}
#endif
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
RADIO_ConfigureNOAA();
#endif
}

24
misc.c
View File

@ -71,7 +71,7 @@ volatile uint16_t gBatterySaveCountdown = battery_save_count;
volatile uint16_t gDualWatchCountdown;
volatile uint16_t gTxTimerCountdown;
volatile uint16_t gTailNoteEliminationCountdown;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
volatile uint16_t gNOAA_Countdown;
#endif
@ -88,7 +88,7 @@ uint8_t gReducedService;
uint8_t gBatteryVoltageIndex;
CssScanMode_t gCssScanMode;
bool gUpdateRSSI;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
AlarmState_t gAlarmState;
#endif
uint8_t gVoltageMenuCountdown;
@ -101,14 +101,18 @@ bool gFlagResetVfos;
bool gRequestSaveVFO;
uint8_t gRequestSaveChannel;
bool gRequestSaveSettings;
bool gRequestSaveFM;
#ifdef ENABLE_FMRADIO
bool gRequestSaveFM;
#endif
bool gFlagPrepareTX;
bool gFlagAcceptSetting;
bool gFlagRefreshSetting;
bool gFlagSaveVfo;
bool gFlagSaveSettings;
bool gFlagSaveChannel;
bool gFlagSaveFM;
#ifdef ENABLE_FMRADIO
bool gFlagSaveFM;
#endif
uint8_t gDTMF_RequestPending;
bool g_CDCSS_Lost;
uint8_t gCDCSSCodeType;
@ -130,7 +134,7 @@ uint8_t gCurrentScanList;
uint8_t gPreviousMrChannel;
uint32_t gRestoreFrequency;
uint8_t gRxVfoIsActive;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
uint8_t gAlarmToneCounter;
uint16_t gAlarmRunningCounter;
#endif
@ -140,13 +144,13 @@ uint8_t gPttDebounceCounter;
uint8_t gMenuListCount;
uint8_t gBackupCROSS_BAND_RX_TX;
uint8_t gScanDelay;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
uint8_t gAircopySendCountdown;
#endif
uint8_t gFSKWriteIndex;
uint8_t gNeverUsed;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
bool gIsNoaaMode;
uint8_t gNoaaChannel;
#endif
@ -165,11 +169,13 @@ volatile bool gNextTimeslice40ms;
volatile bool gSchedulePowerSave;
volatile bool gBatterySaveCountdownExpired;
volatile bool gScheduleDualWatch = true;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
volatile bool gScheduleNOAA = true;
#endif
volatile bool gFlagTteComplete;
volatile bool gScheduleFM;
#ifdef ENABLE_FMRADIO
volatile bool gScheduleFM;
#endif
uint16_t gCurrentRSSI;

28
misc.h
View File

@ -124,8 +124,10 @@ extern volatile uint16_t gBatterySaveCountdown;
extern volatile uint16_t gDualWatchCountdown;
extern volatile uint16_t gTxTimerCountdown;
extern volatile uint16_t gTailNoteEliminationCountdown;
extern volatile uint16_t gFmPlayCountdown;
#ifndef DISABLE_NOAA
#ifdef ENABLE_FMRADIO
extern volatile uint16_t gFmPlayCountdown;
#endif
#ifdef ENABLE_NOAA
extern volatile uint16_t gNOAA_Countdown;
#endif
extern bool gEnableSpeaker;
@ -151,7 +153,9 @@ extern bool gFlagResetVfos;
extern bool gRequestSaveVFO;
extern uint8_t gRequestSaveChannel;
extern bool gRequestSaveSettings;
extern bool gRequestSaveFM;
#ifdef ENABLE_FMRADIO
extern bool gRequestSaveFM;
#endif
extern uint8_t gKeypadLocked;
extern bool gFlagPrepareTX;
extern bool gFlagAcceptSetting;
@ -159,7 +163,9 @@ extern bool gFlagRefreshSetting;
extern bool gFlagSaveVfo;
extern bool gFlagSaveSettings;
extern bool gFlagSaveChannel;
extern bool gFlagSaveFM;
#ifdef ENABLE_FMRADIO
extern bool gFlagSaveFM;
#endif
extern uint8_t gDTMF_RequestPending;
extern bool g_CDCSS_Lost;
extern uint8_t gCDCSSCodeType;
@ -189,18 +195,20 @@ extern uint8_t gPttDebounceCounter;
extern uint8_t gMenuListCount;
extern uint8_t gBackupCROSS_BAND_RX_TX;
extern uint8_t gScanDelay;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
extern uint8_t gAircopySendCountdown;
#endif
extern uint8_t gFSKWriteIndex;
extern uint8_t gNeverUsed;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
extern bool gIsNoaaMode;
extern uint8_t gNoaaChannel;
#endif
extern volatile bool gNextTimeslice;
extern bool gUpdateDisplay;
extern uint8_t gFM_ChannelPosition;
#ifdef ENABLE_FMRADIO
extern uint8_t gFM_ChannelPosition;
#endif
extern bool gF_LOCK;
extern uint8_t gShowChPrefix;
extern volatile uint16_t gSystickCountdown2;
@ -212,11 +220,13 @@ extern volatile bool gNextTimeslice40ms;
extern volatile bool gSchedulePowerSave;
extern volatile bool gBatterySaveCountdownExpired;
extern volatile bool gScheduleDualWatch;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
extern volatile bool gScheduleNOAA;
#endif
extern volatile bool gFlagTteComplete;
extern volatile bool gScheduleFM;
#ifdef ENABLE_FMRADIO
extern volatile bool gScheduleFM;
#endif
extern uint16_t gCurrentRSSI;
extern uint8_t gIsLocked;

42
radio.c
View File

@ -17,7 +17,9 @@
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
@ -160,7 +162,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
if (IS_VALID_CHANNEL(Channel))
{
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (Channel >= NOAA_CHANNEL_FIRST)
{
RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], 2, NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]);
@ -546,7 +548,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
// mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f));
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode)
Frequency = gRxVfo->pRX->Frequency;
else
@ -573,7 +575,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
InterruptMask = 0 | BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
@ -628,7 +630,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_EnableScramble(gRxVfo->SCRAMBLING_TYPE - 1);
}
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
else
{
BK4819_SetCTCSSFrequency(2625);
@ -640,10 +642,18 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
}
#endif
#ifndef DISABLE_NOAA
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM)
#ifdef ENABLE_NOAA
#ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM)
#else
if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM)
#endif
#else
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !gCurrentVfo->IsAM)
#ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !gCurrentVfo->IsAM)
#else
if (gEeprom.VOX_SWITCH && !gCurrentVfo->IsAM)
#endif
#endif
{
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
@ -671,7 +681,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
void RADIO_ConfigureNOAA(void)
{
uint8_t ChanAB;
@ -774,7 +784,9 @@ void RADIO_SetVfoState(VfoState_t State)
VfoState[0] = VFO_STATE_NORMAL;
VfoState[1] = VFO_STATE_NORMAL;
gFM_ResumeCountdown = 0;
#ifdef ENABLE_FMRADIO
gFM_ResumeCountdown = 0;
#endif
}
else
{
@ -789,7 +801,9 @@ void RADIO_SetVfoState(VfoState_t State)
VfoState[Channel] = State;
}
gFM_ResumeCountdown = 5;
#ifdef ENABLE_FMRADIO
gFM_ResumeCountdown = 5;
#endif
}
gUpdateDisplay = true;
@ -812,7 +826,7 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo();
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_OFF || gAlarmState == ALARM_STATE_TX1750 || (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
#endif
{
@ -843,7 +857,7 @@ void RADIO_PrepareTX(void)
RADIO_SetVfoState(State);
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
gAlarmState = ALARM_STATE_OFF;
#endif
@ -872,7 +886,7 @@ Skip:
FUNCTION_Select(FUNCTION_TRANSMIT);
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
gTxTimerCountdown = (gAlarmState == ALARM_STATE_OFF) ? gEeprom.TX_TIMEOUT_TIMER * 120 : 0;
#else
gTxTimerCountdown = gEeprom.TX_TIMEOUT_TIMER * 120;

View File

@ -147,7 +147,7 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
void RADIO_SelectVfos(void);
void RADIO_SetupRegisters(bool bSwitchToFunction0);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
void RADIO_ConfigureNOAA(void);
#endif
void RADIO_SetTxParameters(void);

View File

@ -14,7 +14,9 @@
* limitations under the License.
*/
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "audio.h"
#include "functions.h"
@ -74,7 +76,7 @@ void SystickHandler(void)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gDualWatchCountdown, gScheduleDualWatch);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
if (gCurrentFunction != FUNCTION_RECEIVE)
@ -87,13 +89,15 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown, gFlagTteComplete);
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
#endif
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gFmPlayCountdown, gScheduleFM);
#ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gFmPlayCountdown, gScheduleFM);
#endif
if (gVoxStopCountdown)
gVoxStopCountdown--;

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "driver/eeprom.h"
#include "driver/uart.h"
#include "misc.h"
@ -24,29 +26,31 @@
EEPROM_Config_t gEeprom;
void SETTINGS_SaveFM(void)
{
unsigned int i;
struct
#ifdef ENABLE_FMRADIO
void SETTINGS_SaveFM(void)
{
uint16_t Frequency;
uint8_t Channel;
bool IsChannelSelected;
uint8_t Padding[4];
} State;
UART_LogSend("sFm\r\n", 5);
memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_SelectedChannel;
State.Frequency = gEeprom.FM_SelectedFrequency;
State.IsChannelSelected = gEeprom.FM_IsMrMode;
EEPROM_WriteBuffer(0x0E88, &State);
for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
}
unsigned int i;
struct
{
uint16_t Frequency;
uint8_t Channel;
bool IsChannelSelected;
uint8_t Padding[4];
} State;
UART_LogSend("sFm\r\n", 5);
memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_SelectedChannel;
State.Frequency = gEeprom.FM_SelectedFrequency;
State.IsChannelSelected = gEeprom.FM_IsMrMode;
EEPROM_WriteBuffer(0x0E88, &State);
for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
}
#endif
void SETTINGS_SaveVfoIndices(void)
{
@ -60,7 +64,7 @@ void SETTINGS_SaveVfoIndices(void)
State[3] = gEeprom.ScreenChannel[1];
State[4] = gEeprom.MrChannel[1];
State[5] = gEeprom.FreqChannel[1];
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
State[6] = gEeprom.NoaaChannel[0];
State[7] = gEeprom.NoaaChannel[1];
#else
@ -81,7 +85,7 @@ void SETTINGS_SaveSettings(void)
State[0] = gEeprom.CHAN_1_CALL;
State[1] = gEeprom.SQUELCH_LEVEL;
State[2] = gEeprom.TX_TIMEOUT_TIMER;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
State[3] = gEeprom.NOAA_AUTO_SCAN;
#else
State[3] = false;
@ -116,13 +120,13 @@ void SETTINGS_SaveSettings(void)
Password[0] = gEeprom.POWER_ON_PASSWORD;
EEPROM_WriteBuffer(0x0E98, State);
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
memset(State, 0xFF, sizeof(State));
State[0] = gEeprom.VOICE_PROMPT;
EEPROM_WriteBuffer(0x0EA0, State);
#endif
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
State[0] = gEeprom.ALARM_MODE;
#else
State[0] = false;
@ -173,7 +177,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
{
UART_LogSend("schn\r\n", 6);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
#endif
{
@ -227,7 +231,7 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdat
{
UART_LogSend("svalid\r\n", 8);
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
#endif
{

View File

@ -82,7 +82,7 @@ enum {
ACTION_OPT_LEN
};
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
enum VOICE_Prompt_t
{
VOICE_PROMPT_OFF = 0,
@ -121,7 +121,7 @@ typedef struct {
uint8_t ScreenChannel[2];
uint8_t FreqChannel[2];
uint8_t MrChannel[2];
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
uint8_t NoaaChannel[2];
#endif
uint8_t RX_CHANNEL;
@ -136,7 +136,7 @@ typedef struct {
bool KEY_LOCK;
bool VOX_SWITCH;
uint8_t VOX_LEVEL;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
VOICE_Prompt_t VOICE_PROMPT;
#endif
bool BEEP_CONTROL;
@ -158,18 +158,24 @@ typedef struct {
uint16_t VOX1_THRESHOLD;
uint16_t VOX0_THRESHOLD;
uint16_t FM_SelectedFrequency;
uint8_t FM_SelectedChannel;
bool FM_IsMrMode;
uint16_t FM_FrequencyPlaying;
#ifdef ENABLE_FMRADIO
uint16_t FM_SelectedFrequency;
uint8_t FM_SelectedChannel;
bool FM_IsMrMode;
uint16_t FM_FrequencyPlaying;
#endif
uint8_t field37_0x32;
uint8_t field38_0x33;
uint16_t FM_LowerLimit;
uint16_t FM_UpperLimit;
#ifdef ENABLE_FMRADIO
uint16_t FM_LowerLimit;
uint16_t FM_UpperLimit;
#endif
bool AUTO_KEYPAD_LOCK;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
ALARM_Mode_t ALARM_MODE;
#endif
POWER_OnDisplayMode_t POWER_ON_DISPLAY_MODE;
@ -207,7 +213,7 @@ typedef struct {
bool DTMF_SIDE_TONE;
bool PERMIT_REMOTE_KILL;
int16_t BK4819_XTAL_FREQ_LOW;
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
bool NOAA_AUTO_SCAN;
#endif
uint8_t VOLUME_GAIN;
@ -222,7 +228,9 @@ typedef struct {
extern EEPROM_Config_t gEeprom;
void SETTINGS_SaveFM(void);
#ifdef ENABLE_FMRADIO
void SETTINGS_SaveFM(void);
#endif
void SETTINGS_SaveVfoIndices(void);
void SETTINGS_SaveSettings(void);
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include <string.h>

View File

@ -17,7 +17,7 @@
#ifndef UI_AIRCOPY_H
#define UI_AIRCOPY_H
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
void UI_DisplayAircopy(void);
#endif

View File

@ -14,7 +14,10 @@
* limitations under the License.
*/
#ifdef ENABLE_FMRADIO
#include <string.h>
#include "app/fm.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
@ -104,3 +107,5 @@ void UI_DisplayFM(void)
ST7565_BlitFullScreen();
}
#endif

View File

@ -17,7 +17,9 @@
#ifndef UI_FM_H
#define UI_FM_H
void UI_DisplayFM(void);
#ifdef ENABLE_FMRADIO
void UI_DisplayFM(void);
#endif
#endif

View File

@ -28,6 +28,10 @@
#include "ui/inputbox.h"
#include "ui/main.h"
//#ifndef ARRAY_SIZE
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
//#endif
void UI_DisplayMain(void)
{
const unsigned int display_width = 128;
@ -135,7 +139,7 @@ void UI_DisplayMain(void)
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_ALARM)
{
SomeValue = 2;
@ -204,7 +208,7 @@ void UI_DisplayMain(void)
uint8_t State = VfoState[vfo_num];
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM)
{
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;
@ -282,7 +286,7 @@ void UI_DisplayMain(void)
switch (gEeprom.CHANNEL_DISPLAY_MODE)
{
case MDF_FREQUENCY: // show the channel frequency
#ifndef DISABLE_BIG_FREQ
#ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency_Hz, String);
// show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false);
@ -313,7 +317,7 @@ void UI_DisplayMain(void)
}
break;
#ifdef CHAN_NAME_FREQ
#ifdef ENABLE_CHAN_NAME_FREQ
case MDF_NAME_FREQ: // show the channel name and frequency
if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF)
{ // no channel name, show channel number instead
@ -343,7 +347,7 @@ void UI_DisplayMain(void)
else
{ // frequency mode
#ifndef DISABLE_BIG_FREQ
#ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency_Hz, String); // 8 digits
// show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false);

View File

@ -52,7 +52,7 @@ static const char MenuList[][7] =
"TxVFO", // was "WX"
"Beep",
"TxTOut", // was "TOT"
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
"Voice",
#endif
"SC-Rev",
@ -67,7 +67,7 @@ static const char MenuList[][7] =
"S-List",
"SList1",
"SList2",
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
"AL-Mod",
#endif
"ANI-ID",
@ -84,7 +84,7 @@ static const char MenuList[][7] =
"Roger",
"BatVol", // was "VOL"
"Mode", // was "AM"
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
"NOAA_S",
#endif
"MemDel", // was "Del-CH"
@ -167,7 +167,7 @@ static const char gSubMenu_CHAN[3][7] =
"CHAN_B",
};
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
static const char gSubMenu_VOICE[3][4] =
{
"OFF",
@ -183,7 +183,7 @@ static const char gSubMenu_SC_REV[3][3] =
"SE",
};
#ifndef CHAN_NAME_FREQ
#ifndef ENABLE_CHAN_NAME_FREQ
static const char gSubMenu_MDF[3][5] =
{
"FREQ",
@ -200,7 +200,7 @@ static const char gSubMenu_SC_REV[3][3] =
};
#endif
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
static const char gSubMenu_AL_MOD[2][5] =
{
"SITE",
@ -414,7 +414,7 @@ void UI_DisplayMenu(void)
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
#endif
case MENU_350TX:
@ -450,7 +450,7 @@ void UI_DisplayMenu(void)
sprintf(String, "%umin", gSubMenuSelection);
break;
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
case MENU_VOICE:
strcpy(String, gSubMenu_VOICE[gSubMenuSelection]);
break;
@ -475,7 +475,7 @@ void UI_DisplayMenu(void)
sprintf(String, "LIST%u", gSubMenuSelection);
break;
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]);
break;
@ -556,6 +556,10 @@ void UI_DisplayMenu(void)
gBatteryVoltageAverage;
sprintf(String, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintString(String, 50, 127, 3, 8);
#if 0
sprintf(String, "Curr %u", gBatteryCurrent); // needs scaling into mA
UI_PrintString(String, 50, 127, 5, 8);
#endif
}
else
if (gMenuCursor == MENU_OFFSET)

View File

@ -42,7 +42,7 @@ enum
MENU_XB,
MENU_BEEP,
MENU_TOT,
#ifndef DISABLE_VOICE
#ifdef ENABLE_VOICE
MENU_VOICE,
#endif
MENU_SC_REV,
@ -57,7 +57,7 @@ enum
MENU_S_LIST,
MENU_SLIST1,
MENU_SLIST2,
#ifndef DISABLE_ALARM
#ifdef ENABLE_ALARM
MENU_AL_MOD,
#endif
MENU_ANI_ID,
@ -74,7 +74,7 @@ enum
MENU_ROGER,
MENU_VOL,
MENU_AM,
#ifndef DISABLE_NOAA
#ifdef ENABLE_NOAA
MENU_NOAA_S,
#endif
MENU_DEL_CH,

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "bitmaps.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
@ -26,65 +28,63 @@
#include "settings.h"
#include "ui/status.h"
void UI_DisplayStatus(void)
void UI_DisplayStatus(const bool test_display)
{
memset(gStatusLine, 0, sizeof(gStatusLine));
if (gCurrentFunction == FUNCTION_POWER_SAVE)
if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display)
memcpy(gStatusLine, BITMAP_PowerSave, sizeof(BITMAP_PowerSave));
if (gBatteryDisplayLevel < 2)
{
if (gLowBatteryBlink == 1)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
}
else
{
if (gBatteryDisplayLevel == 2)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
#ifdef ENABLE_NOAA
if (gIsNoaaMode || test_display)
memcpy(gStatusLine + 7, BITMAP_NOAA, sizeof(BITMAP_NOAA));
#endif
if (gSetting_KILLED || test_display)
memset(gStatusLine + 21, 0xFF, 10);
#ifdef ENABLE_FMRADIO
else
if (gBatteryDisplayLevel == 3)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3));
else
if (gBatteryDisplayLevel == 4)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
else
memcpy(gStatusLine + 110, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
}
if (gFmRadioMode || test_display)
memcpy(gStatusLine + 21, BITMAP_FM, sizeof(BITMAP_FM));
#endif
if (gChargingWithTypeC)
memcpy(gStatusLine + 100, BITMAP_USB_C, sizeof(BITMAP_USB_C));
#ifdef ENABLE_VOICE
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display)
memcpy(gStatusLine + 34, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
#endif
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display)
memcpy(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR));
if (gEeprom.KEY_LOCK)
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
memcpy(gStatusLine + 58, BITMAP_XB, sizeof(BITMAP_XB));
if (gEeprom.VOX_SWITCH || test_display)
memcpy(gStatusLine + 71, BITMAP_VOX, sizeof(BITMAP_VOX));
if (gEeprom.KEY_LOCK || test_display)
memcpy(gStatusLine + 90, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
else
if (gWasFKeyPressed)
memcpy(gStatusLine + 90, BITMAP_F_Key, sizeof(BITMAP_F_Key));
if (gEeprom.VOX_SWITCH)
memcpy(gStatusLine + 71, BITMAP_VOX, sizeof(BITMAP_VOX));
if (gChargingWithTypeC || test_display)
memcpy(gStatusLine + 100, BITMAP_USB_C, sizeof(BITMAP_USB_C));
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
memcpy(gStatusLine + 58, BITMAP_XB, sizeof(BITMAP_XB));
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
memcpy(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR));
#ifndef DISABLE_VOICE
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
memcpy(gStatusLine + 34, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
#endif
if (gSetting_KILLED)
memset(gStatusLine + 21, 0xFF, 10);
if (gBatteryDisplayLevel >= 5 || test_display)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
else
if (gFmRadioMode)
memcpy(gStatusLine + 21, BITMAP_FM, sizeof(BITMAP_FM));
if (gBatteryDisplayLevel >= 4)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
else
if (gBatteryDisplayLevel >= 3)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3));
else
if (gBatteryDisplayLevel >= 2)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
else
if (gLowBatteryBlink == 1)
memcpy(gStatusLine + 110, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
#ifndef DISABLE_NOAA
if (gIsNoaaMode)
memcpy(gStatusLine + 7, BITMAP_NOAA, sizeof(BITMAP_NOAA));
#endif
ST7565_BlitStatusLine();
}

View File

@ -17,7 +17,7 @@
#ifndef UI_STATUS_H
#define UI_STATUS_H
void UI_DisplayStatus(void);
void UI_DisplayStatus(const bool test_display);
#endif

26
ui/ui.c
View File

@ -17,14 +17,18 @@
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "driver/keyboard.h"
#include "misc.h"
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
#include "ui/aircopy.h"
#endif
#include "ui/fmradio.h"
#ifdef ENABLE_FMRADIO
#include "ui/fmradio.h"
#endif
#include "ui/inputbox.h"
#include "ui/main.h"
#include "ui/menu.h"
@ -46,10 +50,12 @@ void GUI_DisplayScreen(void)
UI_DisplayMain();
break;
case DISPLAY_FM:
UI_DisplayFM();
break;
#ifdef ENABLE_FMRADIO
case DISPLAY_FM:
UI_DisplayFM();
break;
#endif
case DISPLAY_MENU:
UI_DisplayMenu();
break;
@ -58,7 +64,7 @@ void GUI_DisplayScreen(void)
UI_DisplayScanner();
break;
#ifndef DISABLE_AIRCOPY
#ifdef ENABLE_AIRCOPY
case DISPLAY_AIRCOPY:
UI_DisplayAircopy();
break;
@ -79,7 +85,9 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gIsInSubMenu = false;
gCssScanMode = CSS_SCAN_MODE_OFF;
gScanState = SCAN_OFF;
gFM_ScanState = FM_SCAN_OFF;
#ifdef ENABLE_FMRADIO
gFM_ScanState = FM_SCAN_OFF;
#endif
gAskForConfirmation = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;

View File

@ -26,9 +26,7 @@ enum GUI_DisplayType_t
DISPLAY_FM,
DISPLAY_MENU,
DISPLAY_SCANNER,
#ifndef DISABLE_AIRCOPY
DISPLAY_AIRCOPY,
#endif
DISPLAY_AIRCOPY,
DISPLAY_INVALID = 0xFFu
};

View File

@ -24,13 +24,15 @@
#include "misc.h"
#include "ui/helper.h"
#include "ui/welcome.h"
#include "ui/status.h"
#include "version.h"
void UI_DisplayWelcome(void)
{
char WelcomeString0[16];
char WelcomeString1[16];
char WelcomeString2[16];
memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
@ -42,6 +44,7 @@ void UI_DisplayWelcome(void)
{
memset(WelcomeString0, 0, sizeof(WelcomeString0));
memset(WelcomeString1, 0, sizeof(WelcomeString1));
memset(WelcomeString2, 0, sizeof(WelcomeString2));
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE)
{
@ -54,6 +57,10 @@ void UI_DisplayWelcome(void)
gBatteryVoltageAverage / 100,
gBatteryVoltageAverage % 100,
(100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
#if 0
sprintf(WelcomeString2, "Current %u", gBatteryCurrent); // needs scaling into mA
#endif
}
else
{
@ -63,9 +70,17 @@ void UI_DisplayWelcome(void)
UI_PrintString(WelcomeString0, 0, 127, 0, 10);
UI_PrintString(WelcomeString1, 0, 127, 2, 10);
#if 0
UI_PrintStringSmall(WelcomeString2, 0, 127, 4);
#endif
UI_PrintString(Version, 0, 127, 5, 10);
ST7565_BlitStatusLine();
#if 1
ST7565_BlitStatusLine(); // blank status line
#else
UI_DisplayStatus(true); // show all status line symbols (test)
#endif
ST7565_BlitFullScreen();
}
}

View File

@ -2,7 +2,7 @@
#ifdef GIT_HASH
#define VER GIT_HASH
#else
#define VER "230913"
#define VER "230914"
#endif
const char Version[] = "OEFW-"VER;