0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

More counter renames + dual watch active indicator

This commit is contained in:
OneOfEleven 2023-09-18 08:30:24 +01:00
parent 6cdd8f35b1
commit 777117c76b
23 changed files with 306 additions and 231 deletions

View File

@ -85,16 +85,16 @@ static void ACTION_Monitor(void)
if (gScanState != SCAN_OFF)
{
ScanPauseDelayIn10msec = 500; // 5 seconds
gScheduleScanListen = false;
gScanPauseMode = true;
ScanPauseDelayIn_10ms = 500; // 5 seconds
gScheduleScanListen = false;
gScanPauseMode = true;
}
#ifdef ENABLE_NOAA
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode)
{
gNOAA_Countdown = 500;
gScheduleNOAA = false;
gNOAA_Countdown_10ms = 500; // 5 sec
gScheduleNOAA = false;
}
#endif

220
app/app.c
View File

@ -16,7 +16,6 @@
#include <string.h>
#include "scheduler.h"
#include "app/action.h"
#ifdef ENABLE_AIRCOPY
#include "app/aircopy.h"
@ -73,9 +72,9 @@ static void APP_CheckForIncoming(void)
{
if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE)
{
ScanPauseDelayIn10msec = 100; // 1 second
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED;
ScanPauseDelayIn_10ms = 100; // 1 second
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED;
}
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
@ -83,8 +82,8 @@ static void APP_CheckForIncoming(void)
#ifdef ENABLE_NOAA
if (gIsNoaaMode)
{
gNOAA_Countdown = 20;
gScheduleNOAA = false;
gNOAA_Countdown_10ms = 20; // 200ms
gScheduleNOAA = false;
}
#endif
@ -98,8 +97,12 @@ static void APP_CheckForIncoming(void)
return;
}
gDualWatchCountdown = dual_watch_count_after_rx_10ms;
gScheduleDualWatch = false;
gDualWatchCountdown_10ms = dual_watch_count_after_rx_10ms;
gDualWatchCountdownExpired = false;
// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
}
else
{
@ -109,8 +112,8 @@ static void APP_CheckForIncoming(void)
return;
}
ScanPauseDelayIn10msec = 20; // 200ms
gScheduleScanListen = false;
ScanPauseDelayIn_10ms = 20; // 200ms
gScheduleScanListen = false;
}
gRxReceptionMode = RX_MODE_DETECTED;
@ -132,10 +135,10 @@ static void APP_HandleIncoming(void)
bFlag = (gScanState == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gSystickCountdown2)
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0)
{
bFlag = true;
gSystickCountdown2 = 0;
gNOAACountdown_10ms = 0;
bFlag = true;
}
#endif
@ -163,9 +166,15 @@ static void APP_HandleIncoming(void)
{
if (gRxReceptionMode == RX_MODE_DETECTED)
{
gDualWatchCountdown = dual_watch_count_after_1_10ms;
gScheduleDualWatch = false;
gRxReceptionMode = RX_MODE_LISTENING;
gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms;
gDualWatchCountdownExpired = false;
gRxReceptionMode = RX_MODE_LISTENING;
// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
return;
}
}
@ -183,7 +192,7 @@ static void APP_HandleReceive(void)
uint8_t Mode = END_OF_RX_MODE_SKIP;
if (gFlagTteComplete)
if (gFlagTailNoteEliminationComplete)
{
Mode = END_OF_RX_MODE_END;
goto Skip;
@ -205,7 +214,7 @@ static void APP_HandleReceive(void)
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (gFoundCTCSS && gFoundCTCSSCountdown == 0)
if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0)
{
gFoundCTCSS = false;
gFoundCDCSS = false;
@ -216,7 +225,7 @@ static void APP_HandleReceive(void)
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (gFoundCDCSS && gFoundCDCSSCountdown == 0)
if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0)
{
gFoundCTCSS = false;
gFoundCDCSS = false;
@ -255,8 +264,8 @@ static void APP_HandleReceive(void)
else
if (!gFoundCTCSS)
{
gFoundCTCSS = true;
gFoundCTCSSCountdown = 100;
gFoundCTCSS = true;
gFoundCTCSSCountdown_10ms = 100; // 1 sec
}
if (g_CxCSS_TAIL_Found)
@ -275,8 +284,8 @@ static void APP_HandleReceive(void)
else
if (!gFoundCDCSS)
{
gFoundCDCSS = true;
gFoundCDCSSCountdown = 100;
gFoundCDCSS = true;
gFoundCDCSSCountdown_10ms = 100; // 1 sec
}
if (g_CxCSS_TAIL_Found)
@ -315,7 +324,7 @@ Skip:
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
gSystickCountdown2 = 300;
gNOAACountdown_10ms = 300; // 3 sec
#endif
gUpdateDisplay = true;
@ -328,8 +337,8 @@ Skip:
break;
case SCAN_RESUME_CO:
ScanPauseDelayIn10msec = 360;
gScheduleScanListen = false;
ScanPauseDelayIn_10ms = 360;
gScheduleScanListen = false;
break;
case SCAN_RESUME_SE:
@ -345,10 +354,10 @@ Skip:
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gTailNoteEliminationCountdown = 20;
gFlagTteComplete = false;
gEnableSpeaker = false;
gEndOfRxDetectedMaybe = true;
gTailNoteEliminationCountdown_10ms = 20;
gFlagTailNoteEliminationComplete = false;
gEndOfRxDetectedMaybe = true;
gEnableSpeaker = false;
}
break;
}
@ -407,16 +416,16 @@ void APP_StartListening(FUNCTION_Type_t Function)
case SCAN_RESUME_TO:
if (!gScanPauseMode)
{
ScanPauseDelayIn10msec = 500;
gScheduleScanListen = false;
gScanPauseMode = true;
ScanPauseDelayIn_10ms = 500;
gScheduleScanListen = false;
gScanPauseMode = true;
}
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_SE:
ScanPauseDelayIn10msec = 0;
gScheduleScanListen = false;
ScanPauseDelayIn_10ms = 0;
gScheduleScanListen = false;
break;
}
@ -430,7 +439,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gRxVfo->CHANNEL_SAVE;
gNOAA_Countdown = 500;
gNOAA_Countdown_10ms = 500; // 5 sec
gScheduleNOAA = false;
}
#endif
@ -440,9 +449,14 @@ void APP_StartListening(FUNCTION_Type_t Function)
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
gRxVfoIsActive = true;
gDualWatchCountdown = dual_watch_count_after_2_10ms;
gScheduleDualWatch = false;
gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms;
gDualWatchCountdownExpired = false;
gRxVfoIsActive = true;
// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
}
if (gRxVfo->IsAM)
@ -531,9 +545,9 @@ static void FREQ_NextChannel(void)
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true);
gUpdateDisplay = true;
ScanPauseDelayIn10msec = 10;
bScanKeepFrequency = false;
gUpdateDisplay = true;
ScanPauseDelayIn_10ms = 10;
bScanKeepFrequency = false;
}
static void MR_NextChannel(void)
@ -587,9 +601,9 @@ Skip:
gUpdateDisplay = true;
}
ScanPauseDelayIn10msec = 20;
ScanPauseDelayIn_10ms = 20;
bScanKeepFrequency = false;
bScanKeepFrequency = false;
if (bEnabled)
if (++gCurrentScanList >= 2)
@ -629,10 +643,16 @@ static void DUALWATCH_Alternate(void)
RADIO_SetupRegisters(false);
#ifdef ENABLE_NOAA
gDualWatchCountdown = gIsNoaaMode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms;
gDualWatchCountdown_10ms = gIsNoaaMode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms;
#else
gDualWatchCountdown = dual_watch_count_toggle_10ms;
gDualWatchCountdown_10ms = dual_watch_count_toggle_10ms;
#endif
if (!gDualWatchActive)
{ // let the user see DW is active
gDualWatchActive = true;
gUpdateStatus = true;
}
}
void APP_CheckRadioInterrupts(void)
@ -718,14 +738,18 @@ void APP_CheckRadioInterrupts(void)
{
if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode)
{
gBatterySave = 20;
gBatterySaveCountdownExpired = false;
gBatterySave_10ms = 20; // 200ms
gBatterySaveExpired = false;
}
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown < dual_watch_count_after_vox_10ms))
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gBatterySaveCountdownExpired || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms))
{
gDualWatchCountdown = dual_watch_count_after_vox_10ms;
gScheduleDualWatch = false;
gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms;
gDualWatchCountdownExpired = false;
// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
}
}
}
@ -816,9 +840,9 @@ static void APP_HandleVox(void)
if (gVOX_NoiseDetected)
{
if (g_VOX_Lost)
gVoxStopCountdown = 100;
gVoxStopCountdown_10ms = 100; // 1 sec
else
if (gVoxStopCountdown == 0)
if (gVoxStopCountdown_10ms == 0)
gVOX_NoiseDetected = false;
if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected)
@ -943,28 +967,30 @@ void APP_Update(void)
NOAA_IncreaseChannel();
RADIO_SetupRegisters(false);
gScheduleNOAA = false;
gNOAA_Countdown = 7;
gNOAA_Countdown_10ms = 7; // 70ms
gScheduleNOAA = false;
}
#endif
// toggle between the VFO's if dual watch is enabled
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
#ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0)
if (gDualWatchCountdownExpired && gVoiceWriteIndex == 0)
#else
if (gScheduleDualWatch)
if (gDualWatchCountdownExpired)
#endif
{
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{
#ifdef ENABLE_FMRADIO
if (!gPttIsPressed && !gFmRadioMode && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE)
#else
if (!gPttIsPressed && gDTMF_CallState == DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_POWER_SAVE)
#endif
if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gDTMF_CallState == DTMF_CALL_STATE_NONE &&
gCurrentFunction != FUNCTION_POWER_SAVE)
{
gScheduleDualWatch = false;
gDualWatchCountdownExpired = false;
DUALWATCH_Alternate(); // toggle between the two VFO's
@ -994,7 +1020,7 @@ void APP_Update(void)
if (gEeprom.VOX_SWITCH)
APP_HandleVox();
if (gSchedulePowerSave)
if (gBatterySaveCountdownExpired)
{
#ifdef ENABLE_NOAA
if (
@ -1008,12 +1034,20 @@ void APP_Update(void)
gCssScanMode != CSS_SCAN_MODE_OFF ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
gBatterySaveCountdown = battery_save_count_10ms;
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdownExpired = false;
}
else
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
else
gBatterySaveCountdown = battery_save_count_10ms;
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdownExpired = false;
}
#else
if (
#ifdef ENABLE_FMRADIO
@ -1026,18 +1060,21 @@ void APP_Update(void)
gCssScanMode != CSS_SCAN_MODE_OFF ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
gBatterySaveCountdown = battery_save_count_10ms;
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdownExpired = false;
}
else
{
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
#endif
gSchedulePowerSave = false;
}
#ifdef ENABLE_VOICE
if (gBatterySaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0)
if (gBatterySaveExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0)
#else
if (gBatterySaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE)
if (gBatterySaveExpired && gCurrentFunction == FUNCTION_POWER_SAVE)
#endif
{
if (gRxIdleMode)
@ -1050,13 +1087,16 @@ void APP_Update(void)
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{
DUALWATCH_Alternate(); // toggle between the two VFO's
gUpdateRSSI = false;
}
FUNCTION_Init();
gBatterySave = 10;
gRxIdleMode = false;
gBatterySave_10ms = 10; // 100ms
gBatterySaveExpired = false;
gRxIdleMode = false;
}
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI)
@ -1064,8 +1104,10 @@ void APP_Update(void)
gCurrentRSSI = BK4819_GetRSSI();
UI_UpdateRSSI(gCurrentRSSI);
gBatterySave = gEeprom.BATTERY_SAVE * 10;
gRxIdleMode = true;
gBatterySave_10ms = gEeprom.BATTERY_SAVE * 10;
gBatterySaveExpired = false;
gRxIdleMode = true;
BK4819_DisableVox();
BK4819_Sleep();
@ -1078,11 +1120,11 @@ void APP_Update(void)
{
DUALWATCH_Alternate(); // toggle between the two VFO's
gUpdateRSSI = true;
gBatterySave = 10;
}
gUpdateRSSI = true;
gBatterySaveCountdownExpired = false;
gBatterySave_10ms = 10; // 100ms
gBatterySaveExpired = false;
}
}
}
@ -1144,6 +1186,7 @@ void APP_CheckKeys(void)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
boot_counter_10ms = 0;
gPttDebounceCounter = 0;
gPttIsPressed = true;
APP_ProcessKey(KEY_PTT, true, false);
@ -1157,6 +1200,9 @@ void APP_CheckKeys(void)
// scan the hardware keys
Key = KEYBOARD_Poll();
if (Key != KEY_INVALID)
boot_counter_10ms = 0;
if (gKeyReading0 != Key)
{ // new key pressed
@ -1233,8 +1279,8 @@ void APP_TimeSlice10ms(void)
gFlashLightBlinkCounter++;
#ifdef ENABLE_BOOT_BEEPS
if (boot_counter < 255)
if ((boot_counter % 25) == 0)
if (boot_counter_10ms > 0)
if ((boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
@ -1783,11 +1829,11 @@ void CHANNEL_Next(bool bFlag, int8_t Direction)
FREQ_NextChannel();
}
ScanPauseDelayIn10msec = 50; // 500ms
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
ScanPauseDelayIn_10ms = 50; // 500ms
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
}
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
@ -1797,7 +1843,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);
gBatterySaveCountdown = battery_save_count_10ms;
gBatterySaveCountdown_10ms = battery_save_count_10ms;
if (gEeprom.AUTO_KEYPAD_LOCK)
gKeyLockCountdown = 30; // 15 seconds

