0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 14:51:26 +03:00

Stop TX transmitting out of allowed frequency range when alarm is activated

This commit is contained in:
OneOfEleven 2023-10-06 19:31:29 +01:00
parent 5397b3ee88
commit b385b53af0
23 changed files with 423 additions and 388 deletions

View File

@ -35,7 +35,7 @@ ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 0 ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1 ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1 #ENABLE_PANADAPTER := 1
############################################################# #############################################################
@ -305,8 +305,8 @@ endif
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1) ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
CFLAGS += -DENABLE_SINGLE_VFO_CHAN CFLAGS += -DENABLE_SINGLE_VFO_CHAN
endif endif
ifeq ($(ENABLE_BAND_SCOPE),1) ifeq ($(ENABLE_PANADAPTER),1)
CFLAGS += -DENABLE_BAND_SCOPE CFLAGS += -DENABLE_PANADAPTER
endif endif
LDFLAGS = LDFLAGS =

View File

@ -56,7 +56,7 @@ ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status
ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan)
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now) ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it) ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it)
ENABLE_SQUELCH_MORE_SENSITIVE := 0 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves
ENABLE_FASTER_CHANNEL_SCAN := 0 increases the channel scan speed, but the squelch is also made more twitchy ENABLE_FASTER_CHANNEL_SCAN := 0 increases the channel scan speed, but the squelch is also made more twitchy
ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols
ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing
@ -75,6 +75,25 @@ ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO
* *
* Long-press '*' .. Start scanning, then toggles the scanning between scanlists 1, 2 or ALL channels * Long-press '*' .. Start scanning, then toggles the scanning between scanlists 1, 2 or ALL channels
# Edit channel/memory name
1. Press Menu button
2. Scroll to "CH NAM" (around number 17)
3. Press the Menu button to enter
4. Use up/down keys to choose the desired channel to edit
5. Press the Menu button again to enter edit name mode
6. Use the up/down keys to cycle through the letters etc
7. Press the Menu button again to move to the next character position
8. Repeat steps 6 and/or 7 till you reach the end
9. When it pops up the "Sure?" text, press Menu button to save, or Exit to cancel
Press the Exit button at any time to cancel the edit and return to the main menu.
Sounds a lot/complicated but once you done it a couple of times you'll be fine (hopefully).
When you're editing the name, you can enter digits (0 ~ 9) directly without having to use the up/down
buttons to find them.
# Some changes made from the Quansheng firmware # Some changes made from the Quansheng firmware
* Various Quansheng firmware bugs fixed * Various Quansheng firmware bugs fixed

View File

