This commit is contained in:
104
functions.c
104
functions.c
@@ -17,16 +17,24 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "app/dtmf.h"
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
#include "app/fm.h"
|
||||
|
||||
#include "app/fm.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include "audio.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "dcs.h"
|
||||
#include "driver/backlight.h"
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
#include "driver/bk1080.h"
|
||||
|
||||
#include "driver/bk1080.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/system.h"
|
||||
@@ -39,36 +47,36 @@
|
||||
#include "settings.h"
|
||||
#include "ui/status.h"
|
||||
#include "ui/ui.h"
|
||||
#include "app/app.h"
|
||||
|
||||
|
||||
FUNCTION_Type_t gCurrentFunction;
|
||||
|
||||
bool FUNCTION_IsRx()
|
||||
{
|
||||
bool FUNCTION_IsRx() {
|
||||
return gCurrentFunction == FUNCTION_MONITOR ||
|
||||
gCurrentFunction == FUNCTION_INCOMING ||
|
||||
gCurrentFunction == FUNCTION_RECEIVE;
|
||||
}
|
||||
|
||||
void FUNCTION_Init(void)
|
||||
{
|
||||
void FUNCTION_Init(void) {
|
||||
g_CxCSS_TAIL_Found = false;
|
||||
g_CDCSS_Lost = false;
|
||||
g_CTCSS_Lost = false;
|
||||
g_CDCSS_Lost = false;
|
||||
g_CTCSS_Lost = false;
|
||||
|
||||
g_SquelchLost = false;
|
||||
g_SquelchLost = false;
|
||||
|
||||
gFlagTailNoteEliminationComplete = false;
|
||||
gFlagTailNoteEliminationComplete = false;
|
||||
gTailNoteEliminationCountdown_10ms = 0;
|
||||
gFoundCTCSS = false;
|
||||
gFoundCDCSS = false;
|
||||
gFoundCTCSSCountdown_10ms = 0;
|
||||
gFoundCDCSSCountdown_10ms = 0;
|
||||
gEndOfRxDetectedMaybe = false;
|
||||
gFoundCTCSS = false;
|
||||
gFoundCDCSS = false;
|
||||
gFoundCTCSSCountdown_10ms = 0;
|
||||
gFoundCDCSSCountdown_10ms = 0;
|
||||
gEndOfRxDetectedMaybe = false;
|
||||
|
||||
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_VOX_Lost = false;
|
||||
g_VOX_Lost = false;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
@@ -86,8 +94,7 @@ void FUNCTION_Init(void)
|
||||
gUpdateStatus = true;
|
||||
}
|
||||
|
||||
void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
||||
{
|
||||
void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) {
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
||||
RADIO_PrepareCssTX();
|
||||
@@ -109,8 +116,7 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT ||
|
||||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED ||
|
||||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
||||
{
|
||||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) {
|
||||
gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2;
|
||||
}
|
||||
#endif
|
||||
@@ -118,18 +124,15 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
||||
}
|
||||
|
||||
void FUNCTION_PowerSave() {
|
||||
#ifdef ENABLE_FEAT_F4HWN_SLEEP
|
||||
if(gWakeUp)
|
||||
{
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav
|
||||
}
|
||||
else
|
||||
{
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
}
|
||||
#else
|
||||
#ifdef ENABLE_FEAT_F4HWN_SLEEP
|
||||
if (gWakeUp) {
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav
|
||||
} else {
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
#endif
|
||||
gPowerSaveCountdownExpired = false;
|
||||
|
||||
gRxIdleMode = true;
|
||||
@@ -147,9 +150,11 @@ void FUNCTION_PowerSave() {
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
}
|
||||
|
||||
void FUNCTION_Transmit()
|
||||
{
|
||||
void FUNCTION_Transmit() {
|
||||
// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
|
||||
|
||||
MSG_EnableRX(false);
|
||||
|
||||
BK4819_DisableDTMF();
|
||||
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
@@ -167,8 +172,7 @@ void FUNCTION_Transmit()
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState == ALARM_STATE_SITE_ALARM)
|
||||
{
|
||||
if (gAlarmState == ALARM_STATE_SITE_ALARM) {
|
||||
GUI_DisplayScreen();
|
||||
|
||||
AUDIO_AudioPathOff();
|
||||
@@ -205,35 +209,35 @@ void FUNCTION_Transmit()
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
if (gAlarmState != ALARM_STATE_OFF) {
|
||||
#ifdef ENABLE_TX1750
|
||||
if (gAlarmState == ALARM_STATE_TX1750)
|
||||
BK4819_TransmitTone(true, 1750);
|
||||
#endif
|
||||
#ifdef ENABLE_TX1750
|
||||
if (gAlarmState == ALARM_STATE_TX1750) {
|
||||
BK4819_TransmitTone(false, 1750);
|
||||
gAlarmState = ALARM_STATE_OFF;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
#ifdef ENABLE_ALARM
|
||||
if (gAlarmState == ALARM_STATE_TXALARM)
|
||||
BK4819_TransmitTone(true, 500);
|
||||
|
||||
gAlarmToneCounter = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
AUDIO_AudioPathOn();
|
||||
gEnableSpeaker = true;
|
||||
BK4819_ExitTxMute();
|
||||
|
||||
gVfoConfigureMode = VFO_CONFIGURE;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FEAT_F4HWN
|
||||
BK4819_DisableScramble();
|
||||
#else
|
||||
if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
|
||||
|
||||
if (gCurrentVfo->SCRAMBLING_TYPE > 0)
|
||||
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
||||
else
|
||||
BK4819_DisableScramble();
|
||||
#endif
|
||||
|
||||
if (gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX) {
|
||||
BACKLIGHT_TurnOn();
|
||||
@@ -241,9 +245,7 @@ void FUNCTION_Transmit()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||
{
|
||||
void FUNCTION_Select(FUNCTION_Type_t Function) {
|
||||
const FUNCTION_Type_t PreviousFunction = gCurrentFunction;
|
||||
const bool bWasPowerSave = PreviousFunction == FUNCTION_POWER_SAVE;
|
||||
|
||||
@@ -298,10 +300,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||
}
|
||||
|
||||
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||
gSchedulePowerSave = false;
|
||||
gSchedulePowerSave = false;
|
||||
|
||||
#if defined(ENABLE_FMRADIO)
|
||||
if(Function != FUNCTION_INCOMING)
|
||||
if (Function != FUNCTION_INCOMING)
|
||||
gFM_RestoreCountdown_10ms = 0;
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user