0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 14:48:03 +03:00

Fix big freq digits moving 1 pixel to the right + added chan name edit menu

This commit is contained in:
OneOfEleven
2023-09-20 08:29:11 +01:00
parent 0b676d29e3
commit af9b0d6cb7
23 changed files with 619 additions and 399 deletions

View File

@ -86,7 +86,7 @@ bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
bool DTMF_GetContact(const int Index, char *pContact)
{
int i = -1;
if (Index >= 0 && Index < 16 && pContact != NULL) // max 16 DTMF contacts
if (Index >= 0 && Index < MAX_DTMF_CONTACTS && pContact != NULL)
{
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
i = (int)pContact[0] - ' ';
@ -96,10 +96,10 @@ bool DTMF_GetContact(const int Index, char *pContact)
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact [16];
char Contact[16];
unsigned int i;
for (i = 0; i < 16; i++)
for (i = 0; i < MAX_DTMF_CONTACTS; i++)
{
unsigned int j;
@ -130,7 +130,6 @@ char DTMF_GetCharacter(const uint8_t code)
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup)
{
unsigned int i;
for (i = 0; i < Size; i++)
{
if (pMsg[i] != pTemplate[i])
@ -147,7 +146,6 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size,
bool DTMF_CheckGroupCall(const char *pMsg, uint32_t Size)
{
uint32_t i;
for (i = 0; i < Size; i++)
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE)
break;
@ -189,12 +187,15 @@ void DTMF_HandleRequest(void)
{
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true))
{
if (gEeprom.PERMIT_REMOTE_KILL)
{
gSetting_KILLED = true;
SETTINGS_SaveSettings();
gDTMF_ReplyState = DTMF_REPLY_AB;
#ifdef ENABLE_FMRADIO
@ -220,12 +221,12 @@ void DTMF_HandleRequest(void)
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true))
{
gSetting_KILLED = false;
gSetting_KILLED = false;
SETTINGS_SaveSettings();
gDTMF_ReplyState = DTMF_REPLY_AB;
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true;
gUpdateStatus = true;
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true;
gUpdateStatus = true;
return;
}
}
@ -234,7 +235,7 @@ void DTMF_HandleRequest(void)
{
if (DTMF_CompareMessage(gDTMF_Received + (gDTMF_WriteIndex - 2), "AB", 2, true))
{
gDTMF_State = DTMF_STATE_TX_SUCC;
gDTMF_State = DTMF_STATE_TX_SUCC;
gUpdateDisplay = true;
return;
}
@ -243,10 +244,12 @@ void DTMF_HandleRequest(void)
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && gDTMF_WriteIndex >= 9)
{
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false))
{
gDTMF_State = DTMF_STATE_CALL_OUT_RSP;
gDTMF_State = DTMF_STATE_CALL_OUT_RSP;
gUpdateDisplay = true;
}
}
@ -257,12 +260,16 @@ void DTMF_HandleRequest(void)
if (gDTMF_WriteIndex >= 7)
{
Offset = gDTMF_WriteIndex - 7;
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
gDTMF_IsGroupCall = false;
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true))
{
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED;
memmove(gDTMF_Callee, gDTMF_Received + Offset, 3);
memmove(gDTMF_Callee, gDTMF_Received + Offset + 0, 3);
memmove(gDTMF_Caller, gDTMF_Received + Offset + 4, 3);
gUpdateDisplay = true;
@ -364,4 +371,3 @@ void DTMF_Reply(void)
BK4819_ExitDTMF_TX(false);
}

View File