@ -334,10 +334,10 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gDTMF_InputIndex > 0) if (gDTMF_InputBox_Index > 0)
{ {
gDTMF_InputBox[--gDTMF_InputIndex] = '-'; gDTMF_InputBox[--gDTMF_InputBox_Index] = '-';
if (gDTMF_InputIndex > 0) if (gDTMF_InputBox_Index > 0)
{ {
gPttWasReleased = true; gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;

327
app/app.c
View File

@ -1367,27 +1367,20 @@ void APP_CheckKeys(void)
return; return;
} }
if (gDebounceCounter < key_repeat_delay_10ms)
return;
// key is being held pressed // key is being held pressed
if (gDebounceCounter == key_repeat_delay_10ms) if (gDebounceCounter == key_repeat_delay_10ms)
{ // initial delay after pressed { // initial key repeat delay after pressed
if (Key == KEY_STAR || if (Key != KEY_PTT)
Key == KEY_F ||
Key == KEY_SIDE2 ||
Key == KEY_SIDE1 ||
Key == KEY_UP ||
Key == KEY_DOWN ||
Key == KEY_EXIT ||
Key == KEY_MENU ||
(Key >= KEY_0 && Key <= KEY_9)) // keys 0-9 can be held down to bypass pressing the F-Key
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true); APP_ProcessKey(Key, true, true);
} }
return;
} }
else
if (gDebounceCounter > key_repeat_delay_10ms)
{ // key repeat { // key repeat
if (Key == KEY_UP || Key == KEY_DOWN) if (Key == KEY_UP || Key == KEY_DOWN)
{ {
@ -1400,7 +1393,6 @@ void APP_CheckKeys(void)
return; return;
gDebounceCounter = key_repeat_delay_10ms; gDebounceCounter = key_repeat_delay_10ms;
return;
} }
} }
@ -1433,34 +1425,23 @@ void APP_TimeSlice10ms(void)
if (gCurrentFunction != FUNCTION_POWER_SAVE || !gRxIdleMode) if (gCurrentFunction != FUNCTION_POWER_SAVE || !gRxIdleMode)
APP_CheckRadioInterrupts(); APP_CheckRadioInterrupts();
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // receiving
if (gUpdateStatus)
UI_DisplayStatus(false);
if (gUpdateDisplay)
{
gUpdateDisplay = false;
GUI_DisplayScreen();
}
}
else
{ // transmitting { // transmitting
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms
UI_DisplayAudioBar(); UI_DisplayAudioBar();
#endif #endif
if (gUpdateDisplay)
{
gUpdateDisplay = false;
GUI_DisplayScreen();
}
if (gUpdateStatus)
UI_DisplayStatus(false);
} }
if (gUpdateDisplay)
{
gUpdateDisplay = false;
GUI_DisplayScreen();
}
if (gUpdateStatus)
UI_DisplayStatus(false);
// Skipping authentic device checks // Skipping authentic device checks
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -1699,22 +1680,31 @@ void APP_TimeSlice10ms(void)
void cancelUserInputModes(void) void cancelUserInputModes(void)
{ {
gKeyInputCountdown = 0; gKeyInputCountdown = 0;
if (gDTMF_InputMode || gInputBoxIndex > 0)
if (gDTMF_InputMode || gDTMF_InputBox_Index > 0)
// if (gDTMF_InputMode || gInputBoxIndex > 0)
{ {
memset(gDTMF_String, 0, sizeof(gDTMF_String)); DTMF_clear_input_box();
gDTMF_InputMode = false; gDTMF_PreviousIndex = 0;
gDTMF_InputIndex = 0;
gInputBoxIndex = 0; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
gUpdateDisplay = true;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; if (gWasFKeyPressed)
{
gWasFKeyPressed = false;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gUpdateStatus = true;
} }
} }
// this is called once every 500ms // this is called once every 500ms
void APP_TimeSlice500ms(void) void APP_TimeSlice500ms(void)
{ {
bool exit_menu = false;
// Skipped authentic device check // Skipped authentic device check
if (gKeypadLocked > 0) if (gKeypadLocked > 0)
@ -1722,9 +1712,19 @@ void APP_TimeSlice500ms(void)
gUpdateDisplay = true; gUpdateDisplay = true;
if (gKeyInputCountdown > 0) if (gKeyInputCountdown > 0)
{
if (--gKeyInputCountdown == 0) if (--gKeyInputCountdown == 0)
{
cancelUserInputModes(); cancelUserInputModes();
if (gBeepToPlay != BEEP_NONE)
{
AUDIO_PlayBeep(gBeepToPlay);
gBeepToPlay = BEEP_NONE;
}
}
}
if (gDTMF_RX_live_timeout > 0) if (gDTMF_RX_live_timeout > 0)
{ {
#ifdef ENABLE_RSSI_BAR #ifdef ENABLE_RSSI_BAR
@ -1743,15 +1743,14 @@ void APP_TimeSlice500ms(void)
} }
} }
if (gMenuCountdown > 0)
if (--gMenuCountdown == 0)
exit_menu = (gScreenToDisplay == DISPLAY_MENU); // exit menu mode
if (gDTMF_RX_timeout > 0) if (gDTMF_RX_timeout > 0)
if (--gDTMF_RX_timeout == 0) if (--gDTMF_RX_timeout == 0)
DTMF_clear_RX(); DTMF_clear_RX();
if (gSerialConfigCountDown_500ms > 0)
{
// gReducedService = true; // a serial config upload/download is in progress
}
// Skipped authentic device check // Skipped authentic device check
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -1763,6 +1762,16 @@ void APP_TimeSlice500ms(void)
} }
#endif #endif
if (gBacklightCountdown > 0 && !gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
if (gScreenToDisplay != DISPLAY_MENU || gMenuCursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option
if (--gBacklightCountdown == 0)
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
if (gSerialConfigCountDown_500ms > 0)
{
}
if (gReducedService) if (gReducedService)
{ {
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
@ -1802,94 +1811,90 @@ void APP_TimeSlice500ms(void)
#endif #endif
} }
if (gCurrentFunction != FUNCTION_TRANSMIT) #ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
#else
if (gCssScanMode == CSS_SCAN_MODE_OFF)
#endif
{ {
if (gCurrentFunction != FUNCTION_POWER_SAVE) #ifdef ENABLE_AIRCOPY
updateRSSI(gEeprom.RX_VFO); if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
#else #else
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#endif #endif
{ {
if (gBacklightCountdown > 0) if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode)
if (gScreenToDisplay != DISPLAY_MENU || gMenuCursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option
if (--gBacklightCountdown == 0)
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
#ifdef ENABLE_AIRCOPY
if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#else
if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#endif
{ {
bool exit_menu = false; if (--gKeyLockCountdown == 0)
gEeprom.KEY_LOCK = true; // lock the keyboard
gUpdateStatus = true; // lock symbol needs showing
}
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) if (exit_menu)
{
gMenuCountdown = 0;
if (gEeprom.BACKLIGHT == 0)
{ {
if (--gKeyLockCountdown == 0) gBacklightCountdown = 0;
gEeprom.KEY_LOCK = true; // lock the keyboard GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
gUpdateStatus = true; // lock symbol needs showing
} }
if (gMenuCountdown > 0) if (gInputBoxIndex > 0 || gDTMF_InputMode)
if (--gMenuCountdown == 0) AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
exit_menu = true; // exit menu mode /*
if (gScreenToDisplay == DISPLAY_SCANNER)
if (exit_menu)
{ {
gMenuCountdown = 0; BK4819_StopScan();
if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU) RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
{ RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU) RADIO_SetupRegisters(true);
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); }
*/
DTMF_clear_input_box();
if (gScreenToDisplay == DISPLAY_SCANNER) gWasFKeyPressed = false;
{ gInputBoxIndex = 0;
BK4819_StopScan();
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); gAskToSave = false;
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); gAskToDelete = false;
RADIO_SetupRegisters(true); gUpdateStatus = true;
} gUpdateDisplay = true;
gWasFKeyPressed = false; {
gUpdateStatus = true; GUI_DisplayType_t disp = DISPLAY_INVALID;
gInputBoxIndex = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode && if (gFmRadioMode &&
gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT) gCurrentFunction != FUNCTION_TRANSMIT)
{ {
GUI_SelectNextDisplay(DISPLAY_FM); disp = DISPLAY_FM;
} }
else
#endif #endif
#ifndef ENABLE_CODE_SCAN_TIMEOUT
if (gScreenToDisplay != DISPLAY_SCANNER) if (disp == DISPLAY_INVALID)
#endif {
GUI_SelectNextDisplay(DISPLAY_MAIN); #ifndef ENABLE_CODE_SCAN_TIMEOUT
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
disp = DISPLAY_MAIN;
}
if (disp != DISPLAY_INVALID)
GUI_SelectNextDisplay(disp);
} }
} }
} }
} }
if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT)
updateRSSI(gEeprom.RX_VFO);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0)
{ {
@ -1947,7 +1952,7 @@ void APP_TimeSlice500ms(void)
//if (gCurrentFunction != FUNCTION_POWER_SAVE) //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_Configure_GPIO_B11(); ST7565_HardwareReset();
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight off
@ -1985,6 +1990,7 @@ void APP_TimeSlice500ms(void)
if (gDTMF_DecodeRingCountdown_500ms > 0) if (gDTMF_DecodeRingCountdown_500ms > 0)
{ // make "ring-ring" sound { // make "ring-ring" sound
gDTMF_DecodeRingCountdown_500ms--; gDTMF_DecodeRingCountdown_500ms--;
AUDIO_PlayBeep(BEEP_880HZ_200MS); AUDIO_PlayBeep(BEEP_880HZ_200MS);
} }
} }
@ -2074,6 +2080,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
bool bFlag = false; bool bFlag = false;
if (Key == KEY_INVALID)
return;
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
if (Key == KEY_EXIT && !backlight_was_on && gEeprom.BACKLIGHT > 0) if (Key == KEY_EXIT && !backlight_was_on && gEeprom.BACKLIGHT > 0)
@ -2189,14 +2198,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
if (Key != KEY_PTT && if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F)
Key != KEY_UP &&
Key != KEY_DOWN &&
Key != KEY_EXIT &&
Key != KEY_SIDE1 &&
Key != KEY_SIDE2 &&
Key != KEY_STAR &&
Key != KEY_MENU)
{ {
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
{ // FREQ/CTCSS/DCS scanning { // FREQ/CTCSS/DCS scanning
@ -2231,9 +2233,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
if (gWasFKeyPressed && Key > KEY_9 && Key != KEY_F && Key != KEY_STAR) if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
// if (gWasFKeyPressed && Key > KEY_9 && Key != KEY_F && Key != KEY_STAR && Key != KEY_MENU) { // cancel the F-key
{
gWasFKeyPressed = false; gWasFKeyPressed = false;
gUpdateStatus = true; gUpdateStatus = true;
} }
@ -2247,59 +2248,58 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gAlarmState == ALARM_STATE_OFF) if (gAlarmState == ALARM_STATE_OFF)
#endif #endif
{ {
char Code;
if (Key == KEY_PTT) if (Key == KEY_PTT)
{ {
GENERIC_Key_PTT(bKeyPressed); GENERIC_Key_PTT(bKeyPressed);
goto Skip;
}
if (Key == KEY_SIDE2)
{ // transmit 1750Hz tone
Code = 0xFE;
} }
else else
{ {
char Code; Code = DTMF_GetCharacter(Key - KEY_0);
if (Code == 0xFF)
goto Skip;
if (Key == KEY_SIDE2) // transmit DTMF keys
{ // transmit 1750Hz tone }
Code = 0xFE;
} if (!bKeyPressed || bKeyHeld)
else {
if (!bKeyPressed)
{ {
Code = DTMF_GetCharacter(Key - KEY_0); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
if (Code == 0xFF)
goto Skip;
// transmit DTMF keys gEnableSpeaker = false;
}
if (!bKeyPressed || bKeyHeld) BK4819_ExitDTMF_TX(false);
{
if (!bKeyPressed)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = false; if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable)
BK4819_DisableScramble();
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
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
}
BK4819_DisableScramble();
if (Code == 0xFE)
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);
else else
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code); BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
} }
} }
else
{
if (gEeprom.DTMF_SIDE_TONE)
{ // user will here the DTMF tones in speaker
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
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) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
else else
@ -2307,13 +2307,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
ALARM_Off(); ALARM_Off();
// TODO: fix side key 1750, you have to press it twice to restart the tone :(
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
{ FUNCTION_Select(FUNCTION_FOREGROUND);
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
@ -2332,9 +2327,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
case DISPLAY_MAIN: case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
bKeyHeld = false; // allow the channel setting to be saved bKeyHeld = false; // allow the channel setting to be saved
break; break;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -2376,10 +2369,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }
else else
{ if (Key == KEY_EXIT && bKeyHeld)
if (Key == KEY_EXIT && bKeyHeld) cancelUserInputModes();
cancelUserInputModes();
}
Skip: Skip:
if (gBeepToPlay != BEEP_NONE) if (gBeepToPlay != BEEP_NONE)

View File

@ -36,9 +36,9 @@
char gDTMF_String[15]; char gDTMF_String[15];
char gDTMF_InputBox[15]; char gDTMF_InputBox[15];
uint8_t gDTMF_InputIndex = 0; uint8_t gDTMF_InputBox_Index = 0;
bool gDTMF_InputMode = false; bool gDTMF_InputMode = false;
uint8_t gDTMF_PreviousIndex = 0; uint8_t gDTMF_PreviousIndex = 0;
char gDTMF_RX[17]; char gDTMF_RX[17];
uint8_t gDTMF_RX_index = 0; uint8_t gDTMF_RX_index = 0;
@ -133,8 +133,26 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
char DTMF_GetCharacter(const unsigned int code) char DTMF_GetCharacter(const unsigned int code)
{ {
const char list[] = "0123456789ABCD*#"; switch (code)
return (code < ARRAY_SIZE(list)) ? list[code] : 0xFF; {
case KEY_0: return '0';
case KEY_1: return '1';
case KEY_2: return '2';
case KEY_3: return '3';
case KEY_4: return '4';
case KEY_5: return '5';
case KEY_6: return '6';
case KEY_7: return '7';
case KEY_8: return '8';
case KEY_9: return '9';
case KEY_MENU: return 'A';
case KEY_UP: return 'B';
case KEY_DOWN: return 'C';
case KEY_EXIT: return 'D';
case KEY_STAR: return '*';
case KEY_F: return '#';
default: return 0xff;
}
} }
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup) bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup)
@ -163,16 +181,23 @@ DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP; return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
} }
void DTMF_clear_input_box(void)
{
memset(gDTMF_InputBox, 0, sizeof(gDTMF_InputBox));
gDTMF_InputBox_Index = 0;
gDTMF_InputMode = false;
}
void DTMF_Append(const char code) void DTMF_Append(const char code)
{ {
if (gDTMF_InputIndex == 0) if (gDTMF_InputBox_Index == 0)
{ {
memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox)); memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox) - 1);
gDTMF_InputBox[sizeof(gDTMF_InputBox) - 1] = 0; gDTMF_InputBox[sizeof(gDTMF_InputBox) - 1] = 0;
} }
if (gDTMF_InputIndex < sizeof(gDTMF_InputBox)) if (gDTMF_InputBox_Index < (sizeof(gDTMF_InputBox) - 1))
gDTMF_InputBox[gDTMF_InputIndex++] = code; gDTMF_InputBox[gDTMF_InputBox_Index++] = code;
} }
void DTMF_HandleRequest(void) void DTMF_HandleRequest(void)

