Ability to disable FM Radio.

This commit is contained in:
Dual Tachyon 2023-09-13 22:55:14 +01:00
parent 779449ca50
commit 377b2ca396
21 changed files with 233 additions and 35 deletions

View File

@ -1,6 +1,7 @@
TARGET = firmware
ENABLE_AIRCOPY := 1
ENABLE_FMRADIO := 1
ENABLE_OVERLAY := 1
ENABLE_UART := 1
@ -23,7 +24,9 @@ ifeq ($(ENABLE_UART),1)
OBJS += driver/aes.o
endif
OBJS += driver/backlight.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += driver/bk1080.o
endif
OBJS += driver/bk4819.o
ifeq ($(filter $(ENABLE_AIRCOPY) $(ENABLE_UART),1),1)
OBJS += driver/crc.o
@ -50,7 +53,9 @@ OBJS += app/aircopy.o
endif
OBJS += app/app.o
OBJS += app/dtmf.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += app/fm.o
endif
OBJS += app/generic.o
OBJS += app/main.o
OBJS += app/menu.o
@ -75,7 +80,9 @@ ifeq ($(ENABLE_AIRCOPY),1)
OBJS += ui/aircopy.o
endif
OBJS += ui/battery.o
ifeq ($(ENABLE_FMRADIO),1)
OBJS += ui/fmradio.o
endif
OBJS += ui/helper.o
OBJS += ui/inputbox.o
OBJS += ui/lock.o
@ -114,6 +121,9 @@ 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

View File

@ -17,7 +17,9 @@
#include "app/action.h"
#include "app/app.h"
#include "app/dtmf.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
@ -78,16 +80,21 @@ static void ACTION_Monitor(void)
gScheduleNOAA = false;
}
RADIO_SetupRegisters(true);
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
FM_Start();
gRequestDisplayScreen = DISPLAY_FM;
} else {
#endif
gRequestDisplayScreen = gScreenToDisplay;
#if defined(ENABLE_FMRADIO)
}
#endif
}
void ACTION_Scan(bool bRestart)
{
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
uint16_t Frequency;
@ -112,7 +119,9 @@ void ACTION_Scan(bool bRestart)
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
}
}
} else if (gScreenToDisplay != DISPLAY_SCANNER) {
} else
#endif
if (gScreenToDisplay != DISPLAY_SCANNER) {
RADIO_SelectVfos();
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
GUI_SelectNextDisplay(DISPLAY_MAIN);
@ -150,6 +159,7 @@ static void ACTION_AlarmOr1750(bool b1750)
gRequestDisplayScreen = DISPLAY_MAIN;
}
#if defined(ENABLE_FMRADIO)
void ACTION_FM(void)
{
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR) {
@ -168,6 +178,7 @@ void ACTION_FM(void)
gRequestDisplayScreen = DISPLAY_FM;
}
}
#endif
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
@ -234,7 +245,9 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
ACTION_AlarmOr1750(false);
break;
case 7:
#if defined(ENABLE_FMRADIO)
ACTION_FM();
#endif
break;
case 8:
ACTION_AlarmOr1750(true);

View File

