Merge pull request #250 from armel/feature_update_v5

Feature update v5
This commit is contained in:
Armel FAUVEAU authored and GitHub committed 2026-03-31 18:46:53 +02:00
commit 61aa14cd86
18 files changed
+204 -100

No files matched your search

+6 -2
View File
@@ -572,7 +572,11 @@ void ACTION_MainOnly(void)
#ifdef ENABLE_FEAT_F4HWN_AUDIO
void ACTION_RxA(void)
{
gSetting_set_audio = (gSetting_set_audio + 1) % 5;
if(gRxVfo->Modulation == MODULATION_AM)
gSetting_set_audio_am = (gSetting_set_audio_am + 1) % 3;
else if (gRxVfo->Modulation == MODULATION_FM)
gSetting_set_audio_fm = (gSetting_set_audio_fm + 1) % 5;
RADIO_SetModulation(gRxVfo->Modulation);
}
#endif
@@ -678,4 +682,4 @@ void ACTION_Remove_Offset(void)
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
}
#endif
#endif
#endif
+1 -1
View File
@@ -39,7 +39,7 @@ static const uint16_t Obfuscation[8] = { 0x6C16, 0xE614, 0x912E, 0x400D, 0x3521,
AIRCOPY_State_t gAircopyState;
uint16_t gAirCopyBlockNumber;
uint16_t gErrorsDuringAirCopy;
uint8_t gAirCopyIsSendMode;
bool gAirCopyIsSendMode;
uint16_t g_FSK_Buffer[36];
+1 -1
View File
@@ -92,7 +92,7 @@ typedef enum {
extern AIRCOPY_State_t gAircopyState;
extern uint16_t gAirCopyBlockNumber;
extern uint16_t gErrorsDuringAirCopy;
extern uint8_t gAirCopyIsSendMode;
extern bool gAirCopyIsSendMode;
extern uint16_t g_FSK_Buffer[36];
-1
View File
@@ -2144,7 +2144,6 @@ Skip:
else
flagSaveSettings = 1;
gRequestSaveSettings = false;
gRequestSaveSquelch = false;
gUpdateStatus = true;
}
+3
View File
@@ -301,6 +301,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
RADIO_NextValidList(isKeyUp ? 1 : -1);
} else {
// Adjust squelch: UP increments, DOWN decrements
if (gSquelchLevelOriginal == 10)
gSquelchLevelOriginal = gEeprom.SQUELCH_LEVEL;
if (isKeyUp) {
gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL < 9) ? gEeprom.SQUELCH_LEVEL + 1 : 9;
} else {
+21 -5
View File
@@ -429,7 +429,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD) - 1;
if(gTxVfo->Modulation == MODULATION_AM)
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD_AM) - 1;
else if (gTxVfo->Modulation == MODULATION_USB)
*pMax = 0;
else
*pMax = ARRAY_SIZE(gSubMenu_SET_AUD_FM) - 1;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -480,7 +485,9 @@ void MENU_AcceptSetting(void)
case MENU_SQL:
gEeprom.SQUELCH_LEVEL = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE;
gRequestSaveSquelch = true;
#ifdef ENABLE_FEAT_F4HWN
gSquelchLevelOriginal = 10;
#endif
break;
case MENU_STEP:
@@ -962,8 +969,12 @@ void MENU_AcceptSetting(void)
break;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
gSetting_set_audio = gSubMenuSelection;
RADIO_SetModulation(gRxVfo->Modulation);
if(gTxVfo->Modulation == MODULATION_AM)
gSetting_set_audio_am = gSubMenuSelection;
else if (gTxVfo->Modulation == MODULATION_FM)
gSetting_set_audio_fm = gSubMenuSelection;
RADIO_SetModulation(gTxVfo->Modulation);
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -1417,7 +1428,12 @@ void MENU_ShowCurrentSetting(void)
break;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
gSubMenuSelection = gSetting_set_audio;
if(gTxVfo->Modulation == MODULATION_AM)
gSubMenuSelection = gSetting_set_audio_am;
else if (gTxVfo->Modulation == MODULATION_USB)
gSubMenuSelection = 0;
else
gSubMenuSelection = gSetting_set_audio_fm;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
+9 -8
View File
@@ -36,6 +36,13 @@
BEEP_Type_t gBeepToPlay = BEEP_NONE;
static void AUDIO_PlayBeepPulse(void) {
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
}
void AUDIO_PlayBeep(BEEP_Type_t Beep)
{
@@ -128,17 +135,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
switch (Beep)
{
case BEEP_880HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
AUDIO_PlayBeepPulse();
[[fallthrough]];
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
case BEEP_500HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
AUDIO_PlayBeepPulse();
[[fallthrough]];
case BEEP_1KHZ_60MS_OPTIONAL:
BK4819_ExitTxMute();
+3 -2
View File
@@ -127,7 +127,8 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gSetting_set_met = 0;
bool gSetting_set_gui = 0;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
uint8_t gSetting_set_audio = 0;
uint8_t gSetting_set_audio_fm = 0;
uint8_t gSetting_set_audio_am = 0;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool gSetting_set_nfm = 0;
@@ -250,7 +251,6 @@ bool gFlagResetVfos;
bool gRequestSaveVFO;
uint16_t gRequestSaveChannel;
bool gRequestSaveSettings;
bool gRequestSaveSquelch;
#ifdef ENABLE_FMRADIO
bool gRequestSaveFM;
#endif
@@ -331,6 +331,7 @@ uint8_t gIsLocked = 0xFF;
bool gMute = false;
uint8_t gBacklightTimeOriginal;
uint8_t gBacklightBrightnessOld;
uint8_t gSquelchLevelOriginal = 10;
uint8_t gPttOnePushCounter = 0;
uint32_t gBlinkCounter = 0;
+3 -2
View File
@@ -189,7 +189,8 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gSetting_set_met;
extern bool gSetting_set_gui;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
extern uint8_t gSetting_set_audio;
extern uint8_t gSetting_set_audio_fm;
extern uint8_t gSetting_set_audio_am;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
extern bool gSetting_set_nfm;
@@ -375,7 +376,6 @@ extern bool gFlagResetVfos;
extern bool gRequestSaveVFO;
extern uint16_t gRequestSaveChannel;
extern bool gRequestSaveSettings;
extern bool gRequestSaveSquelch;
#ifdef ENABLE_FMRADIO
extern bool gRequestSaveFM;
#endif
@@ -454,6 +454,7 @@ extern volatile uint8_t boot_counter_10ms;
extern bool gMute;
extern uint8_t gBacklightTimeOriginal;
extern uint8_t gBacklightBrightnessOld;
extern uint8_t gSquelchLevelOriginal;
extern uint8_t gPttOnePushCounter;
extern uint32_t gBlinkCounter;
+105 -34
View File
@@ -54,7 +54,22 @@ const char gModulationStr[MODULATION_UKNOWN][4] = {
};
#ifdef ENABLE_FEAT_F4HWN_AUDIO
static void AUDIO_ApplyProfile(uint8_t profile)
// About BK4819_WriteRegister(0x2b, val) experimentation...
//
// 0x000: 300 Hz high-pass filter enabled, 3 kHz low-pass filter enabled, de-emphasis enabled.
// Audio impression: the most "classic radio" tuning, more filtered and smoother.
//
// 0x300: 300 Hz high-pass filter enabled, 3 kHz low-pass filter disabled, de-emphasis disabled.
// Audio impression: clearer, brighter, and more open, while still cutting low frequencies.
//
// 0x400: 300 Hz high-pass filter disabled, 3 kHz low-pass filter enabled, de-emphasis enabled.
// Audio impression: fuller low end, but still softened by de-emphasis and upper-frequency limiting.
//
// 0x500: 300 Hz high-pass filter disabled, 3 kHz low-pass filter enabled, de-emphasis disabled.
// Audio impression: fuller bass, more direct sound, while still keeping the 3 kHz top-end limit.
static void AUDIO_ApplyFMProfile(uint8_t profile)
{
switch (profile)
{
@@ -85,6 +100,41 @@ const char gModulationStr[MODULATION_UKNOWN][4] = {
break;
}
}
static void AUDIO_ApplyAMProfile(uint8_t profile)
{
switch (profile)
{
default:
case 0: // SHARP (ALPHA test profile) - Narrow IF filter (REG54 bits[14:8]=0, bits[7:0]=9), low IF gain (REG55 bits[11:8]=1, ref=169)
// Selective and crisp, best adjacent channel rejection, may sound harsh on strong signals
BK4819_WriteRegister(0x2b, 0x0300);
BK4819_WriteRegister(0x2f, 0x9990);
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31A9);
break;
case 1: // STOCK - Narrow IF filter (REG54 bits[14:8]=0, bits[7:0]=9), moderate IF gain (REG55 bits[11:8]=4, ref=180)
// Selective filter with balanced gain, punchy and detailed, good compromise between rejection and sensitivity
BK4819_WriteRegister(0x2b, 0x0500);
BK4819_WriteRegister(0x2f, 0x9990);
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31A9);
break;
case 2: // OPEN (BRAVO test profile) - Medium-wide IF filter (REG54 bits[14:8]=8, bits[7:0]=70), high IF gain (REG55 bits[11:8]=8, ref=192)
// Wide and pleasant, better sensitivity on weak signals, may struggle with adjacent channel interference
BK4819_WriteRegister(0x2b, 0x0300);
BK4819_WriteRegister(0x2f, 0x9990);
BK4819_WriteRegister(0x54, 0x8846);
BK4819_WriteRegister(0x55, 0x38C0);
break;
}
}
static void AUDIO_ApplyUSBProfile(void)
{
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31A9);
}
#endif
bool RADIO_CheckValidList(uint8_t scanList)
@@ -1098,48 +1148,70 @@ void RADIO_SetModulation(ModulationMode_t modulation)
BK4819_SetAF(mod);
// HACK, FIXME:
//
// What follows is a direct copy of the AM enable/disable code from
// the original UV-K1 firmware. It is not clear why these specific register
// values are used for AM all of a sudden instead of the AF setting like on
// the BK4819, nor what exactly they do.
// So for now we just keep it as is to maintain compatibility.
//
if (modulation != MODULATION_AM)
switch (modulation)
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31,uVar1 & 0xfffffffe);
BK4819_WriteRegister(0x42,0x6b5a);
BK4819_WriteRegister(0x2a,0x7400);
BK4819_WriteRegister(0x2b,0);
BK4819_WriteRegister(0x2f,0x9890);
//BK4819_WriteRegister(0x54, 0x9009);
//BK4819_WriteRegister(0x55, 0x31a9);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyProfile(gSetting_set_audio);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
}
else
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31,uVar1 | 1);
BK4819_WriteRegister(0x42,0x6f5c);
BK4819_WriteRegister(0x2a,0x7434);
BK4819_WriteRegister(0x2b,0x400);
BK4819_WriteRegister(0x2f,0x9990);
//BK4819_WriteRegister(0x54, 0x9775);
//BK4819_WriteRegister(0x55, 0x32c6);
case MODULATION_AM:
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, uVar1 | 1); // AM Demodulation Enable
BK4819_WriteRegister(0x42, 0x6f5c);
BK4819_WriteRegister(0x2a, 0x7434);
//BK4819_WriteRegister(0x54, 0x8846);
//BK4819_WriteRegister(0x55, 0x38C0);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyAMProfile(gSetting_set_audio_am);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true);
break;
}
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true);
case MODULATION_USB:
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, uVar1 & 0xfffe); // AM Demodulation Disable
BK4819_WriteRegister(0x42, 0x6b5a);
BK4819_WriteRegister(0x2a, 0x7400);
BK4819_WriteRegister(0x2b, 0x0000);
BK4819_WriteRegister(0x2f, 0x9890);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyUSBProfile();
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
break;
}
case MODULATION_FM:
default:
{
uint16_t uVar1 = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, uVar1 & 0xfffe); // AM Demodulation Disable
BK4819_WriteRegister(0x42, 0x6b5a);
BK4819_WriteRegister(0x2a, 0x7400);
BK4819_WriteRegister(0x2b, 0x0000);
BK4819_WriteRegister(0x2f, 0x9890);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
AUDIO_ApplyFMProfile(gSetting_set_audio_fm);
#else
BK4819_WriteRegister(0x54, 0x9009);
BK4819_WriteRegister(0x55, 0x31a9);
#endif
break;
}
}
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
@@ -1147,7 +1219,6 @@ void RADIO_SetModulation(ModulationMode_t modulation)
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
RADIO_SetupAGC(modulation == MODULATION_AM, false);
//RADIO_SetupAGC(false, false);
}
void RADIO_SetupAGC(bool listeningAM, bool disable)
+8 -5
View File
@@ -121,7 +121,8 @@ void SETTINGS_InitEEPROM(void)
// 0E70..0E77
PY25Q16_ReadBuffer(0x00A000, Data, 8);
#ifdef ENABLE_FEAT_F4HWN_AUDIO
gSetting_set_audio = (Data[0] < 5) ? Data[0] : 0;
gSetting_set_audio_fm = ((Data[0] & 0x0F) < 5) ? (Data[0] & 0x0F) : 0;
gSetting_set_audio_am = (((Data[0] >> 4) & 0x0F) < 3) ? ((Data[0] >> 4) & 0x0F) : 0;
#endif
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1;
gEeprom.TX_TIMEOUT_TIMER = (Data[2] > 4 && Data[2] < 180) ? Data[2] : 11;
@@ -764,12 +765,14 @@ void SETTINGS_SaveSettings(void)
// 0x0E70
State = SecBuf;
#ifdef ENABLE_FEAT_F4HWN_AUDIO
State[0] = gSetting_set_audio;
State[0] = (gSetting_set_audio_fm & 0x0F) | ((gSetting_set_audio_am & 0x0F) << 4);
#endif
#ifdef ENABLE_FEAT_F4HWN
if (gSquelchLevelOriginal < 10)
State[1] = gSquelchLevelOriginal;
else
#endif
if (gRequestSaveSquelch)
{
State[1] = gEeprom.SQUELCH_LEVEL;
}
State[2] = gEeprom.TX_TIMEOUT_TIMER;
#ifdef ENABLE_NOAA
State[3] = gEeprom.NOAA_AUTO_SCAN;
+13 -8
View File
@@ -897,17 +897,25 @@ void UI_DisplayMain(void)
// }
// if (RxBlink == 0 || RxBlink == 1) {
if(gRxVfo->Modulation == MODULATION_AM)
GUI_DisplaySmallest("AIR", 10, RxLine == 0 ? 1 : 33, false, true);
if(gRxVfo->Modulation == MODULATION_AM) {
#ifdef ENABLE_FEAT_F4HWN_AUDIO
strcpy(String, gSubMenu_SET_AUD_AM[gSetting_set_audio_am]);
#else
strcpy(String, "AIR");
#endif
}
else if (gRxVfo->Modulation == MODULATION_USB) {
strcpy(String, "USB");
}
else {
#ifdef ENABLE_FEAT_F4HWN_AUDIO
strcpy(String, gSubMenu_SET_AUD[gSetting_set_audio]);
strcpy(String, gSubMenu_SET_AUD_FM[gSetting_set_audio_fm]);
#else
strcpy(String, "RX");
#endif
GUI_DisplaySmallest(String, 10, RxLine == 0 ? 1 : 33, false, true);
}
GUI_DisplaySmallest(String, 10, RxLine == 0 ? 1 : 33, false, true);
//UI_PrintStringSmallBold("RX", 8, 0, RxLine);
// }
#else
@@ -1353,11 +1361,8 @@ void UI_DisplayMain(void)
break;
case 2:
sprintf(String, "%03oN", DCS_Options[pConfig->Code]);
break;
case 3:
sprintf(String, "%03oI", DCS_Options[pConfig->Code]);
sprintf(String, (int)pConfig->CodeType == 2 ? "%03oN" : "%03oI", DCS_Options[pConfig->Code]);
break;
default:
+26 -20
View File
@@ -413,7 +413,7 @@ const char gSubMenu_SCRAMBLER[][7] =
};
#ifdef ENABLE_FEAT_F4HWN_AUDIO
const char gSubMenu_SET_AUD[][6] =
const char gSubMenu_SET_AUD_FM[][6] =
{
"FLAT",
"CLEAN",
@@ -421,6 +421,13 @@ const char gSubMenu_SCRAMBLER[][7] =
"BOOST",
"MAX"
};
const char gSubMenu_SET_AUD_AM[][6] =
{
"SHARP",
"STOCK",
"OPEN"
};
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
@@ -968,9 +975,10 @@ void UI_DisplayMenu(void)
break;
case MENU_LIST_CH:
case MENU_S_LIST:
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
strcpy(String, "ALL");
else if (gSubMenuSelection == 0)
else if (gSubMenuSelection == 0 && UI_MENU_GetCurrentMenuId() == MENU_LIST_CH)
strcpy(String, "OFF");
else {
const char *name = gListName[gSubMenuSelection - 1];
@@ -982,20 +990,7 @@ void UI_DisplayMenu(void)
sprintf(String, "%02u (%.3s)", gSubMenuSelection, name);
}
break;
case MENU_S_LIST:
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
strcpy(String, "ALL");
else {
const char *name = gListName[gSubMenuSelection - 1];
// If first character is empty/invalid, display "N/A"
if (IsEmptyName(name, sizeof(gListName[0])))
sprintf(String, "%02u", gSubMenuSelection);
else
sprintf(String, "%02u (%.3s)", gSubMenuSelection, name);
}
break;
#ifdef ENABLE_ALARM
case MENU_AL_MOD:
sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]);
@@ -1194,7 +1189,18 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case MENU_SET_AUD:
strcpy(String, gSubMenu_SET_AUD[gSubMenuSelection]);
if(gTxVfo->Modulation == MODULATION_AM) {
strcpy(String, gSubMenu_SET_AUD_AM[gSubMenuSelection]);
UI_PrintStringSmallNormal("AM", 114, 0, 0);
}
else if (gTxVfo->Modulation == MODULATION_USB) {
strcpy(String, "USB");
UI_PrintStringSmallNormal("USB", 108, 0, 0);
}
else {
strcpy(String, gSubMenu_SET_AUD_FM[gSubMenuSelection]);
UI_PrintStringSmallNormal("FM", 114, 0, 0);
}
break;
#endif
@@ -1345,8 +1351,8 @@ void UI_DisplayMenu(void)
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
#endif
) {
sprintf(String, "%2d", gSubMenuSelection);
UI_PrintStringSmallNormal(String, 105, 0, 0);
sprintf(String, "%03d", gSubMenuSelection);
UI_PrintStringSmallNormal(String, 107, 0, 0);
}
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
@@ -1359,4 +1365,4 @@ void UI_DisplayMenu(void)
}
ST7565_BlitFullScreen();
}
}
+2 -1
View File
@@ -198,7 +198,8 @@ extern const char gSubMenu_D_RSP[4][11];
extern const char gSubMenu_SET_KEY[][9];
#endif
#ifdef ENABLE_FEAT_F4HWN_AUDIO
extern const char gSubMenu_SET_AUD[5][6];
extern const char gSubMenu_SET_AUD_FM[5][6];
extern const char gSubMenu_SET_AUD_AM[3][6];
#endif
#endif
+2 -9
View File
@@ -99,15 +99,8 @@ void UI_DisplayStatus()
if(gEeprom.SCAN_LIST_DEFAULT == MR_CHANNELS_LIST + 1)
{
if(gEeprom.SCAN_LIST_ENABLED==1) {
sprintf(str, "%s+", "ALL");
end = 18;
}
else
{
sprintf(str, "%s", "ALL");
end = 14;
}
sprintf(str, gEeprom.SCAN_LIST_ENABLED ? "%s+" : "%s", "ALL");
end = gEeprom.SCAN_LIST_ENABLED ? 18 : 14;
}
else
{
+1 -1
View File
@@ -71,7 +71,7 @@
"ENABLE_UART_RW_BK_REGS": false,
"ENABLE_SWD": false,
"VERSION_STRING_1": "v0.22",
"VERSION_STRING_2": "v5.3.0"
"VERSION_STRING_2": "v5.3.1"
}
},
{
BIN
View File
Binary file not shown.
Binary file not shown.