@ -20,6 +20,8 @@
#include <stdbool.h>
#include <stdint.h>
#define MAX_DTMF_CONTACTS 16
enum DTMF_State_t {
DTMF_STATE_0 = 0,
DTMF_STATE_TX_SUCC,

View File

@ -59,7 +59,11 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++)
{
Channel %= ARRAY_SIZE(gFM_Channels);
if (Channel == 0xFF)
Channel = ARRAY_SIZE(gFM_Channels) - 1;
else
if (Channel >= ARRAY_SIZE(gFM_Channels))
Channel = 0;
if (FM_CheckValidChannel(Channel))
return Channel;
Channel += Direction;
@ -182,7 +186,7 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10)
{
// if (Deviation > -281 && Deviation < 280)
//if (Deviation > -281 && Deviation < 280)
if (Deviation < 280 || Deviation > 3815)
{
// not BLE(less than or equal)

View File

@ -314,6 +314,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (!RADIO_CheckValidChannel(Channel, false, 0))
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -398,7 +399,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
Channel = (gInputBox[0] * 10) + gInputBox[1];
if (Channel >= 1 && Channel <= 10)
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
{
Channel += NOAA_CHANNEL_FIRST;
#ifdef ENABLE_VOICE

View File

@ -39,6 +39,7 @@
#endif
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/menu.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
@ -64,15 +65,16 @@
VOICE_ID_BUSY_LOCKOUT, // BUSYCL
VOICE_ID_MEMORY_CHANNEL, // CH-SAV
VOICE_ID_DELETE_CHANNEL, // CH-DEL
VOICE_ID_INVALID, // CH-EDIT
VOICE_ID_INVALID, // CH-DIS
VOICE_ID_SAVE_MODE, // BATSAV
VOICE_ID_VOX, // VOX
VOICE_ID_INVALID, // BACKLT
VOICE_ID_DUAL_STANDBY, // DUALRX
VOICE_ID_BEEP_PROMPT, // BEEP
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
VOICE_ID_VOICE_PROMPT, // VOICE
#endif
#endif
VOICE_ID_INVALID, // SC-REV
VOICE_ID_INVALID, // KEYLOC
VOICE_ID_INVALID, // S-ADD1
@ -285,17 +287,16 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_MEM_CH:
case MENU_1_CALL:
// case MENU_SLIST1:
// case MENU_SLIST2:
case MENU_DEL_CH:
case MENU_MEM_NAME:
*pMin = 0;
*pMax = 199;
*pMax = MR_CHANNEL_LAST;
break;
case MENU_SLIST1:
case MENU_SLIST2:
*pMin = -1;
*pMax = 199;
*pMax = MR_CHANNEL_LAST;
break;
case MENU_SAVE:
@ -344,8 +345,8 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
break;
case MENU_F_CALI:
*pMin = -1000;
*pMax = +1000;
*pMin = -50;
*pMax = +50;
break;
default:
@ -373,7 +374,7 @@ void MENU_AcceptSetting(void)
{
default:
return;
case MENU_SQL:
gEeprom.SQUELCH_LEVEL = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE_1;
@ -479,7 +480,28 @@ void MENU_AcceptSetting(void)
case MENU_MEM_CH:
gTxVfo->CHANNEL_SAVE = gSubMenuSelection;
gRequestSaveChannel = 2;
gEeprom.MrChannel[0] = gSubMenuSelection;
#if 0
gEeprom.MrChannel[0] = gSubMenuSelection;
#else
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = gSubMenuSelection;
#endif
return;
case MENU_MEM_NAME:
{ // trailing trim
for (int i = 9; i >= 0; i--)
{
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0 && edit[i] != 0xff)
break;
edit[i] = ' ';
}
}
// save the channel name
memset(gTxVfo->Name, 0xff, sizeof(gTxVfo->Name));
memmove(gTxVfo->Name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_CHANNEL, gTxVfo, 2);
gFlagReconfigureVfos = true;
return;
case MENU_SAVE:
@ -623,13 +645,15 @@ void MENU_AcceptSetting(void)
case MENU_BAT_TXT:
gSetting_battery_text = gSubMenuSelection;
break;
case MENU_D_DCD:
gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection;
gRequestSaveChannel = 1;
return;
case MENU_D_LIVE_DEC:
gDTMF_RecvTimeoutSaved = 0;
gDTMF_ReceivedSaved[0] = '\0';
gSetting_live_DTMF_decoder = gSubMenuSelection;
break;
@ -873,6 +897,10 @@ void MENU_ShowCurrentSetting(void)
#endif
break;
case MENU_MEM_NAME:
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL];
break;
case MENU_SAVE:
gSubMenuSelection = gEeprom.BATTERY_SAVE;
break;
@ -990,7 +1018,7 @@ void MENU_ShowCurrentSetting(void)
case MENU_BAT_TXT:
gSubMenuSelection = gSetting_battery_text;
return;
case MENU_D_DCD:
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE;
break;
@ -1065,12 +1093,12 @@ void MENU_ShowCurrentSetting(void)
static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
uint8_t Offset;
int32_t Min;
int32_t Max;
uint16_t Value = 0;
if (bKeyHeld)
return;
if (!bKeyPressed)
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@ -1106,89 +1134,92 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
else
if (gMenuCursor == MENU_OFFSET)
{
if (gMenuCursor == MENU_OFFSET)
{
uint32_t Frequency;
uint32_t Frequency;
if (gInputBoxIndex < 6)
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
return;
}
gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency);
Frequency += 75;
if (gInputBoxIndex < 6)
{ // invalid frequency
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, 0);
return;
}
if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL)
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
NUMBER_Get(gInputBox, &Frequency);
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 62, gTxVfo->StepFrequency, 0);
gInputBoxIndex = 0;
return;
}
if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL || gMenuCursor == MENU_MEM_NAME)
{ // enter 3-digit channel number
if (gInputBoxIndex < 3)
{
if (gInputBoxIndex < 3)
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
gInputBoxIndex = 0;
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (IS_MR_CHANNEL(Value))
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = Value;
return;
}
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
else
gInputBoxIndex = 0;
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (IS_MR_CHANNEL(Value))
{
int32_t Min;
int32_t Max;
if (!MENU_GetLimits(gMenuCursor, &Min, &Max))
{
const uint8_t Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
switch (gInputBoxIndex)
{
case 1:
Value = gInputBox[0];
break;
case 2:
Value = (gInputBox[0] * 10) + gInputBox[1];
break;
case 3:
Value = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2];
break;
}
if (Offset == gInputBoxIndex)
gInputBoxIndex = 0;
if (Value <= Max)
{
gSubMenuSelection = Value;
return;
}
}
else
gInputBoxIndex = 0;
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = Value;
return;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (MENU_GetLimits(gMenuCursor, &Min, &Max))
{
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
switch (gInputBoxIndex)
{
case 1:
Value = gInputBox[0];
break;
case 2:
Value = (gInputBox[0] * 10) + gInputBox[1];
break;
case 3:
Value = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2];
break;
}
if (Offset == gInputBoxIndex)
gInputBoxIndex = 0;
if (Value <= Max)
{
gSubMenuSelection = Value;
return;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -1196,162 +1227,213 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed)
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gCssScanMode == CSS_SCAN_MODE_OFF)
if (gIsInSubMenu)
{
if (gIsInSubMenu)
if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET)
{
if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET)
{
gAskForConfirmation = 0; // fix bug
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
else
gInputBox[--gInputBoxIndex] = 10;
gAskForConfirmation = 0;
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
}
else
{
MENU_StopCssScan();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
}
gPttWasReleased = true;
}
}
static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MENU;
if (!gIsInSubMenu)
{
#ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR)
gAnotherVoiceID = MenuVoices[gMenuCursor];
#endif
gAskForConfirmation = 0;
gIsInSubMenu = true;
}
else
{
if (gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH)
{
switch (gAskForConfirmation)
{
case 0:
gAskForConfirmation = 1;
break;
case 1:
gAskForConfirmation = 2;
UI_DisplayMenu();
if (gMenuCursor == MENU_RESET)
{
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
#endif
MENU_AcceptSetting();
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
}
gFlagAcceptSetting = true;
gIsInSubMenu = false;
gAskForConfirmation = 0;
}
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
}
else
{
gFlagAcceptSetting = true;
gIsInSubMenu = false;
}
gInputBox[--gInputBoxIndex] = 10;
gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true;
#ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else
gAnotherVoiceID = VOICE_ID_CONFIRM;
#endif
}
gInputBoxIndex = 0;
}
}
static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && !gRxVfo->IsAM)
#else
if (!gRxVfo->IsAM)
#endif
{
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS)
{
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
MENU_StartCssScan(1);
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(1);
#endif
}
else
{
MENU_StopCssScan();
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
}
gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
}
else
{
MENU_StopCssScan();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
}
gPttWasReleased = true;
}
static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MENU;
if (!gIsInSubMenu)
{
#ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR)
gAnotherVoiceID = MenuVoices[gMenuCursor];
#endif
#if 1
if (gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel
#endif
gAskForConfirmation = 0;
gIsInSubMenu = true;
gInputBoxIndex = 0;
edit_index = -1;
return;
}
if (gMenuCursor == MENU_MEM_NAME)
{
if (edit_index < 0)
{ // enter channel name edit mode
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
{
return;
}
BOARD_fetchChannelName(edit, gSubMenuSelection);
// pad the channel name out with '_'
edit_index = strlen(edit);
while (edit_index < 10)
edit[edit_index++] = '_';
edit[edit_index] = 0;
edit_index = 0; // 'edit_index' is going to be used as the cursor position
return;
}
else
if (edit_index >= 0 && edit_index < 10)
{ // editing the channel name characters
if (++edit_index < 10)
return; // next char
// exit
gFlagAcceptSetting = false;
gAskForConfirmation = 0;
}
}
if (gMenuCursor == MENU_RESET ||
gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH ||
gMenuCursor == MENU_MEM_NAME)
{
switch (gAskForConfirmation)
{
case 0:
gAskForConfirmation = 1;
break;
case 1:
gAskForConfirmation = 2;
UI_DisplayMenu();
if (gMenuCursor == MENU_RESET)
{
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
#endif
MENU_AcceptSetting();
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
}
gFlagAcceptSetting = true;
gIsInSubMenu = false;
gAskForConfirmation = 0;
}
}
else
{
gFlagAcceptSetting = true;
gIsInSubMenu = false;
}
gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true;
#ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else
gAnotherVoiceID = VOICE_ID_CONFIRM;
#endif
gInputBoxIndex = 0;
}
static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
{
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && !gRxVfo->IsAM)
#else
if (!gRxVfo->IsAM)
#endif
{
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
MENU_StartCssScan(1);
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(1);
#endif
}
else
{
MENU_StopCssScan();
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
}
gPttWasReleased = true;
return;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}
static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
@ -1360,12 +1442,76 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Channel;
bool bCheckScanList;
if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character
if (bKeyPressed && edit_index < 10)
{
#if 0
char c1 = edit[edit_index];
char c2 = 0;
if (Direction == 0)
return;
if (Direction < 0)
{
switch (c1)
{
case 'a': c2 = 'Z'; break;
case 'A': c2 = '9'; break;
case '0': c2 = '.'; break;
case '.': c2 = '-'; break;
case '-': c2 = '_'; break;
case '_': c2 = ' '; break;
case ' ': c2 = 'z'; break;
}
}
else
{
switch (c1)
{
case ' ': c2 = '_'; break;
case '_': c2 = '-'; break;
case '-': c2 = '.'; break;
case '.': c2 = '0'; break;
case '9': c2 = 'A'; break;
case 'Z': c2 = 'a'; break;
case 'z': c2 = ' '; break;
}
}
if (c2 == 0)
{
if ((c1 >= '0' && c1 <= '9') ||
(c1 >= 'A' && c1 <= 'Z') ||
(c1 >= 'a' && c1 <= 'z'))
{
c2 = c1 + Direction;
}
else
{
c2 = 'A';
}
}
edit[edit_index] = c2;
#else
const char c = edit[edit_index] + Direction;
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
if (!bKeyHeld)
{
if (!bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gInputBoxIndex = 0;
}
else
@ -1375,6 +1521,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gCssScanMode != CSS_SCAN_MODE_OFF)
{
MENU_StartCssScan(Direction);
gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MENU;
return;
@ -1410,14 +1557,12 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{
case MENU_DEL_CH:
case MENU_1_CALL:
case MENU_MEM_NAME:
bCheckScanList = false;
break;
case MENU_SLIST2:
VFO = 1;
// Fallthrough
case MENU_SLIST1:
bCheckScanList = true;
break;

View File

@ -300,7 +300,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
if (gScannerEditState == 1)
{
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, 199);
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST);
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
gRequestDisplayScreen = DISPLAY_SCANNER;
}