From 222448e1adc4fbc25e16f5a2c4b365eee218391e Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Thu, 30 Jul 2026 02:32:13 +0200 Subject: [PATCH] Avoid full-buffer channel attribute writes --- App/app/main.c | 2 +- App/app/menu.c | 6 ++--- App/settings.c | 68 ++++++++++++++++---------------------------------- App/settings.h | 2 +- 4 files changed, 26 insertions(+), 52 deletions(-) diff --git a/App/app/main.c b/App/app/main.c index a3a45362..84856c70 100644 --- a/App/app/main.c +++ b/App/app/main.c @@ -105,7 +105,7 @@ static void toggle_chan_scanlist(void) gTxVfo->SCANLIST_PARTICIPATION = scanlist; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true); + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); } gVfoConfigureMode = VFO_CONFIGURE; diff --git a/App/app/menu.c b/App/app/menu.c index 1155455e..9bede201 100644 --- a/App/app/menu.c +++ b/App/app/menu.c @@ -725,7 +725,7 @@ void MENU_AcceptSetting(void) case MENU_LIST_CH: gTxVfo->SCANLIST_PARTICIPATION = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; return; @@ -752,7 +752,7 @@ void MENU_AcceptSetting(void) case MENU_COMPAND: gTxVfo->Compander = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; // gRequestSaveChannel = 1; @@ -864,7 +864,7 @@ void MENU_AcceptSetting(void) #endif case MENU_DEL_CH: - SETTINGS_UpdateChannel(gSubMenuSelection, NULL, false, false, true); + SETTINGS_UpdateChannel(gSubMenuSelection, NULL, false); gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gFlagResetVfos = true; return; diff --git a/App/settings.c b/App/settings.c index 83fb8182..6cd43647 100644 --- a/App/settings.c +++ b/App/settings.c @@ -1210,7 +1210,7 @@ void SETTINGS_SaveChannel(uint16_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, PY25Q16_WriteBuffer(OffsetVFO, Buf, 0x10, false); - SETTINGS_UpdateChannel(Channel, pVFO, true, true, true); + SETTINGS_UpdateChannel(Channel, pVFO, true); if (IS_MR_CHANNEL(Channel)) { #ifndef ENABLE_KEEP_MEM_NAME @@ -1241,58 +1241,32 @@ void SETTINGS_SaveChannelName(uint16_t channel, const char * name) PY25Q16_WriteBuffer(0x004000 + offset, buf, 0x10, false); } -void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep, bool check, bool save) +void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep) { #ifdef ENABLE_NOAA - if (!IS_NOAA_CHANNEL(channel)) + if (IS_NOAA_CHANNEL(channel)) + return; #endif - { - ChannelAttributes_t state; - ChannelAttributes_t att = { - .band = 0x7, - .compander = 0, - .unused_1 = 0, - .unused_2 = 0, - .exclude = 0, - .scanlist = 0, - }; // default attributes - // 0x0D60 - PY25Q16_ReadBuffer(0x008000 + (channel * 2), &state, 2); + ChannelAttributes_t att = { + .band = 0x7, + .compander = 0, + .unused_1 = 0, + .unused_2 = 0, + .exclude = 0, + .scanlist = 0, + }; - if (keep) { - att.band = pVFO->Band; - att.compander = pVFO->Compander; - att.unused_1 = 0; - att.unused_2 = 0; - att.exclude = 0; - att.scanlist = pVFO->SCANLIST_PARTICIPATION; - if (check && state.__val == att.__val) - return; // no change in the attributes - } - - state.__val = att.__val; - -#ifndef ENABLE_FEAT_F4HWN - save = true; -#endif - if(save) - { - uint16_t buf[MR_CHANNELS_MAX + 24]; - PY25Q16_ReadBuffer(0x008000, buf, sizeof(buf)); - buf[channel] = state.__val; - PY25Q16_WriteBuffer(0x008000, buf, sizeof(buf), false); - } - - MR_SetChannelAttributes(channel, &att); - - if (IS_MR_CHANNEL(channel)) { // it's a memory channel - if (!keep) { - // clear/reset the channel name - SETTINGS_SaveChannelName(channel, ""); - } - } + if (keep) { + att.band = pVFO->Band; + att.compander = pVFO->Compander; + att.scanlist = pVFO->SCANLIST_PARTICIPATION; } + + MR_SetChannelAttributes(channel, &att); + + if (IS_MR_CHANNEL(channel) && !keep) + SETTINGS_SaveChannelName(channel, ""); } void SETTINGS_WriteBuildOptions(void) diff --git a/App/settings.h b/App/settings.h index 1f0153f9..f450a349 100644 --- a/App/settings.h +++ b/App/settings.h @@ -346,7 +346,7 @@ void SETTINGS_SaveSettings(void); 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, bool check, bool save); +void SETTINGS_UpdateChannel(uint16_t channel, const VFO_Info_t *pVFO, bool keep); void SETTINGS_WriteBuildOptions(void); #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE void SETTINGS_WriteCurrentState(void);