View File

@ -65,7 +65,7 @@ typedef enum DTMF_CallMode_t DTMF_CallMode_t;
extern char gDTMF_String[15]; extern char gDTMF_String[15];
extern char gDTMF_InputBox[15]; extern char gDTMF_InputBox[15];
extern uint8_t gDTMF_InputIndex; extern uint8_t gDTMF_InputBox_Index;
extern bool gDTMF_InputMode; extern bool gDTMF_InputMode;
extern uint8_t gDTMF_PreviousIndex; extern uint8_t gDTMF_PreviousIndex;
@ -98,6 +98,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult);
char DTMF_GetCharacter(const unsigned int code); char DTMF_GetCharacter(const unsigned int code);
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool bFlag); bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool bFlag);
DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size); DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
void DTMF_clear_input_box(void);
void DTMF_Append(const char vode); void DTMF_Append(const char vode);
void DTMF_HandleRequest(void); void DTMF_HandleRequest(void);
void DTMF_Reply(void); void DTMF_Reply(void);

View File

@ -81,6 +81,9 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gWasFKeyPressed = !gWasFKeyPressed; gWasFKeyPressed = !gWasFKeyPressed;
if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (!gWasFKeyPressed) if (!gWasFKeyPressed)
gAnotherVoiceID = VOICE_ID_CANCEL; gAnotherVoiceID = VOICE_ID_CANCEL;
@ -106,6 +109,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
#endif #endif
gBeepToPlay = BEEP_440HZ_500MS; gBeepToPlay = BEEP_440HZ_500MS;
gPttWasReleased = true; gPttWasReleased = true;
} }
} }
@ -192,64 +196,61 @@ void GENERIC_Key_PTT(bool bKeyPressed)
return; return;
} }
gFlagPrepareTX = true;
if (gDTMF_InputMode)
{
if (gDTMF_InputIndex > 0 || gDTMF_PreviousIndex > 0)
{
if (gDTMF_InputIndex == 0)
gDTMF_InputIndex = gDTMF_PreviousIndex;
gDTMF_InputBox[gDTMF_InputIndex] = 0;
#if 0
// append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long
if (gDTMF_InputIndex == 3)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
else
#else
// append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled
if (gDTMF_InputIndex == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
else
#endif
gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
strcpy(gDTMF_String, gDTMF_InputBox);
gDTMF_PreviousIndex = gDTMF_InputIndex;
gDTMF_ReplyState = DTMF_REPLY_ANI;
gDTMF_State = DTMF_STATE_0;
}
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
gRequestDisplayScreen = DISPLAY_MAIN;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
return;
}
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
gFlagPrepareTX = true; if (!gDTMF_InputMode)
gInputBoxIndex = 0; {
gFlagPrepareTX = true;
gInputBoxIndex = 0;
return;
}
gDTMF_InputMode = false;
// gUpdateDisplay = true;
if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0)
{
if (gDTMF_InputBox_Index == 0)
gDTMF_InputBox_Index = gDTMF_PreviousIndex;
if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox))
gDTMF_InputBox[gDTMF_InputBox_Index] = 0;
#if 0
// append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long
if (gDTMF_InputBox_Index == 3)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
else
#else
// append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled
if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
else
#endif
gDTMF_CallMode = DTMF_CALL_MODE_DTMF;
strcpy(gDTMF_String, gDTMF_InputBox);
gDTMF_PreviousIndex = gDTMF_InputBox_Index;
DTMF_clear_input_box();
gDTMF_ReplyState = DTMF_REPLY_ANI;
gDTMF_State = DTMF_STATE_0;
gFlagPrepareTX = true;
}
return; return;
} }
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
gRequestDisplayScreen = DISPLAY_MAIN;
gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX; gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX;
gUpdateStatus = true;
gFlagStopScan = true; gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true; gFlagResetVfos = true;
gUpdateStatus = true;
} }
else else
{ {

View File

@ -529,7 +529,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex > 0) if (gInputBoxIndex > 0)
{ // cancel key input mode (channel/frequency entry) { // cancel key input mode (channel/frequency entry)
gDTMF_InputMode = false; gDTMF_InputMode = false;
gDTMF_InputIndex = 0; gDTMF_InputBox_Index = 0;
memset(gDTMF_String, 0, sizeof(gDTMF_String)); memset(gDTMF_String, 0, sizeof(gDTMF_String));
gInputBoxIndex = 0; gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
@ -550,6 +550,8 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (bKeyPressed) if (bKeyPressed)
{ // long press MENU key { // long press MENU key
gWasFKeyPressed = false;
if (gScreenToDisplay == DISPLAY_MAIN) if (gScreenToDisplay == DISPLAY_MAIN)
{ {
if (gInputBoxIndex > 0) if (gInputBoxIndex > 0)
@ -634,77 +636,77 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{ {
if (gInputBoxIndex) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ return;
if (gInputBoxIndex > 0)
{ // entering a frequency or DTMF string
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (bKeyHeld || !bKeyPressed) if (bKeyHeld && !gWasFKeyPressed)
{ // long press { // long press .. toggle scanning
if (!bKeyPressed)
return; // released
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
ACTION_Scan(false);
return;
}
if (bKeyHeld || bKeyPressed) if (bKeyPressed)
{ { // just pressed
if (!bKeyHeld) // gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL;
return;
}
if (!bKeyPressed) // just released
return;
ACTION_Scan(false); if (!gWasFKeyPressed)
{ // pressed without the F-key
return;
}
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else #else
if (gScanStateDir == SCAN_OFF) if (gScanStateDir == SCAN_OFF)
#endif #endif
{ { // start entering a DTMF string
gKeyInputCountdown = key_input_timeout_500ms;
memmove(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1));
gDTMF_InputBox_Index = 0;
gDTMF_InputMode = true; gDTMF_InputMode = true;
memmove(gDTMF_InputBox, gDTMF_String, sizeof(gDTMF_InputBox));
gDTMF_InputIndex = 0; gKeyInputCountdown = key_input_timeout_500ms;
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
return;
} }
} }
else else
{ { // with the F-key
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!gWasFKeyPressed)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
gWasFKeyPressed = false; gWasFKeyPressed = false;
gUpdateStatus = true;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gFlagStartScan = true;
gScanSingleFrequency = true;
gBackupCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
}
else
{ {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
} }
#else
gFlagStartScan = true;
gScanSingleFrequency = true;
gBackupCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
#endif #endif
/*
gPttWasReleased = true; // scan the CTCSS/DCS code
gFlagStartScan = true;
gScanSingleFrequency = true;
gBackupCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
*/
ACTION_Scan(false);
} }
gPttWasReleased = true;
gUpdateStatus = true;
} }
static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
@ -712,7 +714,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO]; uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (bKeyHeld || !bKeyPressed) if (bKeyHeld || !bKeyPressed)
{ { // long press
if (gInputBoxIndex > 0) if (gInputBoxIndex > 0)
return; return;
@ -822,7 +825,7 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
if (!bKeyHeld) if (!bKeyHeld)
{ {
const char Character = DTMF_GetCharacter(Key - KEY_0); const char Character = DTMF_GetCharacter(Key);
if (Character != 0xFF) if (Character != 0xFF)
{ // add key to DTMF string { // add key to DTMF string
DTMF_Append(Character); DTMF_Append(Character);

View File

@ -674,7 +674,7 @@ void MENU_AcceptSetting(void)
{ {
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
gDTMF_InputMode = true; gDTMF_InputMode = true;
gDTMF_InputIndex = 3; gDTMF_InputBox_Index = 3;
memmove(gDTMF_InputBox, gDTMF_ID, 4); memmove(gDTMF_InputBox, gDTMF_ID, 4);
gRequestDisplayScreen = DISPLAY_INVALID; gRequestDisplayScreen = DISPLAY_INVALID;
} }

View File

@ -36,8 +36,8 @@ static const struct {
// We are very fortunate. // We are very fortunate.
// The key and pin defines fit together in a single u8, making this very efficient // The key and pin defines fit together in a single u8, making this very efficient
struct { struct {
uint8_t key : 5; // Key 23 is highest KEY_Code_t key : 5;
uint8_t pin : 3; // Pin 6 is highest uint8_t pin : 3; // Pin 6 is highest
} pins[4]; } pins[4];
} keyboard[] = { } keyboard[] = {

View File

@ -21,28 +21,29 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
typedef enum { enum KEY_Code_e {
KEY_INVALID = 0, KEY_0 = 0, // 0
KEY_0, KEY_1, // 1
KEY_1, KEY_2, // 2
KEY_2, KEY_3, // 3
KEY_3, KEY_4, // 4
KEY_4, KEY_5, // 5
KEY_5, KEY_6, // 6
KEY_6, KEY_7, // 7
KEY_7, KEY_8, // 8
KEY_8, KEY_9, // 9
KEY_9, KEY_MENU, // A
KEY_MENU, KEY_UP, // B
KEY_UP, KEY_DOWN, // C
KEY_DOWN, KEY_EXIT, // D
KEY_EXIT, KEY_STAR, // *
KEY_STAR, KEY_F, // #
KEY_F, KEY_PTT, //
KEY_PTT, KEY_SIDE2, //
KEY_SIDE2, KEY_SIDE1, //
KEY_SIDE1 KEY_INVALID //
} KEY_Code_t; };
typedef enum KEY_Code_e KEY_Code_t;
extern KEY_Code_t gKeyReading0; extern KEY_Code_t gKeyReading0;
extern KEY_Code_t gKeyReading1; extern KEY_Code_t gKeyReading1;

View File

@ -146,7 +146,7 @@ void ST7565_Init(const bool full)
{ {
SPI0_Init(); SPI0_Init();
ST7565_Configure_GPIO_B11(); ST7565_HardwareReset();
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
@ -199,7 +199,7 @@ void ST7565_Init(const bool full)
ST7565_FillScreen(0x00); ST7565_FillScreen(0x00);
} }
void ST7565_Configure_GPIO_B11(void) void ST7565_HardwareReset(void)
{ {
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
SYSTEM_DelayMs(1); SYSTEM_DelayMs(1);

View File

@ -31,7 +31,7 @@ void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void); void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value); void ST7565_FillScreen(uint8_t Value);
void ST7565_Init(const bool full); void ST7565_Init(const bool full);
void ST7565_Configure_GPIO_B11(void); void ST7565_HardwareReset(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value); void ST7565_WriteByte(uint8_t Value);

Binary file not shown.

Binary file not shown.

3
misc.c
View File

@ -33,8 +33,7 @@ const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds
const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds
const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds
const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms
const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay' const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay'
const uint16_t key_debounce_10ms = 20 / 10; // 20ms const uint16_t key_debounce_10ms = 20 / 10; // 20ms

8
misc.h
View File

@ -24,6 +24,14 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif #endif
#ifndef MAX
#define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
#endif
#ifndef MIN
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
#endif
#define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST) #define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST)
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL) #define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)

57
radio.c
View File

@ -939,6 +939,7 @@ void RADIO_PrepareTX(void)
gEeprom.RX_VFO = gEeprom.TX_VFO; gEeprom.RX_VFO = gEeprom.TX_VFO;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
// gRxVfoIsActive = true; // gRxVfoIsActive = true;
gRxVfoIsActive = false;
} }
// let the user see that DW is not active // let the user see that DW is not active
@ -948,47 +949,35 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
#if defined(ENABLE_ALARM) && defined(ENABLE_TX1750) #ifndef ENABLE_TX_WHEN_AM
if (gAlarmState == ALARM_STATE_OFF || if (gCurrentVfo->AM_mode)
gAlarmState == ALARM_STATE_TX1750 || { // not allowed to TX if in AM mode
(gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
#elif defined(ENABLE_ALARM)
if (gAlarmState == ALARM_STATE_OFF ||
(gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
#elif defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF ||
gAlarmState == ALARM_STATE_TX1750)
#endif
{
#ifndef ENABLE_TX_WHEN_AM
if (gCurrentVfo->AM_mode)
{ // not allowed to TX if in AM mode
State = VFO_STATE_TX_DISABLE;
}
else
#endif
if (!gSetting_TX_EN || gSerialConfigCountDown_500ms > 0)
{ // TX is disabled or config upload/download in progress
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) #endif
{ // TX frequency is allowed if (!gSetting_TX_EN || gSerialConfigCountDown_500ms > 0)
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) { // TX is disabled or config upload/download in progress
State = VFO_STATE_BUSY; // busy RX'ing a station State = VFO_STATE_TX_DISABLE;
else
if (gBatteryDisplayLevel == 0)
State = VFO_STATE_BAT_LOW; // charge your battery !
else
if (gBatteryDisplayLevel >= 6)
State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain
}
else
State = VFO_STATE_TX_DISABLE; // TX frequency not allowed
} }
else
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0)
{ // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; // busy RX'ing a station
else
if (gBatteryDisplayLevel == 0)
State = VFO_STATE_BAT_LOW; // charge your battery !
else
if (gBatteryDisplayLevel >= 6)
State = VFO_STATE_VOLTAGE_HIGH; // over voltage (no doubt to protect the PA) .. this is being a pain
}
else
State = VFO_STATE_TX_DISABLE; // TX frequency not allowed
if (State != VFO_STATE_NORMAL) if (State != VFO_STATE_NORMAL)
{ // TX not allowed { // TX not allowed
RADIO_SetVfoState(State); RADIO_SetVfoState(State);
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)

View File

@ -31,5 +31,6 @@ void INPUTBOX_Append(const KEY_Code_t Digit)
if (Digit >= KEY_0 && Digit != KEY_INVALID) if (Digit >= KEY_0 && Digit != KEY_INVALID)
gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0); gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0);
// gInputBox[gInputBoxIndex++] = Digit;
} }

View File

@ -386,10 +386,8 @@ void UI_DisplayMain(void)
else else
{ {
sprintf(String, ">%s", gDTMF_InputBox); sprintf(String, ">%s", gDTMF_InputBox);
center_line = CENTER_LINE_IN_USE;
} }
UI_PrintString(String, 2, 0, vfo_num * 3, 8); UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8);
memset(String, 0, sizeof(String)); memset(String, 0, sizeof(String));
if (!gDTMF_InputMode) if (!gDTMF_InputMode)
@ -404,10 +402,6 @@ void UI_DisplayMain(void)
if (gDTMF_IsTx) if (gDTMF_IsTx)
sprintf(String, ">%s", gDTMF_String); sprintf(String, ">%s", gDTMF_String);
} }
else
{
center_line = CENTER_LINE_IN_USE;
}
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8); UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
center_line = CENTER_LINE_IN_USE; center_line = CENTER_LINE_IN_USE;

