mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Fix SetNav persistence in Fusion and Transfer
This commit is contained in:
1 parent
e5f6fb236b
commit
7a2687b0b2
1 file changed
+19
-21
+19
-21
@@ -149,15 +149,11 @@ void SETTINGS_InitEEPROM(void)
|
|||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false;
|
||||||
#endif
|
#endif
|
||||||
|
gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0;
|
||||||
|
gEeprom.SET_NAV = (Data[4] & 0x40) != 0;
|
||||||
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
|
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
|
||||||
gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0;
|
|
||||||
gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0;
|
gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0;
|
||||||
gEeprom.SET_KEY = ((Data[4] >> 2) & 0x0F) > 4 ? 0 : (Data[4] >> 2) & 0x0F;
|
gEeprom.SET_KEY = ((Data[4] >> 2) & 0x0F) > 4 ? 0 : (Data[4] >> 2) & 0x0F;
|
||||||
gEeprom.SET_NAV = (Data[4] & 0x40) != 0;
|
|
||||||
#else
|
|
||||||
// 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
|
#endif
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false;
|
||||||
@@ -753,30 +749,31 @@ void SETTINGS_FactoryReset(bool bIsAll)
|
|||||||
PY25Q16_SectorErase(0x00A000);
|
PY25Q16_SectorErase(0x00A000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent reset to restart in RO mode...
|
// Reset navigation in every edition and lock controls in RescueOps editions.
|
||||||
|
uint8_t Data8[0x10];
|
||||||
|
PY25Q16_ReadBuffer(0x00A000, Data8, sizeof(Data8));
|
||||||
|
|
||||||
|
// SET_NAV to false
|
||||||
|
Data8[4] &= (uint8_t)~0x40; // Clear bit 6 (SET_NAV) for UV-K1 by default
|
||||||
|
|
||||||
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
|
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
|
||||||
// Bloc 0x0E70..0x0E7F -> offset 0x00A000
|
|
||||||
uint8_t Data8[0x10];
|
|
||||||
PY25Q16_ReadBuffer(0x00A000, Data8, sizeof(Data8));
|
|
||||||
|
|
||||||
// MENU_LOCK & KEY_LOCK to 0
|
// MENU_LOCK & KEY_LOCK to 0
|
||||||
|
|
||||||
Data8[4] &= (uint8_t)~0x01;
|
Data8[4] &= (uint8_t)~0x01;
|
||||||
Data8[4] &= (uint8_t)~0x02;
|
Data8[4] &= (uint8_t)~0x02;
|
||||||
|
|
||||||
// SET_KEY to 0
|
// SET_KEY to 0
|
||||||
Data8[4] &= (uint8_t)~0x3C; // Clear bits 2-5 (SET_KEY)
|
Data8[4] &= (uint8_t)~0x3C; // Clear bits 2-5 (SET_KEY)
|
||||||
|
|
||||||
// SET_NAV to false
|
|
||||||
Data8[4] &= (uint8_t)~0x40; // Clear bit 6 (SET_NAV) for UV-K1 by default
|
|
||||||
|
|
||||||
#ifdef ENABLE_FEAT_F4HWN_RESET_VFO
|
#ifdef ENABLE_FEAT_F4HWN_RESET_VFO
|
||||||
Data8[7] = (1 & 0x01);
|
Data8[7] = (1 & 0x01);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
PY25Q16_WriteBuffer(0x00A000, Data8, sizeof(Data8), false);
|
PY25Q16_WriteBuffer(0x00A000, Data8, sizeof(Data8), false);
|
||||||
|
|
||||||
// cohérence RAM
|
// Keep RAM consistent with the persisted defaults.
|
||||||
|
gEeprom.SET_NAV = false;
|
||||||
|
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
|
||||||
gEeprom.MENU_LOCK = 0;
|
gEeprom.MENU_LOCK = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -901,11 +898,12 @@ void SETTINGS_SaveSettings(void)
|
|||||||
((gEeprom.SET_KEY & 0x0F) << 2) |
|
((gEeprom.SET_KEY & 0x0F) << 2) |
|
||||||
(gEeprom.SET_NAV ? 0x40 : 0);
|
(gEeprom.SET_NAV ? 0x40 : 0);
|
||||||
#else
|
#else
|
||||||
// A non-RescueOps preset owns KEY_LOCK only. Preserve Set RescueOps,
|
// A non-RescueOps preset owns KEY_LOCK and SET_NAV. Preserve the
|
||||||
// SetKEY, SetNav and reserved bits from a config created by another
|
// RescueOps-only MENU_LOCK and SET_KEY fields plus the reserved bit.
|
||||||
// preset while updating bit 0.
|
|
||||||
PY25Q16_ReadBuffer(0x00A004, &State[4], 1);
|
PY25Q16_ReadBuffer(0x00A004, &State[4], 1);
|
||||||
State[4] = (State[4] & 0xFEu) | (gEeprom.KEY_LOCK ? 0x01u : 0u);
|
State[4] = (State[4] & 0xBEu) |
|
||||||
|
(gEeprom.KEY_LOCK ? 0x01u : 0u) |
|
||||||
|
(gEeprom.SET_NAV ? 0x40u : 0u);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
|
|||||||
Reference in new issue
Block a user