@ -21,7 +21,9 @@
#endif
#include "app/app.h"
#include "app/dtmf.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/main.h"
#include "app/menu.h"
@ -34,7 +36,9 @@
#include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/backlight.h"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/keyboard.h"
@ -294,9 +298,11 @@ static void APP_HandleFunction(void)
void APP_StartListening(FUNCTION_Type_t Function)
{
if (!gSetting_KILLED) {
#if defined(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);
gEnableSpeaker = true;
@ -351,7 +357,11 @@ void APP_StartListening(FUNCTION_Type_t Function)
}
}
FUNCTION_Select(Function);
if (Function == FUNCTION_MONITOR || gFmRadioMode) {
if (Function == FUNCTION_MONITOR
#if defined(ENABLE_FMRADIO)
|| gFmRadioMode
#endif
) {
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
}
@ -572,7 +582,11 @@ static void APP_HandleVox(void)
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && !gFmRadioMode) {
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF
#if defined(ENABLE_FMRADIO)
&& !gFmRadioMode
#endif
) {
if (gVOX_NoiseDetected) {
if (g_VOX_Lost) {
gVoxStopCountdown = 100;
@ -631,9 +645,11 @@ void APP_Update(void)
if (gCurrentFunction != FUNCTION_TRANSMIT) {
APP_HandleFunction();
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioCountdown) {
return;
}
#endif
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0) {
if (IS_FREQ_CHANNEL(gNextMrChannel)) {
@ -669,7 +685,12 @@ void APP_Update(void)
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
if (gScheduleDualWatch && gVoiceWriteIndex == 0) {
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
if (!gPttIsPressed && !gFmRadioMode && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE) {
if (!gPttIsPressed
#if defined(ENABLE_FMRADIO)
&& !gFmRadioMode
#endif
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
&& gCurrentFunction != FUNCTION_POWER_SAVE) {
DUALWATCH_Alternate();
if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) {
GUI_SelectNextDisplay(DISPLAY_MAIN);
@ -683,17 +704,25 @@ void APP_Update(void)
}
}
#if defined(ENABLE_FMRADIO)
if (gFM_ScanState != FM_SCAN_OFF && gScheduleFM && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT) {
FM_Play();
gScheduleFM = false;
}
#endif
if (gEeprom.VOX_SWITCH) {
APP_HandleVox();
}
if (gSchedulePowerSave) {
if (gEeprom.BATTERY_SAVE == 0 || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gFmRadioMode || gPttIsPressed || gScreenToDisplay != DISPLAY_MAIN || gKeyBeingHeld || gDTMF_CallState != DTMF_CALL_STATE_NONE) {
if (gEeprom.BATTERY_SAVE == 0 || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF
#if defined(ENABLE_FMRADIO)
|| gFmRadioMode
#endif
|| gPttIsPressed || gScreenToDisplay != DISPLAY_MAIN || gKeyBeingHeld
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
) {
gBatterySaveCountdown = 1000;
} else {
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) {
@ -843,9 +872,11 @@ void APP_TimeSlice10ms(void)
// Skipping authentic device checks
#if defined(ENABLE_FMRADIO)
if (gFmRadioCountdown) {
return;
}
#endif
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15U) == 0) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
@ -900,6 +931,7 @@ void APP_TimeSlice10ms(void)
}
}
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode && gFM_RestoreCountdown) {
gFM_RestoreCountdown--;
if (gFM_RestoreCountdown == 0) {
@ -907,6 +939,7 @@ void APP_TimeSlice10ms(void)
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
#endif
if (gScreenToDisplay == DISPLAY_SCANNER) {
uint32_t Result;
int32_t Delta;
@ -1029,10 +1062,12 @@ void APP_TimeSlice500ms(void)
// Skipped authentic device check
#if defined(ENABLE_FMRADIO)
if (gFmRadioCountdown) {
gFmRadioCountdown--;
return;
}
#endif
if (gReducedService) {
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) {
@ -1061,7 +1096,11 @@ void APP_TimeSlice500ms(void)
gCurrentRSSI = BK4819_GetRSSI();
UI_UpdateRSSI(gCurrentRSSI);
}
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
if (
#if defined(ENABLE_FMRADIO)
(gFM_ScanState == FM_SCAN_OFF || gAskToSave) &&
#endif
gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gBacklightCountdown) {
gBacklightCountdown--;
if (gBacklightCountdown == 0) {
@ -1099,17 +1138,22 @@ void APP_TimeSlice500ms(void)
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
GUI_SelectNextDisplay(DISPLAY_FM);
} else {
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#else
GUI_SelectNextDisplay(DISPLAY_MAIN);
#endif
}
}
}
}
}
#if defined(ENABLE_FMRADIO)
if (!gPttIsPressed && gFM_ResumeCountdown) {
gFM_ResumeCountdown--;
if (gFM_ResumeCountdown == 0) {
@ -1120,6 +1164,7 @@ void APP_TimeSlice500ms(void)
}
}
}
#endif
if (gLowBattery) {
gLowBatteryBlink = ++gLowBatteryCountdown & 1;
@ -1255,10 +1300,12 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
SETTINGS_SaveSettings();
gFlagSaveSettings = false;
}
#if defined(ENABLE_FMRADIO)
if (gFlagSaveFM) {
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
#endif
if (gFlagSaveChannel) {
SETTINGS_SaveChannel(
gTxVfo->CHANNEL_SAVE,
@ -1421,9 +1468,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#if defined(ENABLE_FMRADIO)
case DISPLAY_FM:
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#endif
case DISPLAY_MENU:
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
@ -1473,6 +1522,7 @@ Skip:
gRequestSaveSettings = false;
gUpdateStatus = true;
}
#if defined(ENABLE_FMRADIO)
if (gRequestSaveFM) {
if (!bKeyHeld) {
SETTINGS_SaveFM();
@ -1481,6 +1531,7 @@ Skip:
}
gRequestSaveFM = false;
}
#endif
if (gRequestSaveVFO) {
if (!bKeyHeld) {
SETTINGS_SaveVfoIndices();

View File

@ -15,7 +15,9 @@
*/
#include <string.h>
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk4819.h"
@ -201,10 +203,12 @@ void DTMF_HandleRequest(void)
gSetting_KILLED = true;
SETTINGS_SaveSettings();
gDTMF_ReplyState = DTMF_REPLY_AB;
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
FM_TurnOff();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#endif
} else {
gDTMF_ReplyState = DTMF_REPLY_NONE;
}

View File

@ -20,7 +20,9 @@
#include "app/generic.h"
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/eeprom.h"
#include "driver/gpio.h"
#include "functions.h"

View File

@ -15,7 +15,9 @@
*/
#include "app/app.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/menu.h"
#include "app/scanner.h"
@ -53,9 +55,15 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true;
} else {
#if defined(ENABLE_FMRADIO)
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM) {
return;
}
#else
if (gScreenToDisplay != DISPLAY_MAIN) {
return;
}
#endif
gWasFKeyPressed = !gWasFKeyPressed;
if (!gWasFKeyPressed) {
gAnotherVoiceID = VOICE_ID_CANCEL;
@ -63,16 +71,17 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true;
}
} else {
if (gScreenToDisplay != DISPLAY_FM) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
if (gFM_ScanState == FM_SCAN_OFF) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
gBeepToPlay = BEEP_440HZ_500MS;
gPttWasReleased = true;
#if defined(ENABLE_FMRADIO)
if (gScreenToDisplay == DISPLAY_FM) {
if (gFM_ScanState == FM_SCAN_OFF) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
gBeepToPlay = BEEP_440HZ_500MS;
gPttWasReleased = true;
} else
#endif
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
}
@ -111,9 +120,17 @@ void GENERIC_Key_PTT(bool bKeyPressed)
return;
}
#if defined(ENABLE_FMRADIO)
if (gFM_ScanState == FM_SCAN_OFF) {
#else
if (1) {
#endif
if (gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gScreenToDisplay == DISPLAY_MENU || gScreenToDisplay == DISPLAY_FM) {
if (gScreenToDisplay == DISPLAY_MENU
#if defined(ENABLE_FMRADIO)
|| gScreenToDisplay == DISPLAY_FM
#endif
) {
gRequestDisplayScreen = DISPLAY_MAIN;
gInputBoxIndex = 0;
gPttIsPressed = false;
@ -163,8 +180,10 @@ void GENERIC_Key_PTT(bool bKeyPressed)
gRequestDisplayScreen = DISPLAY_MENU;
}
} else {
#if defined(ENABLE_FMRADIO)
FM_PlayAndUpdate();
gRequestDisplayScreen = DISPLAY_FM;
#endif
}
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
gPttWasPressed = true;

View File

@ -17,7 +17,9 @@
#include <string.h>
#include "app/action.h"
#include "app/app.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/generic.h"
#include "app/main.h"
#include "app/scanner.h"
@ -131,7 +133,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true;
switch (Key) {
case KEY_0:
#if defined(ENABLE_FMRADIO)
ACTION_FM();
#endif
break;
case KEY_1:
@ -261,24 +265,26 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!gFmRadioMode) {
if (gScanState == SCAN_OFF) {
if (gInputBoxIndex == 0) {
return;
}
gInputBoxIndex--;
gInputBox[gInputBoxIndex] = 10;
if (gInputBoxIndex == 0) {
gAnotherVoiceID = VOICE_ID_CANCEL;
}
} else {
SCANNER_Stop();
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
}
gRequestDisplayScreen = DISPLAY_MAIN;
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
ACTION_FM();
return;
}
ACTION_FM();
#endif
if (gScanState == SCAN_OFF) {
if (gInputBoxIndex == 0) {
return;
}
gInputBoxIndex--;
gInputBox[gInputBoxIndex] = 10;
if (gInputBoxIndex == 0) {
gAnotherVoiceID = VOICE_ID_CANCEL;
}
} else {
SCANNER_Stop();
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
}
gRequestDisplayScreen = DISPLAY_MAIN;
}
}
@ -411,12 +417,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 defined(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) {
char Character = DTMF_GetCharacter(Key);
if (Character != 0xFF) {

View File

@ -18,7 +18,9 @@
#if !defined(ENABLE_OVERLAY)
#include "ARMCM0.h"
#endif
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/uart.h"
#include "board.h"
#include "bsp/dp32g030/dma.h"
@ -219,7 +221,9 @@ static void CMD_0514(const uint8_t *pBuffer)
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;
Timestamp = pCmd->Timestamp;
#if defined(ENABLE_FMRADIO)
gFmRadioCountdown = 4;
#endif
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
SendVersion();
}
@ -234,7 +238,9 @@ static void CMD_051B(const uint8_t *pBuffer)
return;
}
#if defined(ENABLE_FMRADIO)
gFmRadioCountdown = 4;
#endif
memset(&Reply, 0, sizeof(Reply));
Reply.Header.ID = 0x051C;
Reply.Header.Size = pCmd->Size + 4;
@ -265,7 +271,9 @@ static void CMD_051D(const uint8_t *pBuffer)
bReloadEeprom = false;
#if defined(ENABLE_FMRADIO)
gFmRadioCountdown = 4;
#endif
Reply.Header.ID = 0x051E;
Reply.Header.Size = sizeof(Reply.Data);
Reply.Data.Offset = pCmd->Offset;
@ -330,7 +338,9 @@ static void CMD_052D(const uint8_t *pBuffer)
REPLY_052D_t Reply;
bool bIsLocked;
#if defined(ENABLE_FMRADIO)
gFmRadioCountdown = 4;
#endif
Reply.Header.ID = 0x052E;
Reply.Header.Size = sizeof(Reply.Data);

14
audio.c
View File

@ -14,10 +14,14 @@
* limitations under the License.
*/
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/system.h"
@ -89,9 +93,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
BK4819_RX_TurnOn();
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Mute(true);
}
#endif
SYSTEM_DelayMs(20);
switch (Beep) {
case BEEP_1KHZ_60MS_OPTIONAL:
@ -143,9 +149,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gEnableSpeaker) {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Mute(false);
}
#endif
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode) {
BK4819_Sleep();
}
@ -198,9 +206,11 @@ void AUDIO_PlaySingleVoice(bool bFlag)
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) {
BK4819_SetAF(BK4819_AF_MUTE);
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Mute(true);
}
#endif
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gVoxResumeCountdown = 2000;
SYSTEM_DelayMs(5);
@ -217,9 +227,11 @@ void AUDIO_PlaySingleVoice(bool bFlag)
BK4819_SetAF(BK4819_AF_OPEN);
}
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Mute(false);
}
#endif
if (!gEnableSpeaker) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
}
@ -332,9 +344,11 @@ void AUDIO_PlayQueuedVoice(void)
BK4819_SetAF(BK4819_AF_OPEN);
}
}
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Mute(false);
}
#endif
if (!gEnableSpeaker) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
}