View File

@ -131,8 +131,8 @@ void MENU_StartCssScan(int8_t Direction)
MENU_SelectNextCode();
ScanPauseDelayIn10msec = 50;
gScheduleScanListen = false;
ScanPauseDelayIn_10ms = 50;
gScheduleScanListen = false;
}
void MENU_StopCssScan(void)
@ -746,7 +746,7 @@ void MENU_SelectNextCode(void)
RADIO_SetupRegisters(true);
ScanPauseDelayIn10msec = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? 20 : 30;
ScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? 20 : 30;
gUpdateDisplay = true;
}

View File

@ -36,7 +36,7 @@ uint32_t gScanFrequency;
bool gScanPauseMode;
SCAN_CssState_t gScanCssState;
volatile bool gScheduleScanListen = true;
volatile uint16_t ScanPauseDelayIn10msec;
volatile uint16_t ScanPauseDelayIn_10ms;
uint8_t gScanProgressIndicator;
uint8_t gScanHitCount;
bool gScanUseCssResult;

View File

@ -46,7 +46,7 @@ extern uint32_t gScanFrequency;
extern bool gScanPauseMode;
extern SCAN_CssState_t gScanCssState;
extern volatile bool gScheduleScanListen;
extern volatile uint16_t ScanPauseDelayIn10msec;
extern volatile uint16_t ScanPauseDelayIn_10ms;
extern uint8_t gScanProgressIndicator;
extern uint8_t gScanHitCount;
extern bool gScanUseCssResult;

