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

1972 lines
43 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/search.h"
2023-09-09 08:03:56 +01:00
#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 "driver/st7565.h"
2023-09-09 08:03:56 +01:00
#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_WriteBuffer8(0x1F88, &misc);
2023-10-04 10:01:07 +01:00
}
}
#endif
void MENU_start_css_scan(int8_t Direction)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_css_scan_mode = CSS_SCAN_MODE_SCANNING;
g_update_status = true;
2023-10-20 16:06:38 +01:00
g_menu_scroll_direction = Direction;
2023-09-19 11:44:49 +01:00
RADIO_select_vfos();
2023-09-09 08:03:56 +01:00
MENU_SelectNextCode();
2023-09-19 11:44:49 +01:00
g_scan_pause_10ms = scan_pause_css_10ms;
2023-09-09 08:03:56 +01:00
}
void MENU_stop_css_scan(void)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_update_status = true;
2023-09-09 08:03:56 +01:00
RADIO_setup_registers(true);
2023-09-09 08:03:56 +01:00
}
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:
case MENU_CHAN_SQL:
2023-09-09 08:03:56 +01:00
*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;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(STEP_FREQ_TABLE) - 1;
2023-09-15 15:53:37 +01:00
break;
2023-09-10 09:57:49 +01:00
case MENU_AUTO_BACKLITE:
2023-09-09 08:03:56 +01:00
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_backlight) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-15 17:45:07 +01:00
2023-10-14 10:33:21 +01:00
case MENU_FREQ_LOCK:
2023-09-15 17:45:07 +01:00
*pMin = 0;
2023-10-18 13:00:57 +01:00
*pMax = FREQ_LOCK_LAST - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MEM_DISP:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_MEM_DISP) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_TX_POWER:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_TX_POWER) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SHIFT_DIR:
2023-09-15 17:45:07 +01:00
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_shift_dir) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DUAL_WATCH:
2023-09-15 17:45:07 +01:00
*pMin = 0;
// *pMax = ARRAY_SIZE(g_sub_MENU_DUAL_WATCH) - 1;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SCAN_HOLD:
*pMin = 2;
2023-10-18 11:31:30 +01:00
*pMax = 20; // 10 seconds
break;
case MENU_CROSS_VFO:
2023-09-30 11:22:19 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_CROSS_VFO) - 1;
2023-09-30 11:22:19 +01:00
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;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_voice) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
case MENU_SCAN_CAR_RESUME:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_SCAN_CAR_RESUME) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_ROGER_MODE:
2023-09-09 08:03:56 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_ROGER_MODE_mode) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-10 09:57:49 +01:00
case MENU_PON_MSG:
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_pwr_on_msg) - 1;
break;
case MENU_RX_CDCSS:
case MENU_TX_CDCSS:
2023-09-09 08:03:56 +01:00
*pMin = 0;
*pMax = 208;
2023-10-08 20:23:37 +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
case MENU_RX_CTCSS:
case MENU_TX_CTCSS:
2023-09-09 08:03:56 +01:00
*pMin = 0;
2023-10-08 20:23:37 +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
case MENU_BANDWIDTH:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_BANDWIDTH) - 1;
2023-09-15 17:45:07 +01:00
break;
#ifdef ENABLE_ALARM
case MENU_ALARM_MODE:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_ALARM_MODE) - 1;
2023-09-15 17:45:07 +01:00
break;
#endif
#ifdef ENABLE_SIDE_BUTT_MENU
case MENU_SIDE1_SHORT:
case MENU_SIDE1_LONG:
case MENU_SIDE2_SHORT:
case MENU_SIDE2_LONG:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_SIDE_BUTT) - 1;
break;
#endif
2023-10-06 22:16:03 +01:00
2023-09-15 17:45:07 +01:00
case MENU_RESET:
2023-09-16 09:10:10 +01:00
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_RESET) - 1;
2023-09-16 09:10:10 +01:00
break;
2023-09-15 17:45:07 +01:00
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
case MENU_AUTO_BACKLITE_ON_TX_RX:
2023-10-04 16:37:11 +01:00
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_rx_tx) - 1;
2023-10-04 16:37:11 +01:00
break;
2023-09-16 09:10:10 +01:00
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_CONTRAST
case MENU_CONTRAST:
//*pMin = 0;
//*pMax = 63;
*pMin = 26;
*pMax = 45;
break;
#endif
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_AM_FIX_test1) - 1;
2023-09-23 17:23:21 +01:00
break;
#endif
#ifdef ENABLE_AM_FIX
case MENU_AM_FIX:
#endif
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_TX_AUDIO_BAR
2023-10-17 21:22:40 +01:00
case MENU_TX_BAR:
#endif
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_RX_SIGNAL_BAR
2023-10-17 21:22:40 +01:00
case MENU_RX_BAR:
#endif
case MENU_BUSY_CHAN_LOCK:
2023-09-09 08:03:56 +01:00
case MENU_BEEP:
#ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK:
#endif
2023-09-09 08:03:56 +01:00
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_STE:
case MENU_DTMF_ST:
case MENU_DTMF_DCD:
case MENU_DTMF_LIVE_DEC:
case MENU_MOD_MODE:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1;
break;
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
case MENU_NOAA_SCAN:
2023-09-09 08:03:56 +01:00
#endif
case MENU_350_TX:
case MENU_174_TX:
case MENU_470_TX:
case MENU_350_EN:
case MENU_SCRAMBLER_EN:
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
2023-09-09 08:03:56 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_DIS_EN) - 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SCRAMBLER:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_SCRAMBLERAMBLER) - 1;
break;
case MENU_TX_TO:
2023-09-28 17:39:45 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_TX_TO) - 1;
2023-09-28 17:39:45 +01:00
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
case MENU_MEM_SAVE:
2023-09-09 08:03:56 +01:00
case MENU_1_CALL:
case MENU_MEM_DEL:
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;
case MENU_BAT_SAVE:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_BAT_SAVE) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MIC_GAIN:
2023-09-09 08:03:56 +01:00
*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
case MENU_DTMF_RSP:
2023-09-15 17:45:07 +01:00
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_MENU_DTMF_RSP) - 1;
2023-09-15 17:45:07 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_PTT_ID:
*pMin = 0;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_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;
2023-10-08 20:23:37 +01:00
*pMax = ARRAY_SIZE(g_sub_menu_BAT_TXT) - 1;
break;
case MENU_DTMF_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
case MENU_DTMF_PRE:
2023-09-09 08:03:56 +01:00
*pMin = 3;
*pMax = 99;
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_LIST:
2023-09-09 08:03:56 +01:00
*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
case MENU_BAT_CAL:
*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 20:23:37 +01:00
freq_config_t *pConfig = &g_tx_vfo->freq_config_rx;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
if (!MENU_GetLimits(g_menu_cursor, &Min, &Max))
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection < Min) g_sub_menu_selection = Min;
2023-09-09 08:03:56 +01:00
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection > Max) g_sub_menu_selection = Max;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
switch (g_menu_cursor)
2023-09-09 08:03:56 +01:00
{
default:
return;
2023-09-09 08:03:56 +01:00
case MENU_SQL:
2023-10-08 20:23:37 +01:00
g_eeprom.squelch_level = g_sub_menu_selection;
g_vfo_configure_mode = VFO_CONFIGURE;
break;
case MENU_CHAN_SQL:
g_tx_vfo->squelch_level = g_sub_menu_selection;
g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE;
2023-10-19 19:30:53 +01:00
return;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_STEP:
g_tx_vfo->step_setting = step_freq_table_sorted[g_sub_menu_selection];
g_request_save_channel = 1;
2023-10-19 19:30:53 +01:00
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_TX_POWER:
2023-10-08 20:23:37 +01:00
g_tx_vfo->output_power = g_sub_menu_selection;
g_request_save_channel = 1;
2023-10-19 19:30:53 +01:00
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_TX_CDCSS:
2023-10-08 20:23:37 +01:00
pConfig = &g_tx_vfo->freq_config_tx;
2023-09-09 08:03:56 +01:00
// Fallthrough
case MENU_RX_CDCSS:
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection == 0)
2023-09-09 08:03:56 +01:00
{
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
{
2023-10-08 20:23:37 +01:00
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
}
2023-10-08 17:14:13 +01:00
Code = 0;
pConfig->code_type = CODE_TYPE_NONE;
2023-09-09 08:03:56 +01:00
}
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection < 105)
2023-09-09 08:03:56 +01:00
{
2023-10-08 17:14:13 +01:00
pConfig->code_type = CODE_TYPE_DIGITAL;
2023-10-08 20:23:37 +01:00
Code = g_sub_menu_selection - 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;
2023-10-08 20:23:37 +01:00
Code = g_sub_menu_selection - 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-10-08 20:23:37 +01:00
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
case MENU_TX_CTCSS:
2023-10-08 20:23:37 +01:00
pConfig = &g_tx_vfo->freq_config_tx;
case MENU_RX_CTCSS:
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection == 0)
2023-09-09 08:03:56 +01:00
{
2023-10-08 17:14:13 +01:00
if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
}
2023-10-08 20:23:37 +01:00
Code = 0;
pConfig->code = Code;
pConfig->code_type = CODE_TYPE_NONE;
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-10-08 20:23:37 +01:00
Code = g_sub_menu_selection - 1;
pConfig->code = Code;
2023-10-03 00:14:36 +01:00
2023-10-08 20:23:37 +01:00
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]);
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
#pragma GCC diagnostic pop
case MENU_SHIFT_DIR:
2023-10-08 20:23:37 +01:00
g_tx_vfo->tx_offset_freq_dir = g_sub_menu_selection;
g_request_save_channel = 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 20:23:37 +01:00
g_tx_vfo->tx_offset_freq = g_sub_menu_selection;
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_BANDWIDTH:
2023-10-08 20:23:37 +01:00
g_tx_vfo->channel_bandwidth = g_sub_menu_selection;
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_SCRAMBLER:
2023-10-08 20:23:37 +01:00
g_tx_vfo->scrambling_type = g_sub_menu_selection;
2023-10-03 00:14:36 +01:00
#if 0
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection > 0 && g_setting_scramble_enable)
BK4819_EnableScramble(g_sub_menu_selection - 1);
2023-10-03 00:14:36 +01:00
else
BK4819_DisableScramble();
#endif
2023-10-19 19:30:53 +01:00
g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_BUSY_CHAN_LOCK:
2023-10-08 20:23:37 +01:00
g_tx_vfo->busy_channel_lock = g_sub_menu_selection;
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_MEM_SAVE:
2023-10-08 20:23:37 +01:00
g_tx_vfo->channel_save = g_sub_menu_selection;
#if 0
2023-10-08 20:23:37 +01:00
g_eeprom.user_channel[0] = g_sub_menu_selection;
#else
2023-10-08 20:23:37 +01:00
g_eeprom.user_channel[g_eeprom.tx_vfo] = g_sub_menu_selection;
#endif
2023-10-08 20:23:37 +01:00
g_request_save_channel = 2;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_flag_reset_vfos = true;
return;
case MENU_MEM_NAME:
{ // trailing trim
for (int i = 9; i >= 0; i--)
{
2023-10-08 20:23:37 +01:00
if (g_edit[i] != ' ' && g_edit[i] != '_' && g_edit[i] != 0x00 && g_edit[i] != 0xff)
break;
2023-10-08 20:23:37 +01:00
g_edit[i] = ' ';
}
}
2023-09-20 11:58:47 +01:00
// save the channel name
2023-10-08 20:23:37 +01:00
memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name));
memmove(g_tx_vfo->name, g_edit, 10);
2023-10-19 14:21:37 +01:00
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
2023-10-08 20:23:37 +01:00
g_flag_reconfigure_vfos = true;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_BAT_SAVE:
2023-10-08 20:23:37 +01:00
g_eeprom.battery_save = g_sub_menu_selection;
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 20:23:37 +01:00
g_eeprom.vox_switch = g_sub_menu_selection != 0;
2023-10-08 17:14:13 +01:00
if (g_eeprom.vox_switch)
2023-10-08 20:23:37 +01:00
g_eeprom.vox_level = g_sub_menu_selection - 1;
2023-10-14 09:43:53 +01:00
BOARD_EEPROM_LoadCalibration();
2023-10-08 20:23:37 +01:00
g_flag_reconfigure_vfos = true;
g_update_status = true;
break;
#endif
2023-09-19 11:44:49 +01:00
case MENU_AUTO_BACKLITE:
2023-10-08 20:23:37 +01:00
g_eeprom.backlight = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_AUTO_BACKLITE_ON_TX_RX:
2023-10-08 20:23:37 +01:00
g_setting_backlight_on_tx_rx = g_sub_menu_selection;
break;
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_CONTRAST
case MENU_CONTRAST:
g_setting_contrast = g_sub_menu_selection;
ST7565_SetContrast(g_setting_contrast);
break;
#endif
case MENU_DUAL_WATCH:
2023-10-08 20:23:37 +01:00
// g_eeprom.dual_watch = g_sub_menu_selection;
g_eeprom.dual_watch = (g_sub_menu_selection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF;
2023-10-07 10:14:23 +01:00
2023-10-08 20:23:37 +01:00
g_flag_reconfigure_vfos = true;
g_update_status = true;
break;
2023-09-19 11:44:49 +01:00
case MENU_SCAN_HOLD:
g_eeprom.scan_hold_time_500ms = g_sub_menu_selection;
break;
case MENU_CROSS_VFO:
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
return;
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
return;
2023-09-19 11:44:49 +01:00
2023-10-08 20:23:37 +01:00
g_eeprom.cross_vfo_rx_tx = g_sub_menu_selection;
g_flag_reconfigure_vfos = true;
g_update_status = true;
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BEEP:
2023-10-08 20:23:37 +01:00
g_eeprom.beep_control = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_TX_TO:
2023-10-08 20:23:37 +01:00
g_eeprom.tx_timeout_timer = g_sub_menu_selection;
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 20:23:37 +01:00
g_eeprom.voice_prompt = g_sub_menu_selection;
g_update_status = true;
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
case MENU_SCAN_CAR_RESUME:
2023-10-08 20:23:37 +01:00
g_eeprom.scan_resume_mode = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MEM_DISP:
2023-10-08 20:23:37 +01:00
g_eeprom.channel_display_mode = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK:
g_eeprom.auto_keypad_lock = g_sub_menu_selection;
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
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_S_ADD1:
2023-10-08 20:23:37 +01:00
g_tx_vfo->scanlist_1_participation = g_sub_menu_selection;
2023-10-19 14:21:37 +01:00
SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo);
2023-10-08 20:23:37 +01:00
g_vfo_configure_mode = VFO_CONFIGURE;
g_flag_reset_vfos = 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_S_ADD2:
2023-10-08 20:23:37 +01:00
g_tx_vfo->scanlist_2_participation = g_sub_menu_selection;
2023-10-19 14:21:37 +01:00
SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo);
2023-10-08 20:23:37 +01:00
g_vfo_configure_mode = VFO_CONFIGURE;
g_flag_reset_vfos = 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_STE:
2023-10-08 20:23:37 +01:00
g_eeprom.tail_note_elimination = g_sub_menu_selection;
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 20:23:37 +01:00
g_eeprom.repeater_tail_tone_elimination = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MIC_GAIN:
2023-10-08 20:23:37 +01:00
g_eeprom.mic_sensitivity = g_sub_menu_selection;
2023-10-14 09:43:53 +01:00
BOARD_EEPROM_LoadCalibration();
2023-10-08 20:23:37 +01:00
g_flag_reconfigure_vfos = true;
break;
2023-09-19 11:44:49 +01:00
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_TX_AUDIO_BAR
2023-10-17 21:22:40 +01:00
case MENU_TX_BAR:
2023-10-08 20:23:37 +01:00
g_setting_mic_bar = g_sub_menu_selection;
break;
#endif
2023-10-18 11:31:30 +01:00
#ifdef ENABLE_RX_SIGNAL_BAR
2023-10-17 21:22:40 +01:00
case MENU_RX_BAR:
g_setting_rssi_bar = g_sub_menu_selection;
break;
#endif
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
g_tx_vfo->compand = g_sub_menu_selection;
2023-10-17 21:22:40 +01:00
#if 1
g_request_save_channel = 1;
#else
2023-10-19 14:21:37 +01:00
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
2023-10-17 21:22:40 +01:00
g_flag_reconfigure_vfos = true;
#endif
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 20:23:37 +01:00
g_eeprom.chan_1_call = g_sub_menu_selection;
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 20:23:37 +01:00
g_eeprom.scan_list_default = g_sub_menu_selection;
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
case MENU_ALARM_MODE:
2023-10-08 20:23:37 +01:00
g_eeprom.alarm_mode = g_sub_menu_selection;
2023-09-09 09:01:52 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
case MENU_DTMF_ST:
2023-10-08 20:23:37 +01:00
g_eeprom.dtmf_side_tone = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_RSP:
2023-10-08 20:23:37 +01:00
g_eeprom.dtmf_decode_response = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_HOLD:
2023-10-08 20:23:37 +01:00
g_eeprom.dtmf_auto_reset_time = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_PRE:
2023-10-08 20:23:37 +01:00
g_eeprom.dtmf_preload_time = g_sub_menu_selection * 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 20:23:37 +01:00
g_tx_vfo->dtmf_ptt_id_tx_mode = g_sub_menu_selection;
if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{
g_eeprom.roger_mode = ROGER_MODE_OFF;
break;
}
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_BAT_TXT:
2023-10-08 20:23:37 +01:00
g_setting_battery_text = g_sub_menu_selection;
break;
case MENU_DTMF_DCD:
2023-10-08 20:23:37 +01:00
g_tx_vfo->dtmf_decoding_enable = g_sub_menu_selection;
2023-09-30 11:22:19 +01:00
DTMF_clear_RX();
g_request_save_channel = 1;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_LIVE_DEC:
2023-10-08 20:23:37 +01:00
g_setting_live_dtmf_decoder = g_sub_menu_selection;
g_dtmf_rx_live_timeout = 0;
memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live));
if (!g_setting_live_dtmf_decoder)
2023-09-25 21:24:50 +01:00
BK4819_DisableDTMF();
2023-10-08 20:23:37 +01:00
g_flag_reconfigure_vfos = true;
g_update_status = true;
break;
case MENU_DTMF_LIST:
2023-10-08 20:23:37 +01:00
g_dtmf_chosen_contact = g_sub_menu_selection - 1;
if (g_dtmf_is_contact_valid)
2023-09-09 08:03:56 +01:00
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
2023-10-08 20:23:37 +01:00
g_dtmf_input_mode = true;
g_dtmf_input_box_index = 3;
memmove(g_dtmf_input_box, g_dtmf_id, 4);
g_request_display_screen = DISPLAY_INVALID;
2023-09-09 08:03:56 +01:00
}
return;
2023-09-19 11:44:49 +01:00
case MENU_PON_MSG:
2023-10-08 20:23:37 +01:00
g_eeprom.pwr_on_display_mode = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_ROGER_MODE:
2023-10-08 20:23:37 +01:00
g_eeprom.roger_mode = g_sub_menu_selection;
if (g_eeprom.roger_mode != ROGER_MODE_OFF)
{
if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{
g_tx_vfo->dtmf_ptt_id_tx_mode = PTT_ID_OFF; // // disable PTT ID tail
g_request_save_channel = 1;
}
}
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MOD_MODE:
2023-10-08 20:23:37 +01:00
g_tx_vfo->am_mode = g_sub_menu_selection;
g_request_save_channel = 1;
2023-10-19 19:30:53 +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:
2023-10-08 20:23:37 +01:00
g_setting_am_fix = g_sub_menu_selection;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_flag_reset_vfos = true;
2023-09-21 23:06:47 +01:00
break;
#endif
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
2023-10-08 20:23:37 +01:00
g_setting_am_fix_test1 = g_sub_menu_selection;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_flag_reset_vfos = true;
2023-09-23 17:23:21 +01:00
break;
#endif
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
case MENU_NOAA_SCAN:
2023-10-08 20:23:37 +01:00
g_eeprom.noaa_auto_scan = g_sub_menu_selection;
g_flag_reconfigure_vfos = true;
break;
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 11:44:49 +01:00
case MENU_MEM_DEL:
2023-10-19 14:21:37 +01:00
SETTINGS_save_chan_attribs_name(g_sub_menu_selection, NULL);
2023-10-08 20:23:37 +01:00
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_flag_reset_vfos = true;
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_SIDE_BUTT_MENU
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_SHORT:
2023-10-08 20:23:37 +01:00
g_eeprom.key1_short_press_action = g_sub_menu_selection;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_LONG:
2023-10-08 20:23:37 +01:00
g_eeprom.key1_long_press_action = g_sub_menu_selection;
2023-10-06 22:16:03 +01:00
break;
case MENU_SIDE2_SHORT:
2023-10-08 20:23:37 +01:00
g_eeprom.key2_short_press_action = g_sub_menu_selection;
2023-10-06 22:16:03 +01:00
break;
2023-10-06 22:16:03 +01:00
case MENU_SIDE2_LONG:
2023-10-08 20:23:37 +01:00
g_eeprom.key2_long_press_action = g_sub_menu_selection;
2023-10-06 22:16:03 +01:00
break;
#endif
2023-10-06 22:16:03 +01:00
2023-09-09 08:03:56 +01:00
case MENU_RESET:
2023-10-08 20:23:37 +01:00
BOARD_FactoryReset(g_sub_menu_selection);
2023-09-09 08:03:56 +01:00
return;
2023-09-19 11:44:49 +01:00
case MENU_350_TX:
2023-10-08 20:23:37 +01:00
g_setting_350_tx_enable = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-10-14 10:33:21 +01:00
case MENU_FREQ_LOCK:
g_setting_freq_lock = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_174_TX:
g_setting_174_tx_enable = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_470_TX:
g_setting_470_tx_enable = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_350_EN:
2023-10-08 20:23:37 +01:00
g_setting_350_enable = g_sub_menu_selection;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_flag_reset_vfos = true;
break;
2023-09-19 11:44:49 +01:00
case MENU_SCRAMBLER_EN:
2023-10-08 20:23:37 +01:00
g_setting_scramble_enable = g_sub_menu_selection;
g_flag_reconfigure_vfos = true;
break;
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
g_setting_tx_enable = g_sub_menu_selection;
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
2023-10-08 20:23:37 +01:00
writeXtalFreqCal(g_sub_menu_selection, true);
return;
#endif
2023-10-02 01:09:35 +01:00
case MENU_BAT_CAL:
{
uint16_t buf[4];
2023-10-08 20:23:37 +01:00
g_battery_calibration[0] = (520ul * g_sub_menu_selection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
g_battery_calibration[1] = (700ul * g_sub_menu_selection) / 760; // 7.00V, ~5%, 1 bars above this value
g_battery_calibration[2] = (745ul * g_sub_menu_selection) / 760; // 7.45V, ~17%, 2 bars above this value
g_battery_calibration[3] = g_sub_menu_selection; // 7.6V, ~29%, 3 bars above this value
g_battery_calibration[4] = (788ul * g_sub_menu_selection) / 760; // 7.88V, ~65%, 4 bars above this value
g_battery_calibration[5] = 2300;
EEPROM_WriteBuffer8(0x1F40, g_battery_calibration);
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
2023-10-08 20:23:37 +01:00
buf[0] = g_battery_calibration[4];
buf[1] = g_battery_calibration[5];
EEPROM_WriteBuffer8(0x1F48, buf);
2023-10-02 01:09:35 +01:00
break;
}
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_request_save_settings = true;
2023-09-09 08:03:56 +01:00
}
void MENU_SelectNextCode(void)
{
int32_t UpperLimit;
2023-09-09 08:03:56 +01:00
if (g_menu_cursor == MENU_RX_CDCSS)
2023-09-09 08:03:56 +01:00
UpperLimit = 208;
2023-10-08 20:23:37 +01:00
//UpperLimit = ARRAY_SIZE(DCS_OPTIONS);
2023-09-09 08:03:56 +01:00
else
if (g_menu_cursor == MENU_RX_CTCSS)
2023-10-08 20:23:37 +01:00
UpperLimit = ARRAY_SIZE(CTCSS_OPTIONS) - 1;
2023-09-09 08:03:56 +01:00
else
return;
2023-10-20 16:06:38 +01:00
g_sub_menu_selection = NUMBER_AddWithWraparound(g_sub_menu_selection, g_menu_scroll_direction, 1, UpperLimit);
2023-09-09 08:03:56 +01:00
if (g_menu_cursor == MENU_RX_CDCSS)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection > 104)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_selected_code_type = CODE_TYPE_REVERSE_DIGITAL;
g_selected_code = g_sub_menu_selection - 105;
2023-09-09 08:03:56 +01:00
}
else
{
2023-10-08 20:23:37 +01:00
g_selected_code_type = CODE_TYPE_DIGITAL;
g_selected_code = g_sub_menu_selection - 1;
2023-09-09 08:03:56 +01:00
}
}
else
{
2023-10-08 20:23:37 +01:00
g_selected_code_type = CODE_TYPE_CONTINUOUS_TONE;
g_selected_code = g_sub_menu_selection - 1;
2023-09-09 08:03:56 +01:00
}
RADIO_setup_registers(true);
2023-09-09 08:03:56 +01:00
g_scan_pause_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_ctcss_10ms : scan_pause_cdcss_10ms;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_update_display = true;
2023-09-09 08:03:56 +01:00
}
static void MENU_ClampSelection(int8_t Direction)
{
int32_t Min;
int32_t Max;
2023-09-26 17:35:03 +01:00
2023-10-08 20:23:37 +01:00
if (!MENU_GetLimits(g_menu_cursor, &Min, &Max))
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
int32_t Selection = g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
if (Selection < Min) Selection = Min;
else
if (Selection > Max) Selection = Max;
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = NUMBER_AddWithWraparound(Selection, Direction, Min, Max);
2023-09-09 08:03:56 +01:00
}
}
void MENU_ShowCurrentSetting(void)
{
2023-10-08 20:23:37 +01:00
switch (g_menu_cursor)
2023-09-09 08:03:56 +01:00
{
case MENU_SQL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.squelch_level;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_CHAN_SQL:
g_sub_menu_selection = g_tx_vfo->squelch_level;
break;
2023-09-09 08:03:56 +01:00
case MENU_STEP:
g_sub_menu_selection = FREQUENCY_get_step_index(STEP_FREQ_TABLE[g_tx_vfo->step_setting]);
2023-09-09 08:03:56 +01:00
break;
case MENU_TX_POWER:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->output_power;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_RX_CDCSS:
2023-10-08 20:23:37 +01:00
switch (g_tx_vfo->freq_config_rx.code_type)
2023-09-09 08:03:56 +01:00
{
case CODE_TYPE_DIGITAL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->freq_config_rx.code + 1;
2023-09-09 08:03:56 +01:00
break;
case CODE_TYPE_REVERSE_DIGITAL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->freq_config_rx.code + 105;
2023-09-09 08:03:56 +01:00
break;
default:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 0;
2023-09-09 08:03:56 +01:00
break;
}
break;
2023-09-19 11:44:49 +01:00
2023-09-09 08:03:56 +01:00
case MENU_RESET:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 0;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_RX_CTCSS:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = (g_tx_vfo->freq_config_rx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? g_tx_vfo->freq_config_rx.code + 1 : 0;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_TX_CDCSS:
2023-10-08 20:23:37 +01:00
switch (g_tx_vfo->freq_config_tx.code_type)
2023-09-09 08:03:56 +01:00
{
case CODE_TYPE_DIGITAL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->freq_config_tx.code + 1;
2023-09-09 08:03:56 +01:00
break;
case CODE_TYPE_REVERSE_DIGITAL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->freq_config_tx.code + 105;
2023-09-09 08:03:56 +01:00
break;
default:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 0;
2023-09-09 08:03:56 +01:00
break;
}
break;
2023-09-19 11:44:49 +01:00
case MENU_TX_CTCSS:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = (g_tx_vfo->freq_config_tx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? g_tx_vfo->freq_config_tx.code + 1 : 0;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SHIFT_DIR:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->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 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->tx_offset_freq;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_BANDWIDTH:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->channel_bandwidth;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SCRAMBLER:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->scrambling_type;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_BUSY_CHAN_LOCK:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->busy_channel_lock;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MEM_SAVE:
#if 0
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.user_channel[0];
#else
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.user_channel[g_eeprom.tx_vfo];
break;
case MENU_BAT_SAVE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0;
break;
#endif
case MENU_AUTO_BACKLITE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.backlight;
2023-09-20 13:01:08 +01:00
2023-10-08 20:23:37 +01:00
g_backlight_count_down = 0;
2023-09-20 13:01:08 +01:00
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_AUTO_BACKLITE_ON_TX_RX:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_backlight_on_tx_rx;
break;
#ifdef ENABLE_CONTRAST
2023-10-18 11:31:30 +01:00
case MENU_CONTRAST:
g_sub_menu_selection = g_setting_contrast;
break;
#endif
2023-10-18 11:31:30 +01:00
case MENU_DUAL_WATCH:
2023-10-08 20:23:37 +01:00
// g_sub_menu_selection = g_eeprom.dual_watch;
g_sub_menu_selection = (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_SCAN_HOLD:
g_sub_menu_selection = g_eeprom.scan_hold_time_500ms;
break;
case MENU_CROSS_VFO:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.beep_control;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_TX_TO:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.tx_timeout_timer;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_VOICE
2023-09-09 08:03:56 +01:00
case MENU_VOICE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.voice_prompt;
2023-09-09 08:03:56 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
case MENU_SCAN_CAR_RESUME:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.scan_resume_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MEM_DISP:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.channel_display_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.auto_keypad_lock;
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_S_ADD1:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->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 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->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 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.repeater_tail_tone_elimination;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MIC_GAIN:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.mic_sensitivity;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_TX_AUDIO_BAR
2023-10-17 21:22:40 +01:00
case MENU_TX_BAR:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_mic_bar;
break;
#endif
#ifdef ENABLE_RX_SIGNAL_BAR
2023-10-17 21:22:40 +01:00
case MENU_RX_BAR:
g_sub_menu_selection = g_setting_rssi_bar;
break;
#endif
2023-10-04 16:37:11 +01:00
case MENU_COMPAND:
2023-10-17 21:22:40 +01:00
g_sub_menu_selection = g_tx_vfo->compand;
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 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = 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:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = RADIO_FindNextChannel(0, 1, true, 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_SLIST2:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = RADIO_FindNextChannel(0, 1, true, 1);
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_ALARM
case MENU_ALARM_MODE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.alarm_mode;
2023-09-09 09:01:52 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
case MENU_DTMF_ST:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.dtmf_side_tone;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_RSP:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.dtmf_decode_response;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_HOLD:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.dtmf_auto_reset_time;
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= DTMF_HOLD_MIN)
g_sub_menu_selection = DTMF_HOLD_MIN;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= 10)
g_sub_menu_selection = 10;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= 20)
g_sub_menu_selection = 20;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= 30)
g_sub_menu_selection = 30;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= 40)
g_sub_menu_selection = 40;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection <= 50)
g_sub_menu_selection = 50;
else
2023-10-08 20:23:37 +01:00
if (g_sub_menu_selection < DTMF_HOLD_MAX)
g_sub_menu_selection = 50;
else
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = DTMF_HOLD_MAX;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_PRE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->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:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_battery_text;
return;
case MENU_DTMF_DCD:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->dtmf_decoding_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_LIST:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_dtmf_chosen_contact + 1;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_DTMF_LIVE_DEC:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_live_dtmf_decoder;
break;
case MENU_PON_MSG:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.pwr_on_display_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_ROGER_MODE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.roger_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_MOD_MODE:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_tx_vfo->am_mode;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_AM_FIX
2023-09-21 23:06:47 +01:00
case MENU_AM_FIX:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_am_fix;
2023-09-21 23:06:47 +01:00
break;
#endif
#ifdef ENABLE_AM_FIX_TEST1
2023-09-23 17:23:21 +01:00
case MENU_AM_FIX_TEST1:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_am_fix_test1;
2023-09-23 17:23:21 +01:00
break;
#endif
2023-09-23 17:23:21 +01:00
#ifdef ENABLE_NOAA
case MENU_NOAA_SCAN:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.noaa_auto_scan;
2023-09-09 08:03:56 +01:00
break;
#endif
2023-09-19 11:44:49 +01:00
case MENU_MEM_DEL:
#if 0
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1);
#else
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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
#ifdef ENABLE_SIDE_BUTT_MENU
2023-10-06 22:16:03 +01:00
case MENU_SIDE1_SHORT:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.key1_long_press_action;
2023-10-06 22:16:03 +01:00
break;
case MENU_SIDE2_SHORT:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = 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 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.key2_long_press_action;
2023-10-06 22:16:03 +01:00
break;
#endif
2023-10-06 22:16:03 +01:00
case MENU_350_TX:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_350_tx_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
2023-10-14 10:33:21 +01:00
case MENU_FREQ_LOCK:
g_sub_menu_selection = g_setting_freq_lock;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_174_TX:
g_sub_menu_selection = g_setting_174_tx_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_470_TX:
g_sub_menu_selection = g_setting_470_tx_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_350_EN:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_350_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 11:44:49 +01:00
case MENU_SCRAMBLER_EN:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_setting_scramble_enable;
2023-09-09 08:03:56 +01:00
break;
2023-09-19 09:16:57 +01:00
case MENU_TX_EN:
g_sub_menu_selection = g_setting_tx_enable;
2023-09-19 09:16:57 +01:00
break;
2023-09-19 11:44:49 +01:00
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_eeprom.BK4819_xtal_freq_low;
break;
#endif
2023-10-02 01:09:35 +01:00
case MENU_BAT_CAL:
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = g_battery_calibration[3];
2023-10-02 01:09:35 +01:00
break;
2023-10-02 01:09:35 +01:00
default:
return;
2023-09-09 08:03:56 +01:00
}
}
2023-10-08 20:23:37 +01:00
static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
2023-09-09 08:03:56 +01:00
{
2023-10-20 18:00:36 +01:00
unsigned int index;
int32_t min;
int32_t max;
uint32_t value = 0;
2023-10-08 20:23:37 +01:00
if (key_held || !key_pressed)
2023-09-09 08:03:56 +01:00
return;
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0)
2023-09-20 11:58:47 +01:00
{ // currently editing the channel name
2023-10-08 20:23:37 +01:00
if (g_edit_index < 10)
2023-09-20 11:58:47 +01:00
{
2023-10-10 00:00:22 +01:00
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
2023-10-05 16:28:20 +01:00
if (Key >= KEY_0 && Key <= KEY_9)
2023-09-20 11:58:47 +01:00
{
2023-10-08 20:23:37 +01:00
g_edit[g_edit_index] = '0' + Key - KEY_0;
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
if (++g_edit_index >= 10)
2023-09-20 11:58:47 +01:00
{ // exit edit
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 1;
2023-09-20 11:58:47 +01:00
}
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-20 11:58:47 +01:00
}
2023-10-10 00:00:22 +01:00
#pragma GCC diagnostic pop
2023-09-20 11:58:47 +01:00
}
return;
}
2023-10-20 18:00:36 +01:00
INPUTBOX_append(Key);
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-09 08:03:56 +01:00
2023-10-20 18:00:36 +01:00
if (!g_in_sub_menu)
2023-09-09 08:03:56 +01:00
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
2023-10-08 20:23:37 +01:00
switch (g_input_box_index)
2023-09-09 08:03:56 +01:00
{
2023-09-26 17:35:03 +01:00
case 2:
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-09-26 17:35:03 +01:00
2023-10-20 18:00:36 +01:00
value = (g_input_box[0] * 10) + g_input_box[1];
2023-10-20 18:00:36 +01:00
if (value > 0 && value <= g_menu_list_count)
2023-09-09 08:03:56 +01:00
{
2023-10-20 18:00:36 +01:00
g_menu_cursor = value - 1;
2023-10-08 20:23:37 +01:00
g_flag_refresh_menu = true;
2023-09-09 08:03:56 +01:00
return;
}
2023-10-20 18:00:36 +01:00
if (value <= g_menu_list_count)
2023-09-26 17:35:03 +01:00
break;
2023-10-08 20:23:37 +01:00
g_input_box[0] = g_input_box[1];
g_input_box_index = 1;
2023-09-26 17:35:03 +01:00
case 1:
2023-10-20 18:00:36 +01:00
value = g_input_box[0];
if (value > 0 && value <= g_menu_list_count)
2023-09-09 08:03:56 +01:00
{
2023-10-20 18:00:36 +01:00
g_menu_cursor = value - 1;
2023-10-08 20:23:37 +01:00
g_flag_refresh_menu = true;
2023-09-09 08:03:56 +01:00
return;
}
break;
}
#pragma GCC diagnostic pop
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_OFFSET)
{
uint32_t Frequency;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
if (g_input_box_index < 6)
2023-10-20 18:00:36 +01:00
{ // not yet enough characters
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
2023-10-20 18:00:36 +01:00
#endif
2023-09-09 08:03:56 +01:00
return;
}
2023-10-20 18:00:36 +01:00
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
2023-10-20 18:00:36 +01:00
#endif
2023-09-19 11:44:49 +01:00
2023-10-08 20:23:37 +01:00
NUMBER_Get(g_input_box, &Frequency);
2023-10-20 18:00:36 +01:00
g_input_box_index = 0;
g_sub_menu_selection = FREQUENCY_FloorToStep(Frequency + (g_tx_vfo->step_freq / 2), g_tx_vfo->step_freq, 0);
return;
}
if (g_menu_cursor == MENU_BAT_CAL)
{
g_sub_menu_selection = INPUTBOX_value(); // get the current value from the input box
if (g_input_box_index < 4)
{ // not yet enough characters
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
#endif
return;
}
#ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key;
#endif
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
return;
}
2023-09-09 08:03:56 +01:00
if (g_menu_cursor == MENU_MEM_SAVE ||
g_menu_cursor == MENU_MEM_DEL ||
2023-10-08 20:23:37 +01:00
g_menu_cursor == MENU_1_CALL ||
g_menu_cursor == MENU_MEM_NAME)
{ // enter 3-digit channel number
2023-10-08 20:23:37 +01:00
if (g_input_box_index < 3)
{
2023-10-20 18:00:36 +01:00
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
2023-10-20 18:00:36 +01:00
#endif
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
return;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-10-20 18:00:36 +01:00
value = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1;
2023-10-20 18:00:36 +01:00
if (value <= USER_CHANNEL_LAST)
2023-10-08 20:23:37 +01:00
{ // user channel
2023-10-20 18:00:36 +01:00
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = (voice_id_t)Key;
2023-10-20 18:00:36 +01:00
#endif
g_sub_menu_selection = value;
return;
}
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
2023-09-09 08:03:56 +01:00
2023-10-20 18:00:36 +01:00
if (MENU_GetLimits(g_menu_cursor, &min, &max))
{
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
2023-09-19 11:44:49 +01:00
2023-10-20 18:00:36 +01:00
index = (max >= 100000) ? 6 : (max >= 10000) ? 5 : (max >= 1000) ? 4 : (max >= 100) ? 3 : (max >= 10) ? 2 : 1;
// NUMBER_Get(g_input_box, &value);
2023-10-08 20:23:37 +01:00
switch (g_input_box_index)
{
case 1:
2023-10-20 18:00:36 +01:00
value = g_input_box[0];
break;
case 2:
2023-10-20 18:00:36 +01:00
value = (g_input_box[0] * 10) + g_input_box[1];
break;
case 3:
2023-10-20 18:00:36 +01:00
value = (g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2];
break;
case 4:
value = (g_input_box[0] * 1000) + (g_input_box[1] * 100) + (g_input_box[2] * 10) + g_input_box[3];
break;
}
2023-10-20 18:00:36 +01:00
if (index == g_input_box_index)
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-10-20 18:00:36 +01:00
if ((int32_t)value <= max)
{
2023-10-20 18:00:36 +01:00
g_sub_menu_selection = value;
return;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
static void MENU_Key_EXIT(bool key_pressed, bool key_held)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (key_held || !key_pressed)
return;
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-19 11:44:49 +01:00
2023-10-08 20:23:37 +01:00
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
{
2023-10-20 18:00:36 +01:00
if (g_in_sub_menu)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (g_input_box_index == 0 || g_menu_cursor != MENU_OFFSET)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 0;
2023-10-20 18:00:36 +01:00
g_in_sub_menu = false;
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
g_flag_refresh_menu = 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
2023-10-08 20:23:37 +01:00
g_input_box[--g_input_box_index] = 10;
2023-09-09 08:03:56 +01:00
// ***********************
2023-10-08 20:23:37 +01:00
g_request_display_screen = 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
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MAIN;
2023-10-08 17:14:13 +01:00
if (g_eeprom.backlight == 0)
2023-09-20 13:01:08 +01:00
{
2023-10-08 20:23:37 +01:00
g_backlight_count_down = 0;
2023-09-20 13:01:08 +01:00
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
2023-09-09 08:03:56 +01:00
}
else
{
MENU_stop_css_scan();
#ifdef ENABLE_VOICE
2023-10-08 17:14:13 +01:00
g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
}
2023-10-08 20:23:37 +01:00
g_ptt_was_released = true;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (key_held || !key_pressed)
return;
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_request_display_screen = DISPLAY_MENU;
2023-10-20 18:00:36 +01:00
if (!g_in_sub_menu)
2023-09-09 08:03:56 +01:00
{
#ifdef ENABLE_VOICE
if (g_menu_cursor != MENU_SCRAMBLER)
2023-10-08 20:23:37 +01:00
g_another_voice_id = g_menu_list[g_menu_list_sorted[g_menu_cursor]].voice_id;
#endif
2023-09-19 11:44:49 +01:00
#if 1
if (g_menu_cursor == MENU_MEM_DEL || g_menu_cursor == MENU_MEM_NAME)
2023-10-08 20:23:37 +01:00
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0))
return; // invalid channel
#endif
2023-09-19 11:44:49 +01:00
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 0;
2023-10-20 18:00:36 +01:00
g_in_sub_menu = true;
// if (g_menu_cursor != MENU_DTMF_LIST)
2023-09-30 11:22:19 +01:00
{
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
g_edit_index = -1;
2023-09-30 11:22:19 +01:00
}
return;
}
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_MEM_NAME)
{
2023-10-08 20:23:37 +01:00
if (g_edit_index < 0)
{ // enter channel name edit mode
2023-10-08 20:23:37 +01:00
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0))
return;
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
BOARD_fetchChannelName(g_edit, g_sub_menu_selection);
2023-09-20 11:58:47 +01:00
// pad the channel name out with '_'
2023-10-08 20:23:37 +01:00
g_edit_index = strlen(g_edit);
while (g_edit_index < 10)
g_edit[g_edit_index++] = '_';
g_edit[g_edit_index] = 0;
g_edit_index = 0; // 'g_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
2023-10-08 20:23:37 +01:00
memmove(g_edit_original, g_edit, sizeof(g_edit_original));
2023-09-20 11:58:47 +01:00
return;
2023-09-09 08:03:56 +01:00
}
else
2023-10-08 20:23:37 +01:00
if (g_edit_index >= 0 && g_edit_index < 10)
{ // editing the channel name characters
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
if (++g_edit_index < 10)
return; // next char
2023-09-20 11:58:47 +01:00
// exit
2023-10-08 20:23:37 +01:00
if (memcmp(g_edit_original, g_edit, sizeof(g_edit_original)) == 0)
2023-09-20 11:58:47 +01:00
{ // no change - drop it
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = false;
2023-10-20 18:00:36 +01:00
g_in_sub_menu = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 0;
2023-09-20 11:23:45 +01:00
}
else
{
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 0;
2023-09-20 11:23:45 +01:00
}
}
}
2023-09-20 11:23:45 +01:00
// exiting the sub menu
2023-09-20 11:58:47 +01:00
2023-10-20 18:00:36 +01:00
if (g_in_sub_menu)
{
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_RESET ||
g_menu_cursor == MENU_MEM_SAVE ||
g_menu_cursor == MENU_MEM_DEL ||
2023-10-08 20:23:37 +01:00
g_menu_cursor == MENU_MEM_NAME)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
switch (g_ask_for_confirmation)
2023-09-20 11:23:45 +01:00
{
case 0:
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 1;
2023-09-20 11:23:45 +01:00
break;
2023-09-20 11:58:47 +01:00
2023-09-20 11:23:45 +01:00
case 1:
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 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-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_RESET)
2023-09-20 11:23:45 +01:00
{
#ifdef ENABLE_VOICE
2023-09-20 11:23:45 +01:00
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
#if defined(ENABLE_OVERLAY)
2023-09-20 11:23:45 +01:00
overlay_FLASH_RebootToBootloader();
#else
2023-09-20 11:23:45 +01:00
NVIC_SystemReset();
#endif
2023-09-20 11:23:45 +01:00
}
2023-09-20 11:58:47 +01:00
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = true;
2023-10-20 18:00:36 +01:00
g_in_sub_menu = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 0;
2023-09-20 11:23:45 +01:00
}
}
else
{
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = true;
2023-10-20 18:00:36 +01:00
g_in_sub_menu = false;
}
}
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
{
2023-10-08 20:23:37 +01:00
g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_update_status = true;
2023-09-09 08:03:56 +01:00
}
2023-09-20 11:58:47 +01:00
#ifdef ENABLE_VOICE
if (g_menu_cursor == MENU_SCRAMBLER)
2023-10-08 20:23:37 +01:00
g_another_voice_id = (g_sub_menu_selection == 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
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
static void MENU_Key_STAR(const bool key_pressed, const bool key_held)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (key_held || !key_pressed)
return;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0)
2023-09-20 11:58:47 +01:00
{ // currently editing the channel name
2023-10-08 20:23:37 +01:00
if (g_edit_index < 10)
2023-09-20 11:58:47 +01:00
{
2023-10-08 20:23:37 +01:00
g_edit[g_edit_index] = '-';
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
if (++g_edit_index >= 10)
2023-09-20 11:58:47 +01:00
{ // exit edit
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 1;
2023-09-20 11:58:47 +01:00
}
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-20 11:58:47 +01:00
}
return;
}
RADIO_select_vfos();
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_rx_vfo->am_mode == 0)
{
if (g_menu_cursor == MENU_RX_CTCSS || g_menu_cursor == MENU_RX_CDCSS)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal
2023-10-08 20:23:37 +01:00
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
2023-09-09 08:03:56 +01:00
{
MENU_start_css_scan(1);
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(1);
#endif
}
else
{
MENU_stop_css_scan();
2023-10-08 20:23:37 +01:00
g_request_display_screen = 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
}
}
2023-10-08 20:23:37 +01:00
g_ptt_was_released = true;
return;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
2023-09-09 08:03:56 +01:00
{
uint8_t VFO;
uint8_t Channel;
bool bCheckScanList;
2023-10-20 18:00:36 +01:00
if (g_menu_cursor == MENU_MEM_NAME && g_in_sub_menu && g_edit_index >= 0)
{ // change the character
2023-10-08 20:23:37 +01:00
if (key_pressed && g_edit_index < 10 && Direction != 0)
{
2023-09-20 13:34:00 +01:00
const char unwanted[] = "$%&!\"':;?^`|{}";
2023-10-08 20:23:37 +01:00
char c = g_edit[g_edit_index] + Direction;
2023-09-20 13:34:00 +01:00
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
}
2023-10-08 20:23:37 +01:00
g_edit[g_edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
2023-09-20 11:58:47 +01:00
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
}
return;
}
2023-10-08 20:23:37 +01:00
if (!key_held)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
if (!key_pressed)
2023-09-09 08:03:56 +01:00
return;
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
2023-10-08 20:23:37 +01:00
g_input_box_index = 0;
2023-09-09 08:03:56 +01:00
}
else
2023-10-08 20:23:37 +01:00
if (!key_pressed)
2023-09-09 08:03:56 +01:00
return;
2023-10-08 20:23:37 +01:00
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
2023-09-09 08:03:56 +01:00
{
MENU_start_css_scan(Direction);
2023-10-08 20:23:37 +01:00
g_ptt_was_released = true;
g_request_display_screen = DISPLAY_MENU;
2023-09-09 08:03:56 +01:00
return;
}
2023-10-20 18:00:36 +01:00
if (!g_in_sub_menu)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_menu_cursor = NUMBER_AddWithWraparound(g_menu_cursor, -Direction, 0, g_menu_list_count - 1);
2023-10-08 20:23:37 +01:00
g_flag_refresh_menu = true;
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-20 13:01:08 +01:00
if (g_menu_cursor != MENU_AUTO_BACKLITE && g_eeprom.backlight == 0)
2023-09-20 13:01:08 +01:00
{
2023-10-08 20:23:37 +01:00
g_backlight_count_down = 0;
2023-09-20 13:01:08 +01:00
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
}
2023-09-09 08:03:56 +01:00
return;
}
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_OFFSET)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
int32_t Offset = (Direction * g_tx_vfo->step_freq) + g_sub_menu_selection;
2023-09-09 08:03:56 +01:00
if (Offset < 99999990)
{
if (Offset < 0)
Offset = 99999990;
}
else
Offset = 0;
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = FREQUENCY_FloorToStep(Offset, g_tx_vfo->step_freq, 0);
g_request_display_screen = DISPLAY_MENU;
2023-09-09 08:03:56 +01:00
return;
}
VFO = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
2023-10-08 20:23:37 +01:00
switch (g_menu_cursor)
2023-09-09 08:03:56 +01:00
{
case MENU_MEM_DEL:
2023-09-09 08:03:56 +01:00
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);
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-09 08:03:56 +01:00
return;
}
#pragma GCC diagnostic pop
2023-10-08 20:23:37 +01:00
Channel = RADIO_FindNextChannel(g_sub_menu_selection + Direction, Direction, bCheckScanList, VFO);
2023-09-09 08:03:56 +01:00
if (Channel != 0xFF)
2023-10-08 20:23:37 +01:00
g_sub_menu_selection = Channel;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-09 08:03:56 +01:00
}
void MENU_process_key(key_code_t Key, bool key_pressed, bool key_held)
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-10-08 20:23:37 +01:00
MENU_Key_0_to_9(Key, key_pressed, key_held);
2023-09-09 08:03:56 +01:00
break;
case KEY_MENU:
2023-10-08 20:23:37 +01:00
MENU_Key_MENU(key_pressed, key_held);
2023-09-09 08:03:56 +01:00
break;
case KEY_UP:
2023-10-08 20:23:37 +01:00
MENU_Key_UP_DOWN(key_pressed, key_held, 1);
2023-09-09 08:03:56 +01:00
break;
case KEY_DOWN:
2023-10-08 20:23:37 +01:00
MENU_Key_UP_DOWN(key_pressed, key_held, -1);
2023-09-09 08:03:56 +01:00
break;
case KEY_EXIT:
2023-10-08 20:23:37 +01:00
MENU_Key_EXIT(key_pressed, key_held);
2023-09-09 08:03:56 +01:00
break;
case KEY_STAR:
2023-10-08 20:23:37 +01:00
MENU_Key_STAR(key_pressed, key_held);
2023-09-09 08:03:56 +01:00
break;
case KEY_F:
2023-10-08 20:23:37 +01:00
if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0)
2023-09-20 11:58:47 +01:00
{ // currently editing the channel name
2023-10-08 20:23:37 +01:00
if (!key_held && key_pressed)
2023-09-20 11:58:47 +01:00
{
2023-10-08 20:23:37 +01:00
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
if (g_edit_index < 10)
2023-09-20 12:02:50 +01:00
{
2023-10-08 20:23:37 +01:00
g_edit[g_edit_index] = ' ';
if (++g_edit_index >= 10)
2023-09-20 12:02:50 +01:00
{ // exit edit
2023-10-14 09:43:53 +01:00
g_flag_accept_setting = false;
2023-10-08 20:23:37 +01:00
g_ask_for_confirmation = 1;
2023-09-20 12:02:50 +01:00
}
2023-10-08 20:23:37 +01:00
g_request_display_screen = DISPLAY_MENU;
2023-09-20 11:58:47 +01:00
}
}
break;
}
2023-10-08 20:23:37 +01:00
GENERIC_Key_F(key_pressed, key_held);
2023-09-09 08:03:56 +01:00
break;
case KEY_PTT:
2023-10-08 20:23:37 +01:00
GENERIC_Key_PTT(key_pressed);
2023-09-09 08:03:56 +01:00
break;
default:
2023-10-08 20:23:37 +01:00
if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
2023-09-09 08:03:56 +01:00
break;
}
2023-10-08 20:23:37 +01:00
if (g_screen_to_display == DISPLAY_MENU)
{
if (g_menu_cursor == MENU_VOLTAGE ||
#ifdef ENABLE_F_CAL_MENU
2023-10-20 16:06:38 +01:00
g_menu_cursor == MENU_F_CALI ||
#endif
g_menu_cursor == MENU_BAT_CAL)
{
2023-10-08 20:23:37 +01:00
g_menu_count_down = menu_timeout_long_500ms;
}
else
{
2023-10-08 20:23:37 +01:00
g_menu_count_down = menu_timeout_500ms;
}
}
2023-09-09 08:03:56 +01:00
}