Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Ability to disable ALARM and TX1750.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Sep 15, 2023
1 parent 65d7e51 commit 6c81075
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -246,15 +255,19 @@ 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)
ACTION_FM();
#endif
break;
case 8:
#if defined(ENABLE_TX1750)
ACTION_AlarmOr1750(true);
#endif
break;
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -944,6 +945,7 @@ void APP_TimeSlice10ms(void)
}
}
}
#endif
if (gRTTECountdown) {
gRTTECountdown--;
if (gRTTECountdown == 0) {
Expand Down Expand Up @@ -1263,6 +1265,7 @@ void APP_TimeSlice500ms(void)
}
}

#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
static void ALARM_Off(void)
{
gAlarmState = ALARM_STATE_OFF;
Expand All @@ -1277,6 +1280,7 @@ static void ALARM_Off(void)
RADIO_SetupRegisters(true);
gRequestDisplayScreen = DISPLAY_MAIN;
}
#endif

void CHANNEL_Next(bool bBackup, int8_t Direction)
{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -144,25 +145,35 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
gAlarmToneCounter = 0;
break;
}
#endif

GUI_DisplayScreen();
RADIO_SetTxParameters();
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true);

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 {
Expand Down
5 changes: 4 additions & 1 deletion helper/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 18 additions & 1 deletion radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -191,6 +196,7 @@ void UI_DisplayMain(void)
State = VFO_STATE_ALARM;
}
}
#endif
if (State) {
uint8_t Width = 10;

Expand All @@ -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;
Expand Down
Loading

0 comments on commit 6c81075

Please sign in to comment.