diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index e978273f..3985dcdf 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -195,6 +195,7 @@ enable_feature(ENABLE_FEAT_F4HWN_INV) enable_feature(ENABLE_FEAT_F4HWN_CTR) enable_feature(ENABLE_FEAT_F4HWN_RESCUE_OPS) enable_feature(ENABLE_FEAT_F4HWN_VOL) +enable_feature(ENABLE_FEAT_F4HWN_AUDIO) enable_feature(ENABLE_FEAT_F4HWN_RESET_VFO) enable_feature(ENABLE_FEAT_F4HWN_PMR) enable_feature(ENABLE_FEAT_F4HWN_GMRS_FRS_MURS) diff --git a/App/app/menu.c b/App/app/menu.c index 38ef390a..453bc9c2 100644 --- a/App/app/menu.c +++ b/App/app/menu.c @@ -407,19 +407,19 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1; break; -#ifdef ENABLE_FEAT_F4HWN_CTR + #ifdef ENABLE_FEAT_F4HWN_CTR case MENU_SET_CTR: *pMin = 1; *pMax = 15; break; -#endif + #endif case MENU_TX_LOCK: -#ifdef ENABLE_FEAT_F4HWN_INV + #ifdef ENABLE_FEAT_F4HWN_INV case MENU_SET_INV: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; break; -#endif + #endif case MENU_SET_LCK: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1; @@ -429,6 +429,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SET_MET) - 1; break; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + case MENU_SET_AUD: + //*pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_SET_AUD) - 1; + break; + #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER case MENU_SET_NFM: //*pMin = 0; @@ -939,11 +945,11 @@ void MENU_AcceptSetting(void) case MENU_SET_EOT: gSetting_set_eot = gSubMenuSelection; break; -#ifdef ENABLE_FEAT_F4HWN_CTR + #ifdef ENABLE_FEAT_F4HWN_CTR case MENU_SET_CTR: gSetting_set_ctr = gSubMenuSelection; break; -#endif + #endif case MENU_SET_INV: gSetting_set_inv = gSubMenuSelection; break; @@ -956,6 +962,12 @@ void MENU_AcceptSetting(void) case MENU_SET_GUI: gSetting_set_gui = gSubMenuSelection; break; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + case MENU_SET_AUD: + gSetting_set_audio = gSubMenuSelection; + RADIO_SetModulation(gRxVfo->Modulation); + break; + #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER case MENU_SET_NFM: gSetting_set_nfm = gSubMenuSelection; @@ -1388,11 +1400,11 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_EOT: gSubMenuSelection = gSetting_set_eot; break; -#ifdef ENABLE_FEAT_F4HWN_CTR + #ifdef ENABLE_FEAT_F4HWN_CTR case MENU_SET_CTR: gSubMenuSelection = gSetting_set_ctr; break; -#endif + #endif case MENU_SET_INV: gSubMenuSelection = gSetting_set_inv; break; @@ -1405,6 +1417,11 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_GUI: gSubMenuSelection = gSetting_set_gui; break; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + case MENU_SET_AUD: + gSubMenuSelection = gSetting_set_audio; + break; + #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER case MENU_SET_NFM: gSubMenuSelection = gSetting_set_nfm; diff --git a/App/misc.c b/App/misc.c index 835a1f8f..fe3d56fa 100644 --- a/App/misc.c +++ b/App/misc.c @@ -126,6 +126,9 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; bool gSetting_set_lck = false; bool gSetting_set_met = 0; bool gSetting_set_gui = 0; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + uint8_t gSetting_set_audio = 0; + #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER bool gSetting_set_nfm = 0; #endif diff --git a/App/misc.h b/App/misc.h index 490ec733..36c27af4 100644 --- a/App/misc.h +++ b/App/misc.h @@ -188,6 +188,9 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; extern bool gSetting_set_lck; extern bool gSetting_set_met; extern bool gSetting_set_gui; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + extern uint8_t gSetting_set_audio; + #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER extern bool gSetting_set_nfm; #endif diff --git a/App/radio.c b/App/radio.c index b29b3782..ad395e53 100644 --- a/App/radio.c +++ b/App/radio.c @@ -53,6 +53,40 @@ const char gModulationStr[MODULATION_UKNOWN][4] = { #endif }; +#ifdef ENABLE_FEAT_F4HWN_AUDIO + static void AUDIO_ApplyProfile(uint8_t profile) + { + switch (profile) + { + default: + case 0: // FLAT + BK4819_WriteRegister(0x54, 0x9009); + BK4819_WriteRegister(0x55, 0x3200); + break; + + case 1: // CLEAN + BK4819_WriteRegister(0x54, 0x9009); + BK4819_WriteRegister(0x55, 0x33A9); + break; + + case 2: // MID + BK4819_WriteRegister(0x54, 0x9009); + BK4819_WriteRegister(0x55, 0x3600); + break; + + case 3: // BOOST + BK4819_WriteRegister(0x54, 0x8546); + BK4819_WriteRegister(0x55, 0x3AF0); + break; + + case 4: // MAX + BK4819_WriteRegister(0x54, 0x8566); + BK4819_WriteRegister(0x55, 0x3D00); + break; + } + } +#endif + bool RADIO_CheckValidList(uint8_t scanList) { if(scanList == MR_CHANNELS_LIST + 1) @@ -1060,8 +1094,14 @@ void RADIO_SetModulation(ModulationMode_t modulation) BK4819_WriteRegister(0x2a,0x7400); BK4819_WriteRegister(0x2b,0); BK4819_WriteRegister(0x2f,0x9890); - BK4819_WriteRegister(0x54, 0x9009); - BK4819_WriteRegister(0x55, 0x31a9); + //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 { @@ -1073,6 +1113,10 @@ void RADIO_SetModulation(ModulationMode_t modulation) BK4819_WriteRegister(0x2f,0x9990); //BK4819_WriteRegister(0x54, 0x9775); //BK4819_WriteRegister(0x55, 0x32c6); + + BK4819_WriteRegister(0x54, 0x8846); + BK4819_WriteRegister(0x55, 0x38C0); + BK4819_SetFilterBandwidth(BK4819_FILTER_BW_AM, true); } diff --git a/App/settings.c b/App/settings.c index f72bf44c..cca89b4e 100644 --- a/App/settings.c +++ b/App/settings.c @@ -35,6 +35,9 @@ void SETTINGS_InitEEPROM(void) uint8_t Data[16] = {0}; // 0E70..0E77 PY25Q16_ReadBuffer(0x00A000, Data, 8); + #ifdef ENABLE_FEAT_F4HWN_AUDIO + gSetting_set_audio = (Data[0] < 5) ? Data[0] : 0; + #endif gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1; gEeprom.TX_TIMEOUT_TIMER = (Data[2] > 4 && Data[2] < 180) ? Data[2] : 11; #ifdef ENABLE_NOAA @@ -657,6 +660,9 @@ void SETTINGS_SaveSettings(void) // 0x0E70 State = SecBuf; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + State[0] = gSetting_set_audio; + #endif State[1] = gEeprom.SQUELCH_LEVEL; State[2] = gEeprom.TX_TIMEOUT_TIMER; #ifdef ENABLE_NOAA diff --git a/App/ui/menu.c b/App/ui/menu.c index 23bbd8b5..85035a7a 100644 --- a/App/ui/menu.c +++ b/App/ui/menu.c @@ -147,6 +147,9 @@ const t_menu_item MenuList[] = {"SetLck", MENU_SET_LCK }, {"SetMet", MENU_SET_MET }, {"SetGUI", MENU_SET_GUI }, +#ifdef ENABLE_FEAT_F4HWN_AUDIO + {"SetRxA", MENU_SET_AUD }, +#endif {"SetTmr", MENU_SET_TMR }, #ifdef ENABLE_FEAT_F4HWN_SLEEP {"SetOff", MENU_SET_OFF }, @@ -409,6 +412,17 @@ const char gSubMenu_SCRAMBLER[][7] = "CLASSIC" }; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + const char gSubMenu_SET_AUD[][6] = + { + "FLAT", + "CLEAN", + "MID", + "BOOST", + "MAX" + }; + #endif + #ifdef ENABLE_FEAT_F4HWN_NARROWER const char gSubMenu_SET_NFM[][9] = { @@ -1161,6 +1175,12 @@ void UI_DisplayMenu(void) strcpy(String, gSubMenu_SET_MET[gSubMenuSelection]); // Same as SET_MET break; + #ifdef ENABLE_FEAT_F4HWN_AUDIO + case MENU_SET_AUD: + strcpy(String, gSubMenu_SET_AUD[gSubMenuSelection]); + break; + #endif + #ifdef ENABLE_FEAT_F4HWN_NARROWER case MENU_SET_NFM: strcpy(String, gSubMenu_SET_NFM[gSubMenuSelection]); diff --git a/App/ui/menu.h b/App/ui/menu.h index 199aa04e..70ee5f12 100644 --- a/App/ui/menu.h +++ b/App/ui/menu.h @@ -150,6 +150,9 @@ enum MENU_NOAA_S, #endif MENU_SET_NAV, + #ifdef ENABLE_FEAT_F4HWN_AUDIO + MENU_SET_AUD, + #endif #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT, @@ -194,6 +197,9 @@ extern const char gSubMenu_D_RSP[4][11]; #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS extern const char gSubMenu_SET_KEY[][9]; #endif + #ifdef ENABLE_FEAT_F4HWN_AUDIO + extern const char gSubMenu_SET_AUD[5][6]; + #endif #endif extern const char* const gSubMenu_PTT_ID[5]; diff --git a/CMakePresets.json b/CMakePresets.json index ebcd037a..400f3144 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -58,6 +58,7 @@ "ENABLE_FEAT_F4HWN_CTR": true, "ENABLE_FEAT_F4HWN_RESCUE_OPS": false, "ENABLE_FEAT_F4HWN_VOL": false, + "ENABLE_FEAT_F4HWN_AUDIO": false, "ENABLE_FEAT_F4HWN_RESET_VFO": true, "ENABLE_FEAT_F4HWN_PMR": false, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": false, @@ -185,6 +186,7 @@ "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true, "ENABLE_FEAT_F4HWN_RESCUE_OPS": true, "ENABLE_FEAT_F4HWN_VOL": true, + "ENABLE_FEAT_F4HWN_AUDIO": true, "ENABLE_SWD": true, "EDITION_STRING": "Fusion", "TARGET": "f4hwn.fusion"