From 6c81075980fa628c5e8c99c280e7d6834f001828 Mon Sep 17 00:00:00 2001 From: Dual Tachyon Date: Thu, 14 Sep 2023 16:32:21 +0100 Subject: [PATCH] Ability to disable ALARM and TX1750. --- Makefile | 8 ++++++++ app/action.c | 13 +++++++++++++ app/app.c | 10 ++++++++++ app/menu.c | 9 ++++++++- board.c | 2 ++ functions.c | 13 ++++++++++++- helper/boot.c | 5 ++++- main.c | 5 ++++- misc.c | 4 ++++ misc.h | 2 ++ radio.c | 19 ++++++++++++++++++- settings.c | 4 ++++ ui/main.c | 8 ++++++++ ui/menu.c | 10 +++++++++- ui/menu.h | 2 ++ 15 files changed, 108 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 70189139..3b04d461 100755 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ TARGET = firmware ENABLE_AIRCOPY := 1 +ENABLE_ALARM := 1 ENABLE_FMRADIO := 1 ENABLE_NOAA := 1 ENABLE_OVERLAY := 1 ENABLE_SWD := 0 +ENABLE_TX1750 := 1 ENABLE_UART := 1 BSP_DEFINITIONS := $(wildcard hardware/*/*.def) @@ -123,6 +125,9 @@ CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" ifeq ($(ENABLE_AIRCOPY),1) CFLAGS += -DENABLE_AIRCOPY endif +ifeq ($(ENABLE_ALARM),1) +CFLAGS += -DENABLE_ALARM +endif ifeq ($(ENABLE_FMRADIO),1) CFLAGS += -DENABLE_FMRADIO endif @@ -135,6 +140,9 @@ endif ifeq ($(ENABLE_SWD),1) CFLAGS += -DENABLE_SWD endif +ifeq ($(ENABLE_TX1750),1) +CFLAGS += -DENABLE_TX1750 +endif ifeq ($(ENABLE_UART),1) CFLAGS += -DENABLE_UART endif diff --git a/app/action.c b/app/action.c index 2846cd6c..91f2be75 100644 --- a/app/action.c +++ b/app/action.c @@ -150,18 +150,27 @@ void ACTION_Vox(void) gUpdateStatus = true; } +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) static void ACTION_AlarmOr1750(bool b1750) { gInputBoxIndex = 0; +#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750) if (b1750) { gAlarmState = ALARM_STATE_TX1750; } else { gAlarmState = ALARM_STATE_TXALARM; } gAlarmRunningCounter = 0; +#elif defined(ENABLE_ALARM) + gAlarmState = ALARM_STATE_TXALARM; + gAlarmRunningCounter = 0; +#else + gAlarmState = ALARM_STATE_TX1750; +#endif gFlagPrepareTX = true; gRequestDisplayScreen = DISPLAY_MAIN; } +#endif #if defined(ENABLE_FMRADIO) void ACTION_FM(void) @@ -246,7 +255,9 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) ACTION_Vox(); break; case 6: +#if defined(ENABLE_ALARM) ACTION_AlarmOr1750(false); +#endif break; case 7: #if defined(ENABLE_FMRADIO) @@ -254,7 +265,9 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #endif break; case 8: +#if defined(ENABLE_TX1750) ACTION_AlarmOr1750(true); +#endif break; } } diff --git a/app/app.c b/app/app.c index 1a7a7a5d..0e6ed6ca 100644 --- a/app/app.c +++ b/app/app.c @@ -909,6 +909,7 @@ void APP_TimeSlice10ms(void) gVoxPauseCountdown--; } if (gCurrentFunction == FUNCTION_TRANSMIT) { +#if defined(ENABLE_ALARM) if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_ALARM) { uint16_t Tone; @@ -944,6 +945,7 @@ void APP_TimeSlice10ms(void) } } } +#endif if (gRTTECountdown) { gRTTECountdown--; if (gRTTECountdown == 0) { @@ -1263,6 +1265,7 @@ void APP_TimeSlice500ms(void) } } +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) static void ALARM_Off(void) { gAlarmState = ALARM_STATE_OFF; @@ -1277,6 +1280,7 @@ static void ALARM_Off(void) RADIO_SetupRegisters(true); gRequestDisplayScreen = DISPLAY_MAIN; } +#endif void CHANNEL_Next(bool bBackup, int8_t Direction) { @@ -1433,7 +1437,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (!bFlag) { if (gCurrentFunction == FUNCTION_TRANSMIT) { +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState == ALARM_STATE_OFF) { +#else + if (1) { +#endif if (Key == KEY_PTT) { GENERIC_Key_PTT(bKeyPressed); } else { @@ -1473,6 +1481,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } } } else if (!bKeyHeld && bKeyPressed) { +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) ALARM_Off(); if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) { FUNCTION_Select(FUNCTION_FOREGROUND); @@ -1484,6 +1493,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } else { gPttWasReleased = true; } +#endif } } else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) { switch (gScreenToDisplay) { diff --git a/app/menu.c b/app/menu.c index 431eca45..6535fbbc 100644 --- a/app/menu.c +++ b/app/menu.c @@ -151,7 +151,10 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax) case MENU_W_N: case MENU_BCL: case MENU_BEEP: case MENU_AUTOLK: case MENU_S_ADD1: case MENU_S_ADD2: - case MENU_STE: case MENU_AL_MOD: + case MENU_STE: +#if defined(ENABLE_ALARM) + case MENU_AL_MOD: +#endif case MENU_D_ST: case MENU_D_DCD: case MENU_AM: #if defined(ENABLE_NOAA) @@ -420,9 +423,11 @@ void MENU_AcceptSetting(void) gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection - 1; break; +#if defined(ENABLE_ALARM) case MENU_AL_MOD: gEeprom.ALARM_MODE = gSubMenuSelection; break; +#endif case MENU_D_ST: gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; @@ -753,9 +758,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 1); break; +#if defined(ENABLE_ALARM) case MENU_AL_MOD: gSubMenuSelection = gEeprom.ALARM_MODE; break; +#endif case MENU_D_ST: gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; diff --git a/board.c b/board.c index 390a9503..c5238835 100644 --- a/board.c +++ b/board.c @@ -592,7 +592,9 @@ void BOARD_EEPROM_Init(void) // 0EA8..0EAF EEPROM_ReadBuffer(0x0EA8, Data, 8); +#if defined(ENABLE_ALARM) gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true; +#endif gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0; gEeprom.TX_CHANNEL = (Data[3] < 2) ? Data[3] : 0; diff --git a/functions.c b/functions.c index edfb6cd3..049a318d 100644 --- a/functions.c +++ b/functions.c @@ -130,6 +130,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } #endif +#if defined(ENABLE_ALARM) if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) { gAlarmState = ALARM_STATE_ALARM; GUI_DisplayScreen(); @@ -144,6 +145,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gAlarmToneCounter = 0; break; } +#endif GUI_DisplayScreen(); RADIO_SetTxParameters(); @@ -151,18 +153,27 @@ void FUNCTION_Select(FUNCTION_Type_t Function) DTMF_Reply(); +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState != ALARM_STATE_OFF) { +#if defined(ENABLE_TX1750) if (gAlarmState == ALARM_STATE_TX1750) { BK4819_TransmitTone(true, 1750); - } else { + } +#endif +#if defined(ENABLE_ALARM) + if (gAlarmState == ALARM_STATE_TXALARM) { BK4819_TransmitTone(true, 500); } +#endif SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); +#if defined(ENABLE_ALARM) gAlarmToneCounter = 0; +#endif gEnableSpeaker = true; break; } +#endif if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) { BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U); } else { diff --git a/helper/boot.c b/helper/boot.c index 2c2c884e..bbe2d366 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -62,7 +62,10 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) gMenuCursor = MENU_350TX; gSubMenuSelection = gSetting_350TX; GUI_SelectNextDisplay(DISPLAY_MENU); - gMenuListCount = 56; + gMenuListCount = 55; +#if defined(ENABLE_ALARM) + gMenuListCount++; +#endif #if defined(ENABLE_NOAA) gMenuListCount++; #endif diff --git a/main.c b/main.c index be24fce1..43afe704 100644 --- a/main.c +++ b/main.c @@ -104,7 +104,10 @@ void Main(void) UI_DisplayWelcome(); BACKLIGHT_TurnOn(); SYSTEM_DelayMs(1000); - gMenuListCount = 50; + gMenuListCount = 49; +#if defined(ENABLE_ALARM) + gMenuListCount++; +#endif #if defined(ENABLE_NOAA) gMenuListCount++; #endif diff --git a/misc.c b/misc.c index 899cbf51..c57504d9 100644 --- a/misc.c +++ b/misc.c @@ -73,7 +73,9 @@ uint8_t gReducedService; uint8_t gBatteryVoltageIndex; CssScanMode_t gCssScanMode; bool gUpdateRSSI; +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) AlarmState_t gAlarmState; +#endif uint8_t gVoltageMenuCountdown; bool gPttWasReleased; bool gPttWasPressed; @@ -117,8 +119,10 @@ uint8_t gCurrentScanList; uint8_t gPreviousMrChannel; uint32_t gRestoreFrequency; uint8_t gRxVfoIsActive; +#if defined(ENABLE_ALARM) uint8_t gAlarmToneCounter; uint16_t gAlarmRunningCounter; +#endif bool gKeyBeingHeld; bool gPttIsPressed; uint8_t gPttDebounceCounter; diff --git a/misc.h b/misc.h index 9da19777..8a7b5906 100644 --- a/misc.h +++ b/misc.h @@ -168,8 +168,10 @@ extern uint8_t gCurrentScanList; extern uint8_t gPreviousMrChannel; extern uint32_t gRestoreFrequency; extern uint8_t gRxVfoIsActive; +#if defined(ENABLE_ALARM) extern uint8_t gAlarmToneCounter; extern uint16_t gAlarmRunningCounter; +#endif extern bool gKeyBeingHeld; extern bool gPttIsPressed; extern uint8_t gPttDebounceCounter; diff --git a/radio.c b/radio.c index db07aaef..14c6d4c7 100644 --- a/radio.c +++ b/radio.c @@ -739,7 +739,18 @@ void RADIO_PrepareTX(void) gRxVfoIsActive = true; } RADIO_SelectCurrentVfo(); - if (gAlarmState == ALARM_STATE_OFF || gAlarmState == ALARM_STATE_TX1750 || (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE)) { +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + if (gAlarmState == ALARM_STATE_OFF +#if defined(ENABLE_TX1750) + || gAlarmState == ALARM_STATE_TX1750 +#endif +#if defined(ENABLE_ALARM) + || (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE) +#endif + ) { +#else + if (1) { +#endif VfoState_t State; if (!FREQUENCY_Check(gCurrentVfo)) { @@ -756,7 +767,9 @@ void RADIO_PrepareTX(void) State = VFO_STATE_TX_DISABLE; } RADIO_SetVfoState(State); +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) gAlarmState = ALARM_STATE_OFF; +#endif AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); gDTMF_ReplyState = DTMF_REPLY_NONE; return; @@ -774,11 +787,15 @@ void RADIO_PrepareTX(void) } } FUNCTION_Select(FUNCTION_TRANSMIT); +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState == ALARM_STATE_OFF) { gTxTimerCountdown = gEeprom.TX_TIMEOUT_TIMER * 120; } else { gTxTimerCountdown = 0; } +#else + gTxTimerCountdown = gEeprom.TX_TIMEOUT_TIMER * 120; +#endif gTxTimeoutReached = false; gFlagEndTransmission = false; gRTTECountdown = 0; diff --git a/settings.c b/settings.c index da732eca..0242c67f 100644 --- a/settings.c +++ b/settings.c @@ -128,7 +128,11 @@ void SETTINGS_SaveSettings(void) EEPROM_WriteBuffer(0x0EA0, State); +#if defined(ENABLE_ALARM) State[0] = gEeprom.ALARM_MODE; +#else + State[0] = 0xFF; +#endif State[1] = gEeprom.ROGER; State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; State[3] = gEeprom.TX_CHANNEL; diff --git a/ui/main.c b/ui/main.c index 3ce5593d..800cd8f5 100644 --- a/ui/main.c +++ b/ui/main.c @@ -130,9 +130,13 @@ void UI_DisplayMain(void) uint32_t SomeValue = 0; if (gCurrentFunction == FUNCTION_TRANSMIT) { +#if defined(ENABLE_ALARM) if (gAlarmState == ALARM_STATE_ALARM) { SomeValue = 2; } else { +#else + if (1) { +#endif if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { Channel = gEeprom.RX_CHANNEL; } else { @@ -181,6 +185,7 @@ void UI_DisplayMain(void) // 0x8FEC uint8_t State = VfoState[i]; +#if defined(ENABLE_ALARM) if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) { if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { Channel = gEeprom.RX_CHANNEL; @@ -191,6 +196,7 @@ void UI_DisplayMain(void) State = VFO_STATE_ALARM; } } +#endif if (State) { uint8_t Width = 10; @@ -209,9 +215,11 @@ void UI_DisplayMain(void) case 4: strcpy(String, "TIMEOUT"); break; +#if defined(ENABLE_ALARM) case 5: strcpy(String, "ALARM"); break; +#endif case 6: sprintf(String, "VOL HIGH"); Width = 8; diff --git a/ui/menu.c b/ui/menu.c index be5e0b14..508aee6f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -42,7 +42,11 @@ static const char MenuList[][7] = { "S-ADD1", "S-ADD2", "STE", "RP-STE", "MIC", "1-CALL", "S-LIST", "SLIST1", // 0x20 - "SLIST2", "AL-MOD", "ANI-ID", "UPCODE", + "SLIST2", +#if defined(ENABLE_ALARM) + "AL-MOD", +#endif + "ANI-ID", "UPCODE", "DWCODE", "D-ST", "D-RSP", "D-HOLD", // 0x28 "D-PRE", "PTT-ID", "D-DCD", "D-LIST", @@ -121,10 +125,12 @@ static const char gSubMenu_MDF[3][5] = { "NAME", }; +#if defined(ENABLE_ALARM) static const char gSubMenu_AL_MOD[2][5] = { "SITE", "TONE", }; +#endif static const char gSubMenu_D_RSP[4][6] = { "NULL", @@ -353,9 +359,11 @@ void UI_DisplayMenu(void) sprintf(String, "LIST%d", gSubMenuSelection); break; +#if defined(ENABLE_ALARM) case MENU_AL_MOD: sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]); break; +#endif case MENU_ANI_ID: strcpy(String, gEeprom.ANI_DTMF_ID); diff --git a/ui/menu.h b/ui/menu.h index b1a3f4fa..669724f5 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -54,7 +54,9 @@ enum { MENU_S_LIST, MENU_SLIST1, MENU_SLIST2, +#if defined(ENABLE_ALARM) MENU_AL_MOD, +#endif MENU_ANI_ID, MENU_UPCODE, MENU_DWCODE,