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

1852 lines
38 KiB
C
Raw Normal View History

2023-09-09 08:03:56 +01:00
/* 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.
*/
#include <string.h>
2023-09-16 07:08:18 +01:00
#if !defined(ENABLE_OVERLAY)
#include "ARMCM0.h"
#endif
2023-09-09 08:03:56 +01:00
#include "app/dtmf.h"
#include "app/generic.h"
#include "app/menu.h"
#include "app/scanner.h"
#include "audio.h"
#include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/backlight.h"
#include "driver/bk4819.h"
#include "driver/eeprom.h"
2023-09-09 08:03:56 +01:00
#include "driver/gpio.h"
#include "driver/keyboard.h"
#include "frequencies.h"
#include "helper/battery.h"
2023-09-09 08:03:56 +01:00
#include "misc.h"
#include "settings.h"
2023-09-16 07:08:18 +01:00
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
2023-09-09 08:03:56 +01:00
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/menu.h"
2023-09-09 08:03:56 +01:00
#include "ui/ui.h"
2023-09-15 15:53:37 +01:00
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
2023-10-04 10:01:07 +01:00
#ifdef ENABLE_F_CAL_MENU
void writeXtalFreqCal(const int32_t value, const bool update_eeprom)
{
2023-10-04 10:01:07 +01:00
BK4819_WriteRegister(BK4819_REG_3B, 22656 + value);
2023-10-04 10:01:07 +01:00
if (update_eeprom)
{
struct
{
int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C;
2023-10-08 17:14:13 +01:00
uint8_t volume_gain;
uint8_t dac_gain;
2023-10-04 10:01:07 +01:00
} __attribute__((packed)) misc;
2023-10-08 17:14:13 +01:00
g_eeprom.BK4819_xtal_freq_low = value;
2023-10-04 10:01:07 +01:00
// radio 1 .. 04 00 46 00 50 00 2C 0E
// radio 2 .. 05 00 46 00 50 00 2C 0E
//
EEPROM_ReadBuffer(0x1F88, &misc, 8);
misc.BK4819_XtalFreqLow = value;
EEPROM_WriteBuffer(0x1F88, &misc);
}
}
#endif
2023-09-09 08:03:56 +01:00
void MENU_StartCssScan(int8_t Direction)
{
gCssScanMode = CSS_SCAN_MODE_SCANNING;
gUpdateStatus = true;
2023-09-09 08:03:56 +01:00
gMenuScrollDirection = Direction;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
RADIO_SelectVfos();
MENU_SelectNextCode();
2023-09-19 11:44:49 +01:00
2023-10-05 23:58:55 +01:00
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
2023-09-09 08:03:56 +01:00
}
void MENU_StopCssScan(void)
{
gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true;
2023-09-09 08:03:56 +01:00
RADIO_SetupRegisters(true);
}
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
2023-09-09 08:03:56 +01:00
{
switch (Cursor)
{
case MENU_SQL:
*pMin = 0;
*pMax = 9;
break;
2023-09-10 09:57:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STEP:
2023-09-15 15:53:37 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(StepFrequencyTable) - 1;
break;
2023-09-10 09:57:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_ABR:
*pMin = 0;
2023-10-08 17:14:13 +01:00
*pMax = ARRAY_SIZE(gSubMenu_backlight) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-15 17:45:07 +01:00
case MENU_F_LOCK:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_F_LOCK) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-10 09:57:49 +01:00
case MENU_MDF:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_MDF) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TXP:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_TXP) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SFT_D:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SFT_D) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TDR:
2023-09-15 17:45:07 +01:00
*pMin = 0;
2023-10-07 10:14:23 +01:00
// *pMax = ARRAY_SIZE(gSubMenu_TDR) - 1;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-30 11:22:19 +01:00
case MENU_XB:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_XB) - 1;
break;
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-09-09 08:03:56 +01:00
case MENU_VOICE:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_VOICE) - 1;
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SC_REV:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SC_REV) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_ROGER:
*pMin = 0;
2023-09-15 17:45:07 +01:00
*pMax = ARRAY_SIZE(gSubMenu_ROGER) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-10 09:57:49 +01:00
case MENU_PONMSG:
*pMin = 0;
2023-09-15 17:45:07 +01:00
*pMax = ARRAY_SIZE(gSubMenu_PONMSG) - 1;
break;
2023-09-09 08:03:56 +01:00
case MENU_R_DCS:
case MENU_T_DCS:
*pMin = 0;
*pMax = 208;
2023-09-15 17:45:07 +01:00
//*pMax = (ARRAY_SIZE(DCS_Options) * 2);
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_R_CTCS:
case MENU_T_CTCS:
*pMin = 0;
2023-09-15 17:45:07 +01:00
*pMax = ARRAY_SIZE(CTCSS_Options) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-15 17:45:07 +01:00
case MENU_W_N:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_W_N) - 1;
break;
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_AL_MOD) - 1;
break;
#endif
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_SHORT:
case MENU_SIDE1_LONG:
case MENU_SIDE2_SHORT:
case MENU_SIDE2_LONG:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SIDE_BUTT) - 1;
break;
2023-09-15 17:45:07 +01:00
case MENU_RESET:
2023-09-16 09:10:10 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_RESET) - 1;
break;
2023-09-15 17:45:07 +01:00
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
case MENU_ABR_ON_TX_RX:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1;
break;
2023-09-16 09:10:10 +01:00
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_AM_fix_test1) - 1;
break;
#endif
#ifdef ENABLE_AM_FIX
case MENU_AM_FIX:
#endif
#ifdef ENABLE_AUDIO_BAR
case MENU_MIC_BAR:
#endif
2023-09-09 08:03:56 +01:00
case MENU_BCL:
case MENU_BEEP:
case MENU_AUTOLK:
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
case MENU_D_LIVE_DEC:
2023-09-09 08:03:56 +01:00
case MENU_AM:
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
case MENU_NOAA_S:
#endif
case MENU_350TX:
case MENU_200TX:
case MENU_500TX:
case MENU_350EN:
case MENU_SCREN:
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
2023-09-09 08:03:56 +01:00
*pMin = 0;
2023-09-15 17:45:07 +01:00
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SCR:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1;
break;
2023-09-09 08:03:56 +01:00
case MENU_TOT:
2023-09-28 17:39:45 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_TOT) - 1;
break;
#ifdef ENABLE_VOX
case MENU_VOX:
#endif
2023-09-09 08:03:56 +01:00
case MENU_RP_STE:
*pMin = 0;
*pMax = 10;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MEM_CH:
case MENU_1_CALL:
case MENU_DEL_CH:
case MENU_MEM_NAME:
2023-09-09 08:03:56 +01:00
*pMin = 0;
2023-10-08 17:14:13 +01:00
*pMax = USER_CHANNEL_LAST;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SLIST1:
case MENU_SLIST2:
*pMin = -1;
2023-10-08 17:14:13 +01:00
*pMax = USER_CHANNEL_LAST;
2023-09-19 11:44:49 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_SAVE:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SAVE) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MIC:
*pMin = 0;
*pMax = 4;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_LIST:
2023-10-04 22:08:13 +01:00
*pMin = 0;
// *pMax = 1;
2023-09-09 08:03:56 +01:00
*pMax = 2;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_RSP:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_D_RSP) - 1;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_PTT_ID:
*pMin = 0;
2023-09-15 17:45:07 +01:00
*pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_BAT_TXT:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1;
break;
2023-09-09 08:03:56 +01:00
case MENU_D_HOLD:
*pMin = DTMF_HOLD_MIN;
*pMax = DTMF_HOLD_MAX;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_PRE:
*pMin = 3;
*pMax = 99;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_LIST:
*pMin = 1;
*pMax = 16;
break;
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
*pMin = -50;
*pMax = +50;
break;
#endif
2023-09-19 11:44:49 +01:00
2023-10-02 01:09:35 +01:00
case MENU_BATCAL:
*pMin = 1600; // 0
*pMax = 2200; // 2300
2023-10-02 01:09:35 +01:00
break;
2023-09-09 08:03:56 +01:00
default:
return -1;
}
return 0;
}
void MENU_AcceptSetting(void)
{
int32_t Min;
int32_t Max;
2023-09-09 08:03:56 +01:00
uint8_t Code;
2023-10-08 17:14:13 +01:00
FREQ_Config_t *pConfig = &gTxVfo->freq_config_rx;
2023-09-09 08:03:56 +01:00
if (!MENU_GetLimits(gMenuCursor, &Min, &Max))
{
if (gSubMenuSelection < Min) gSubMenuSelection = Min;
else
if (gSubMenuSelection > Max) gSubMenuSelection = Max;
}
switch (gMenuCursor)
{
default:
return;
2023-09-09 08:03:56 +01:00
case MENU_SQL:
2023-10-08 17:14:13 +01:00
g_eeprom.squelch_level = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STEP:
2023-10-08 17:14:13 +01:00
gTxVfo->step_setting = gSubMenuSelection;
if (IS_FREQ_CHANNEL(gTxVfo->channel_save))
2023-09-09 08:03:56 +01:00
{
2023-09-28 17:39:45 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
}
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TXP:
2023-10-08 17:14:13 +01:00
gTxVfo->output_power = gSubMenuSelection;
2023-09-27 23:22:01 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_T_DCS:
2023-10-08 17:14:13 +01:00
pConfig = &gTxVfo->freq_config_tx;
2023-09-09 08:03:56 +01:00
// Fallthrough
case MENU_R_DCS:
if (gSubMenuSelection == 0)
{
2023-10-08 17:14:13 +01:00
if (pConfig->code_type != CODE_TYPE_DIGITAL && pConfig->code_type != CODE_TYPE_REVERSE_DIGITAL)
2023-09-09 08:03:56 +01:00
{
gRequestSaveChannel = 1;
return;
}
2023-10-08 17:14:13 +01:00
Code = 0;
pConfig->code_type = CODE_TYPE_OFF;
2023-09-09 08:03:56 +01:00
}
else
if (gSubMenuSelection < 105)
{
2023-10-08 17:14:13 +01:00
pConfig->code_type = CODE_TYPE_DIGITAL;
Code = gSubMenuSelection - 1;
2023-09-09 08:03:56 +01:00
}
else
{
2023-10-08 17:14:13 +01:00
pConfig->code_type = CODE_TYPE_REVERSE_DIGITAL;
Code = gSubMenuSelection - 105;
2023-09-09 08:03:56 +01:00
}
2023-09-19 11:44:49 +01:00
2023-10-08 17:14:13 +01:00
pConfig->code = Code;
2023-09-09 08:03:56 +01:00
gRequestSaveChannel = 1;
return;
2023-09-19 11:44:49 +01:00
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
2023-09-09 08:03:56 +01:00
case MENU_T_CTCS:
2023-10-08 17:14:13 +01:00
pConfig = &gTxVfo->freq_config_tx;
2023-09-09 08:03:56 +01:00
case MENU_R_CTCS:
if (gSubMenuSelection == 0)
{
2023-10-08 17:14:13 +01:00
if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE)
2023-09-09 08:03:56 +01:00
{
gRequestSaveChannel = 1;
return;
}
Code = 0;
2023-10-08 17:14:13 +01:00
pConfig->code = Code;
pConfig->code_type = CODE_TYPE_OFF;
2023-10-03 00:14:36 +01:00
BK4819_ExitSubAu();
2023-09-09 08:03:56 +01:00
}
else
2023-10-03 00:14:36 +01:00
{
2023-10-08 17:14:13 +01:00
pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE;
2023-09-09 08:03:56 +01:00
Code = gSubMenuSelection - 1;
2023-10-08 17:14:13 +01:00
pConfig->code = Code;
2023-10-03 00:14:36 +01:00
BK4819_SetCTCSSFrequency(CTCSS_Options[Code]);
2023-09-09 08:03:56 +01:00
}
2023-09-09 08:03:56 +01:00
gRequestSaveChannel = 1;
return;
2023-09-19 11:44:49 +01:00
#pragma GCC diagnostic pop
2023-09-09 08:03:56 +01:00
case MENU_SFT_D:
2023-10-08 17:14:13 +01:00
gTxVfo->tx_offset_freq_dir = gSubMenuSelection;
2023-09-15 12:31:30 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_OFFSET:
2023-10-08 17:14:13 +01:00
gTxVfo->tx_offset_freq = gSubMenuSelection;
2023-09-15 12:31:30 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_W_N:
2023-10-08 17:14:13 +01:00
gTxVfo->channel_bandwidth = gSubMenuSelection;
2023-09-27 23:22:01 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SCR:
2023-10-08 17:14:13 +01:00
gTxVfo->scrambling_type = gSubMenuSelection;
2023-10-03 00:14:36 +01:00
#if 0
if (gSubMenuSelection > 0 && gSetting_ScrambleEnable)
BK4819_EnableScramble(gSubMenuSelection - 1);
else
BK4819_DisableScramble();
#endif
2023-09-27 23:22:01 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BCL:
2023-10-08 17:14:13 +01:00
gTxVfo->busy_channel_lock = gSubMenuSelection;
2023-09-27 23:22:01 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MEM_CH:
2023-10-08 17:14:13 +01:00
gTxVfo->channel_save = gSubMenuSelection;
#if 0
2023-10-08 17:14:13 +01:00
g_eeprom.user_channel[0] = gSubMenuSelection;
#else
2023-10-08 17:14:13 +01:00
g_eeprom.user_channel[g_eeprom.tx_vfo] = gSubMenuSelection;
#endif
2023-09-28 22:22:06 +01:00
gRequestSaveChannel = 2;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
return;
case MENU_MEM_NAME:
{ // trailing trim
for (int i = 9; i >= 0; i--)
{
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff)
break;
edit[i] = ' ';
}
}
2023-09-20 11:58:47 +01:00
// save the channel name
2023-10-08 17:14:13 +01:00
memset(gTxVfo->name, 0, sizeof(gTxVfo->name));
memmove(gTxVfo->name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, g_eeprom.tx_vfo, gTxVfo, 3);
gFlagReconfigureVfos = true;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SAVE:
2023-10-08 17:14:13 +01:00
g_eeprom.battery_save = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_VOX
case MENU_VOX:
2023-10-08 17:14:13 +01:00
g_eeprom.vox_switch = gSubMenuSelection != 0;
if (g_eeprom.vox_switch)
g_eeprom.vox_level = gSubMenuSelection - 1;
BOARD_EEPROM_LoadMoreSettings();
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_ABR:
2023-10-08 17:14:13 +01:00
g_eeprom.backlight = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_ABR_ON_TX_RX:
gSetting_backlight_on_tx_rx = gSubMenuSelection;
break;
2023-09-09 08:03:56 +01:00
case MENU_TDR:
2023-10-08 17:14:13 +01:00
// g_eeprom.dual_watch = gSubMenuSelection;
g_eeprom.dual_watch = (gSubMenuSelection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF;
2023-10-07 10:14:23 +01:00
2023-09-09 08:03:56 +01:00
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;
2023-09-19 11:44:49 +01:00
case MENU_XB:
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-10-08 17:14:13 +01:00
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
2023-09-09 08:03:56 +01:00
return;
2023-10-08 17:14:13 +01:00
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
2023-09-09 08:03:56 +01:00
return;
#endif
2023-09-19 11:44:49 +01:00
2023-10-08 17:14:13 +01:00
g_eeprom.cross_vfo_rx_tx = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BEEP:
2023-10-08 17:14:13 +01:00
g_eeprom.beep_control = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TOT:
2023-10-08 17:14:13 +01:00
g_eeprom.tx_timeout_timer = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-09-09 08:03:56 +01:00
case MENU_VOICE:
2023-10-08 17:14:13 +01:00
g_eeprom.voice_prompt = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
gUpdateStatus = true;
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SC_REV:
2023-10-08 17:14:13 +01:00
g_eeprom.scan_resume_mode = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MDF:
2023-10-08 17:14:13 +01:00
g_eeprom.channel_display_mode = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_AUTOLK:
2023-10-08 17:14:13 +01:00
g_eeprom.auto_keypad_lock = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
gKeyLockCountdown = 30;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_ADD1:
2023-10-08 17:14:13 +01:00
gTxVfo->scanlist_1_participation = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE;
2023-09-09 08:03:56 +01:00
gFlagResetVfos = true;
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_ADD2:
2023-10-08 17:14:13 +01:00
gTxVfo->scanlist_2_participation = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE;
2023-09-09 08:03:56 +01:00
gFlagResetVfos = true;
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STE:
2023-10-08 17:14:13 +01:00
g_eeprom.tail_note_elimination = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_RP_STE:
2023-10-08 17:14:13 +01:00
g_eeprom.repeater_tail_tone_elimination = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MIC:
2023-10-08 17:14:13 +01:00
g_eeprom.mic_sensitivity = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
BOARD_EEPROM_LoadMoreSettings();
gFlagReconfigureVfos = true;
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_AUDIO_BAR
case MENU_MIC_BAR:
gSetting_mic_bar = gSubMenuSelection;
break;
#endif
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
2023-10-08 17:14:13 +01:00
gTxVfo->compander = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
2023-10-04 16:37:11 +01:00
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
// gRequestSaveChannel = 1;
return;
2023-09-15 10:57:26 +01:00
2023-09-09 08:03:56 +01:00
case MENU_1_CALL:
2023-10-08 17:14:13 +01:00
g_eeprom.chan_1_call = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_LIST:
2023-10-08 17:14:13 +01:00
g_eeprom.scan_list_default = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_ALARM
2023-09-09 09:01:52 +01:00
case MENU_AL_MOD:
2023-10-08 17:14:13 +01:00
g_eeprom.alarm_mode = gSubMenuSelection;
2023-09-09 09:01:52 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_ST:
2023-10-08 17:14:13 +01:00
g_eeprom.DTMF_side_tone = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_RSP:
2023-10-08 17:14:13 +01:00
g_eeprom.DTMF_decode_response = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_HOLD:
2023-10-08 17:14:13 +01:00
g_eeprom.DTMF_auto_reset_time = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_PRE:
2023-10-08 17:14:13 +01:00
g_eeprom.DTMF_preload_time = gSubMenuSelection * 10;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_PTT_ID:
2023-10-08 17:14:13 +01:00
gTxVfo->DTMF_ptt_id_tx_mode = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
gRequestSaveChannel = 1;
return;
2023-09-19 11:44:49 +01:00
case MENU_BAT_TXT:
gSetting_battery_text = gSubMenuSelection;
break;
2023-09-09 08:03:56 +01:00
case MENU_D_DCD:
2023-10-08 17:14:13 +01:00
gTxVfo->DTMF_decoding_enable = gSubMenuSelection;
2023-09-30 11:22:19 +01:00
DTMF_clear_RX();
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_D_LIVE_DEC:
gSetting_live_DTMF_decoder = gSubMenuSelection;
2023-09-30 11:22:19 +01:00
gDTMF_RX_live_timeout = 0;
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
2023-09-25 21:24:50 +01:00
if (!gSetting_live_DTMF_decoder)
BK4819_DisableDTMF();
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;
2023-09-09 08:03:56 +01:00
case MENU_D_LIST:
2023-10-04 21:29:35 +01:00
gDTMF_chosen_contact = gSubMenuSelection - 1;
2023-09-09 08:03:56 +01:00
if (gIsDtmfContactValid)
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
gDTMF_InputMode = true;
gDTMF_InputBox_Index = 3;
2023-09-17 09:54:24 +01:00
memmove(gDTMF_InputBox, gDTMF_ID, 4);
2023-09-09 08:03:56 +01:00
gRequestDisplayScreen = DISPLAY_INVALID;
}
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_PONMSG:
2023-10-08 17:14:13 +01:00
g_eeprom.pwr_on_display_mode = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_ROGER:
2023-10-08 17:14:13 +01:00
g_eeprom.roger_mode = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_AM:
2023-10-08 17:14:13 +01:00
gTxVfo->am_mode = gSubMenuSelection;
2023-09-28 23:32:08 +01:00
gRequestSaveChannel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-21 23:25:46 +01:00
#ifdef ENABLE_AM_FIX
2023-09-21 23:06:47 +01:00
case MENU_AM_FIX:
gSetting_AM_fix = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
break;
#endif
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
gSetting_AM_fix_test1 = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
break;
#endif
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
case MENU_NOAA_S:
2023-10-08 17:14:13 +01:00
g_eeprom.NOAA_auto_scan = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
gFlagReconfigureVfos = true;
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_DEL_CH:
SETTINGS_UpdateChannel(gSubMenuSelection, NULL, false);
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
return;
2023-09-19 11:44:49 +01:00
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_SHORT:
2023-10-08 17:14:13 +01:00
g_eeprom.key1_short_press_action = gSubMenuSelection;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_LONG:
2023-10-08 17:14:13 +01:00
g_eeprom.key1_long_press_action = gSubMenuSelection;
2023-10-06 22:16:03 +01:00
break;
case MENU_SIDE2_SHORT:
2023-10-08 17:14:13 +01:00
g_eeprom.key2_short_press_action = gSubMenuSelection;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE2_LONG:
2023-10-08 17:14:13 +01:00
g_eeprom.key2_long_press_action = gSubMenuSelection;
2023-10-06 22:16:03 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_RESET:
BOARD_FactoryReset(gSubMenuSelection);
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_350TX:
gSetting_350TX = gSubMenuSelection;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_F_LOCK:
gSetting_F_LOCK = gSubMenuSelection;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_200TX:
gSetting_200TX = gSubMenuSelection;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_500TX:
gSetting_500TX = gSubMenuSelection;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_350EN:
gSetting_350EN = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SCREN:
gSetting_ScrambleEnable = gSubMenuSelection;
gFlagReconfigureVfos = true;
break;
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
gSetting_TX_EN = gSubMenuSelection;
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
2023-10-04 10:01:07 +01:00
writeXtalFreqCal(gSubMenuSelection, true);
return;
#endif
2023-10-02 01:09:35 +01:00
case MENU_BATCAL:
{
uint16_t buf[4];
gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value
gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value
gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value
gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value
gBatteryCalibration[5] = 2300;
2023-10-02 01:09:35 +01:00
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration);
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = gBatteryCalibration[4];
buf[1] = gBatteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf);
2023-10-02 01:09:35 +01:00
break;
}
2023-09-09 08:03:56 +01:00
}
gRequestSaveSettings = true;
}
void MENU_SelectNextCode(void)
{
int32_t UpperLimit;
2023-09-09 08:03:56 +01:00
if (gMenuCursor == MENU_R_DCS)
UpperLimit = 208;
//UpperLimit = ARRAY_SIZE(DCS_Options);
2023-09-09 08:03:56 +01:00
else
if (gMenuCursor == MENU_R_CTCS)
UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1;
2023-09-09 08:03:56 +01:00
else
return;
gSubMenuSelection = NUMBER_AddWithWraparound(gSubMenuSelection, gMenuScrollDirection, 1, UpperLimit);
if (gMenuCursor == MENU_R_DCS)
{
if (gSubMenuSelection > 104)
{
2023-10-08 17:14:13 +01:00
gSelectedcode_type = CODE_TYPE_REVERSE_DIGITAL;
2023-09-09 08:03:56 +01:00
gSelectedCode = gSubMenuSelection - 105;
}
else
{
2023-10-08 17:14:13 +01:00
gSelectedcode_type = CODE_TYPE_DIGITAL;
2023-09-09 08:03:56 +01:00
gSelectedCode = gSubMenuSelection - 1;
}
}
else
{
2023-10-08 17:14:13 +01:00
gSelectedcode_type = CODE_TYPE_CONTINUOUS_TONE;
2023-09-09 08:03:56 +01:00
gSelectedCode = gSubMenuSelection - 1;
}
RADIO_SetupRegisters(true);
2023-10-08 17:14:13 +01:00
gScanPauseDelayIn_10ms = (gSelectedcode_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
2023-09-09 08:03:56 +01:00
gUpdateDisplay = true;
}
static void MENU_ClampSelection(int8_t Direction)
{
int32_t Min;
int32_t Max;
2023-09-26 17:35:03 +01:00
2023-09-09 08:03:56 +01:00
if (!MENU_GetLimits(gMenuCursor, &Min, &Max))
{
int32_t Selection = gSubMenuSelection;
2023-09-09 08:03:56 +01:00
if (Selection < Min) Selection = Min;
else
if (Selection > Max) Selection = Max;
gSubMenuSelection = NUMBER_AddWithWraparound(Selection, Direction, Min, Max);
}
}
void MENU_ShowCurrentSetting(void)
{
switch (gMenuCursor)
{
case MENU_SQL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.squelch_level;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STEP:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->step_setting;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TXP:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->output_power;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_R_DCS:
2023-10-08 17:14:13 +01:00
switch (gTxVfo->freq_config_rx.code_type)
2023-09-09 08:03:56 +01:00
{
case CODE_TYPE_DIGITAL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->freq_config_rx.code + 1;
2023-09-09 08:03:56 +01:00
break;
case CODE_TYPE_REVERSE_DIGITAL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->freq_config_rx.code + 105;
2023-09-09 08:03:56 +01:00
break;
default:
gSubMenuSelection = 0;
break;
}
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_RESET:
gSubMenuSelection = 0;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_R_CTCS:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = (gTxVfo->freq_config_rx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_rx.code + 1 : 0;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_T_DCS:
2023-10-08 17:14:13 +01:00
switch (gTxVfo->freq_config_tx.code_type)
2023-09-09 08:03:56 +01:00
{
case CODE_TYPE_DIGITAL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->freq_config_tx.code + 1;
2023-09-09 08:03:56 +01:00
break;
case CODE_TYPE_REVERSE_DIGITAL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->freq_config_tx.code + 105;
2023-09-09 08:03:56 +01:00
break;
default:
gSubMenuSelection = 0;
break;
}
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_T_CTCS:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = (gTxVfo->freq_config_tx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_tx.code + 1 : 0;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SFT_D:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->tx_offset_freq_dir;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_OFFSET:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->tx_offset_freq;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_W_N:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->channel_bandwidth;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SCR:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->scrambling_type;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BCL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->busy_channel_lock;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MEM_CH:
#if 0
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.user_channel[0];
#else
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo];
#endif
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MEM_NAME:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo];
break;
2023-09-09 08:03:56 +01:00
case MENU_SAVE:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.battery_save;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_VOX
case MENU_VOX:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0;
break;
#endif
2023-09-09 08:03:56 +01:00
case MENU_ABR:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.backlight;
2023-09-20 13:01:08 +01:00
gBacklightCountdown = 0;
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_ABR_ON_TX_RX:
gSubMenuSelection = gSetting_backlight_on_tx_rx;
break;
2023-09-09 08:03:56 +01:00
case MENU_TDR:
2023-10-08 17:14:13 +01:00
// gSubMenuSelection = g_eeprom.dual_watch;
gSubMenuSelection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_XB:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.cross_vfo_rx_tx;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BEEP:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.beep_control;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_TOT:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.tx_timeout_timer;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-09-09 08:03:56 +01:00
case MENU_VOICE:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.voice_prompt;
2023-09-09 08:03:56 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SC_REV:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.scan_resume_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MDF:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.channel_display_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_AUTOLK:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.auto_keypad_lock;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_ADD1:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->scanlist_1_participation;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_ADD2:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->scanlist_2_participation;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STE:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.tail_note_elimination;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_RP_STE:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.repeater_tail_tone_elimination;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_MIC:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.mic_sensitivity;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_AUDIO_BAR
case MENU_MIC_BAR:
gSubMenuSelection = gSetting_mic_bar;
break;
#endif
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->compander;
2023-10-04 16:37:11 +01:00
return;
2023-09-15 10:57:26 +01:00
2023-09-09 08:03:56 +01:00
case MENU_1_CALL:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.chan_1_call;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_S_LIST:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.scan_list_default;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SLIST1:
gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 0);
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SLIST2:
gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 1);
break;
2023-09-19 11:44:49 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_ALARM
2023-09-09 09:01:52 +01:00
case MENU_AL_MOD:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.alarm_mode;
2023-09-09 09:01:52 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_ST:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.DTMF_side_tone;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_RSP:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.DTMF_decode_response;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_HOLD:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.DTMF_auto_reset_time;
if (gSubMenuSelection <= DTMF_HOLD_MIN)
gSubMenuSelection = DTMF_HOLD_MIN;
else
if (gSubMenuSelection <= 10)
gSubMenuSelection = 10;
else
if (gSubMenuSelection <= 20)
gSubMenuSelection = 20;
else
if (gSubMenuSelection <= 30)
gSubMenuSelection = 30;
else
if (gSubMenuSelection <= 40)
gSubMenuSelection = 40;
else
if (gSubMenuSelection <= 50)
gSubMenuSelection = 50;
else
if (gSubMenuSelection < DTMF_HOLD_MAX)
gSubMenuSelection = 50;
else
gSubMenuSelection = DTMF_HOLD_MAX;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_PRE:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.DTMF_preload_time / 10;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_PTT_ID:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->DTMF_ptt_id_tx_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_BAT_TXT:
gSubMenuSelection = gSetting_battery_text;
return;
2023-09-09 08:03:56 +01:00
case MENU_D_DCD:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->DTMF_decoding_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_D_LIST:
2023-10-04 21:29:35 +01:00
gSubMenuSelection = gDTMF_chosen_contact + 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_D_LIVE_DEC:
gSubMenuSelection = gSetting_live_DTMF_decoder;
break;
2023-09-09 08:03:56 +01:00
case MENU_PONMSG:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.pwr_on_display_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_ROGER:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.roger_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_AM:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = gTxVfo->am_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-21 23:25:46 +01:00
#ifdef ENABLE_AM_FIX
2023-09-21 23:06:47 +01:00
case MENU_AM_FIX:
gSubMenuSelection = gSetting_AM_fix;
break;
#endif
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
gSubMenuSelection = gSetting_AM_fix_test1;
break;
#endif
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
case MENU_NOAA_S:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.NOAA_auto_scan;
2023-09-09 08:03:56 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_DEL_CH:
#if 0
2023-10-08 17:14:13 +01:00
gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1);
#else
2023-10-08 17:14:13 +01:00
gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 1);
#endif
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_SHORT:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.key1_short_press_action;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_LONG:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.key1_long_press_action;
2023-10-06 22:16:03 +01:00
break;
case MENU_SIDE2_SHORT:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.key2_short_press_action;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE2_LONG:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.key2_long_press_action;
2023-10-06 22:16:03 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_350TX:
gSubMenuSelection = gSetting_350TX;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_F_LOCK:
gSubMenuSelection = gSetting_F_LOCK;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_200TX:
gSubMenuSelection = gSetting_200TX;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_500TX:
gSubMenuSelection = gSetting_500TX;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_350EN:
gSubMenuSelection = gSetting_350EN;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_SCREN:
gSubMenuSelection = gSetting_ScrambleEnable;
break;
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
gSubMenuSelection = gSetting_TX_EN;
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
2023-10-08 17:14:13 +01:00
gSubMenuSelection = g_eeprom.BK4819_xtal_freq_low;
break;
#endif
2023-10-02 01:09:35 +01:00
case MENU_BATCAL:
gSubMenuSelection = gBatteryCalibration[3];
break;
2023-10-02 01:09:35 +01:00
default:
return;
2023-09-09 08:03:56 +01:00
}
}
2023-10-08 17:14:13 +01:00
static void MENU_Key_0_to_9(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
2023-09-09 08:03:56 +01:00
{
uint8_t Offset;
int32_t Min;
int32_t Max;
2023-09-09 08:03:56 +01:00
uint16_t Value = 0;
if (bKeyHeld || !bKeyPressed)
2023-09-09 08:03:56 +01:00
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-20 11:58:47 +01:00
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name
if (edit_index < 10)
{
2023-10-05 16:28:20 +01:00
if (Key >= KEY_0 && Key <= KEY_9)
2023-09-20 11:58:47 +01:00
{
edit[edit_index] = '0' + Key - KEY_0;
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
gRequestDisplayScreen = DISPLAY_MENU;
}
}
return;
}
2023-09-09 08:03:56 +01:00
INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_MENU;
if (!gIsInSubMenu)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
2023-09-09 08:03:56 +01:00
switch (gInputBoxIndex)
{
2023-09-26 17:35:03 +01:00
case 2:
gInputBoxIndex = 0;
Value = (gInputBox[0] * 10) + gInputBox[1];
2023-09-09 08:03:56 +01:00
if (Value > 0 && Value <= gMenuListCount)
{
gMenuCursor = Value - 1;
gFlagRefreshSetting = true;
return;
}
2023-09-26 17:35:03 +01:00
if (Value <= gMenuListCount)
break;
gInputBox[0] = gInputBox[1];
gInputBoxIndex = 1;
2023-09-26 17:35:03 +01:00
case 1:
Value = gInputBox[0];
2023-09-09 08:03:56 +01:00
if (Value > 0 && Value <= gMenuListCount)
{
gMenuCursor = Value - 1;
gFlagRefreshSetting = true;
return;
}
break;
}
#pragma GCC diagnostic pop
2023-09-09 08:03:56 +01:00
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
2023-09-09 08:03:56 +01:00
}
if (gMenuCursor == MENU_OFFSET)
{
uint32_t Frequency;
2023-09-09 08:03:56 +01:00
if (gInputBoxIndex < 6)
{ // invalid frequency
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
2023-09-09 08:03:56 +01:00
#endif
return;
}
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
#endif
2023-09-19 11:44:49 +01:00
NUMBER_Get(gInputBox, &Frequency);
2023-10-08 17:14:13 +01:00
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->step_freq, 0);
2023-09-09 08:03:56 +01:00
gInputBoxIndex = 0;
return;
}
2023-09-09 08:03:56 +01:00
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)
{
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
return;
2023-09-09 08:03:56 +01:00
}
gInputBoxIndex = 0;
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
2023-10-08 17:14:13 +01:00
if (Value <= USER_CHANNEL_LAST)
2023-09-09 08:03:56 +01:00
{
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
#endif
gSubMenuSelection = Value;
return;
}
2023-09-09 08:03:56 +01:00
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
2023-09-09 08:03:56 +01:00
if (MENU_GetLimits(gMenuCursor, &Min, &Max))
{
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
2023-09-19 11:44:49 +01:00
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
2023-09-09 08:03:56 +01:00
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;
2023-09-09 08:03:56 +01:00
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}
static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-19 11:44:49 +01:00
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (gIsInSubMenu)
2023-09-09 08:03:56 +01:00
{
if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET)
2023-09-09 08:03:56 +01:00
{
gAskForConfirmation = 0;
gIsInSubMenu = false;
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
2023-09-09 08:03:56 +01:00
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_CANCEL;
#endif
2023-09-09 08:03:56 +01:00
}
else
gInputBox[--gInputBoxIndex] = 10;
2023-09-09 08:03:56 +01:00
// ***********************
2023-09-09 08:03:56 +01:00
gRequestDisplayScreen = DISPLAY_MENU;
return;
2023-09-09 08:03:56 +01:00
}
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_CANCEL;
#endif
gRequestDisplayScreen = DISPLAY_MAIN;
2023-10-08 17:14:13 +01:00
if (g_eeprom.backlight == 0)
2023-09-20 13:01:08 +01:00
{
gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
2023-09-09 08:03:56 +01:00
}
else
{
MENU_StopCssScan();
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
}
gPttWasReleased = true;
2023-09-09 08:03:56 +01:00
}
static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
2023-09-09 08:03:56 +01:00
{
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MENU;
if (!gIsInSubMenu)
2023-09-09 08:03:56 +01:00
{
#ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR)
2023-10-08 17:14:13 +01:00
g_another_voice_id = MenuList[MenuList_sorted[gMenuCursor]].voice_id;
#endif
2023-09-19 11:44:49 +01:00
#if 1
if (gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel
#endif
2023-09-19 11:44:49 +01:00
gAskForConfirmation = 0;
gIsInSubMenu = true;
2023-09-30 11:22:19 +01:00
// if (gMenuCursor != MENU_D_LIST)
{
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;
2023-09-20 11:58:47 +01:00
BOARD_fetchChannelName(edit, gSubMenuSelection);
2023-09-20 11:58:47 +01:00
// 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
2023-09-20 11:23:45 +01:00
// make a copy so we can test for change when exiting the menu item
memmove(edit_original, edit, sizeof(edit_original));
2023-09-20 11:58:47 +01:00
return;
2023-09-09 08:03:56 +01:00
}
else
if (edit_index >= 0 && edit_index < 10)
{ // editing the channel name characters
2023-09-20 11:58:47 +01:00
if (++edit_index < 10)
return; // next char
2023-09-20 11:58:47 +01:00
// exit
2023-09-20 11:23:45 +01:00
if (memcmp(edit_original, edit, sizeof(edit_original)) == 0)
2023-09-20 11:58:47 +01:00
{ // no change - drop it
2023-09-20 11:23:45 +01:00
gFlagAcceptSetting = false;
gIsInSubMenu = false;
gAskForConfirmation = 0;
}
else
{
gFlagAcceptSetting = false;
gAskForConfirmation = 0;
}
}
}
2023-09-20 11:23:45 +01:00
// exiting the sub menu
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
if (gIsInSubMenu)
{
2023-09-20 11:23:45 +01:00
if (gMenuCursor == MENU_RESET ||
gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH ||
gMenuCursor == MENU_MEM_NAME)
2023-09-09 08:03:56 +01:00
{
2023-09-20 11:23:45 +01:00
switch (gAskForConfirmation)
{
case 0:
gAskForConfirmation = 1;
break;
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
case 1:
gAskForConfirmation = 2;
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
UI_DisplayMenu();
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
if (gMenuCursor == MENU_RESET)
{
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
#endif
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
MENU_AcceptSetting();
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
}
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
gFlagAcceptSetting = true;
gIsInSubMenu = false;
gAskForConfirmation = 0;
}
}
else
{
gFlagAcceptSetting = true;
gIsInSubMenu = false;
}
}
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
if (gCssScanMode != CSS_SCAN_MODE_OFF)
{
2023-09-20 11:23:45 +01:00
gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true;
2023-09-09 08:03:56 +01:00
}
2023-09-20 11:58:47 +01:00
#ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR)
2023-10-08 17:14:13 +01:00
g_another_voice_id = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_CONFIRM;
#endif
gInputBoxIndex = 0;
2023-09-09 08:03:56 +01:00
}
static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
2023-09-09 08:03:56 +01:00
{
if (bKeyHeld || !bKeyPressed)
return;
2023-09-09 08:03:56 +01:00
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-09 08:03:56 +01:00
2023-09-20 11:58:47 +01:00
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name
if (edit_index < 10)
{
edit[edit_index] = '-';
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
2023-10-08 17:14:13 +01:00
if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save) && gRxVfo->am_mode == 0)
#else
2023-10-08 17:14:13 +01:00
if (gRxVfo->am_mode == 0)
#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)
2023-09-09 08:03:56 +01:00
{
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
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif
2023-09-09 08:03:56 +01:00
}
}
gPttWasReleased = true;
return;
2023-09-09 08:03:56 +01:00
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
2023-09-09 08:03:56 +01:00
}
static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{
uint8_t VFO;
uint8_t Channel;
bool bCheckScanList;
if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character
2023-09-20 13:34:00 +01:00
if (bKeyPressed && edit_index < 10 && Direction != 0)
{
2023-09-20 13:34:00 +01:00
const char unwanted[] = "$%&!\"':;?^`|{}";
char c = edit[edit_index] + Direction;
unsigned int i = 0;
while (i < sizeof(unwanted) && c >= 32 && c <= 126)
{
if (c == unwanted[i++])
{ // choose next character
c += Direction;
i = 0;
}
2023-09-20 13:34:00 +01:00
}
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
2023-09-20 11:58:47 +01:00
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
2023-09-09 08:03:56 +01:00
if (!bKeyHeld)
{
if (!bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-09 08:03:56 +01:00
gInputBoxIndex = 0;
}
else
if (!bKeyPressed)
return;
if (gCssScanMode != CSS_SCAN_MODE_OFF)
{
MENU_StartCssScan(Direction);
2023-09-09 08:03:56 +01:00
gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
if (!gIsInSubMenu)
{
gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1);
gFlagRefreshSetting = true;
2023-09-09 08:03:56 +01:00
gRequestDisplayScreen = DISPLAY_MENU;
2023-09-20 13:01:08 +01:00
2023-10-08 17:14:13 +01:00
if (gMenuCursor != MENU_ABR && g_eeprom.backlight == 0)
2023-09-20 13:01:08 +01:00
{
gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
2023-09-09 08:03:56 +01:00
return;
}
if (gMenuCursor == MENU_OFFSET)
{
2023-10-08 17:14:13 +01:00
int32_t Offset = (Direction * gTxVfo->step_freq) + gSubMenuSelection;
2023-09-09 08:03:56 +01:00
if (Offset < 99999990)
{
if (Offset < 0)
Offset = 99999990;
}
else
Offset = 0;
2023-10-08 17:14:13 +01:00
gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->step_freq, 0);
2023-09-09 08:03:56 +01:00
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
VFO = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
2023-09-09 08:03:56 +01:00
switch (gMenuCursor)
{
case MENU_DEL_CH:
case MENU_1_CALL:
case MENU_MEM_NAME:
2023-09-09 08:03:56 +01:00
bCheckScanList = false;
break;
2023-09-09 08:03:56 +01:00
case MENU_SLIST2:
VFO = 1;
case MENU_SLIST1:
bCheckScanList = true;
break;
default:
2023-09-09 08:03:56 +01:00
MENU_ClampSelection(Direction);
gRequestDisplayScreen = DISPLAY_MENU;
return;
}
#pragma GCC diagnostic pop
2023-09-09 08:03:56 +01:00
Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO);
if (Channel != 0xFF)
gSubMenuSelection = Channel;
gRequestDisplayScreen = DISPLAY_MENU;
}
2023-10-08 17:14:13 +01:00
void MENU_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
2023-09-09 08:03:56 +01:00
{
switch (Key)
{
case KEY_0:
case KEY_1:
case KEY_2:
case KEY_3:
case KEY_4:
case KEY_5:
case KEY_6:
case KEY_7:
case KEY_8:
case KEY_9:
2023-09-20 11:58:47 +01:00
MENU_Key_0_to_9(Key, bKeyPressed, bKeyHeld);
2023-09-09 08:03:56 +01:00
break;
case KEY_MENU:
MENU_Key_MENU(bKeyPressed, bKeyHeld);
break;
case KEY_UP:
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
2023-09-09 08:03:56 +01:00
break;
case KEY_DOWN:
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
break;
case KEY_EXIT:
MENU_Key_EXIT(bKeyPressed, bKeyHeld);
break;
case KEY_STAR:
MENU_Key_STAR(bKeyPressed, bKeyHeld);
break;
case KEY_F:
2023-09-20 11:58:47 +01:00
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name
2023-09-20 12:02:50 +01:00
if (!bKeyHeld && bKeyPressed)
2023-09-20 11:58:47 +01:00
{
2023-09-20 12:02:50 +01:00
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (edit_index < 10)
{
edit[edit_index] = ' ';
if (++edit_index >= 10)
{ // exit edit
gFlagAcceptSetting = false;
gAskForConfirmation = 1;
}
gRequestDisplayScreen = DISPLAY_MENU;
2023-09-20 11:58:47 +01:00
}
}
break;
}
2023-09-09 08:03:56 +01:00
GENERIC_Key_F(bKeyPressed, bKeyHeld);
break;
case KEY_PTT:
GENERIC_Key_PTT(bKeyPressed);
break;
default:
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
}
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;
}
}
2023-09-09 08:03:56 +01:00
}