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 int16_t MIC_VOL_MAP[10];
extern int8_t delta; extern int8_t delta;
extern STRING_MIDI USE_MIDI; extern STRING_MIDI USE_MIDI;
void LoadConfig() void LoadConfig(void)
{ {
SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]); SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]);

View File

@ -38,12 +38,12 @@ void UI_Restore_Select_Init(void)
UI_ClearFocus(); UI_ClearFocus();
LCD_FillByColor(0, 0, 240, 320, UI0902_BG_COLOR); 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_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, 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, 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; 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); Draw_System_Item_List(UI,Group);
} }
void RestoreSetting()
/* 将自动关机索引应用到运行时计数器 */
static void ApplyAutoCloseIndex(uint16_t idx)
{ {
uint8_t new_trans; AutoCloseFlag = true;
NvmParam_Type * nvm = drv_nvm_param_ptr(); switch (idx)
//last_value = mGuiData[GUI_TRANSPOSE].Current; {
mGuiData[GUI_TRANSPOSE].Current = 0; case 0: AutoCloseTime = 5; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
new_trans = mGuiData[GUI_TRANSPOSE].Current; case 1: AutoCloseTime = 15; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
if(nvm->param.Transpose != mGuiData[GUI_TRANSPOSE].Current) case 2: AutoCloseTime = 30; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60); break;
{ case 3: AutoCloseTime = 0; AutoCloseFlag = false; break;
nvm->param.Transpose = mGuiData[GUI_TRANSPOSE].Current; default:
} AutoCloseTime = 15;
// delta = new_trans - last_value; mAutoPowerOffCount = (uint16_t)(AutoCloseTime * 60);
// USE_MIDI.Midi_1 += delta; break;
// USE_MIDI.Midi_2 += delta; }
// USE_MIDI.Midi_3 += delta; }
// USE_MIDI.Midi_4 += delta;
// USE_MIDI.Midi_5 += delta; void RestoreSetting(void)
// USE_MIDI.Midi_6 += delta; {
// mGuiData[GUI_SPEED].Current = 78; NvmParam_Type *nvm = drv_nvm_param_ptr();
// AutoBandTop1_ChangeBPM(mGuiData[GUI_SPEED].Current);
if(nvm->param.BPM != mGuiData[GUI_SPEED].Current) /* 写入出厂静态参数到 RAM并同步 GUI / 推子 */
{ drv_nvm_load_default_calibration_static_value(nvm, 1);
nvm->param.BPM = mGuiData[GUI_SPEED].Current;
} mGuiData[GUI_PLAY_SECTION].Current = 0;
mGuiData[GUI_TIMBRE_SELECT].Current = 0;
SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]); mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = 1;
if(nvm->param.Timbre != mGuiData[GUI_TIMBRE_SELECT].Current) mGuiData[GUI_BL_SW].Current = 1;
{ BSP_BlueToothPowerEnable(1);
nvm->param.Timbre = mGuiData[GUI_TIMBRE_SELECT].Current;
} ApplyAutoCloseIndex(mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current);
mGuiData[GUI_PLAY_SECTION].Current = 0;
//AutoBandTop1_SetRunVar(mGuiData[GUI_PLAY_SECTION].Current); /* 音色 / 音量 / 混响等到 DSP */
ParamGuiData[SONG_MODE_PARAM].Current = 0; LoadConfig();
ParamGuiData[EXPRESS_MODE_PARAM].Current = 0; AutoBandTop1_ChangeBPM((int)mGuiData[GUI_SPEED].Current);
ParamGuiData[ALL_MODE_PARAM].Current = 0;
faders[0].val = 7; /* 持久化到内部 Flash */
uint8_t val_127 = (faders[0].val * 127) / 10; drv_nvm_save_to_flash();
SendVolumeChangeMidiEvent(1,val_127); LOG_I("NVM", "factory restore applied and saved");
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;
} }
void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group) 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) switch(Group->Id)
{ {
case GUI_VERSION: 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]); sprintf (Info, "%d.%d.%d", Version[0], Version[1],Version[2]);
/* 0902-07右侧凹槽版本框 */ /* 0902-07右侧凹槽版本框 */
LCD_FillRoundRect(UI->x + 148, UI->y + (UI->h - 22) / 2, 54, 22, 4, UI0902_BG_COLOR); 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; mGuiData[GUI_BL_SW].Current = Group->Current;
break; break;
case GUI_AUTOCLOSE: 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) switch(Group->Current)
{ {
case 0:AutoCloseTime = 5;mAutoPowerOffCount = AutoCloseTime * 60;break; case 0:AutoCloseTime = 5;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 1:AutoCloseTime = 15;mAutoPowerOffCount = AutoCloseTime * 60;break; case 1:AutoCloseTime = 15;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 2:AutoCloseTime = 30;mAutoPowerOffCount = AutoCloseTime * 60;break; case 2:AutoCloseTime = 30;AutoCloseFlag = 1;mAutoPowerOffCount = AutoCloseTime * 60;break;
case 3:AutoCloseTime = 0;AutoCloseFlag = 0;break; //never case 3:AutoCloseTime = 0;AutoCloseFlag = 0;break; //never
} }
LCD_DrawChevron_Left(val_x1 + 4, chev_cy, 5, 2, WHITE); 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_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 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 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 Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group);
/* 子页顶栏:左返回 + 居中标题(调音台/系统设置) */ /* 子页顶栏:左返回 + 居中标题(调音台/系统设置) */
extern void UI_DrawSubPageHeader(const uint8_t *title_gbk); 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 UI_ReturnToModeSelect(void);
extern void IdleProcess(DisplayTaskMessage_Type xEvent); extern void IdleProcess(DisplayTaskMessage_Type xEvent);
extern void LoadConfig(void);
#endif #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.StringVol = 7;
pData->param.MIcVol = 7; pData->param.MIcVol = 7;
pData->param.MicRev = 7; pData->param.MicRev = 7;
pData->param.AutoCloseTime = 0; /* 与系统设置默认项一致1 = 15分钟设计稿 0902-07 */
pData->param.AutoCloseTime = 1;
pData->param.Transpose = 0; pData->param.Transpose = 0;
pData->param.Param1 = 0; pData->param.Param1 = 0;
pData->param.Param2 = 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[1].val = pData->param.StringVol;
faders[2].val = pData->param.MIcVol; faders[2].val = pData->param.MIcVol;
faders[3].val = pData->param.MicRev; 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[SONG_MODE_PARAM].Current = pData->param.Param1;
ParamGuiData[EXPRESS_MODE_PARAM].Current = pData->param.Param2; ParamGuiData[EXPRESS_MODE_PARAM].Current = pData->param.Param2;
ParamGuiData[ALL_MODE_PARAM].Current = pData->param.Param3; ParamGuiData[ALL_MODE_PARAM].Current = pData->param.Param3;