View File

@ -19,7 +19,9 @@ const uint8_t BITMAP_WX[12] = { 0x00, 0x7F, 0x20, 0x18, 0x20, 0x7F, 0x00, 0x63,
const uint8_t BITMAP_TDR[12] = { 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x20, 0x18, 0x20, 0x7F };
const uint8_t BITMAP_VoicePrompt[9] = { 0x00, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0xFF, 0x18 };
#if defined(ENABLE_FMRADIO)
const uint8_t BITMAP_FM[12] = { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F };
#endif
const uint8_t BITMAP_NOAA[12] = { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 };
const uint8_t BITMAP_Antenna[5] = { 0x03, 0x05, 0x7F, 0x05, 0x03 };

View File

@ -22,7 +22,9 @@ extern const uint8_t BITMAP_WX[12];
extern const uint8_t BITMAP_TDR[12];
extern const uint8_t BITMAP_VoicePrompt[9];
#if defined(ENABLE_FMRADIO)
extern const uint8_t BITMAP_FM[12];
#endif
extern const uint8_t BITMAP_NOAA[12];
extern const uint8_t BITMAP_Antenna[5];

10
board.c
View File

@ -17,14 +17,18 @@
#include <string.h>
#include "app/dtmf.h"
#if defined(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"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/crc.h"
#include "driver/eeprom.h"
@ -83,7 +87,9 @@ void BOARD_GPIO_Init(void)
| GPIO_DIR_5_MASK
);
#if defined(ENABLE_FMRADIO)
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
#endif
}
void BOARD_PORTCON_Init(void)
@ -339,7 +345,9 @@ void BOARD_Init(void)
BOARD_GPIO_Init();
BOARD_ADC_Init();
ST7565_Init();
#if defined(ENABLE_FMRADIO)
BK1080_Init(0, false);
#endif
#if defined(ENABLE_AIRCOPY) || defined(ENABLE_UART)
CRC_Init();
#endif
@ -384,6 +392,7 @@ void BOARD_EEPROM_Init(void)
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;
#if defined(ENABLE_FMRADIO)
// 0E88..0E8F
struct {
uint16_t SelectedFrequency;
@ -407,6 +416,7 @@ 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);

