From 4315b98aec1dd64f6821faa94649789bf5c2f9f7 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Sat, 22 Aug 2026 22:49:14 +0200 Subject: [PATCH] Preserve RescueOps settings across presets --- App/main.c | 1 - App/settings.c | 26 ++++++++------------------ App/settings.h | 1 - 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/App/main.c b/App/main.c index 90b28c1f..c28fe525 100644 --- a/App/main.c +++ b/App/main.c @@ -119,7 +119,6 @@ void Main(void) gCB = gEeprom.CROSS_BAND_RX_TX; #endif - SETTINGS_WriteChirpCapabilities(); SETTINGS_LoadCalibration(); RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); diff --git a/App/settings.c b/App/settings.c index 330feb59..f7836c87 100644 --- a/App/settings.c +++ b/App/settings.c @@ -152,7 +152,9 @@ void SETTINGS_InitEEPROM(void) gEeprom.SET_KEY = ((Data[4] >> 2) & 0x0F) > 4 ? 0 : (Data[4] >> 2) & 0x0F; gEeprom.SET_NAV = (Data[4] & 0x40) != 0; #else - gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; + // RescueOps fields can be present in a config bank shared with another + // preset. Read only KEY_LOCK here and leave the other bits untouched. + gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0; #endif #ifdef ENABLE_VOX gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false; @@ -896,7 +898,11 @@ void SETTINGS_SaveSettings(void) ((gEeprom.SET_KEY & 0x0F) << 2) | (gEeprom.SET_NAV ? 0x40 : 0); #else - State[4] = gEeprom.KEY_LOCK; + // A non-RescueOps preset owns KEY_LOCK only. Preserve Set RescueOps, + // SetKEY, SetNav and reserved bits from a config created by another + // preset while updating bit 0. + PY25Q16_ReadBuffer(0x00A004, &State[4], 1); + State[4] = (State[4] & 0xFEu) | (gEeprom.KEY_LOCK ? 0x01u : 0u); #endif #ifdef ENABLE_VOX @@ -1251,22 +1257,6 @@ void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep) SETTINGS_SaveChannelName(channel, ""); } -void SETTINGS_WriteChirpCapabilities(void) -{ - enum { - CHIRP_CAP_RESCUE_OPS = 1u << 0, - }; - - uint8_t capabilities[2] = {0}; - -#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - capabilities[0] |= CHIRP_CAP_RESCUE_OPS; -#endif - - // 0xA158..0xA159 are reserved for the firmware/CHIRP capability contract. - PY25Q16_WriteBuffer(0x00A158, capabilities, sizeof(capabilities), false); -} - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE void SETTINGS_WriteCurrentState(void) { diff --git a/App/settings.h b/App/settings.h index 791d0556..22b003ff 100644 --- a/App/settings.h +++ b/App/settings.h @@ -329,7 +329,6 @@ void SETTINGS_SaveChannelName(uint16_t channel, const char * name); void SETTINGS_SaveChannel(uint16_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration); void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep); -void SETTINGS_WriteChirpCapabilities(void); #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE void SETTINGS_WriteCurrentState(void); #endif