Simply some logic. Unify some #ifdef regions
This commit is contained in:
44
functions.c
44
functions.c
@@ -42,39 +42,19 @@
|
|||||||
|
|
||||||
FUNCTION_Type_t gCurrentFunction;
|
FUNCTION_Type_t gCurrentFunction;
|
||||||
|
|
||||||
inline bool FUNCTION_IsRx()
|
bool FUNCTION_IsRx()
|
||||||
{
|
{
|
||||||
return gCurrentFunction == FUNCTION_MONITOR ||
|
return gCurrentFunction == FUNCTION_MONITOR ||
|
||||||
gCurrentFunction == FUNCTION_INCOMING ||
|
gCurrentFunction == FUNCTION_INCOMING ||
|
||||||
gCurrentFunction == FUNCTION_RECEIVE;
|
gCurrentFunction == FUNCTION_RECEIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FUNCTION_Init(void)
|
void FUNCTION_Init(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_NOAA
|
|
||||||
else
|
|
||||||
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
DTMF_clear_RX();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_CxCSS_TAIL_Found = false;
|
g_CxCSS_TAIL_Found = false;
|
||||||
g_CDCSS_Lost = false;
|
g_CDCSS_Lost = false;
|
||||||
g_CTCSS_Lost = false;
|
g_CTCSS_Lost = false;
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
g_VOX_Lost = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_SquelchLost = false;
|
g_SquelchLost = false;
|
||||||
|
|
||||||
gFlagTailNoteEliminationComplete = false;
|
gFlagTailNoteEliminationComplete = false;
|
||||||
@@ -85,9 +65,23 @@ void FUNCTION_Init(void)
|
|||||||
gFoundCDCSSCountdown_10ms = 0;
|
gFoundCDCSSCountdown_10ms = 0;
|
||||||
gEndOfRxDetectedMaybe = false;
|
gEndOfRxDetectedMaybe = false;
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
|
||||||
gNOAACountdown_10ms = 0;
|
|
||||||
#endif
|
#ifdef ENABLE_VOX
|
||||||
|
g_VOX_Lost = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
DTMF_clear_RX();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_NOAA
|
||||||
|
gNOAACountdown_10ms = 0;
|
||||||
|
|
||||||
|
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
|
||||||
|
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
@@ -98,6 +92,7 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction)
|
|||||||
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
if (gDTMF_ReplyState != DTMF_REPLY_NONE)
|
||||||
RADIO_PrepareCssTX();
|
RADIO_PrepareCssTX();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (PreviousFunction == FUNCTION_TRANSMIT) {
|
if (PreviousFunction == FUNCTION_TRANSMIT) {
|
||||||
ST7565_FixInterfGlitch();
|
ST7565_FixInterfGlitch();
|
||||||
gVFO_RSSI_bar_level[0] = 0;
|
gVFO_RSSI_bar_level[0] = 0;
|
||||||
@@ -153,7 +148,6 @@ void FUNCTION_Transmit()
|
|||||||
|
|
||||||
// clear the DTMF RX live decoder buffer
|
// clear the DTMF RX live decoder buffer
|
||||||
gDTMF_RX_live_timeout = 0;
|
gDTMF_RX_live_timeout = 0;
|
||||||
gDTMF_RX_live_timeout = 0;
|
|
||||||
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
|
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
|
||||||
|
|
||||||
#if defined(ENABLE_FMRADIO)
|
#if defined(ENABLE_FMRADIO)
|
||||||
|
77
ui/main.c
77
ui/main.c
@@ -294,13 +294,9 @@ void UI_MAIN_TimeSlice500ms(void)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const bool rx = (gCurrentFunction == FUNCTION_RECEIVE ||
|
if(FUNCTION_IsRx()) {
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING);
|
|
||||||
|
|
||||||
|
|
||||||
if(rx)
|
|
||||||
DisplayRSSIBar(true);
|
DisplayRSSIBar(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,60 +341,57 @@ void UI_DisplayMain(void)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
if(gScanRangeStart) {
|
if(gScanRangeStart) {
|
||||||
UI_PrintString("ScnRng", 5, 0, line, 8);
|
UI_PrintString("ScnRng", 5, 0, line, 8);
|
||||||
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
|
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
|
||||||
UI_PrintStringSmall(String, 56, 0, line);
|
UI_PrintStringSmall(String, 56, 0, line);
|
||||||
sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000);
|
sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000);
|
||||||
UI_PrintStringSmall(String, 56, 0, line + 1);
|
UI_PrintStringSmall(String, 56, 0, line + 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (
|
if (gDTMF_InputMode
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx ||
|
|| gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx
|
||||||
#endif
|
#endif
|
||||||
gDTMF_InputMode)
|
) {
|
||||||
{ // show DTMF stuff
|
// show DTMF stuff
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
char Contact[16];
|
char Contact[16];
|
||||||
|
char *str_ptr = "";
|
||||||
|
if (!gDTMF_InputMode) {
|
||||||
|
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) {
|
||||||
|
str_ptr = DTMF_FindContact(gDTMF_String, Contact) ? Contact : gDTMF_String;
|
||||||
|
} else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY){
|
||||||
|
str_ptr = DTMF_FindContact(gDTMF_Callee, Contact) ? Contact : gDTMF_Callee;
|
||||||
|
}else if (gDTMF_IsTx) {
|
||||||
|
str_ptr = gDTMF_String;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!gDTMF_InputMode)
|
UI_PrintString(str_ptr, 2, 0, 2 + (vfo_num * 3), 8);
|
||||||
{
|
|
||||||
|
|
||||||
memset(Contact, 0, sizeof(Contact));
|
str_ptr = "";
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
|
if (!gDTMF_InputMode) {
|
||||||
strcpy(String, (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT");
|
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) {
|
||||||
else
|
str_ptr = (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT";
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
} else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) {
|
||||||
sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller);
|
sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller);
|
||||||
else
|
str_ptr = String;
|
||||||
if (gDTMF_IsTx)
|
} else if (gDTMF_IsTx) {
|
||||||
strcpy(String, (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX");
|
str_ptr = (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sprintf(String, ">%s", gDTMF_InputBox);
|
sprintf(String, ">%s", gDTMF_InputBox);
|
||||||
}
|
str_ptr = String;
|
||||||
UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8);
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
memset(String, 0, sizeof(String));
|
|
||||||
if (!gDTMF_InputMode) {
|
|
||||||
memset(Contact, 0, sizeof(Contact));
|
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
|
|
||||||
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String);
|
|
||||||
else
|
|
||||||
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
|
|
||||||
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee);
|
|
||||||
else
|
|
||||||
if (gDTMF_IsTx)
|
|
||||||
sprintf(String, ">%s", gDTMF_String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
|
UI_PrintString(str_ptr, 2, 0, 0 + (vfo_num * 3), 8);
|
||||||
#endif
|
|
||||||
center_line = CENTER_LINE_IN_USE;
|
center_line = CENTER_LINE_IN_USE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -450,7 +443,7 @@ void UI_DisplayMain(void)
|
|||||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||||
{ // channel mode
|
{ // channel mode
|
||||||
const unsigned int x = 2;
|
const unsigned int x = 2;
|
||||||
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
|
const bool inputting = gInputBoxIndex != 0 && gEeprom.TX_VFO == vfo_num;
|
||||||
if (!inputting)
|
if (!inputting)
|
||||||
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
|
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user