View File

@ -16,10 +16,14 @@
#include <string.h>
#include "app/dtmf.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/system.h"
@ -69,7 +73,9 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
{
FUNCTION_Type_t PreviousFunction;
bool bWasPowerSave;
#if defined(ENABLE_FMRADIO)
uint16_t Countdown = 0;
#endif
PreviousFunction = gCurrentFunction;
bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);
@ -92,9 +98,11 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
gVFO_RSSI_Level[0] = 0;
gVFO_RSSI_Level[1] = 0;
} else if (PreviousFunction == FUNCTION_RECEIVE) {
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
Countdown = 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);
}
@ -118,9 +126,11 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
return;
case FUNCTION_TRANSMIT:
#if defined(ENABLE_FMRADIO)
if (gFmRadioMode) {
BK1080_Init(0, false);
}
#endif
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) {
gAlarmState = ALARM_STATE_ALARM;
@ -164,6 +174,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
}
gBatterySaveCountdown = 1000;
gSchedulePowerSave = false;
#if defined(ENABLE_FMRADIO)
gFM_RestoreCountdown = Countdown;
#endif
}

6
misc.c
View File

@ -82,14 +82,18 @@ bool gFlagResetVfos;
bool gRequestSaveVFO;
uint8_t gRequestSaveChannel;
bool gRequestSaveSettings;
#if defined(ENABLE_FMRADIO)
bool gRequestSaveFM;
#endif
bool gFlagPrepareTX;
bool gFlagAcceptSetting;
bool gFlagRefreshSetting;
bool gFlagSaveVfo;
bool gFlagSaveSettings;
bool gFlagSaveChannel;
#if defined(ENABLE_FMRADIO)
bool gFlagSaveFM;
#endif
uint8_t gDTMF_RequestPending;
bool g_CDCSS_Lost;
uint8_t gCDCSSCodeType;
@ -142,7 +146,9 @@ volatile bool gBatterySaveCountdownExpired;
volatile bool gScheduleDualWatch = true;
volatile bool gScheduleNOAA = true;
volatile bool gFlagTteComplete;
#if defined(ENABLE_FMRADIO)
volatile bool gScheduleFM;
#endif
uint16_t gCurrentRSSI;

