committed by
Krzysiek Egzmont
parent
e7a21c470f
commit
2a75f8a9be
313
app/app.c
313
app/app.c
@@ -194,8 +194,8 @@ static void HandleIncoming(void)
|
|||||||
gFoundCTCSS = false;
|
gFoundCTCSS = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
|
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
|
||||||
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
|
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
|
||||||
{
|
{
|
||||||
gFoundCDCSS = false;
|
gFoundCDCSS = false;
|
||||||
}
|
}
|
||||||
@@ -936,17 +936,17 @@ void APP_Update(void)
|
|||||||
gEeprom.BATTERY_SAVE == 0 ||
|
gEeprom.BATTERY_SAVE == 0 ||
|
||||||
gScanStateDir != SCAN_OFF ||
|
gScanStateDir != SCAN_OFF ||
|
||||||
gCssBackgroundScan ||
|
gCssBackgroundScan ||
|
||||||
gScreenToDisplay != DISPLAY_MAIN
|
gScreenToDisplay != DISPLAY_MAIN
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
|| gFmRadioMode
|
|| gFmRadioMode
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
||||||
#endif
|
#endif
|
||||||
){
|
){
|
||||||
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
gBatterySaveCountdown_10ms = battery_save_count_10ms;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
|
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
|
||||||
#endif
|
#endif
|
||||||
@@ -965,12 +965,12 @@ void APP_Update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE
|
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
&& gVoiceWriteIndex == 0
|
&& gVoiceWriteIndex == 0
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static bool goToSleep;
|
static bool goToSleep;
|
||||||
// wake up, enable RX then go back to sleep
|
// wake up, enable RX then go back to sleep
|
||||||
if (gRxIdleMode)
|
if (gRxIdleMode)
|
||||||
@@ -1025,13 +1025,13 @@ void APP_Update(void)
|
|||||||
static void CheckKeys(void)
|
static void CheckKeys(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (0
|
if (0
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|| gSetting_KILLED
|
|| gSetting_KILLED
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
|
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1074,7 +1074,7 @@ static void CheckKeys(void)
|
|||||||
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
|
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
|
||||||
|
|
||||||
if (gKeyReading0 != Key) // new key pressed
|
if (gKeyReading0 != Key) // new key pressed
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
|
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
|
||||||
ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
|
ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
|
||||||
@@ -1087,7 +1087,7 @@ static void CheckKeys(void)
|
|||||||
gDebounceCounter++;
|
gDebounceCounter++;
|
||||||
|
|
||||||
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
|
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
|
||||||
{
|
{
|
||||||
if (Key == KEY_INVALID) //all non PTT keys released
|
if (Key == KEY_INVALID) //all non PTT keys released
|
||||||
{
|
{
|
||||||
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
|
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
|
||||||
@@ -1110,7 +1110,7 @@ static void CheckKeys(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
|
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
|
||||||
{
|
{
|
||||||
if (Key != KEY_PTT)
|
if (Key != KEY_PTT)
|
||||||
{
|
{
|
||||||
gKeyBeingHeld = true;
|
gKeyBeingHeld = true;
|
||||||
@@ -1118,7 +1118,7 @@ static void CheckKeys(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //subsequent fast key repeats
|
else //subsequent fast key repeats
|
||||||
{
|
{
|
||||||
if (Key == KEY_UP || Key == KEY_DOWN) // fast key repeats for up/down buttons
|
if (Key == KEY_UP || Key == KEY_DOWN) // fast key repeats for up/down buttons
|
||||||
{
|
{
|
||||||
gKeyBeingHeld = true;
|
gKeyBeingHeld = true;
|
||||||
@@ -1135,6 +1135,7 @@ static void CheckKeys(void)
|
|||||||
|
|
||||||
void APP_TimeSlice10ms(void)
|
void APP_TimeSlice10ms(void)
|
||||||
{
|
{
|
||||||
|
gNextTimeslice = false;
|
||||||
gFlashLightBlinkCounter++;
|
gFlashLightBlinkCounter++;
|
||||||
|
|
||||||
#ifdef ENABLE_BOOT_BEEPS
|
#ifdef ENABLE_BOOT_BEEPS
|
||||||
@@ -1278,9 +1279,9 @@ void APP_TimeSlice10ms(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
SCANNER_TimeSlice10ms();
|
SCANNER_TimeSlice10ms();
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
|
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
|
||||||
{
|
{
|
||||||
@@ -1317,6 +1318,7 @@ void cancelUserInputModes(void)
|
|||||||
// this is called once every 500ms
|
// this is called once every 500ms
|
||||||
void APP_TimeSlice500ms(void)
|
void APP_TimeSlice500ms(void)
|
||||||
{
|
{
|
||||||
|
gNextTimeslice_500ms = false;
|
||||||
bool exit_menu = false;
|
bool exit_menu = false;
|
||||||
|
|
||||||
// Skipped authentic device check
|
// Skipped authentic device check
|
||||||
@@ -1421,7 +1423,7 @@ void APP_TimeSlice500ms(void)
|
|||||||
BATTERY_GetReadings(true);
|
BATTERY_GetReadings(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// regular display updates (once every 2 sec) - if need be
|
// regular display updates (once every 2 sec) - if need be
|
||||||
if ((gBatteryCheckCounter & 3) == 0)
|
if ((gBatteryCheckCounter & 3) == 0)
|
||||||
{
|
{
|
||||||
@@ -1433,23 +1435,22 @@ void APP_TimeSlice500ms(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
if (!gCssBackgroundScan
|
||||||
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && !gCssBackgroundScan)
|
#ifdef ENABLE_FMRADIO
|
||||||
#else
|
&& (gFM_ScanState == FM_SCAN_OFF || gAskToSave)
|
||||||
if (!gCssBackgroundScan)
|
#endif
|
||||||
#endif
|
) {
|
||||||
{
|
if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning()
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && !SCANNER_IsScanning())
|
&& gScreenToDisplay != DISPLAY_AIRCOPY
|
||||||
#else
|
#endif
|
||||||
if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning())
|
) {
|
||||||
#endif
|
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU) {
|
||||||
{
|
if (--gKeyLockCountdown == 0) {
|
||||||
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU)
|
|
||||||
{
|
|
||||||
if (--gKeyLockCountdown == 0)
|
|
||||||
gEeprom.KEY_LOCK = true; // lock the keyboard
|
gEeprom.KEY_LOCK = true; // lock the keyboard
|
||||||
gUpdateStatus = true; // lock symbol needs showing
|
gUpdateStatus = true; // lock symbol needs showing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exit_menu)
|
if (exit_menu)
|
||||||
@@ -1485,25 +1486,25 @@ void APP_TimeSlice500ms(void)
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
|
|
||||||
{
|
GUI_DisplayType_t disp = DISPLAY_INVALID;
|
||||||
GUI_DisplayType_t disp = DISPLAY_INVALID;
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode && ! FUNCTION_IsRx()) {
|
if (gFmRadioMode && ! FUNCTION_IsRx()) {
|
||||||
disp = DISPLAY_FM;
|
disp = DISPLAY_FM;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (disp == DISPLAY_INVALID)
|
|
||||||
{
|
|
||||||
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
|
||||||
if (!SCANNER_IsScanning())
|
|
||||||
#endif
|
#endif
|
||||||
disp = DISPLAY_MAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disp != DISPLAY_INVALID)
|
if (disp == DISPLAY_INVALID) {
|
||||||
GUI_SelectNextDisplay(disp);
|
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
|
||||||
|
if (!SCANNER_IsScanning())
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
disp = DISPLAY_MAIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disp != DISPLAY_INVALID) {
|
||||||
|
GUI_SelectNextDisplay(disp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1520,7 +1521,7 @@ void APP_TimeSlice500ms(void)
|
|||||||
FM_Start();
|
FM_Start();
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1651,7 +1652,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
!(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX))
|
!(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX))
|
||||||
// not in the backlight menu
|
// not in the backlight menu
|
||||||
&& !(gScreenToDisplay == DISPLAY_MENU && ( m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN))
|
&& !(gScreenToDisplay == DISPLAY_MENU && ( m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BACKLIGHT_TurnOn();
|
BACKLIGHT_TurnOn();
|
||||||
}
|
}
|
||||||
@@ -1669,7 +1670,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
// cancel user input
|
// cancel user input
|
||||||
cancelUserInputModes();
|
cancelUserInputModes();
|
||||||
|
|
||||||
if (gMonitor)
|
if (gMonitor)
|
||||||
ACTION_Monitor(); //turn off the monitor
|
ACTION_Monitor(); //turn off the monitor
|
||||||
#ifdef ENABLE_SCAN_RANGES
|
#ifdef ENABLE_SCAN_RANGES
|
||||||
@@ -1707,7 +1708,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Key == KEY_F)
|
if (Key == KEY_F)
|
||||||
{ // function/key-lock key
|
{ // function/key-lock key
|
||||||
@@ -1781,100 +1782,98 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bFlag)
|
if (bFlag) {
|
||||||
{
|
goto Skip;
|
||||||
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
}
|
||||||
{ // transmitting
|
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
if (gAlarmState == ALARM_STATE_OFF)
|
if (gAlarmState == ALARM_STATE_OFF)
|
||||||
#endif
|
|
||||||
{
|
|
||||||
char Code;
|
|
||||||
|
|
||||||
if (Key == KEY_PTT)
|
|
||||||
{
|
|
||||||
GENERIC_Key_PTT(bKeyPressed);
|
|
||||||
goto Skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Key == KEY_SIDE2)
|
|
||||||
{ // transmit 1750Hz tone
|
|
||||||
Code = 0xFE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Code = DTMF_GetCharacter(Key - KEY_0);
|
|
||||||
if (Code == 0xFF)
|
|
||||||
goto Skip;
|
|
||||||
|
|
||||||
// transmit DTMF keys
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bKeyPressed || bKeyHeld)
|
|
||||||
{
|
|
||||||
if (!bKeyPressed)
|
|
||||||
{
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
gEnableSpeaker = false;
|
|
||||||
|
|
||||||
BK4819_ExitDTMF_TX(false);
|
|
||||||
|
|
||||||
if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable)
|
|
||||||
BK4819_DisableScramble();
|
|
||||||
else
|
|
||||||
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (gEeprom.DTMF_SIDE_TONE)
|
|
||||||
{ // user will here the DTMF tones in speaker
|
|
||||||
AUDIO_AudioPathOn();
|
|
||||||
gEnableSpeaker = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BK4819_DisableScramble();
|
|
||||||
|
|
||||||
if (Code == 0xFE)
|
|
||||||
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);
|
|
||||||
else
|
|
||||||
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
|
||||||
else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed))
|
|
||||||
{
|
|
||||||
ALARM_Off();
|
|
||||||
|
|
||||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
|
||||||
else
|
|
||||||
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
|
||||||
|
|
||||||
if (Key == KEY_PTT)
|
|
||||||
gPttWasPressed = true;
|
|
||||||
else
|
|
||||||
if (!bKeyHeld)
|
|
||||||
gPttWasReleased = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
|
|
||||||
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
|
||||||
if (!SCANNER_IsScanning() && gScreenToDisplay != DISPLAY_AIRCOPY)
|
|
||||||
#else
|
|
||||||
if (!SCANNER_IsScanning())
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
|
char Code;
|
||||||
|
|
||||||
|
if (Key == KEY_PTT)
|
||||||
|
{
|
||||||
|
GENERIC_Key_PTT(bKeyPressed);
|
||||||
|
goto Skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Key == KEY_SIDE2)
|
||||||
|
{ // transmit 1750Hz tone
|
||||||
|
Code = 0xFE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Code = DTMF_GetCharacter(Key - KEY_0);
|
||||||
|
if (Code == 0xFF)
|
||||||
|
goto Skip;
|
||||||
|
|
||||||
|
// transmit DTMF keys
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bKeyPressed || bKeyHeld)
|
||||||
|
{
|
||||||
|
if (!bKeyPressed)
|
||||||
|
{
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
|
gEnableSpeaker = false;
|
||||||
|
|
||||||
|
BK4819_ExitDTMF_TX(false);
|
||||||
|
|
||||||
|
if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable)
|
||||||
|
BK4819_DisableScramble();
|
||||||
|
else
|
||||||
|
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gEeprom.DTMF_SIDE_TONE)
|
||||||
|
{ // user will here the DTMF tones in speaker
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
gEnableSpeaker = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BK4819_DisableScramble();
|
||||||
|
|
||||||
|
if (Code == 0xFE)
|
||||||
|
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);
|
||||||
|
else
|
||||||
|
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!bKeyHeld && bKeyPressed)
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) {
|
||||||
|
ALARM_Off();
|
||||||
|
|
||||||
|
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||||
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
|
else
|
||||||
|
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
|
||||||
|
|
||||||
|
if (Key == KEY_PTT)
|
||||||
|
gPttWasPressed = true;
|
||||||
|
else
|
||||||
|
if (!bKeyHeld)
|
||||||
|
gPttWasReleased = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) {
|
||||||
|
ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld);
|
||||||
|
}
|
||||||
|
else if (!SCANNER_IsScanning()
|
||||||
|
#ifdef ENABLE_AIRCOPY
|
||||||
|
&& gScreenToDisplay != DISPLAY_AIRCOPY
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
|
||||||
|
}
|
||||||
|
else if (!bKeyHeld && bKeyPressed) {
|
||||||
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skip:
|
Skip:
|
||||||
@@ -1904,24 +1903,24 @@ Skip:
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gRequestSaveFM)
|
if (gRequestSaveFM)
|
||||||
{
|
{
|
||||||
if (!bKeyHeld)
|
gRequestSaveFM = false;
|
||||||
SETTINGS_SaveFM();
|
if (!bKeyHeld)
|
||||||
else
|
SETTINGS_SaveFM();
|
||||||
gFlagSaveFM = true;
|
else
|
||||||
gRequestSaveFM = false;
|
gFlagSaveFM = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gRequestSaveVFO)
|
if (gRequestSaveVFO)
|
||||||
{
|
{
|
||||||
|
gRequestSaveVFO = false;
|
||||||
if (!bKeyHeld)
|
if (!bKeyHeld)
|
||||||
SETTINGS_SaveVfoIndices();
|
SETTINGS_SaveVfoIndices();
|
||||||
else
|
else
|
||||||
gFlagSaveVfo = true;
|
gFlagSaveVfo = true;
|
||||||
gRequestSaveVFO = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gRequestSaveChannel > 0) // TODO: remove the gRequestSaveChannel, why use global variable for that??
|
if (gRequestSaveChannel > 0) // TODO: remove the gRequestSaveChannel, why use global variable for that??
|
||||||
|
@@ -16,13 +16,15 @@
|
|||||||
|
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
||||||
|
|
||||||
#include "audio.h"
|
#include "../audio.h"
|
||||||
|
#include "../bsp/dp32g030/gpio.h"
|
||||||
|
#include "../bsp/dp32g030/portcon.h"
|
||||||
|
|
||||||
#include "bk4819.h"
|
#include "bk4819.h"
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "gpio.h"
|
||||||
#include "bsp/dp32g030/portcon.h"
|
#include "system.h"
|
||||||
#include "driver/gpio.h"
|
#include "systick.h"
|
||||||
#include "driver/system.h"
|
|
||||||
#include "driver/systick.h"
|
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#ifndef ARRAY_SIZE
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
@@ -127,7 +129,6 @@ static uint16_t BK4819_ReadU16(void)
|
|||||||
PORTCON_PORTC_IE = (PORTCON_PORTC_IE & ~PORTCON_PORTC_IE_C2_MASK) | PORTCON_PORTC_IE_C2_BITS_ENABLE;
|
PORTCON_PORTC_IE = (PORTCON_PORTC_IE & ~PORTCON_PORTC_IE_C2_MASK) | PORTCON_PORTC_IE_C2_BITS_ENABLE;
|
||||||
GPIOC->DIR = (GPIOC->DIR & ~GPIO_DIR_2_MASK) | GPIO_DIR_2_BITS_INPUT;
|
GPIOC->DIR = (GPIOC->DIR & ~GPIO_DIR_2_MASK) | GPIO_DIR_2_BITS_INPUT;
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
|
|
||||||
Value = 0;
|
Value = 0;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
|
@@ -117,19 +117,13 @@ KEY_Code_t KEYBOARD_Poll(void)
|
|||||||
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
|
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
|
||||||
|
|
||||||
// Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops
|
// Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops
|
||||||
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++)
|
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++) {
|
||||||
{
|
|
||||||
uint16_t reg2;
|
|
||||||
|
|
||||||
SYSTICK_DelayUs(1);
|
SYSTICK_DelayUs(1);
|
||||||
|
uint16_t reg2 = GPIOA->DATA;
|
||||||
reg2 = GPIOA->DATA;
|
i *= reg == reg2;
|
||||||
if (reg != reg2)
|
reg = reg2;
|
||||||
{ // noise
|
|
||||||
reg = reg2;
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
break; // noise is too bad
|
break; // noise is too bad
|
||||||
|
|
||||||
|
@@ -14,10 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bsp/dp32g030/pmu.h"
|
#include "../bsp/dp32g030/pmu.h"
|
||||||
#include "bsp/dp32g030/syscon.h"
|
#include "../bsp/dp32g030/syscon.h"
|
||||||
#include "driver/system.h"
|
#include "system.h"
|
||||||
#include "driver/systick.h"
|
#include "systick.h"
|
||||||
|
|
||||||
void SYSTEM_DelayMs(uint32_t Delay)
|
void SYSTEM_DelayMs(uint32_t Delay)
|
||||||
{
|
{
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ARMCM0.h"
|
#include "ARMCM0.h"
|
||||||
#include "driver/systick.h"
|
#include "systick.h"
|
||||||
#include "misc.h"
|
#include "../misc.h"
|
||||||
|
|
||||||
// 0x20000324
|
// 0x20000324
|
||||||
static uint32_t gTickMultiplier;
|
static uint32_t gTickMultiplier;
|
||||||
@@ -29,17 +29,21 @@ void SYSTICK_Init(void)
|
|||||||
|
|
||||||
void SYSTICK_DelayUs(uint32_t Delay)
|
void SYSTICK_DelayUs(uint32_t Delay)
|
||||||
{
|
{
|
||||||
const uint32_t ticks = Delay * gTickMultiplier;
|
const uint32_t ticks = Delay * gTickMultiplier;
|
||||||
uint32_t i = 0;
|
uint32_t elapsed_ticks = 0;
|
||||||
uint32_t Start = SysTick->LOAD;
|
uint32_t Start = SysTick->LOAD;
|
||||||
uint32_t Previous = SysTick->VAL;
|
uint32_t Previous = SysTick->VAL;
|
||||||
do {
|
do {
|
||||||
uint32_t Current;
|
uint32_t Current;
|
||||||
uint32_t Delta;
|
|
||||||
while ((Current = SysTick->VAL) == Previous) {}
|
|
||||||
Delta = (Current < Previous) ? -Current : Start - Current;
|
|
||||||
i += Delta + Previous;
|
|
||||||
Previous = Current;
|
|
||||||
} while (i < ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
Current = SysTick->VAL;
|
||||||
|
} while (Current == Previous);
|
||||||
|
|
||||||
|
uint32_t Delta = ((Current < Previous) ? - Current : Start - Current);
|
||||||
|
|
||||||
|
elapsed_ticks += Delta + Previous;
|
||||||
|
|
||||||
|
Previous = Current;
|
||||||
|
} while (elapsed_ticks < ticks);
|
||||||
|
}
|
||||||
|
46
main.c
46
main.c
@@ -14,18 +14,26 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
#include "am_fix.h"
|
#include "am_fix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "audio.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "radio.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
#include "audio.h"
|
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "bsp/dp32g030/gpio.h"
|
||||||
#include "bsp/dp32g030/syscon.h"
|
#include "bsp/dp32g030/syscon.h"
|
||||||
#include "board.h"
|
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#include "driver/bk4819.h"
|
#include "driver/bk4819.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
@@ -34,16 +42,13 @@
|
|||||||
#ifdef ENABLE_UART
|
#ifdef ENABLE_UART
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "helper/battery.h"
|
#include "helper/battery.h"
|
||||||
#include "helper/boot.h"
|
#include "helper/boot.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "radio.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "ui/lock.h"
|
#include "ui/lock.h"
|
||||||
#include "ui/welcome.h"
|
#include "ui/welcome.h"
|
||||||
#include "ui/menu.h"
|
#include "ui/menu.h"
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
void _putchar(__attribute__((unused)) char c)
|
void _putchar(__attribute__((unused)) char c)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -67,6 +72,7 @@ void Main(void)
|
|||||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE
|
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE
|
||||||
| SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE;
|
| SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE;
|
||||||
|
|
||||||
|
|
||||||
SYSTICK_Init();
|
SYSTICK_Init();
|
||||||
BOARD_Init();
|
BOARD_Init();
|
||||||
|
|
||||||
@@ -102,9 +108,9 @@ void Main(void)
|
|||||||
|
|
||||||
BATTERY_GetReadings(false);
|
BATTERY_GetReadings(false);
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
AM_fix_init();
|
AM_fix_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const BOOT_Mode_t BootMode = BOOT_GetMode();
|
const BOOT_Mode_t BootMode = BOOT_GetMode();
|
||||||
|
|
||||||
@@ -211,24 +217,18 @@ void Main(void)
|
|||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
RADIO_ConfigureNOAA();
|
RADIO_ConfigureNOAA();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ******************
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
while (true) {
|
||||||
{
|
|
||||||
APP_Update();
|
APP_Update();
|
||||||
|
|
||||||
if (gNextTimeslice)
|
if (gNextTimeslice) {
|
||||||
{
|
|
||||||
APP_TimeSlice10ms();
|
|
||||||
gNextTimeslice = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gNextTimeslice_500ms)
|
APP_TimeSlice10ms();
|
||||||
{
|
|
||||||
APP_TimeSlice500ms();
|
if (gNextTimeslice_500ms) {
|
||||||
gNextTimeslice_500ms = false;
|
APP_TimeSlice500ms();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user