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

749 lines
16 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>
#include <stdlib.h> // abs()
2023-09-09 08:03:56 +01:00
#include "app/dtmf.h"
#include "bitmaps.h"
#include "board.h"
2023-09-09 08:03:56 +01:00
#include "dcs.h"
#include "driver/backlight.h"
#include "driver/bk4819.h"
2023-09-09 08:03:56 +01:00
#include "driver/eeprom.h" // EEPROM_ReadBuffer()
#include "driver/st7565.h"
#include "external/printf/printf.h"
2023-09-15 15:53:37 +01:00
#include "frequencies.h"
2023-09-09 08:03:56 +01:00
#include "helper/battery.h"
#include "misc.h"
#include "settings.h"
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "ui/menu.h"
#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
const char *MenuList[] =
2023-09-09 08:03:56 +01:00
{
"SQL",
2023-09-15 17:45:07 +01:00
"STEP",
2023-09-18 00:48:40 +01:00
"T-PWR", // was "TXP"
"R-DCS", // was "R_DCS"
"R-CTCS", // was "R_CTCS"
"T-DCS", // was "T_DCS"
"T-CTCS", // was "T_CTCS"
"T-DIR", // was "SFT_D"
"T-OFFS", // was "OFFSET"
2023-09-19 14:48:09 +01:00
"T-VFO", // was "WX"
"T-TOUT", // was "TOT"
2023-09-09 08:03:56 +01:00
"W/N",
2023-09-15 17:45:07 +01:00
"SCRAM", // was "SCR"
"BUSYCL", // was "BCL"
2023-09-19 14:48:09 +01:00
"CH-SAV", // was "MEM-CH"
"CH-DEL", // was "DEL-CH"
"CH-NAM",
2023-09-19 14:48:09 +01:00
"CH-DIS", // was "MDF"
2023-09-15 17:45:07 +01:00
"BATSAV", // was "SAVE"
2023-09-09 08:03:56 +01:00
"VOX",
2023-09-15 17:45:07 +01:00
"BACKLT", // was "ABR"
"DUALRX", // was "TDR"
"BEEP",
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-09-15 17:45:07 +01:00
"VOICE",
2023-09-09 08:03:56 +01:00
#endif
2023-09-15 17:45:07 +01:00
"SC-REV",
"KEYLOC", // was "AUTOLk"
"S-ADD1",
"S-ADD2",
2023-09-09 08:03:56 +01:00
"STE",
"RP-STE",
2023-09-15 17:45:07 +01:00
"MIC",
"MICBAR",
2023-09-15 10:57:26 +01:00
#ifdef ENABLE_COMPANDER
2023-09-15 17:45:07 +01:00
"COMPND",
2023-09-15 10:57:26 +01:00
#endif
2023-09-15 17:45:07 +01:00
"1-CALL",
"SLIST",
"SLIST1",
"SLIST2",
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_ALARM
2023-09-15 17:45:07 +01:00
"AL-MOD",
2023-09-09 09:01:52 +01:00
#endif
2023-09-09 08:03:56 +01:00
"ANI-ID",
2023-09-15 17:45:07 +01:00
"UPCODE",
"DWCODE",
2023-09-09 08:03:56 +01:00
"D-ST",
"D-RSP",
2023-09-15 17:45:07 +01:00
"D-HOLD",
"D-PRE",
2023-09-09 08:03:56 +01:00
"PTT-ID",
"D-DCD",
2023-09-15 17:45:07 +01:00
"D-LIST",
"D-LIVE", // live DTMF decoder
2023-09-15 17:45:07 +01:00
"PONMSG",
"ROGER",
"BATVOL", // was "VOL"
"BATTXT",
2023-09-15 17:45:07 +01:00
"MODE", // was "AM"
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-15 17:45:07 +01:00
"NOAA-S",
2023-09-09 08:03:56 +01:00
#endif
2023-09-19 14:48:09 +01:00
"RESET", // might be better to move this to the hidden menu items ?
2023-09-09 08:03:56 +01:00
2023-09-19 14:48:09 +01:00
// hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on
2023-09-09 08:03:56 +01:00
2023-09-15 17:45:07 +01:00
"F-LOCK",
2023-09-19 09:16:57 +01:00
"TX-200", // was "200TX"
"TX-350", // was "350TX"
"TX-500", // was "500TX"
"350-EN", // was "350EN"
"SCR-EN", // was "SCREN"
2023-09-19 09:16:57 +01:00
"TX-EN", // enable TX
"F-CALI", // reference xtal calibration
NULL // end of list - DO NOT DELETE THIS
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_TXP[3][5] =
2023-09-09 08:03:56 +01:00
{
"LOW",
"MID",
2023-09-15 17:45:07 +01:00
"HIGH"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_SFT_D[3][4] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"+",
2023-09-15 17:45:07 +01:00
"-"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_W_N[2][7] =
2023-09-09 08:03:56 +01:00
{
"WIDE",
2023-09-15 17:45:07 +01:00
"NARROW"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_OFF_ON[2][4] =
2023-09-09 08:03:56 +01:00
{
"OFF",
2023-09-15 17:45:07 +01:00
"ON"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_SAVE[5][4] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"1:1",
"1:2",
"1:3",
2023-09-15 17:45:07 +01:00
"1:4"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_CHAN[3][7] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"CHAN_A",
2023-09-15 17:45:07 +01:00
"CHAN_B"
2023-09-09 08:03:56 +01:00
};
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_VOICE
2023-09-15 17:45:07 +01:00
const char gSubMenu_VOICE[3][4] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"CHI",
2023-09-15 17:45:07 +01:00
"ENG"
2023-09-09 08:03:56 +01:00
};
#endif
2023-09-15 17:45:07 +01:00
const char gSubMenu_SC_REV[3][3] =
2023-09-09 08:03:56 +01:00
{
"TO",
"CO",
2023-09-15 17:45:07 +01:00
"SE"
2023-09-09 08:03:56 +01:00
};
const char gSubMenu_MDF[4][8] =
{
"FREQ",
"CHAN",
"NAME",
"NAM+FRE"
};
2023-09-09 08:03:56 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_ALARM
2023-09-15 17:45:07 +01:00
const char gSubMenu_AL_MOD[2][5] =
2023-09-09 09:01:52 +01:00
{
"SITE",
2023-09-15 17:45:07 +01:00
"TONE"
2023-09-09 09:01:52 +01:00
};
#endif
2023-09-09 08:03:56 +01:00
2023-09-15 17:45:07 +01:00
const char gSubMenu_D_RSP[4][6] =
2023-09-09 08:03:56 +01:00
{
"NULL",
"RING",
"REPLY",
2023-09-15 17:45:07 +01:00
"BOTH"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_PTT_ID[4][5] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"BOT",
"EOT",
2023-09-15 17:45:07 +01:00
"BOTH"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_PONMSG[4][5] =
2023-09-09 08:03:56 +01:00
{
"FULL",
"MSG",
"VOL",
"NONE"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_ROGER[3][6] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"ROGER",
2023-09-15 17:45:07 +01:00
"MDC"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_RESET[2][4] =
2023-09-09 08:03:56 +01:00
{
"VFO",
2023-09-15 17:45:07 +01:00
"ALL"
2023-09-09 08:03:56 +01:00
};
2023-09-15 17:45:07 +01:00
const char gSubMenu_F_LOCK[6][4] =
2023-09-09 08:03:56 +01:00
{
"OFF",
"FCC",
"CE",
"GB",
"430",
2023-09-15 17:45:07 +01:00
"438"
2023-09-09 08:03:56 +01:00
};
2023-09-20 08:40:35 +01:00
const char gSubMenu_BACK_LIGHT[6][7] =
{
"OFF",
"10 sec",
"20 sec",
"40 sec",
"80 sec",
"ON"
};
2023-09-16 09:10:10 +01:00
#ifdef ENABLE_COMPANDER
const char gSubMenu_Compand[4][6] =
2023-09-16 09:10:10 +01:00
{
"OFF",
"TX",
"RX",
2023-09-16 09:10:10 +01:00
"TX/RX"
};
#endif
const char gSubMenu_BAT_TXT[3][8] =
{
"NONE",
"VOLTAGE",
"PERCENT"
};
bool gIsInSubMenu;
uint8_t gMenuCursor;
int8_t gMenuScrollDirection;
int32_t gSubMenuSelection;
2023-09-09 08:03:56 +01:00
// edit box
2023-09-20 11:23:45 +01:00
char edit_original[17]; // a copy of the text before editing
char edit[17];
int edit_index;
2023-09-09 08:03:56 +01:00
void UI_DisplayMenu(void)
{
unsigned int i;
char String[16];
char Contact[16];
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
for (i = 0; i < 3; i++)
if (gMenuCursor > 0 || i > 0)
2023-09-09 08:03:56 +01:00
if ((gMenuListCount - 1) != gMenuCursor || i != 2)
2023-09-12 15:31:37 +01:00
UI_PrintString(MenuList[gMenuCursor + i - 1], 0, 0, i * 2, 8);
2023-09-09 08:03:56 +01:00
for (i = 0; i < 48; i++)
{
gFrameBuffer[2][i] ^= 0xFF;
gFrameBuffer[3][i] ^= 0xFF;
}
2023-09-09 11:17:45 +01:00
// draw vertical separating line
for (i = 0; i < 6; i++)
gFrameBuffer[i][49] = 0xAA;
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
UI_PrintStringSmall(String, 8, 0, 6);
2023-09-09 08:03:56 +01:00
if (gIsInSubMenu)
2023-09-17 09:54:24 +01:00
memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
2023-09-09 08:03:56 +01:00
memset(String, 0, sizeof(String));
2023-09-19 11:44:49 +01:00
bool already_printed = false;
2023-09-09 08:03:56 +01:00
switch (gMenuCursor)
{
case MENU_SQL:
sprintf(String, "%d", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
case MENU_MIC:
{ // display the mic gain in actual dB rather than just an index number
const uint8_t mic = gMicGain_dB2[gSubMenuSelection];
2023-09-13 02:01:35 +01:00
sprintf(String, "+%u.%01udB", mic / 2, mic % 2);
2023-09-09 08:03:56 +01:00
}
break;
2023-09-15 10:57:26 +01:00
#ifdef ENABLE_AUDIO_BAR
case MENU_MIC_BAR:
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
break;
#endif
2023-09-09 08:03:56 +01:00
case MENU_STEP:
sprintf(String, "%d.%02uKHz", StepFrequencyTable[gSubMenuSelection] / 100, abs(StepFrequencyTable[gSubMenuSelection]) % 100);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_TXP:
strcpy(String, gSubMenu_TXP[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_R_DCS:
case MENU_T_DCS:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
if (gSubMenuSelection < 105)
sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]);
else
sprintf(String, "D%03oI", DCS_Options[gSubMenuSelection - 105]);
break;
2023-09-09 08:03:56 +01:00
case MENU_R_CTCS:
case MENU_T_CTCS:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
2023-09-13 02:01:35 +01:00
sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_SFT_D:
strcpy(String, gSubMenu_SFT_D[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_OFFSET:
if (!gIsInSubMenu || gInputBoxIndex == 0)
{
sprintf(String, "%d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000);
2023-09-19 11:44:49 +01:00
UI_PrintString(String, 50, 127, 1, 8);
}
else
{
for (i = 0; i < 3; i++)
String[i ] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
String[3] = '.';
for (i = 3; i < 6; i++)
String[i + 1] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
String[ 7] = '-';
String[ 8] = '-';
String[ 9] = 0;
String[10] = 0;
String[11] = 0;
UI_PrintString(String, 50, 127, 1, 8);
2023-09-09 08:03:56 +01:00
}
2023-09-19 11:44:49 +01:00
UI_PrintString("MHz", 50, 127, 3, 8);
already_printed = true;
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_W_N:
strcpy(String, gSubMenu_W_N[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_SCR:
case MENU_VOX:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
sprintf(String, "%d", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_ABR:
2023-09-20 08:40:35 +01:00
strcpy(String, gSubMenu_BACK_LIGHT[gSubMenuSelection]);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 10:17:58 +01:00
case MENU_AM:
strcpy(String, (gSubMenuSelection == 0) ? "FM" : "AM");
break;
2023-09-12 21:08:51 +01:00
case MENU_AUTOLK:
strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO");
break;
2023-09-15 10:57:26 +01:00
#ifdef ENABLE_COMPANDER
case MENU_COMPAND:
2023-09-16 09:10:10 +01:00
strcpy(String, gSubMenu_Compand[gSubMenuSelection]);
break;
2023-09-15 10:57:26 +01:00
#endif
2023-09-16 09:10:10 +01:00
2023-09-09 08:03:56 +01:00
case MENU_BCL:
case MENU_BEEP:
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-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
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_MEM_CH:
case MENU_1_CALL:
case MENU_DEL_CH:
{
const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0);
UI_GenerateChannelStringEx(String, valid, gSubMenuSelection);
2023-09-19 11:44:49 +01:00
UI_PrintString(String, 50, 127, 0, 8);
if (valid && !gAskForConfirmation)
{ // show the frequency so that the user knows the channels frequency
struct
{
uint32_t Frequency;
uint32_t Offset;
} __attribute__((packed)) Info;
EEPROM_ReadBuffer(gSubMenuSelection * 16, &Info, sizeof(Info));
sprintf(String, "%03u.%05u", Info.Frequency / 100000, Info.Frequency % 100000);
// UI_PrintStringSmall(String, 50, 127, 5);
UI_PrintString(String, 50, 127, 4, 8);
}
2023-09-19 11:44:49 +01:00
already_printed = true;
2023-09-09 08:03:56 +01:00
break;
}
case MENU_MEM_NAME:
{
const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0);
UI_GenerateChannelStringEx(String, valid, gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8);
if (valid)
{
struct
{
uint32_t Frequency;
uint32_t Offset;
} __attribute__((packed)) Info;
EEPROM_ReadBuffer(gSubMenuSelection * 16, &Info, sizeof(Info));
if (!gIsInSubMenu || edit_index < 0)
{ // show the channel name
BOARD_fetchChannelName(String, gSubMenuSelection);
if (String[0] == 0)
strcpy(String, "--");
UI_PrintString(String, 50, 127, 2, 8);
}
else
{ // show the channel name being edited
UI_PrintString(edit, 50, 0, 2, 8);
if (edit_index < 10)
2023-09-20 11:23:45 +01:00
UI_PrintString("^", 50 + (8 * edit_index), 0, 4, 8); // show the cursor
// UI_PrintStringSmall("^", 50 + (8 * edit_index), 0, 4);
}
if (!gAskForConfirmation)
{ // show the frequency so that the user knows the channels frequency
sprintf(String, "%03u.%05u", Info.Frequency / 100000, Info.Frequency % 100000);
if (!gIsInSubMenu || edit_index < 0)
UI_PrintString(String, 50, 127, 4, 8);
else
UI_PrintString(String, 50, 127, 5, 8);
// UI_PrintStringSmall(String, 50, 127, 5);
}
}
2023-09-19 11:44:49 +01:00
already_printed = true;
break;
}
2023-09-09 08:03:56 +01:00
case MENU_SAVE:
strcpy(String, gSubMenu_SAVE[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_TDR:
case MENU_XB:
2023-09-09 08:03:56 +01:00
strcpy(String, gSubMenu_CHAN[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_TOT:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
sprintf(String, "%dmin", gSubMenuSelection);
2023-09-09 08:03:56 +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:
strcpy(String, gSubMenu_VOICE[gSubMenuSelection]);
break;
#endif
2023-09-09 08:03:56 +01:00
case MENU_SC_REV:
strcpy(String, gSubMenu_SC_REV[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_MDF:
strcpy(String, gSubMenu_MDF[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_RP_STE:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
sprintf(String, "%d*100ms", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_S_LIST:
2023-09-13 02:01:35 +01:00
sprintf(String, "LIST%u", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_ALARM
2023-09-09 09:01:52 +01:00
case MENU_AL_MOD:
sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]);
break;
#endif
2023-09-09 08:03:56 +01:00
case MENU_ANI_ID:
strcpy(String, gEeprom.ANI_DTMF_ID);
break;
2023-09-09 08:03:56 +01:00
case MENU_UPCODE:
strcpy(String, gEeprom.DTMF_UP_CODE);
break;
2023-09-09 08:03:56 +01:00
case MENU_DWCODE:
strcpy(String, gEeprom.DTMF_DOWN_CODE);
break;
2023-09-09 08:03:56 +01:00
case MENU_D_RSP:
strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_D_HOLD:
sprintf(String, "%ds", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_D_PRE:
sprintf(String, "%d*10ms", gSubMenuSelection);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_PTT_ID:
strcpy(String, gSubMenu_PTT_ID[gSubMenuSelection]);
break;
case MENU_BAT_TXT:
strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_D_LIST:
2023-09-12 11:49:16 +01:00
gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact);
2023-09-09 08:03:56 +01:00
if (!gIsDtmfContactValid)
2023-09-12 11:49:16 +01:00
strcpy(String, "NULL");
2023-09-09 08:03:56 +01:00
else
2023-09-17 09:54:24 +01:00
memmove(String, Contact, 8);
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_PONMSG:
strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_ROGER:
strcpy(String, gSubMenu_ROGER[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_VOL:
2023-09-19 11:44:49 +01:00
// 1st text line
2023-09-13 02:01:35 +01:00
sprintf(String, "%u.%02uV", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
2023-09-19 11:44:49 +01:00
UI_PrintString(String, 50, 127, 1, 8);
{ // 2nd text line .. percentage
UI_PrintString(String, 50, 127, 1, 8);
2023-09-19 14:48:09 +01:00
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
sprintf(String, "%u%%", percent);
2023-09-19 11:44:49 +01:00
UI_PrintString(String, 50, 127, 3, 8);
#if 0
sprintf(String, "Curr %u", gBatteryCurrent); // needs scaling into mA
UI_PrintString(String, 50, 127, 5, 8);
#endif
}
already_printed = true;
2023-09-09 08:03:56 +01:00
break;
2023-09-09 08:03:56 +01:00
case MENU_RESET:
strcpy(String, gSubMenu_RESET[gSubMenuSelection]);
break;
2023-09-09 08:03:56 +01:00
case MENU_F_LOCK:
strcpy(String, gSubMenu_F_LOCK[gSubMenuSelection]);
break;
case MENU_F_CALI:
{
const uint32_t value = 22656 + gSubMenuSelection;
2023-09-19 11:44:49 +01:00
//gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection; // already set when the user was adjusting the value
BK4819_WriteRegister(BK4819_REG_3B, value);
2023-09-19 11:44:49 +01:00
sprintf(String, "%d", gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8);
const uint32_t xtal_Hz = (0x4f0000u + value) * 5;
sprintf(String, "%u.%06u", xtal_Hz / 1000000, xtal_Hz % 1000000);
2023-09-16 08:21:19 +01:00
UI_PrintString(String, 50, 127, 2, 8);
2023-09-19 11:44:49 +01:00
2023-09-16 08:21:19 +01:00
UI_PrintString("MHz", 50, 127, 4, 8);
2023-09-19 11:44:49 +01:00
already_printed = true;
}
break;
2023-09-09 08:03:56 +01:00
}
2023-09-19 11:44:49 +01:00
if (!already_printed)
UI_PrintString(String, 50, 127, 2, 8);
if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2)
{
i = (gMenuCursor == MENU_SLIST1) ? 0 : 1;
// if (gSubMenuSelection == 0xFF)
if (gSubMenuSelection < 0)
strcpy(String, "NULL");
else
UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
// if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i])
if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i])
{
UI_PrintString(String, 50, 127, 0, 8);
}
else
{
UI_PrintString(String, 50, 127, 0, 8);
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i]))
2023-09-15 17:45:07 +01:00
{
2023-09-19 11:44:49 +01:00
sprintf(String, "PRI1:%u", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
UI_PrintString(String, 50, 127, 2, 8);
2023-09-15 17:45:07 +01:00
}
2023-09-09 08:03:56 +01:00
2023-09-19 11:44:49 +01:00
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i]))
{
sprintf(String, "PRI2:%u", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
UI_PrintString(String, 50, 127, 4, 8);
}
}
2023-09-09 08:03:56 +01:00
}
2023-09-19 11:44:49 +01:00
if (gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH ||
gMenuCursor == MENU_1_CALL ||
gMenuCursor == MENU_SLIST1 ||
2023-09-19 11:44:49 +01:00
gMenuCursor == MENU_SLIST2)
2023-09-09 13:58:21 +01:00
{ // display the channel name
char s[11];
BOARD_fetchChannelName(s, gSubMenuSelection);
if (s[0] == 0)
strcpy(s, "--");
UI_PrintString(s, 50, 127, 2, 8);
2023-09-09 13:58:21 +01:00
}
2023-09-09 08:03:56 +01:00
if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF)
2023-09-12 15:31:37 +01:00
UI_PrintString("SCAN", 50, 127, 4, 8);
2023-09-09 08:03:56 +01:00
if (gMenuCursor == MENU_UPCODE)
if (strlen(gEeprom.DTMF_UP_CODE) > 8)
2023-09-12 15:31:37 +01:00
UI_PrintString(gEeprom.DTMF_UP_CODE + 8, 50, 127, 4, 8);
2023-09-09 08:03:56 +01:00
if (gMenuCursor == MENU_DWCODE)
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8)
2023-09-12 15:31:37 +01:00
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, 50, 127, 4, 8);
2023-09-09 08:03:56 +01:00
if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid)
{
Contact[11] = 0;
2023-09-17 09:54:24 +01:00
memmove(&gDTMF_ID, Contact + 8, 4);
2023-09-09 08:03:56 +01:00
sprintf(String, "ID:%s", Contact + 8);
2023-09-12 15:31:37 +01:00
UI_PrintString(String, 50, 127, 4, 8);
2023-09-09 08:03:56 +01:00
}
if (gMenuCursor == MENU_R_CTCS ||
gMenuCursor == MENU_T_CTCS ||
gMenuCursor == MENU_R_DCS ||
gMenuCursor == MENU_T_DCS ||
gMenuCursor == MENU_D_LIST)
{
unsigned int Offset;
NUMBER_ToDigits(gSubMenuSelection, String);
2023-09-09 08:03:56 +01:00
Offset = (gMenuCursor == MENU_D_LIST) ? 2 : 3;
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
2023-09-09 08:03:56 +01:00
}
if ((gMenuCursor == MENU_RESET ||
gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_MEM_NAME ||
gMenuCursor == MENU_DEL_CH) && gAskForConfirmation)
2023-09-19 11:44:49 +01:00
{ // display confirmation
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, 50, 127, 5, 8);
2023-09-09 08:03:56 +01:00
}
ST7565_BlitFullScreen();
}