14
audio.c
View File

@ -62,7 +62,7 @@
VOICE_ID_t gVoiceID[8];
uint8_t gVoiceReadIndex;
uint8_t gVoiceWriteIndex;
volatile uint16_t gCountdownToPlayNextVoice;
volatile uint16_t gCountdownToPlayNextVoice_10ms;
volatile bool gFlagPlayQueuedVoice;
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
@ -283,9 +283,9 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
return;
}
gVoiceReadIndex = 1;
gCountdownToPlayNextVoice = Delay;
gFlagPlayQueuedVoice = false;
gVoiceReadIndex = 1;
gCountdownToPlayNextVoice_10ms = Delay;
gFlagPlayQueuedVoice = false;
return;
}
@ -390,9 +390,9 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
AUDIO_PlayVoice(VoiceID);
gCountdownToPlayNextVoice = Delay;
gFlagPlayQueuedVoice = false;
gVoxResumeCountdown = 2000;
gCountdownToPlayNextVoice_10ms = Delay;
gFlagPlayQueuedVoice = false;
gVoxResumeCountdown = 2000;
return;
}

View File

@ -132,7 +132,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep);
extern VOICE_ID_t gVoiceID[8];
extern uint8_t gVoiceReadIndex;
extern uint8_t gVoiceWriteIndex;
extern volatile uint16_t gCountdownToPlayNextVoice;
extern volatile uint16_t gCountdownToPlayNextVoice_10ms;
extern volatile bool gFlagPlayQueuedVoice;
extern VOICE_ID_t gAnotherVoiceID;

