Fix factory restore to write NVM defaults and align settings icons.

Confirm page now persists factory BPM/vols/params via drv_nvm and matches 0902-07/08 icon and button text spacing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuquanjun 2026-09-05 06:33:04 +08:00
parent 2bca0c5673
commit 66ccfdccf6
6 changed files with 58 additions and 77 deletions

View File

@ -109,7 +109,7 @@ extern bool InModeFlag;
extern int16_t MIC_VOL_MAP[10];
extern int8_t delta;
extern STRING_MIDI USE_MIDI;
void LoadConfig()
void LoadConfig(void)
{
SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]);

View File

@ -38,12 +38,12 @@ void UI_Restore_Select_Init(void)
UI_ClearFocus();
LCD_FillByColor(0, 0, 240, 320, UI0902_BG_COLOR);
UI_DrawSubPageHeader((const uint8_t *)"\xBB\xD6\xB8\xB4\xB3\xF6\xB3\xA7\xC9\xE8\xD6\xC3");
/* 确认 */
/* 确 (稿面字间空格) */
UI_Restore_DrawButton(UI0902_RESTORE_BTN_Y0, UI0902_ROW_BG,
(const uint8_t *)"\xC8\xB7\xC8\xCF");
(const uint8_t *)"\xC8\xB7\x20\xC8\xCF");
/* 取 消(主色,稿面默认安全项) */
UI_Restore_DrawButton(UI0902_RESTORE_BTN_Y1, COLOR_GRAD_MID,
(const uint8_t *)"\xC8\xA1\xCF\xFB");
(const uint8_t *)"\xC8\xA1\x20\xCF\xFB");
pCurrentTouch_Area = Touch_Restore_Areas;
}

View File

@ -1041,69 +1041,46 @@ void RefreshSystemSetting(uint8_t last_data,const LEBEL_UI *UI,GUI_SWITCH * Grou
{
Draw_System_Item_List(UI,Group);
}
void RestoreSetting()
/* 将自动关机索引应用到运行时计数器 */
static void ApplyAutoCloseIndex(uint16_t idx)
{
AutoCloseFlag = true;
switch (idx)
{
case 0: AutoCloseTime = 5; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
case 1: AutoCloseTime = 15; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
case 2: AutoCloseTime = 30; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
case 3: AutoCloseTime = 0; AutoCloseFlag = false; break;
default:
AutoCloseTime = 15;
mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60);
break;
}
}
void RestoreSetting(void)
{
uint8_t new_trans;
NvmParam_Type *nvm = drv_nvm_param_ptr();
//last_value = mGuiData[GUI_TRANSPOSE].Current;
mGuiData[GUI_TRANSPOSE].Current = 0;
new_trans = mGuiData[GUI_TRANSPOSE].Current;
if(nvm->param.Transpose != mGuiData[GUI_TRANSPOSE].Current)
{
nvm->param.Transpose = mGuiData[GUI_TRANSPOSE].Current;
}
// delta = new_trans - last_value;
// USE_MIDI.Midi_1 += delta;
// USE_MIDI.Midi_2 += delta;
// USE_MIDI.Midi_3 += delta;
// USE_MIDI.Midi_4 += delta;
// USE_MIDI.Midi_5 += delta;
// USE_MIDI.Midi_6 += delta;
// mGuiData[GUI_SPEED].Current = 78;
// AutoBandTop1_ChangeBPM(mGuiData[GUI_SPEED].Current);
if(nvm->param.BPM != mGuiData[GUI_SPEED].Current)
{
nvm->param.BPM = mGuiData[GUI_SPEED].Current;
}
mGuiData[GUI_TIMBRE_SELECT].Current = 0;
SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]);
if(nvm->param.Timbre != mGuiData[GUI_TIMBRE_SELECT].Current)
{
nvm->param.Timbre = mGuiData[GUI_TIMBRE_SELECT].Current;
}
/* 写入出厂静态参数到 RAM并同步 GUI / 推子 */
drv_nvm_load_default_calibration_static_value(nvm, 1);
mGuiData[GUI_PLAY_SECTION].Current = 0;
//AutoBandTop1_SetRunVar(mGuiData[GUI_PLAY_SECTION].Current);
ParamGuiData[SONG_MODE_PARAM].Current = 0;
ParamGuiData[EXPRESS_MODE_PARAM].Current = 0;
ParamGuiData[ALL_MODE_PARAM].Current = 0;
faders[0].val = 7;
uint8_t val_127 = (faders[0].val * 127) / 10;
SendVolumeChangeMidiEvent(1,val_127);
SendVolumeChangeMidiEvent(2,val_127);
SendVolumeChangeMidiEvent(3,val_127);
SendVolumeChangeMidiEvent(4,val_127);
SendVolumeChangeMidiEvent(5,val_127);
SendVolumeChangeMidiEvent(6,val_127);
SendVolumeChangeMidiEvent(7,val_127);
SendVolumeChangeMidiEvent(8,val_127);
SendVolumeChangeMidiEvent(9,val_127);
SendVolumeChangeMidiEvent(10,val_127);
SendVolumeChangeMidiEvent(11,val_127);
SendVolumeChangeMidiEvent(12,val_127);
SendVolumeChangeMidiEvent(13,val_127);
SendVolumeChangeMidiEvent(14,val_127);
SendVolumeChangeMidiEvent(15,val_127);
faders[1].val = 7;
uint8_t Str_val_127 = (faders[1].val * 127) / 10;
SendVolumeChangeMidiEvent(0,Str_val_127);
faders[2].val = 7;
AW816_Set_Volume(MIC_VOL_MAP[faders[2].val]);
faders[3].val = 7;
AW816_Set_Reverb(faders[3].val * 10);
mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = 1;
mGuiData[GUI_BL_SW].Current = 1;
BSP_BlueToothPowerEnable (mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current);
mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current = 1;
BSP_BlueToothPowerEnable(1);
ApplyAutoCloseIndex(mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current);
/* 音色 / 音量 / 混响等到 DSP */
LoadConfig();
AutoBandTop1_ChangeBPM((int)mGuiData[GUI_SPEED].Current);
/* 持久化到内部 Flash */
drv_nvm_save_to_flash();
LOG_I("NVM", "factory restore applied and saved");
}
void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group)
{
@ -1137,7 +1114,8 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group)
switch(Group->Id)
{
case GUI_VERSION:
LCD_WR_PIC_FROM_FLASH_Trans(UI->x+12, UI->y + (UI->h - 18) / 2, 19, 18, UI0902_ICON_SYS_VERSION_ADDR);
/* 0902-07芯片图标系统设置图标-10 */
LCD_WR_PIC_FROM_FLASH_Trans(UI->x+12, UI->y + (UI->h - 19) / 2, 20, 19, UI0902_ICON_SYS_LANG_ADDR);
sprintf (Info, "%d.%d.%d", Version[0], Version[1],Version[2]);
/* 0902-07右侧凹槽版本框 */
LCD_FillRoundRect(UI->x + 148, UI->y + (UI->h - 22) / 2, 54, 22, 4, UI0902_BG_COLOR);
@ -1157,12 +1135,13 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group)
mGuiData[GUI_BL_SW].Current = Group->Current;
break;
case GUI_AUTOCLOSE:
LCD_WR_PIC_FROM_FLASH_Trans(UI->x+7, UI->y + (UI->h - 34) / 2, 33, 34, UI0902_ICON_SET_GEAR_ADDR);
/* 0902-07电源图标系统设置图标-12 / ABOUT */
LCD_WR_PIC_FROM_FLASH_Trans(UI->x+12, UI->y + (UI->h - 21) / 2, 18, 21, UI0902_ICON_SYS_ABOUT_ADDR);
switch(Group->Current)
{
case 0:AutoCloseTime = 5;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 1:AutoCloseTime = 15;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 2:AutoCloseTime = 30;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 0:AutoCloseTime = 5;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 1:AutoCloseTime = 15;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 2:AutoCloseTime = 30;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 3:AutoCloseTime = 0;AutoCloseFlag = 0;break; //never
}
LCD_DrawChevron_Left(val_x1 + 4, chev_cy, 5, 2, WHITE);

