diff --git a/app/action.c b/app/action.c index 463b9a7..10cdfcd 100644 --- a/app/action.c +++ b/app/action.c @@ -18,11 +18,9 @@ #include "app/app.h" #include "app/dtmf.h" -#include "app/fm.h" #include "app/scanner.h" #include "audio.h" #include "bsp/dp32g030/gpio.h" -#include "driver/bk1080.h" #include "driver/bk4819.h" #include "driver/gpio.h" #include "functions.h" @@ -69,42 +67,12 @@ static void ACTION_Monitor(void) { gScanPauseMode = true; } RADIO_SetupRegisters(true); - if (gFmRadioMode) { - FM_Start(); - gRequestDisplayScreen = DISPLAY_FM; - } else { - gRequestDisplayScreen = gScreenToDisplay; - } + gRequestDisplayScreen = gScreenToDisplay; + } void ACTION_Scan(bool bRestart) { - if (gFmRadioMode) { - if (gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_MONITOR && - gCurrentFunction != FUNCTION_TRANSMIT) { - uint16_t Frequency; - - GUI_SelectNextDisplay(DISPLAY_FM); - if (gFM_ScanState != FM_SCAN_OFF) { - FM_PlayAndUpdate(); - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; - } else { - if (bRestart) { - gFM_AutoScan = true; - gFM_ChannelPosition = 0; - FM_EraseChannels(); - Frequency = gEeprom.FM_LowerLimit; - } else { - gFM_AutoScan = false; - gFM_ChannelPosition = 0; - Frequency = gEeprom.FM_FrequencyPlaying; - } - BK1080_GetFrequencyDeviation(Frequency); - FM_Tune(Frequency, 1, bRestart); - gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN; - } - } - } else if (gScreenToDisplay != DISPLAY_SCANNER) { + if (gScreenToDisplay != DISPLAY_SCANNER) { RADIO_SelectVfos(); GUI_SelectNextDisplay(DISPLAY_MAIN); if (gScanState != SCAN_OFF) { @@ -126,35 +94,18 @@ void ACTION_Vox(void) { gUpdateStatus = true; } -static void ACTION_AlarmOr1750(bool b1750) { +static void ACTION_1750(void) { gInputBoxIndex = 0; - if (b1750) { - gAlarmState = ALARM_STATE_TX1750; - } else { - gAlarmState = ALARM_STATE_TXALARM; - } + gAlarmState = ALARM_STATE_TX1750; gAlarmRunningCounter = 0; gFlagPrepareTX = true; gRequestDisplayScreen = DISPLAY_MAIN; } -void ACTION_FM(void) { - if (gCurrentFunction != FUNCTION_TRANSMIT && - gCurrentFunction != FUNCTION_MONITOR) { - if (gFmRadioMode) { - FM_TurnOff(); - gInputBoxIndex = 0; - gVoxResumeCountdown = 80; - gFlagReconfigureVfos = true; - gRequestDisplayScreen = DISPLAY_MAIN; - return; - } - RADIO_SelectVfos(); - RADIO_SetupRegisters(true); - FM_Start(); - gInputBoxIndex = 0; - gRequestDisplayScreen = DISPLAY_FM; - } +static void ACTION_SwitchAB(void) { +} + +static void ACTION_VFOMR(void) { } void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { @@ -218,13 +169,13 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { ACTION_Vox(); break; case 6: - ACTION_AlarmOr1750(false); + ACTION_VFOMR(); break; case 7: - ACTION_FM(); + ACTION_SwitchAB(); break; case 8: - ACTION_AlarmOr1750(true); + ACTION_1750(); break; } } diff --git a/app/fm.c b/app/fm.c index 31204e6..c6e24b0 100644 --- a/app/fm.c +++ b/app/fm.c @@ -200,298 +200,10 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) return ret; } -static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ -#define STATE_FREQ_MODE 0 -#define STATE_MR_MODE 1 -#define STATE_SAVE 2 - - if (!bKeyHeld && bKeyPressed) { - if (!gWasFKeyPressed) { - uint8_t State; - - if (gAskToDelete) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - if (gAskToSave) { - State = STATE_SAVE; - } else { - if (gFM_ScanState != FM_SCAN_OFF) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - if (gEeprom.FM_IsMrMode) { - State = STATE_MR_MODE; - } else { - State = STATE_FREQ_MODE; - } - } - INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_FM; - if (State == STATE_FREQ_MODE) { - if (gInputBoxIndex == 1) { - if (gInputBox[0] > 1) { - gInputBox[1] = gInputBox[0]; - gInputBox[0] = 0; - gInputBoxIndex = 2; - } - } else if (gInputBoxIndex > 3) { - uint32_t Frequency; - - gInputBoxIndex = 0; - NUMBER_Get(gInputBox, &Frequency); - Frequency = Frequency / 10000; - if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gRequestDisplayScreen = DISPLAY_FM; - return; - } - gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; - gAnotherVoiceID = (VOICE_ID_t)Key; - gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestSaveFM = true; - return; - } - } else if (gInputBoxIndex == 2) { - uint8_t Channel; - - gInputBoxIndex = 0; - Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; - if (State == STATE_MR_MODE) { - if (FM_CheckValidChannel(Channel)) { - gAnotherVoiceID = (VOICE_ID_t)Key; - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestSaveFM = true; - return; - } - } else if (Channel < 20) { - gAnotherVoiceID = (VOICE_ID_t)Key; - gRequestDisplayScreen = DISPLAY_FM; - gInputBoxIndex = 0; - gFM_ChannelPosition = Channel; - return; - } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - gAnotherVoiceID = (VOICE_ID_t)Key; - return; - } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gWasFKeyPressed = false; - gUpdateStatus = true; - gRequestDisplayScreen = DISPLAY_FM; - switch (Key) { - case KEY_0: - ACTION_FM(); - break; - - case KEY_1: - gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; - if (!FM_ConfigureChannelState()) { - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestSaveFM = true; - } else { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - break; - - case KEY_2: - ACTION_Scan(true); - break; - - case KEY_3: - ACTION_Scan(false); - break; - - default: - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - break; - } - } -} - -static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) -{ - if (bKeyHeld) { - return; - } - if (!bKeyPressed) { - return; - } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (gFM_ScanState == FM_SCAN_OFF) { - if (gInputBoxIndex == 0) { - if (!gAskToSave && !gAskToDelete) { - ACTION_FM(); - return; - } - gAskToSave = false; - gAskToDelete = false; - } else { - gInputBoxIndex--; - gInputBox[gInputBoxIndex] = 10; - if (gInputBoxIndex) { - if (gInputBoxIndex != 1) { - gRequestDisplayScreen = DISPLAY_FM; - return; - } - if (gInputBox[0] != 0) { - gRequestDisplayScreen = DISPLAY_FM; - return; - } - } - gInputBoxIndex = 0; - } - gAnotherVoiceID = VOICE_ID_CANCEL; - } else { - FM_PlayAndUpdate(); - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; - } - gRequestDisplayScreen = DISPLAY_FM; -} - -static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) -{ - if (bKeyHeld) { - return; - } - if (!bKeyPressed) { - return; - } - - gRequestDisplayScreen = DISPLAY_FM; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - - if (gFM_ScanState == FM_SCAN_OFF) { - if (!gEeprom.FM_IsMrMode) { - if (gAskToSave) { - gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; - gAskToSave = false; - gRequestSaveFM = true; - } else { - gAskToSave = true; - } - } else { - if (gAskToDelete) { - gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF; - FM_ConfigureChannelState(); - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestSaveFM = true; - gAskToDelete = false; - } else { - gAskToDelete = true; - } - } - } else { - if (gFM_AutoScan || !gFM_FoundFrequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gInputBoxIndex = 0; - return; - } else if (gAskToSave) { - gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; - gAskToSave = false; - gRequestSaveFM = true; - } else { - gAskToSave = true; - } - } -} - -static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) -{ - if (bKeyHeld || !bKeyPressed) { - if (gInputBoxIndex) { - return; - } - if (!bKeyPressed) { - return; - } - } else { - if (gInputBoxIndex) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - } - if (gAskToSave) { - gRequestDisplayScreen = DISPLAY_FM; - gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); - return; - } - if (gFM_ScanState != FM_SCAN_OFF) { - if (gFM_AutoScan) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false); - gRequestDisplayScreen = DISPLAY_FM; - return; - } - if (gEeprom.FM_IsMrMode) { - uint8_t Channel; - - Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); - if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) { - goto Bail; - } - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; - } else { - uint16_t Frequency; - - Frequency = gEeprom.FM_SelectedFrequency + Step; - if (Frequency < gEeprom.FM_LowerLimit) { - Frequency = gEeprom.FM_UpperLimit; - } else if (Frequency > gEeprom.FM_UpperLimit) { - Frequency = gEeprom.FM_LowerLimit; - } - gEeprom.FM_FrequencyPlaying = Frequency; - gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; - } - gRequestSaveFM = true; - -Bail: - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestDisplayScreen = DISPLAY_FM; -} void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { - switch (Key) { - case KEY_0: case KEY_1: case KEY_2: case KEY_3: - case KEY_4: case KEY_5: case KEY_6: case KEY_7: - case KEY_8: case KEY_9: - FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); - break; - case KEY_MENU: - FM_Key_MENU(bKeyPressed, bKeyHeld); - return; - case KEY_UP: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); - break; - case KEY_DOWN: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); - break;; - case KEY_EXIT: - FM_Key_EXIT(bKeyPressed, bKeyHeld); - break; - case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); - break; - case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); - break; - default: - if (!bKeyHeld && bKeyPressed) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - break; - } + } void FM_Play(void) diff --git a/app/main.c b/app/main.c index ccb3379..73fc1e1 100644 --- a/app/main.c +++ b/app/main.c @@ -20,7 +20,6 @@ #include "app/action.h" #include "app/app.h" -#include "app/fm.h" #include "app/generic.h" #include "app/scanner.h" #include "audio.h" @@ -236,7 +235,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { if (!bKeyHeld && bKeyPressed) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (!gFmRadioMode) { + if (true) { if (gScanState == SCAN_OFF) { if (gInputBoxIndex == 0) { return; @@ -373,12 +372,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, } void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { - if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) { - if (!bKeyHeld && bKeyPressed) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - return; - } + if (gDTMF_InputMode && !bKeyHeld && bKeyPressed) { char Character = DTMF_GetCharacter(Key); if (Character != 0xFF) { diff --git a/firmware.packed.bin b/firmware.packed.bin index fba0817..80c0731 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