View File

@ -227,7 +227,7 @@ const uint8_t BITMAP_VOX[] =
};
#endif
const uint8_t BITMAP_TDR[] =
const uint8_t BITMAP_TDR1[] =
{ // "DW"
0b00000000,
0b01111111,
@ -244,6 +244,23 @@ const uint8_t BITMAP_TDR[] =
0b01111111
};
const uint8_t BITMAP_TDR2[] =
{ // "--"
0b00000000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
};
#ifdef ENABLE_VOICE
const uint8_t BITMAP_VoicePrompt[] =
{

View File

@ -26,7 +26,8 @@ extern const uint8_t BITMAP_VOX[18];
extern const uint8_t BITMAP_XB[12];
#endif
extern const uint8_t BITMAP_TDR[12];
extern const uint8_t BITMAP_TDR1[12];
extern const uint8_t BITMAP_TDR2[12];
#ifdef ENABLE_VOICE
extern const uint8_t BITMAP_VoicePrompt[9];

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -64,22 +64,24 @@ void FUNCTION_Init(void)
// gDTMF_ReceivedSaved[0] = '\0';
#endif
g_CxCSS_TAIL_Found = false;
g_CDCSS_Lost = false;
g_CTCSS_Lost = false;
g_CxCSS_TAIL_Found = false;
g_CDCSS_Lost = false;
g_CTCSS_Lost = false;
g_VOX_Lost = false;
g_SquelchLost = false;
gFlagTteComplete = false;
g_VOX_Lost = false;
g_SquelchLost = false;
gTailNoteEliminationCountdown = 0;
gFoundCTCSS = false;
gFoundCDCSS = false;
gFoundCTCSSCountdown = 0;
gFoundCDCSSCountdown = 0;
gEndOfRxDetectedMaybe = false;
gFlagTailNoteEliminationComplete = false;
gTailNoteEliminationCountdown_10ms = 0;
gFoundCTCSS = false;
gFoundCDCSS = false;
gFoundCTCSSCountdown_10ms = 0;
gFoundCDCSSCountdown_10ms = 0;
gEndOfRxDetectedMaybe = false;
gSystickCountdown2 = 0;
#ifdef ENABLE_NOAA
gNOAACountdown_10ms = 0;
#endif
}
void FUNCTION_Select(FUNCTION_Type_t Function)
@ -132,15 +134,16 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
break;
case FUNCTION_POWER_SAVE:
gBatterySave = gEeprom.BATTERY_SAVE * 10;
gRxIdleMode = true;
gBatterySave_10ms = gEeprom.BATTERY_SAVE * 10;
gBatterySaveExpired = false;
gRxIdleMode = true;
BK4819_DisableVox();
BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
gBatterySaveCountdownExpired = false;
gUpdateStatus = true;
gUpdateStatus = true;
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
@ -195,9 +198,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
break;
}
gBatterySaveCountdown = battery_save_count_10ms;
gSchedulePowerSave = false;
gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdownExpired = false;
#if defined(ENABLE_FMRADIO)
gFM_RestoreCountdown = 0;
gFM_RestoreCountdown = 0;
#endif
}

