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

Fixed compander setting, .bat typo and started menulist unify

This commit is contained in:
OneOfEleven 2023-09-21 08:46:24 +01:00
parent 417fe617df
commit 653a00b89d
12 changed files with 244 additions and 314 deletions

View File

@ -46,88 +46,6 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif #endif
#ifdef ENABLE_VOICE
static const VOICE_ID_t MenuVoices[] =
{
VOICE_ID_SQUELCH, // SQL
VOICE_ID_FREQUENCY_STEP, // STEP
VOICE_ID_POWER, // T-PWR
VOICE_ID_DCS, // R-DCS
VOICE_ID_CTCSS, // R-CTCS
VOICE_ID_DCS, // T-DCS
VOICE_ID_CTCSS, // T-CTCS
VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, // T-DIR
VOICE_ID_TX_OFFSET_FREQUENCY, // T-OFFS
VOICE_ID_INVALID, // T-VFO
VOICE_ID_TRANSMIT_OVER_TIME, // T-TOUT
VOICE_ID_CHANNEL_BANDWIDTH, // W/N
VOICE_ID_SCRAMBLER_ON, // SCRAM
VOICE_ID_BUSY_LOCKOUT, // BUSYCL
VOICE_ID_MEMORY_CHANNEL, // CH-SAV
VOICE_ID_DELETE_CHANNEL, // CH-DEL
VOICE_ID_INVALID, // CH-EDIT
VOICE_ID_INVALID, // CH-DIS
VOICE_ID_SAVE_MODE, // BATSAV
VOICE_ID_VOX, // VOX
VOICE_ID_INVALID, // BACKLT
VOICE_ID_DUAL_STANDBY, // DUALRX
VOICE_ID_BEEP_PROMPT, // BEEP
#ifdef ENABLE_VOICE
VOICE_ID_VOICE_PROMPT, // VOICE
#endif
VOICE_ID_INVALID, // SC-REV
VOICE_ID_INVALID, // KEYLOC
VOICE_ID_INVALID, // S-ADD1
VOICE_ID_INVALID, // S-ADD2
VOICE_ID_INVALID, // STE
VOICE_ID_INVALID, // RP-STE
VOICE_ID_INVALID, // MIC
VOICE_ID_INVALID, // MICBAR
#ifdef ENABLE_COMPANDER
VOICE_ID_INVALID, // COMPND
#endif
VOICE_ID_INVALID, // 1-CALL
VOICE_ID_INVALID, // SLIST
VOICE_ID_INVALID, // SLIST1
VOICE_ID_INVALID, // SLIST2
#ifdef ENABLE_ALARM
VOICE_ID_INVALID, // AL-MOD
#endif
VOICE_ID_ANI_CODE, // ANI-ID
VOICE_ID_INVALID, // UPCODE
VOICE_ID_INVALID, // DWCODE
VOICE_ID_INVALID, // D-ST
VOICE_ID_INVALID, // D-RSP
VOICE_ID_INVALID, // D-HOLD
VOICE_ID_INVALID, // D-PRE
VOICE_ID_INVALID, // PTT-ID
VOICE_ID_INVALID, // D-DCD
VOICE_ID_INVALID, // D-LIST
VOICE_ID_INVALID, // D-LIVE
VOICE_ID_INVALID, // PONMSG
VOICE_ID_INVALID, // ROGER
VOICE_ID_INVALID, // BATVOL
VOICE_ID_INVALID, // BATTXT
VOICE_ID_INVALID, // MODE
#ifdef ENABLE_NOAA
VOICE_ID_INVALID, // NOAA-S
#endif
VOICE_ID_INITIALISATION, // RESET
// hidden items
VOICE_ID_INVALID, // F-LOCK
VOICE_ID_INVALID, // TX-200
VOICE_ID_INVALID, // TX-350
VOICE_ID_INVALID, // TX-500
VOICE_ID_INVALID, // 350-EN
VOICE_ID_INVALID, // SCR-EN
VOICE_ID_INVALID, // TX-EN
VOICE_ID_INVALID // F-CALI
};
#endif
void MENU_StartCssScan(int8_t Direction) void MENU_StartCssScan(int8_t Direction)
{ {
gCssScanMode = CSS_SCAN_MODE_SCANNING; gCssScanMode = CSS_SCAN_MODE_SCANNING;
@ -1329,7 +1247,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR) if (gMenuCursor != MENU_SCR)
gAnotherVoiceID = MenuVoices[gMenuCursor]; gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
#endif #endif
#if 1 #if 1

18
audio.h
View File

@ -37,16 +37,14 @@ extern BEEP_Type_t gBeepToPlay;
void AUDIO_PlayBeep(BEEP_Type_t Beep); void AUDIO_PlayBeep(BEEP_Type_t Beep);
#ifdef ENABLE_VOICE enum
{
enum
{
VOICE_ID_CHI_BASE = 0x10U, VOICE_ID_CHI_BASE = 0x10U,
VOICE_ID_ENG_BASE = 0x60U, VOICE_ID_ENG_BASE = 0x60U,
}; };
enum VOICE_ID_t enum VOICE_ID_t
{ {
VOICE_ID_0 = 0x00U, VOICE_ID_0 = 0x00U,
VOICE_ID_1 = 0x01U, VOICE_ID_1 = 0x01U,
VOICE_ID_2 = 0x02U, VOICE_ID_2 = 0x02U,
@ -125,10 +123,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep);
VOICE_ID_END = 0x4BU, VOICE_ID_END = 0x4BU,
VOICE_ID_INVALID = 0xFFU, VOICE_ID_INVALID = 0xFFU,
}; };
typedef enum VOICE_ID_t VOICE_ID_t; typedef enum VOICE_ID_t VOICE_ID_t;
#ifdef ENABLE_VOICE
extern VOICE_ID_t gVoiceID[8]; extern VOICE_ID_t gVoiceID[8];
extern uint8_t gVoiceReadIndex; extern uint8_t gVoiceReadIndex;
extern uint8_t gVoiceWriteIndex; extern uint8_t gVoiceWriteIndex;
@ -141,7 +140,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep);
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID); void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value); uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
void AUDIO_PlayQueuedVoice(void); void AUDIO_PlayQueuedVoice(void);
#endif #endif
#endif #endif