View File

@ -214,7 +214,7 @@ extern void label_Tab_Select_ui(const LEBEL_UI *UI, GUI_SWITCH *Group);
extern void Refresh_SectionSelect(uint16_t last_value, const LEBEL_UI *UI, GUI_SWITCH *Group);
extern void Refresh_TabSelect_ui(const LEBEL_UI *UI, GUI_SWITCH *Group);
extern void RefreshSystemSetting(uint8_t last_data,const LEBEL_UI *UI,GUI_SWITCH * Group);
extern void RestoreSetting();
extern void RestoreSetting(void);
extern void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group);
/* 子页顶栏:左返回 + 居中标题(调音台/系统设置) */
extern void UI_DrawSubPageHeader(const uint8_t *title_gbk);

View File

@ -12,7 +12,6 @@ extern void UI_DrawModeSelectScreen(void);
extern void UI_ReturnToModeSelect(void);
extern void IdleProcess(DisplayTaskMessage_Type xEvent);
extern void LoadConfig(void);
#endif

View File

@ -205,7 +205,8 @@ void drv_nvm_load_default_calibration_static_value(NvmParam_Type * pData, uint8
pData->param.StringVol = 7;
pData->param.MIcVol = 7;
pData->param.MicRev = 7;
pData->param.AutoCloseTime = 0;
/* 与系统设置默认项一致1 = 15分钟设计稿 0902-07 */
pData->param.AutoCloseTime = 1;
pData->param.Transpose = 0;
pData->param.Param1 = 0;
pData->param.Param2 = 0;
@ -219,7 +220,9 @@ void drv_nvm_load_default_calibration_static_value(NvmParam_Type * pData, uint8
faders[1].val = pData->param.StringVol;
faders[2].val = pData->param.MIcVol;
faders[3].val = pData->param.MicRev;
//mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current = pData->param.AutoCloseTime;
if (pData->param.AutoCloseTime > 3)
pData->param.AutoCloseTime = 1;
mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current = pData->param.AutoCloseTime;
ParamGuiData[SONG_MODE_PARAM].Current = pData->param.Param1;
ParamGuiData[EXPRESS_MODE_PARAM].Current = pData->param.Param2;
ParamGuiData[ALL_MODE_PARAM].Current = pData->param.Param3;