View File

@ -31,7 +31,9 @@ bool gChargingWithTypeC;
bool gLowBattery;
bool gLowBatteryBlink;
uint16_t gBatteryCheckCounter;
volatile uint16_t gBatterySave;
volatile uint16_t gBatterySave_10ms;
volatile bool gBatterySaveExpired;
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
{

View File

@ -30,7 +30,9 @@ extern bool gChargingWithTypeC;
extern bool gLowBattery;
extern bool gLowBatteryBlink;
extern uint16_t gBatteryCheckCounter;
extern volatile uint16_t gBatterySave;
extern volatile uint16_t gBatterySave_10ms;
extern volatile bool gBatterySaveExpired;
void BATTERY_GetReadings(bool bDisplayBatteryLevel);

15
main.c
View File

@ -16,7 +16,6 @@
#include <string.h>
#include "scheduler.h"
#include "app/app.h"
#include "app/dtmf.h"
#include "audio.h"
@ -98,6 +97,10 @@ void Main(void)
gMenuListCount = 0;
#ifdef ENABLE_BOOT_BEEPS
boot_counter_10ms = 250; // 2.5 sec
#endif
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);
@ -124,14 +127,18 @@ void Main(void)
if (gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_NONE)
{ // 2.55 second boot-up screen
while (boot_counter < 255 && KEYBOARD_Poll() == KEY_INVALID)
while (boot_counter_10ms > 0)
{
if (KEYBOARD_Poll() != KEY_INVALID)
{ // halt boot beeps
boot_counter_10ms = 0;
break;
}
#ifdef ENABLE_BOOT_BEEPS
if ((boot_counter % 25) == 0)
if ((boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
}
//boot_counter = 255; // halt boot beeps
}
BootMode = BOOT_GetMode();

36
misc.c
View File

@ -43,9 +43,9 @@ const uint16_t dual_watch_count_after_tx_10ms = 3600 / 10; // 3.6 sec af
const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec after RX ends ?
const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec
const uint16_t dual_watch_count_after_2_10ms = 3600 / 10; // 3.6 sec
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms
const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
@ -81,13 +81,18 @@ uint16_t gEEPROM_1F8C;
uint8_t gMR_ChannelAttributes[207];
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
volatile bool gBatterySaveCountdownExpired;
volatile uint16_t gDualWatchCountdown_10ms;
volatile bool gDualWatchCountdownExpired = true;
bool gDualWatchActive = false;
volatile bool gNextTimeslice500ms;
volatile uint16_t gBatterySaveCountdown = battery_save_count_10ms;
volatile uint16_t gDualWatchCountdown;
volatile uint16_t gTxTimerCountdown;
volatile uint16_t gTailNoteEliminationCountdown;
volatile uint16_t gTailNoteEliminationCountdown_10ms;
#ifdef ENABLE_NOAA
volatile uint16_t gNOAA_Countdown;
volatile uint16_t gNOAA_Countdown_10ms;
#endif
bool gEnableSpeaker;
@ -179,21 +184,22 @@ bool gF_LOCK;
uint8_t gShowChPrefix;
volatile bool gNextTimeslice;
volatile uint16_t gSystickCountdown2;
volatile uint8_t gFoundCDCSSCountdown;
volatile uint8_t gFoundCTCSSCountdown;
volatile uint16_t gVoxStopCountdown;
volatile uint8_t gFoundCDCSSCountdown_10ms;
volatile uint8_t gFoundCTCSSCountdown_10ms;
volatile uint16_t gVoxStopCountdown_10ms;
volatile bool gTxTimeoutReached;
volatile bool gNextTimeslice40ms;
volatile bool gSchedulePowerSave;
volatile bool gBatterySaveCountdownExpired;
volatile bool gScheduleDualWatch = true;
#ifdef ENABLE_NOAA
volatile bool gScheduleNOAA = true;
volatile uint16_t gNOAACountdown_10ms = 0;
volatile bool gScheduleNOAA = true;
#endif
volatile bool gFlagTteComplete;
volatile bool gFlagTailNoteEliminationComplete;
#ifdef ENABLE_FMRADIO
volatile bool gScheduleFM;
volatile bool gScheduleFM;
#endif
#ifdef ENABLE_BOOT_BEEPS
volatile uint8_t boot_counter_10ms;
#endif
uint16_t gCurrentRSSI;

29
misc.h
View File

@ -139,16 +139,21 @@ extern uint16_t gEEPROM_1F8C;
extern uint8_t gMR_ChannelAttributes[207];
extern volatile uint16_t gBatterySaveCountdown_10ms;
extern volatile bool gBatterySaveCountdownExpired;
extern volatile uint16_t gDualWatchCountdown_10ms;
extern volatile bool gDualWatchCountdownExpired;
extern bool gDualWatchActive;
extern volatile bool gNextTimeslice500ms;
extern volatile uint16_t gBatterySaveCountdown;
extern volatile uint16_t gDualWatchCountdown;
extern volatile uint16_t gTxTimerCountdown;
extern volatile uint16_t gTailNoteEliminationCountdown;
extern volatile uint16_t gTailNoteEliminationCountdown_10ms;
#ifdef ENABLE_FMRADIO
extern volatile uint16_t gFmPlayCountdown_10ms;
#endif
#ifdef ENABLE_NOAA
extern volatile uint16_t gNOAA_Countdown;
extern volatile uint16_t gNOAA_Countdown_10ms;
#endif
extern bool gEnableSpeaker;
extern uint8_t gKeyInputCountdown;
@ -235,24 +240,24 @@ extern bool gUpdateDisplay;
#endif
extern bool gF_LOCK;
extern uint8_t gShowChPrefix;
extern volatile uint16_t gSystickCountdown2;
extern volatile uint8_t gFoundCDCSSCountdown;
extern volatile uint8_t gFoundCTCSSCountdown;
extern volatile uint16_t gVoxStopCountdown;
extern volatile uint8_t gFoundCDCSSCountdown_10ms;
extern volatile uint8_t gFoundCTCSSCountdown_10ms;
extern volatile uint16_t gVoxStopCountdown_10ms;
extern volatile bool gTxTimeoutReached;
extern volatile bool gNextTimeslice40ms;
extern volatile bool gSchedulePowerSave;
extern volatile bool gBatterySaveCountdownExpired;
extern volatile bool gScheduleDualWatch;
#ifdef ENABLE_NOAA
extern volatile uint16_t gNOAACountdown_10ms;
extern volatile bool gScheduleNOAA;
#endif
extern volatile bool gFlagTteComplete;
extern volatile bool gFlagTailNoteEliminationComplete;
#ifdef ENABLE_FMRADIO
extern volatile bool gScheduleFM;
#endif
extern uint16_t gCurrentRSSI;
extern uint8_t gIsLocked;
#ifdef ENABLE_BOOT_BEEPS
extern volatile uint8_t boot_counter_10ms;
#endif
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits);

18
radio.c
View File

@ -767,10 +767,10 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST)
{
gIsNoaaMode = true;
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
gNOAA_Countdown = 50;
gScheduleNOAA = false;
gIsNoaaMode = true;
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
gNOAA_Countdown_10ms = 50; // 500ms
gScheduleNOAA = false;
}
else
gIsNoaaMode = false;
@ -877,15 +877,19 @@ void RADIO_PrepareTX(void)
{
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
gDualWatchCountdown = dual_watch_count_after_tx_10ms;
gScheduleDualWatch = false;
gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms;
gDualWatchCountdownExpired = false;
if (!gRxVfoIsActive)
{
gEeprom.RX_CHANNEL = gEeprom.TX_CHANNEL;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_CHANNEL];
gRxVfoIsActive = true;
}
gRxVfoIsActive = true;
// let the user see that DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
}
RADIO_SelectCurrentVfo();

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
#include "scheduler.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
@ -29,17 +28,20 @@
#include "bsp/dp32g030/gpio.h"
#include "driver/gpio.h"
#define DECREMENT(cnt) \
do { \
if (cnt > 0) \
cnt--; \
} while (0)
#define DECREMENT_AND_TRIGGER(cnt, flag) \
do { \
if (cnt) { \
if (--cnt == 0) { \
flag = true; \
} \
} \
} while(0)
do { \
if (cnt > 0) \
if (--cnt == 0) \
flag = true; \
} while (0)
static volatile uint32_t gGlobalSysTickCounter;
volatile uint8_t boot_counter = 0;
void SystickHandler(void);
@ -59,40 +61,39 @@ void SystickHandler(void)
if ((gGlobalSysTickCounter & 3) == 0)
gNextTimeslice40ms = true;
if (gSystickCountdown2)
gSystickCountdown2--;
#ifdef ENABLE_NOAA
DECREMENT(gNOAACountdown_10ms);
#endif
if (gFoundCDCSSCountdown)
gFoundCDCSSCountdown--;
DECREMENT(gFoundCDCSSCountdown_10ms);
if (gFoundCTCSSCountdown)
gFoundCTCSSCountdown--;
DECREMENT(gFoundCTCSSCountdown_10ms);
if (gCurrentFunction == FUNCTION_FOREGROUND)
DECREMENT_AND_TRIGGER(gBatterySaveCountdown, gSchedulePowerSave);
DECREMENT_AND_TRIGGER(gBatterySaveCountdown_10ms, gBatterySaveCountdownExpired);
if (gCurrentFunction == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(gBatterySave, gBatterySaveCountdownExpired);
DECREMENT_AND_TRIGGER(gBatterySave_10ms, gBatterySaveExpired);
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gDualWatchCountdown, gScheduleDualWatch);
DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gDualWatchCountdownExpired);
#ifdef ENABLE_NOAA
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
if (gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gNOAA_Countdown, gScheduleNOAA);
DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA);
#endif
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
DECREMENT_AND_TRIGGER(ScanPauseDelayIn10msec, gScheduleScanListen);
DECREMENT_AND_TRIGGER(ScanPauseDelayIn_10ms, gScheduleScanListen);
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown, gFlagTteComplete);
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete);
#ifdef ENABLE_VOICE
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);
#endif
#ifdef ENABLE_FMRADIO
@ -101,9 +102,9 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(gFmPlayCountdown_10ms, gScheduleFM);
#endif
if (gVoxStopCountdown)
gVoxStopCountdown--;
DECREMENT(gVoxStopCountdown_10ms);
if (boot_counter < 255)
boot_counter++;
#ifdef ENABLE_BOOT_BEEPS
DECREMENT(boot_counter_10ms);
#endif
}

View File

@ -1,25 +0,0 @@
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include <stdint.h>
extern volatile uint8_t boot_counter;
#endif

View File

@ -76,7 +76,7 @@ void UI_DisplayMain(void)
}
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive)
Channel = gEeprom.RX_CHANNEL;
Channel = gEeprom.RX_CHANNEL; // we're currently monitoring the other VFO
if (Channel != vfo_num)
{

View File

@ -55,7 +55,12 @@ void UI_DisplayStatus(const bool test_display)
#endif
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display)
memmove(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR));
{
if (gDualWatchActive)
memmove(gStatusLine + 45, BITMAP_TDR1, sizeof(BITMAP_TDR1));
else
memmove(gStatusLine + 45, BITMAP_TDR2, sizeof(BITMAP_TDR2));
}
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
memmove(gStatusLine + 58, BITMAP_XB, sizeof(BITMAP_XB));