diff --git a/Global/Global.c b/Global/Global.c index 3d8047a..5ee5e50 100644 --- a/Global/Global.c +++ b/Global/Global.c @@ -180,11 +180,11 @@ bool powon = false; void System_PowerOn(void) { LOG_I("PWR", "power_on begin"); - /* 控制电源硬件 */ + /* 控制电源硬件;蓝牙按 NVM/系统设置开关恢复,勿强制常开 */ BSP_MainPowerEnable(1); BSP_DreamCorePowerEnable(1); BSP_HT7178PowerEnable(1); - BSP_BlueToothPowerEnable(1); + BSP_BlueToothPowerEnable((uint8_t)(mGuiData[GUI_BL_SW].Current ? 1 : 0)); powon = true; /* 更新开机标志 */ /* 先通知 UI 亮屏,避免外设初始化阻塞导致长时间黑屏 */ @@ -212,13 +212,14 @@ static void PowerOff(void) powon = false; /* 更新关机标志 */ StopFullTask(); - /* 关机前把当前调音台推子写入 NVM 镜像,保证再次开机保持音量 */ + /* 关机前把当前调音台推子与蓝牙开关写入 NVM,保证再次开机保持 */ { NvmParam_Type *nvm = drv_nvm_param_ptr(); nvm->param.BandVol = faders[0].val; nvm->param.StringVol = faders[1].val; nvm->param.MIcVol = faders[2].val; nvm->param.MicRev = faders[3].val; + nvm->param.BluetoothSW = (uint8_t)(mGuiData[GUI_BL_SW].Current ? 1 : 0); } nvm_ret = drv_nvm_save_to_flash(); LOG_I("PWR", "nvm_save=%u", (unsigned)nvm_ret); diff --git a/UI/UI_Setting.c b/UI/UI_Setting.c index 44105b9..3cb9be4 100644 --- a/UI/UI_Setting.c +++ b/UI/UI_Setting.c @@ -39,7 +39,7 @@ const Touch_AreaTypeDef Touch_SystemSetting_Areas[] = GUI_SWITCH mGuiData_SystemSETTING[] = { { 0, 0, 2, GUI_VERSION}, - { 0, 0, 1, GUI_BLUETOOTH_SW}, + { 1, 0, 1, GUI_BLUETOOTH_SW}, /* 默认开;开机由 NVM BluetoothSW 覆盖 */ /* 手册:15/30/45/60 分钟 + 不自动;默认 15 分钟(index 0) */ { 0, 0, 4, GUI_AUTOCLOSE}, { 0, 0, 1, GUI_RESTORE}, diff --git a/UI/UI_global.c b/UI/UI_global.c index 1ae19db..3a8f27e 100644 --- a/UI/UI_global.c +++ b/UI/UI_global.c @@ -310,24 +310,25 @@ void UI_GotoCurrentModePage(void) } } -/* 蓝牙图标:设计稿居中 */ +/* 蓝牙图标:按系统开关显示;关则清空区域不画图标 */ void Show_BL_Icon(uint8_t value) { static int8_t s_bt_pwr = -1; + uint8_t on = value ? 1u : 0u; /* Fill 终点为开区间,传 W/H 本身;高度须停在分割线之上 */ LCD_FillByColor(UI0902_BT_X, UI0902_BT_Y, UI0902_BT_X + UI0902_BT_W, UI0902_BT_Y + UI0902_BT_H, UI0902_BG_COLOR); - if (value) + if (on) { LCD_WR_PIC_Trans(UI0902_BT_X, UI0902_BT_Y, UI0902_BT_W, UI0902_BT_H, gImage_UI0902_Bluetooth_11x17, BLACK); } - if (s_bt_pwr != (int8_t)value) + if (s_bt_pwr != (int8_t)on) { - s_bt_pwr = (int8_t)value; - BSP_BlueToothPowerEnable(value); + s_bt_pwr = (int8_t)on; + BSP_BlueToothPowerEnable(on); } UI_DrawStatusSepLine(); } @@ -1099,8 +1100,10 @@ void RestoreSetting(void) mGuiData[GUI_PLAY_SECTION].Current = 0; + /* 出厂默认蓝牙开(已由 static_value 写入 NVM/GUI) */ mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = 1; mGuiData[GUI_BL_SW].Current = 1; + nvm->param.BluetoothSW = 1; BSP_BlueToothPowerEnable(1); ApplyAutoCloseIndex(mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current); @@ -1176,6 +1179,8 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group) UI_DrawTriRight((uint16_t)(val_x2 - UI0902_TRI_R_W), chev_cy); BSP_BlueToothPowerEnable (Group->Current); mGuiData[GUI_BL_SW].Current = Group->Current; + nvm->param.BluetoothSW = (uint8_t)(Group->Current ? 1 : 0); + drv_nvm_save_to_flash(); break; case GUI_AUTOCLOSE: /* 0902-07:电源图标;档位按手册 15/30/45/60/不自动 */ diff --git a/driver/drv_nvm.c b/driver/drv_nvm.c index a6d583b..2ac4df0 100644 --- a/driver/drv_nvm.c +++ b/driver/drv_nvm.c @@ -208,10 +208,10 @@ void drv_nvm_load_default_calibration_static_value(NvmParam_Type * pData, uint8 /* 手册:0=15 / 1=30 / 2=45 / 3=60 / 4=不自动;默认 15 分钟 */ pData->param.AutoCloseTime = 0; pData->param.Transpose = 0; + pData->param.BluetoothSW = 1; /* 出厂默认蓝牙开 */ pData->param.Param1 = 0; pData->param.Param2 = 0; pData->param.Param3 = 0; - //pData->param.Language = 0; } mGuiData[GUI_SPEED].Current = pData->param.BPM; mGuiData[GUI_TIMBRE_SELECT].Current = pData->param.Timbre; @@ -223,6 +223,11 @@ void drv_nvm_load_default_calibration_static_value(NvmParam_Type * pData, uint8 if (pData->param.AutoCloseTime > 4) pData->param.AutoCloseTime = 0; mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current = pData->param.AutoCloseTime; + /* 旧固件 Language 槽可能为 0xFF;非法值按默认开处理 */ + if (pData->param.BluetoothSW > 1) + pData->param.BluetoothSW = 1; + mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = pData->param.BluetoothSW; + mGuiData[GUI_BL_SW].Current = pData->param.BluetoothSW; /* 开机/出厂:同步自动关机运行时秒表(手册 15/30/45/60/不自动) */ AutoCloseFlag = true; switch (pData->param.AutoCloseTime) diff --git a/driver/drv_nvm.h b/driver/drv_nvm.h index 17d29ff..1fd9bc4 100644 --- a/driver/drv_nvm.h +++ b/driver/drv_nvm.h @@ -19,7 +19,7 @@ typedef struct { uint8_t MicRev; uint8_t AutoCloseTime; uint8_t Transpose; - uint8_t Language; + uint8_t BluetoothSW; /* 0=关 1=开;复用原 Language 槽位,布局不变 */ uint8_t Param1; uint8_t Param2; uint8_t Param3;