diff --git a/Makefile b/Makefile index 2e060a5..983b8ad 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ ENABLE_FEAT_F4HWN_CHARGING_C ?= 1 ENABLE_FEAT_F4HWN_SLEEP ?= 1 ENABLE_FEAT_F4HWN_RESTORE_SCAN ?= 1 ENABLE_FEAT_F4HWN_NARROWER ?= 1 +ENABLE_FEAT_F4HWN_VOL ?= 0 ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0 ENABLE_FEAT_F4HWN_PMR ?= 0 ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0 @@ -431,6 +432,9 @@ endif ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1) CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER endif +ifeq ($(ENABLE_FEAT_F4HWN_VOL),1) + CFLAGS += -DENABLE_FEAT_F4HWN_VOL +endif ifeq ($(ENABLE_FEAT_F4HWN_RESET_CHANNEL),1) CFLAGS += -DENABLE_FEAT_F4HWN_RESET_CHANNEL endif diff --git a/app/menu.c b/app/menu.c index 19ba48e..f5edf32 100644 --- a/app/menu.c +++ b/app/menu.c @@ -424,6 +424,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_SET_NFM) - 1; break; #endif + #ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + //*pMin = 0; + *pMax = 63; + break; + #endif #endif default: @@ -930,6 +936,11 @@ void MENU_AcceptSetting(void) RADIO_SetupRegisters(true); break; #endif + #ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + gEeprom.VOLUME_GAIN = gSubMenuSelection; + break; + #endif case MENU_SET_TMR: gSetting_set_tmr = gSubMenuSelection; break; @@ -1369,6 +1380,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gSetting_set_nfm; break; #endif + #ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + gSubMenuSelection = gEeprom.VOLUME_GAIN; + break; + #endif case MENU_SET_TMR: gSubMenuSelection = gSetting_set_tmr; break; diff --git a/settings.c b/settings.c index 0227ca9..1aa2afb 100644 --- a/settings.c +++ b/settings.c @@ -795,6 +795,10 @@ void SETTINGS_SaveSettings(void) EEPROM_WriteBuffer(0x1FF0, State); #endif + +#ifdef ENABLE_FEAT_F4HWN_VOL + SETTINGS_WriteCurrentVol(); +#endif } void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) @@ -997,3 +1001,13 @@ State[1] = 0 EEPROM_WriteBuffer(0x0E78, State); } #endif + +#ifdef ENABLE_FEAT_F4HWN_VOL + void SETTINGS_WriteCurrentVol(void) + { + uint8_t State[8]; + EEPROM_ReadBuffer(0x1F88, State, sizeof(State)); + State[6] = gEeprom.VOLUME_GAIN; + EEPROM_WriteBuffer(0x1F88, State); + } +#endif diff --git a/settings.h b/settings.h index b2a9897..d104b2b 100644 --- a/settings.h +++ b/settings.h @@ -308,5 +308,7 @@ void SETTINGS_WriteBuildOptions(void); #ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN void SETTINGS_WriteCurrentState(void); #endif - +#ifdef ENABLE_FEAT_F4HWN_VOL + void SETTINGS_WriteCurrentVol(void); +#endif #endif diff --git a/ui/menu.c b/ui/menu.c index 38d74b9..4015842 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -150,9 +150,12 @@ const t_menu_item MenuList[] = #ifdef ENABLE_FEAT_F4HWN_SLEEP {"SetOff", MENU_SET_OFF }, #endif - #ifdef ENABLE_FEAT_F4HWN_NARROWER - {"SetNFM", MENU_SET_NFM }, - #endif +#ifdef ENABLE_FEAT_F4HWN_NARROWER + {"SetNFM", MENU_SET_NFM }, +#endif +#ifdef ENABLE_FEAT_F4HWN_VOL + {"SetVol", MENU_SET_VOL }, +#endif #endif // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on @@ -1046,6 +1049,18 @@ void UI_DisplayMenu(void) strcpy(String, gSubMenu_SET_NFM[gSubMenuSelection]); break; #endif + + #ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + sprintf(String, gSubMenuSelection == 0 ? "OFF" : "%02u", gSubMenuSelection); + gEeprom.VOLUME_GAIN = gSubMenuSelection; + BK4819_WriteRegister(BK4819_REG_48, + (11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference + ( 0u << 10) | // AF Rx Gain-1 + (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 + (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) + break; + #endif #endif } diff --git a/ui/menu.h b/ui/menu.h index 66425fe..81728df 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -144,6 +144,9 @@ enum #ifdef ENABLE_FEAT_F4HWN_NARROWER MENU_SET_NFM, #endif + #ifdef ENABLE_FEAT_F4HWN_VOL + MENU_SET_VOL, + #endif #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT,