Skip to content

Commit

Permalink
Increased menu BATCAL, F-CALI and BATVOL timeouts to 2 mins + disable…
Browse files Browse the repository at this point in the history
… TX when serial config upload/download in progress
  • Loading branch information
OneOfEleven committed Oct 2, 2023
1 parent bf2564b commit 87d1cf7
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 99 deletions.
6 changes: 4 additions & 2 deletions am_fix.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,10 @@ const uint8_t orig_pga = 6; // -3dB
gain_table_index[vfo] = (index <= max_index) ? index : max_index; // limit the gain index
}

if (gain_table_index[vfo] == gain_table_index_prev[vfo])
return; // no gain change
#if 0
if (gain_table_index[vfo] == gain_table_index_prev[vfo])
return; // no gain change
#endif

#endif

Expand Down
149 changes: 72 additions & 77 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,47 +1281,21 @@ void APP_CheckKeys(void)

if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT released
#if 0
// denoise the PTT
unsigned int i = 6; // test the PTT button for 6ms
unsigned int count = 0;
while (i-- > 0)
{
SYSTEM_DelayMs(1);

if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT pressed
if (count > 0)
count--;
continue;
}
if (++count < 3)
continue;

// stop transmitting
APP_ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
break;
}
#else
if (++gPttDebounceCounter >= 3) // 30ms
{ // stop transmitting
APP_ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
}
#endif
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0)
{ // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || gSerialConfigCountDown_500ms > 0) // 30ms
{ // stop transmitting
APP_ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
}
}
else
gPttDebounceCounter = 0;
}
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
Expand Down Expand Up @@ -1739,6 +1713,16 @@ void APP_TimeSlice500ms(void)
if (--gDTMF_RX_timeout == 0)
DTMF_clear_RX();

if (gSerialConfigCountDown_500ms > 0)
{
gReducedService = true; // a serial config upload/download is in progress

// if (gCurrentFunction == FUNCTION_TRANSMIT)
// { // stop transmitting
//
// }
}

// Skipped authentic device check

#ifdef ENABLE_FMRADIO
Expand Down Expand Up @@ -1815,6 +1799,8 @@ void APP_TimeSlice500ms(void)
if (gScanState == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#endif
{
bool exit_menu = false;

if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode)
{
if (--gKeyLockCountdown == 0)
Expand All @@ -1823,52 +1809,55 @@ void APP_TimeSlice500ms(void)
gUpdateStatus = true; // lock symbol needs showing
}

if (gVoltageMenuCountdown > 0)
if (gMenuCountdown > 0)
if (--gMenuCountdown == 0)
exit_menu = true; // exit menu mode

if (exit_menu)
{
if (--gVoltageMenuCountdown == 0)
gMenuCountdown = 0;

if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU)
{
if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU)
{
gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}

if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);

if (gScreenToDisplay == DISPLAY_SCANNER)
{
BK4819_StopScan();

RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
if (gScreenToDisplay == DISPLAY_SCANNER)
{
BK4819_StopScan();

RADIO_SetupRegisters(true);
}
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);

gWasFKeyPressed = false;
gUpdateStatus = true;
gInputBoxIndex = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;

#ifdef ENABLE_FMRADIO
if (gFmRadioMode &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
GUI_SelectNextDisplay(DISPLAY_FM);
}
else
#endif
#ifndef ENABLE_CODE_SCAN_TIMEOUT
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
GUI_SelectNextDisplay(DISPLAY_MAIN);
RADIO_SetupRegisters(true);
}

gWasFKeyPressed = false;
gUpdateStatus = true;
gInputBoxIndex = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;

#ifdef ENABLE_FMRADIO
if (gFmRadioMode &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
GUI_SelectNextDisplay(DISPLAY_FM);
}
else
#endif
#ifndef ENABLE_CODE_SCAN_TIMEOUT
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
}
}
Expand Down Expand Up @@ -2117,8 +2106,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
else
{
if (Key != KEY_PTT)
gVoltageMenuCountdown = menu_timeout_500ms;

{
gMenuCountdown = menu_timeout_500ms;
}

BACKLIGHT_TurnOn();

if (gDTMF_DecodeRingCountdown_500ms > 0)
Expand Down Expand Up @@ -2360,6 +2351,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

if (gFlagAcceptSetting)
{
gMenuCountdown = menu_timeout_500ms;

MENU_AcceptSetting();

gFlagRefreshSetting = true;
Expand Down Expand Up @@ -2467,6 +2460,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gFlagRefreshSetting)
{
gFlagRefreshSetting = false;
gMenuCountdown = menu_timeout_500ms;

MENU_ShowCurrentSetting();
}

Expand Down
1 change: 0 additions & 1 deletion app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (bFlag)
{
gFlagRefreshSetting = true;
gFlagBackupSetting = true;

gRequestDisplayScreen = DISPLAY_MENU;

Expand Down
26 changes: 15 additions & 11 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,12 +1107,6 @@ void MENU_ShowCurrentSetting(void)
default:
return;
}

// if (gFlagBackupSetting)
{ // save a copy incase the user wants to back out
// gFlagBackupSetting = false;
gSubMenuSelection_original = gSubMenuSelection;
}
}

