diff --git a/radio.c b/radio.c index 393e0f4f5..e64e05d9d 100644 --- a/radio.c +++ b/radio.c @@ -977,97 +977,92 @@ void RADIO_PrepareTX(void) RADIO_SelectCurrentVfo(); - #if defined(ENABLE_ALARM) && defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF || - gAlarmState == ALARM_STATE_TX1750 || - (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE)) - #elif defined(ENABLE_ALARM) - if (gAlarmState == ALARM_STATE_OFF || - (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE)) - #elif defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF || - gAlarmState == ALARM_STATE_TX1750) - #endif - { - #ifndef ENABLE_TX_WHEN_AM - if (gCurrentVfo->Modulation != MODULATION_FM) - { // not allowed to TX if in AM mode - State = VFO_STATE_TX_DISABLE; - } - else + if (TX_freq_check(gCurrentVfo->pTX->Frequency) != 0) { + // TX frequency not allowed + State = VFO_STATE_TX_DISABLE; + } + else + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + if (!(gAlarmState == ALARM_STATE_OFF + #if defined(ENABLE_TX1750) + || gAlarmState == ALARM_STATE_TX1750 #endif - if (gSerialConfigCountDown_500ms > 0) - { // TX is disabled or config upload/download in progress - State = VFO_STATE_TX_DISABLE; - } - else - if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) - { // TX frequency is allowed - if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) - State = VFO_STATE_BUSY; // busy RX'ing a station - else - if (gBatteryDisplayLevel == 0) - State = VFO_STATE_BAT_LOW; // charge your battery ! - else - if (gBatteryDisplayLevel > 6) - State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain - } - else - State = VFO_STATE_TX_DISABLE; // TX frequency not allowed + #if defined(ENABLE_ALARM) + || (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE) + #endif + )) { + State = VFO_STATE_TX_DISABLE; + } + else + #endif + #ifndef ENABLE_TX_WHEN_AM + if (gCurrentVfo->Modulation != MODULATION_FM) { + // not allowed to TX if in AM mode + State = VFO_STATE_TX_DISABLE; + } + else + #endif + if (gSerialConfigCountDown_500ms > 0) { + // TX is disabled or config upload/download in progress + State = VFO_STATE_TX_DISABLE; + } else if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) { + // busy RX'ing a station + State = VFO_STATE_BUSY; + } else if (gBatteryDisplayLevel == 0) { + // charge your battery !git co + State = VFO_STATE_BAT_LOW; + } else if (gBatteryDisplayLevel > 6) { + // over voltage .. this is being a pain + State = VFO_STATE_VOLTAGE_HIGH; } - if (State != VFO_STATE_NORMAL) - { // TX not allowed + if (State != VFO_STATE_NORMAL) { + // TX not allowed RADIO_SetVfoState(State); - #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - gAlarmState = ALARM_STATE_OFF; - #endif + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + gAlarmState = ALARM_STATE_OFF; + #endif -#ifdef ENABLE_DTMF_CALLING + #ifdef ENABLE_DTMF_CALLING gDTMF_ReplyState = DTMF_REPLY_NONE; -#endif + #endif AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); return; } // TX is allowed -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_ReplyState == DTMF_REPLY_ANI) - { - if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) - { - gDTMF_IsTx = true; - gDTMF_CallState = DTMF_CALL_STATE_NONE; + #ifdef ENABLE_DTMF_CALLING + if (gDTMF_ReplyState == DTMF_REPLY_ANI) { + if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) { + gDTMF_IsTx = true; + gDTMF_CallState = DTMF_CALL_STATE_NONE; gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms; - } - else - { + } else { + gDTMF_IsTx = false; gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT; - gDTMF_IsTx = false; } } -#endif + #endif FUNCTION_Select(FUNCTION_TRANSMIT); gTxTimerCountdown_500ms = 0; // no timeout #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF) + if (gAlarmState == ALARM_STATE_OFF) #endif { if (gEeprom.TX_TIMEOUT_TIMER == 0) gTxTimerCountdown_500ms = 60; // 30 sec - else - if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) + else if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) gTxTimerCountdown_500ms = 120 * gEeprom.TX_TIMEOUT_TIMER; // minutes else gTxTimerCountdown_500ms = 120 * 15; // 15 minutes } - gTxTimeoutReached = false; + gTxTimeoutReached = false; gFlagEndTransmission = false; gRTTECountdown = 0;