View File

@ -764,8 +764,6 @@ bool BK4819_CompanderEnabled(void)
void BK4819_SetCompander(const unsigned int mode) void BK4819_SetCompander(const unsigned int mode)
{ {
uint16_t val;
// mode 0 .. OFF // mode 0 .. OFF
// mode 1 .. TX // mode 1 .. TX
// mode 2 .. RX // mode 2 .. RX
@ -773,14 +771,12 @@ void BK4819_SetCompander(const unsigned int mode)
if (mode == 0) if (mode == 0)
{ // disable { // disable
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31); BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) & ~(1u < 3));
BK4819_WriteRegister(BK4819_REG_31, Value & ~(1u < 3));
return; return;
} }
// enable // enable
val = BK4819_ReadRegister(BK4819_REG_31); BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) | (1u < 3));
BK4819_WriteRegister(BK4819_REG_31, val | (1u < 3));
// set the compressor ratio // set the compressor ratio
// //
@ -791,8 +787,7 @@ void BK4819_SetCompander(const unsigned int mode)
// 11 = 4:1 // 11 = 4:1
// //
const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 3 : 0; // 4:1 const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 3 : 0; // 4:1
val = BK4819_ReadRegister(BK4819_REG_29); BK4819_WriteRegister(BK4819_REG_29, (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14));
BK4819_WriteRegister(BK4819_REG_29, (val & ~(3u < 14)) | (compress_ratio < 14));
// set the expander ratio // set the expander ratio
// //
@ -803,8 +798,7 @@ void BK4819_SetCompander(const unsigned int mode)
// 11 = 1:4 // 11 = 1:4
// //
const uint16_t expand_ratio = (mode >= 2) ? 3 : 0; // 1:4 const uint16_t expand_ratio = (mode >= 2) ? 3 : 0; // 1:4
val = BK4819_ReadRegister(BK4819_REG_28); BK4819_WriteRegister(BK4819_REG_28, (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14));
BK4819_WriteRegister(BK4819_REG_28, (val & ~(3u < 14)) | (expand_ratio < 14));
} }
void BK4819_DisableVox(void) void BK4819_DisableVox(void)

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -68,8 +68,8 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
{ {
// enable all the menu items // enable all the menu items
gMenuListCount = 0; gMenuListCount = 0;
//while (MenuList[gMenuListCount][0] != 0) // while (MenuList[gMenuListCount].name != NULL)
while (MenuList[gMenuListCount] != NULL) while (MenuList[gMenuListCount].name[0] != '\0')
gMenuListCount++; gMenuListCount++;
gMenuCursor = MENU_350TX; gMenuCursor = MENU_350TX;

17
main.c
View File

@ -96,12 +96,19 @@ void Main(void)
BATTERY_GetReadings(false); BATTERY_GetReadings(false);
// count the number of menu list items { // count the number of menu list items
unsigned int hidden = 0;
gMenuListCount = 0; gMenuListCount = 0;
// while (MenuList[gMenuListCount][0] != 0) // while (MenuList[gMenuListCount].name != NULL)
while (MenuList[gMenuListCount] != NULL) while (MenuList[gMenuListCount].name[0] != '\0')
gMenuListCount++; {
gMenuListCount -= 8; // disable the last few menu items .. they are the normally 'hidden' menu items if (MenuList[++gMenuListCount].hidden != 0)
hidden++;
}
// disable the items marked hidden
//gMenuListCount -= 8;
gMenuListCount -= hidden;
}
boot_counter_10ms = 250; // 2.5 sec boot_counter_10ms = 250; // 2.5 sec

View File

@ -711,7 +711,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_DisableVox(); BK4819_DisableVox();
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
BK4819_SetCompander(!gRxVfo->IsAM ? gRxVfo->Compander : 0); // RX expander
BK4819_SetCompander((!gRxVfo->IsAM && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0);
#endif #endif
#if 0 #if 0
@ -811,7 +812,8 @@ void RADIO_SetTxParameters(void)
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
BK4819_SetCompander(!gCurrentVfo->IsAM ? gCurrentVfo->Compander : 0); // TX compressor
BK4819_SetCompander((!gRxVfo->IsAM && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0);
#endif #endif
BK4819_PrepareTransmit(); BK4819_PrepareTransmit();

161
ui/menu.c
View File

@ -39,89 +39,89 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif #endif
const char *MenuList[] = const t_menu_item MenuList[] =
{ {
"SQL", {"SQL", 0, VOICE_ID_SQUELCH },
"STEP", {"STEP", 0, VOICE_ID_FREQUENCY_STEP },
"T-PWR", // was "TXP" {"T-PWR", 0, VOICE_ID_POWER }, // was "TXP"
"R-DCS", // was "R_DCS" {"R-DCS", 0, VOICE_ID_DCS }, // was "R_DCS"
"R-CTCS", // was "R_CTCS" {"R-CTCS", 0, VOICE_ID_CTCSS }, // was "R_CTCS"
"T-DCS", // was "T_DCS" {"T-DCS", 0, VOICE_ID_DCS }, // was "T_DCS"
"T-CTCS", // was "T_CTCS" {"T-CTCS", 0, VOICE_ID_CTCSS }, // was "T_CTCS"
"T-DIR", // was "SFT_D" {"T-DIR", 0, VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION}, // was "SFT_D"
"T-OFFS", // was "OFFSET" {"T-OFFS", 0, VOICE_ID_TX_OFFSET_FREQUENCY }, // was "OFFSET"
"T-VFO", // was "WX" {"T-VFO", 0, VOICE_ID_INVALID }, // was "WX"
"T-TOUT", // was "TOT" {"T-TOUT", 0, VOICE_ID_TRANSMIT_OVER_TIME }, // was "TOT"
"W/N", {"W/N", 0, VOICE_ID_CHANNEL_BANDWIDTH },
"SCRAM", // was "SCR" {"SCRAM", 0, VOICE_ID_SCRAMBLER_ON }, // was "SCR"
"BUSYCL", // was "BCL" {"BUSYCL", 0, VOICE_ID_BUSY_LOCKOUT }, // was "BCL"
"CH-SAV", // was "MEM-CH" {"CH-SAV", 0, VOICE_ID_MEMORY_CHANNEL }, // was "MEM-CH"
"CH-DEL", // was "DEL-CH" {"CH-DEL", 0, VOICE_ID_DELETE_CHANNEL }, // was "DEL-CH"
"CH-NAM", {"CH-NAM", 0, VOICE_ID_INVALID },
"CH-DIS", // was "MDF" {"CH-DIS", 0, VOICE_ID_INVALID }, // was "MDF"
"BATSAV", // was "SAVE" {"BATSAV", 0, VOICE_ID_SAVE_MODE }, // was "SAVE"
"VOX", {"VOX", 0, VOICE_ID_VOX },
"BACKLT", // was "ABR" {"BACKLT", 0, VOICE_ID_INVALID }, // was "ABR"
"DUALRX", // was "TDR" {"DUALRX", 0, VOICE_ID_DUAL_STANDBY }, // was "TDR"
"BEEP", {"BEEP", 0, VOICE_ID_BEEP_PROMPT },
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
"VOICE", {"VOICE", 0, VOICE_ID_VOICE_PROMPT },
#endif #endif
"SC-REV", {"SC-REV", 0, VOICE_ID_INVALID },
"KEYLOC", // was "AUTOLk" {"KEYLOC", 0, VOICE_ID_INVALID }, // was "AUTOLk"
"S-ADD1", {"S-ADD1", 0, VOICE_ID_INVALID },
"S-ADD2", {"S-ADD2", 0, VOICE_ID_INVALID },
"STE", {"STE", 0, VOICE_ID_INVALID },
"RP-STE", {"RP-STE", 0, VOICE_ID_INVALID },
"MIC", {"MIC", 0, VOICE_ID_INVALID },
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
"MICBAR", {"MICBAR", 0, VOICE_ID_INVALID },
#endif #endif
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
"COMPND", {"COMPND", 0, VOICE_ID_INVALID },
#endif #endif
"1-CALL", {"1-CALL", 0, VOICE_ID_INVALID },
"SLIST", {"SLIST", 0, VOICE_ID_INVALID },
"SLIST1", {"SLIST1", 0, VOICE_ID_INVALID },
"SLIST2", {"SLIST2", 0, VOICE_ID_INVALID },
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
"AL-MOD", "AL-MOD", 0, VOICE_ID_INVALID },
#endif #endif
"ANI-ID", {"ANI-ID", 0, VOICE_ID_ANI_CODE },
"UPCODE", {"UPCODE", 0, VOICE_ID_INVALID },
"DWCODE", {"DWCODE", 0, VOICE_ID_INVALID },
"D-ST", {"D-ST", 0, VOICE_ID_INVALID },
"D-RSP", {"D-RSP", 0, VOICE_ID_INVALID },
"D-HOLD", {"D-HOLD", 0, VOICE_ID_INVALID },
"D-PRE", {"D-PRE", 0, VOICE_ID_INVALID },
"PTT-ID", {"PTT-ID", 0, VOICE_ID_INVALID },
"D-DCD", {"D-DCD", 0, VOICE_ID_INVALID },
"D-LIST", {"D-LIST", 0, VOICE_ID_INVALID },
"D-LIVE", // live DTMF decoder {"D-LIVE", 0, VOICE_ID_INVALID }, // live DTMF decoder
"PONMSG", {"PONMSG", 0, VOICE_ID_INVALID },
"ROGER", {"ROGER", 0, VOICE_ID_INVALID },
"BATVOL", // was "VOL" {"BATVOL", 0, VOICE_ID_INVALID }, // was "VOL"
"BATTXT", {"BATTXT", 0, VOICE_ID_INVALID },
"MODE", // was "AM" {"MODE", 0, VOICE_ID_INVALID }, // was "AM"
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
"NOAA-S", {"NOAA-S", 0, VOICE_ID_INVALID },
#endif #endif
"RESET", // might be better to move this to the hidden menu items ? {"RESET", 0, VOICE_ID_INITIALISATION }, // might be better to move this to the hidden menu items ?
// hidden menu items from here on // hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on // enabled if pressing both the PTT and upper side button at power-on
"F-LOCK", {"F-LOCK", 1, VOICE_ID_INVALID },
"TX-200", // was "200TX" {"TX-200", 1, VOICE_ID_INVALID }, // was "200TX"
"TX-350", // was "350TX" {"TX-350", 1, VOICE_ID_INVALID }, // was "350TX"
"TX-500", // was "500TX" {"TX-500", 1, VOICE_ID_INVALID }, // was "500TX"
"350-EN", // was "350EN" {"350-EN", 1, VOICE_ID_INVALID }, // was "350EN"
"SCR-EN", // was "SCREN" {"SCR-EN", 1, VOICE_ID_INVALID }, // was "SCREN"
"TX-EN", // enable TX {"TX-EN", 1, VOICE_ID_INVALID }, // enable TX
"F-CALI", // reference xtal calibration {"F-CALI", 1, VOICE_ID_INVALID }, // reference xtal calibration
NULL // end of list - DO NOT delete this {"", 0, VOICE_ID_INVALID } // end of list - DO NOT delete this
}; };
const char gSubMenu_TXP[3][5] = const char gSubMenu_TXP[3][5] =
@ -278,7 +278,7 @@ int8_t gMenuScrollDirection;
int32_t gSubMenuSelection; int32_t gSubMenuSelection;
// edit box // edit box
char edit_original[17]; // a copy of the text before editing char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference
char edit[17]; char edit[17];
int edit_index; int edit_index;
@ -293,21 +293,24 @@ void UI_DisplayMenu(void)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (gMenuCursor > 0 || i > 0) if (gMenuCursor > 0 || i > 0)
if ((gMenuListCount - 1) != gMenuCursor || i != 2) if ((gMenuListCount - 1) != gMenuCursor || i != 2)
UI_PrintString(MenuList[gMenuCursor + i - 1], 0, 0, i * 2, 8); UI_PrintString(MenuList[gMenuCursor + i - 1].name, 0, 0, i * 2, 8);
// invert the pixels
for (i = 0; i < 48; i++) for (i = 0; i < 48; i++)
{ {
gFrameBuffer[2][i] ^= 0xFF; gFrameBuffer[2][i] ^= 0xFF;
gFrameBuffer[3][i] ^= 0xFF; gFrameBuffer[3][i] ^= 0xFF;
} }
// draw vertical separating line // draw vertical separating dotted line
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
gFrameBuffer[i][49] = 0xAA; gFrameBuffer[i][49] = 0xAA;
// draw the menu index number/count
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
UI_PrintStringSmall(String, 8, 0, 6); UI_PrintStringSmall(String, 8, 0, 6);
// draw the little marker
if (gIsInSubMenu) if (gIsInSubMenu)
memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));