static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Expand Down Expand Up @@ -1166,7 +1160,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
gMenuCursor = Value - 1;
gFlagRefreshSetting = true;
gFlagBackupSetting = true;
return;
}

Expand All @@ -1182,7 +1175,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
gMenuCursor = Value - 1;
gFlagRefreshSetting = true;
gFlagBackupSetting = true;
return;
}
break;
Expand Down Expand Up @@ -1595,7 +1587,6 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1);

gFlagRefreshSetting = true;
gFlagBackupSetting = true;

gRequestDisplayScreen = DISPLAY_MENU;

Expand Down Expand Up @@ -1715,6 +1706,19 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
break;
}

if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL)
gVoltageMenuCountdown = menu_timeout_500ms;
if (gScreenToDisplay == DISPLAY_MENU)
{
if (gMenuCursor == MENU_VOL ||
#ifdef ENABLE_F_CAL_MENU
gMenuCursor == MENU_F_CALI ||
#endif
gMenuCursor == MENU_BATCAL)
{
gMenuCountdown = menu_timeout_long_500ms;
}
else
{
gMenuCountdown = menu_timeout_500ms;
}
}
}
19 changes: 19 additions & 0 deletions app/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,17 @@ static void CMD_0514(const uint8_t *pBuffer)
const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer;

Timestamp = pCmd->Timestamp;

#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
#endif

gSerialConfigCountDown_500ms = 6; // 3 sec
gSerialConfigCountDown_done = false;

// turn the LCD backlight off
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);

SendVersion();
}

Expand All @@ -241,9 +248,13 @@ static void CMD_051B(const uint8_t *pBuffer)
if (pCmd->Timestamp != Timestamp)
return;

gSerialConfigCountDown_500ms = 6; // 3 sec
gSerialConfigCountDown_done = false;

#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
#endif

memset(&Reply, 0, sizeof(Reply));
Reply.Header.ID = 0x051C;
Reply.Header.Size = pCmd->Size + 4;
Expand All @@ -269,11 +280,15 @@ static void CMD_051D(const uint8_t *pBuffer)
if (pCmd->Timestamp != Timestamp)
return;

gSerialConfigCountDown_500ms = 6; // 3 sec
gSerialConfigCountDown_done = false;

bReloadEeprom = false;

#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
#endif

Reply.Header.ID = 0x051E;
Reply.Header.Size = sizeof(Reply.Data);
Reply.Data.Offset = pCmd->Offset;
Expand Down Expand Up @@ -389,8 +404,12 @@ static void CMD_052F(const uint8_t *pBuffer)
if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);

gSerialConfigCountDown_500ms = 6; // 3 sec
gSerialConfigCountDown_done = false;

Timestamp = pCmd->Timestamp;

// turn the LCD backlight off
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);

SendVersion();
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
9 changes: 6 additions & 3 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms
const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds
const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds

const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes

const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen
const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver
Expand Down Expand Up @@ -124,6 +125,9 @@ volatile uint16_t gDualWatchCountdown_10ms;
volatile bool gDualWatchCountdownExpired = true;
bool gDualWatchActive = false;

volatile uint8_t gSerialConfigCountDown_500ms;
volatile bool gSerialConfigCountDown_done;

volatile bool gNextTimeslice_500ms;

volatile uint16_t gTxTimerCountdown_500ms;
Expand Down Expand Up @@ -155,7 +159,7 @@ bool gUpdateRSSI;
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
AlarmState_t gAlarmState;
#endif
uint8_t gVoltageMenuCountdown;
uint16_t gMenuCountdown;
bool gPttWasReleased;
bool gPttWasPressed;
uint8_t gKeypadLocked;
Expand All @@ -172,7 +176,6 @@ bool gFlagPrepareTX;

bool gFlagAcceptSetting;
bool gFlagRefreshSetting;
bool gFlagBackupSetting;

bool gFlagSaveVfo;
bool gFlagSaveSettings;
Expand Down
Loading

0 comments on commit 87d1cf7

Please sign in to comment.