View File

@ -58,8 +58,8 @@ const t_menu_item MenuList[] =
{"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR" {"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR"
{"BUSYCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL }, // was "BCL" {"BUSYCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL }, // was "BCL"
{"CH SAV", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH" {"CH SAV", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH"
{"CH DEL", VOICE_ID_DELETE_CHANNEL, MENU_DEL_CH }, // was "DEL-CH"
{"CH NAM", VOICE_ID_INVALID, MENU_MEM_NAME }, {"CH NAM", VOICE_ID_INVALID, MENU_MEM_NAME },
{"CH DEL", VOICE_ID_DELETE_CHANNEL, MENU_DEL_CH }, // was "DEL-CH"
{"CH DIS", VOICE_ID_INVALID, MENU_MDF }, // was "MDF" {"CH DIS", VOICE_ID_INVALID, MENU_MDF }, // was "MDF"
{"BATSAV", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE" {"BATSAV", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE"
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
@ -88,7 +88,7 @@ const t_menu_item MenuList[] =
{"SLIST1", VOICE_ID_INVALID, MENU_SLIST1 }, {"SLIST1", VOICE_ID_INVALID, MENU_SLIST1 },
{"SLIST2", VOICE_ID_INVALID, MENU_SLIST2 }, {"SLIST2", VOICE_ID_INVALID, MENU_SLIST2 },
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
{"AL-MOD", VOICE_ID_INVALID, MENU_AL_MOD }, {"ALMODE", VOICE_ID_INVALID, MENU_AL_MOD },
#endif #endif
{"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID }, {"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID },
{"UPCODE", VOICE_ID_INVALID, MENU_UPCODE }, {"UPCODE", VOICE_ID_INVALID, MENU_UPCODE },

View File

@ -28,6 +28,14 @@ typedef struct {
uint8_t menu_id; uint8_t menu_id;
} t_menu_item; } t_menu_item;
// currently this list MUST be in exactly the same order
// as the other menu list "MenuList[]" in "ui/menu.c", otherwise
// you'll have big problems
//
// I'm going to fix that so that you can reorder the menu items
// anyway you like simply by editing this list only (the other list
// you just leave as is, or any which way, it won't matter)
//
enum enum
{ {
MENU_SQL = 0, MENU_SQL = 0,
@ -45,8 +53,8 @@ enum
MENU_SCR, MENU_SCR,
MENU_BCL, MENU_BCL,
MENU_MEM_CH, MENU_MEM_CH,
MENU_DEL_CH,
MENU_MEM_NAME, MENU_MEM_NAME,
MENU_DEL_CH,
MENU_MDF, MENU_MDF,
MENU_SAVE, MENU_SAVE,
#ifdef ENABLE_VOX #ifdef ENABLE_VOX

45
ui/ui.c
View File

@ -77,33 +77,28 @@ void GUI_DisplayScreen(void)
void GUI_SelectNextDisplay(GUI_DisplayType_t Display) void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
{ {
if (Display != DISPLAY_INVALID) if (Display == DISPLAY_INVALID)
return;
if (gScreenToDisplay != Display)
{ {
if (gScreenToDisplay != Display) DTMF_clear_input_box();
{
gInputBoxIndex = 0;
gIsInSubMenu = false;
gCssScanMode = CSS_SCAN_MODE_OFF;
gScanStateDir = SCAN_OFF;
#ifdef ENABLE_FMRADIO
gFM_ScanState = FM_SCAN_OFF;
#endif
gAskForConfirmation = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;
if (gWasFKeyPressed) gInputBoxIndex = 0;
{ gIsInSubMenu = false;
gWasFKeyPressed = false; gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true; gScanStateDir = SCAN_OFF;
} #ifdef ENABLE_FMRADIO
gFM_ScanState = FM_SCAN_OFF;
#endif
gAskForConfirmation = 0;
gAskToSave = false;
gAskToDelete = false;
gWasFKeyPressed = false;
gUpdateStatus = true; gUpdateStatus = true;
}
gUpdateDisplay = true;
gScreenToDisplay = Display;
} }
gScreenToDisplay = Display;
gUpdateDisplay = true;
} }