7
misc.h
View File

@ -132,7 +132,9 @@ extern bool gFlagResetVfos;
extern bool gRequestSaveVFO;
extern uint8_t gRequestSaveChannel;
extern bool gRequestSaveSettings;
#if defined(ENABLE_FMRADIO)
extern bool gRequestSaveFM;
#endif
extern uint8_t gKeypadLocked;
extern bool gFlagPrepareTX;
extern bool gFlagAcceptSetting;
@ -140,7 +142,9 @@ extern bool gFlagRefreshSetting;
extern bool gFlagSaveVfo;
extern bool gFlagSaveSettings;
extern bool gFlagSaveChannel;
#if defined(ENABLE_FMRADIO)
extern bool gFlagSaveFM;
#endif
extern uint8_t gDTMF_RequestPending;
extern bool g_CDCSS_Lost;
extern uint8_t gCDCSSCodeType;
@ -180,7 +184,6 @@ extern bool gIsNoaaMode;
extern volatile bool gNextTimeslice;
extern uint8_t gNoaaChannel;
extern bool gUpdateDisplay;
extern uint8_t gFM_ChannelPosition;
extern bool gF_LOCK;
extern uint8_t gShowChPrefix;
extern volatile uint16_t gSystickCountdown2;
@ -194,7 +197,9 @@ extern volatile bool gBatterySaveCountdownExpired;
extern volatile bool gScheduleDualWatch;
extern volatile bool gScheduleNOAA;
extern volatile bool gFlagTteComplete;
#if defined(ENABLE_FMRADIO)
extern volatile bool gScheduleFM;
#endif
extern uint16_t gCurrentRSSI;