View File

@ -20,6 +20,14 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "audio.h" // VOICE_ID_t
typedef struct {
const char name[7]; // menu display only has room for 6 characters
uint8_t hidden;
VOICE_ID_t voice_id;
} t_menu_item;
enum enum
{ {
MENU_SQL = 0, MENU_SQL = 0,
@ -102,7 +110,7 @@ enum
MENU_F_CALI // reference xtal calibration MENU_F_CALI // reference xtal calibration
}; };
extern const char *MenuList[]; extern const t_menu_item MenuList[];
extern const char gSubMenu_TXP[3][5]; extern const char gSubMenu_TXP[3][5];
extern const char gSubMenu_SFT_D[3][4]; extern const char gSubMenu_SFT_D[3][4];

View File

@ -13,7 +13,7 @@ del /S /Q *.o >nul 2>nul
del /S /Q *.d >nul 2>nul del /S /Q *.d >nul 2>nul
:: If you have python installed, you can create a 'packed' .bin from the compiled firmware.bin file. :: If you have python installed, you can create a 'packed' .bin from the compiled firmware.bin file.
:: The Quangsheng windows upload-to-radio program requires a 'packed' .bin file. :: The Quansheng windows upload-to-radio program requires a 'packed' .bin file.
:: ::
:: if you don't have python installed, then comment out the python line(s) below, in which case you'll need :: if you don't have python installed, then comment out the python line(s) below, in which case you'll need
:: to upload the standard unpacked firmware.bin file another way. :: to upload the standard unpacked firmware.bin file another way.