0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 22:29:50 +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

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