12
radio.c
View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/dtmf.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
@ -581,7 +583,11 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
;
}
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM) {
if (gEeprom.VOX_SWITCH
#if defined(ENABLE_FMRADIO)
&& !gFmRadioMode
#endif
&& IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM) {
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
InterruptMask |= 0
| BK4819_REG_3F_VOX_FOUND
@ -689,7 +695,9 @@ void RADIO_SetVfoState(VfoState_t State)
if (State == VFO_STATE_NORMAL) {
VfoState[0] = VFO_STATE_NORMAL;
VfoState[1] = VFO_STATE_NORMAL;
#if defined(ENABLE_FMRADIO)
gFM_ResumeCountdown = 0;
#endif
} else {
if (State == VFO_STATE_VOL_HIGH) {
VfoState[0] = VFO_STATE_VOL_HIGH;
@ -704,7 +712,9 @@ void RADIO_SetVfoState(VfoState_t State)
}
VfoState[Channel] = State;
}
#if defined(ENABLE_FMRADIO)
gFM_ResumeCountdown = 5;
#endif
}
gUpdateDisplay = true;
}

View File

@ -14,7 +14,9 @@
* limitations under the License.
*/
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "audio.h"
#include "functions.h"
@ -88,11 +90,13 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
#if defined(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

@ -15,7 +15,9 @@
*/
#include <string.h>
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "driver/eeprom.h"
#if defined(ENABLE_UART)
#include "driver/uart.h"
@ -25,6 +27,7 @@
EEPROM_Config_t gEeprom;
#if defined(ENABLE_FMRADIO)
void SETTINGS_SaveFM(void)
{
uint8_t i;
@ -49,6 +52,7 @@ void SETTINGS_SaveFM(void)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
}
}
#endif
void SETTINGS_SaveVfoIndices(void)
{

View File

@ -15,7 +15,9 @@
*/
#include <string.h>
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "bitmaps.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
@ -70,9 +72,11 @@ void UI_DisplayStatus(void)
if (gSetting_KILLED) {
memset(gStatusLine + 21, 0xFF, 10);
}
#if defined(ENABLE_FMRADIO)
else if (gFmRadioMode) {
memcpy(gStatusLine + 21, BITMAP_FM, sizeof(BITMAP_FM));
}
#endif
if (gIsNoaaMode) {
memcpy(gStatusLine + 7, BITMAP_NOAA, sizeof(BITMAP_NOAA));
}

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/dtmf.h"
#if defined(ENABLE_FMRADIO)
#include "app/fm.h"
#endif
#include "app/scanner.h"
#include "driver/keyboard.h"
#include "misc.h"
@ -43,9 +45,11 @@ void GUI_DisplayScreen(void)
case DISPLAY_MAIN:
UI_DisplayMain();
break;
#if defined(ENABLE_FMRADIO)
case DISPLAY_FM:
UI_DisplayFM();
break;
#endif
case DISPLAY_MENU:
UI_DisplayMenu();
break;
@ -70,7 +74,9 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gIsInSubMenu = false;
gCssScanMode = CSS_SCAN_MODE_OFF;
gScanState = SCAN_OFF;
#if defined(ENABLE_FMRADIO)
gFM_ScanState = FM_SCAN_OFF;
#endif
gAskForConfirmation = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;

View File

@ -22,7 +22,9 @@
enum GUI_DisplayType_t {
DISPLAY_MAIN = 0x00U,
#if defined(ENABLE_FMRADIO)
DISPLAY_FM = 0x01U,
#endif
DISPLAY_MENU = 0x02U,
DISPLAY_SCANNER = 0x03U,
#if defined(ENABLE_AIRCOPY)