Skip to content

Commit

Permalink
Use function to check if in RX mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JuantAldea committed Dec 8, 2023
1 parent c3906f4 commit 2164461
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 45 deletions.
4 changes: 1 addition & 3 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ void ACTION_Scan(bool bRestart)
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
{
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
if (FUNCTION_IsRx())
{
GUI_SelectNextDisplay(DISPLAY_FM);

Expand Down
21 changes: 5 additions & 16 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,8 @@ void APP_Update(void)
}

#ifdef ENABLE_FMRADIO
if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT)
{ // switch to FM radio mode
if (gScheduleFM && gFM_ScanState != FM_SCAN_OFF && !FUNCTION_IsRx()) {
// switch to FM radio mode
FM_Play();
gScheduleFM = false;
}
Expand Down Expand Up @@ -1479,11 +1475,7 @@ void APP_TimeSlice500ms(void)
GUI_DisplayType_t disp = DISPLAY_INVALID;

#ifdef ENABLE_FMRADIO
if (gFmRadioMode &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
if (gFmRadioMode && ! FUNCTION_IsRx()) {
disp = DISPLAY_FM;
}
#endif
Expand All @@ -1509,11 +1501,8 @@ void APP_TimeSlice500ms(void)
{
RADIO_SetVfoState(VFO_STATE_NORMAL);
#ifdef ENABLE_FMRADIO
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT &&
gCurrentFunction != FUNCTION_MONITOR &&
gFmRadioMode)
{ // switch back to FM radio mode
if (gFmRadioMode && !FUNCTION_IsRx()) {
// switch back to FM radio mode
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
Expand Down
12 changes: 3 additions & 9 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ void AUDIO_PlaySingleVoice(bool bFlag)
VoiceID += VOICE_ID_ENG_BASE;
}

if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
if (FUNCTION_IsRx()) // 1of11
BK4819_SetAF(BK4819_AF_MUTE);

#ifdef ENABLE_FMRADIO
Expand All @@ -281,9 +279,7 @@ void AUDIO_PlaySingleVoice(bool bFlag)
{
SYSTEM_DelayMs(Delay * 10);

if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
if (FUNCTION_IsRx()) // 1of11
RADIO_SetModulation(gRxVfo->Modulation);

#ifdef ENABLE_FMRADIO
Expand Down Expand Up @@ -422,9 +418,7 @@ void AUDIO_PlayQueuedVoice(void)
}
}

if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING)
if (FUNCTION_IsRx())
{
RADIO_SetModulation(gRxVfo->Modulation); // 1of11
}
Expand Down
12 changes: 10 additions & 2 deletions functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@

FUNCTION_Type_t gCurrentFunction;

inline bool FUNCTION_IsRx()
{
return gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING ||
gCurrentFunction == FUNCTION_RECEIVE;
}


void FUNCTION_Init(void)
{
#ifdef ENABLE_NOAA
Expand Down Expand Up @@ -119,7 +127,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
if (gFmRadioMode)
gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms;
#endif

#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT ||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED ||
Expand Down Expand Up @@ -147,7 +155,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)

gMonitor = false;

BK4819_DisableVox();
BK4819_DisableVox();
BK4819_Sleep();

BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_RX_ENABLE, false);
Expand Down
2 changes: 1 addition & 1 deletion functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ extern FUNCTION_Type_t gCurrentFunction;

void FUNCTION_Init(void);
void FUNCTION_Select(FUNCTION_Type_t Function);
bool FUNCTION_IsRx();

#endif

13 changes: 2 additions & 11 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,8 @@ void DisplayRSSIBar(const bool now)
ST7565_BlitFullScreen();
#endif


}



#ifdef ENABLE_AGC_SHOW_DATA
static void PrintAGC(bool now)
{
Expand Down Expand Up @@ -444,11 +441,7 @@ void UI_DisplayMain(void)
else
{ // receiving .. show the RX symbol
mode = VFO_MODE_RX;
if ((gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) &&
gEeprom.RX_VFO == vfo_num)
{
if (FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num) {
#ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold("RX", 14, 0, line);
#else
Expand Down Expand Up @@ -738,9 +731,7 @@ void UI_DisplayMain(void)
if (center_line == CENTER_LINE_NONE)
{ // we're free to use the middle line

const bool rx = (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING);
const bool rx = FUNCTION_IsRx();

#ifdef ENABLE_AUDIO_BAR
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) {
Expand Down
4 changes: 1 addition & 3 deletions ui/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ void UI_DisplayStatus()
x1 = x + sizeof(BITMAP_TX);
}
else
if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING)
if (FUNCTION_IsRx())
{
memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX));
x1 = x + sizeof(BITMAP_RX);
Expand Down

0 comments on commit 2164461

Please sign in to comment.