Persist Bluetooth switch in NVM and restore it across power cycles.
Reuse the unused Language slot as BluetoothSW, sync top-bar icon from the saved switch, and keep factory restore defaulting Bluetooth to on. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f80c16dbef
commit
280aa1f752
|
|
@ -180,11 +180,11 @@ bool powon = false;
|
||||||
void System_PowerOn(void)
|
void System_PowerOn(void)
|
||||||
{
|
{
|
||||||
LOG_I("PWR", "power_on begin");
|
LOG_I("PWR", "power_on begin");
|
||||||
/* 控制电源硬件 */
|
/* 控制电源硬件;蓝牙按 NVM/系统设置开关恢复,勿强制常开 */
|
||||||
BSP_MainPowerEnable(1);
|
BSP_MainPowerEnable(1);
|
||||||
BSP_DreamCorePowerEnable(1);
|
BSP_DreamCorePowerEnable(1);
|
||||||
BSP_HT7178PowerEnable(1);
|
BSP_HT7178PowerEnable(1);
|
||||||
BSP_BlueToothPowerEnable(1);
|
BSP_BlueToothPowerEnable((uint8_t)(mGuiData[GUI_BL_SW].Current ? 1 : 0));
|
||||||
powon = true; /* 更新开机标志 */
|
powon = true; /* 更新开机标志 */
|
||||||
|
|
||||||
/* 先通知 UI 亮屏,避免外设初始化阻塞导致长时间黑屏 */
|
/* 先通知 UI 亮屏,避免外设初始化阻塞导致长时间黑屏 */
|
||||||
|
|
@ -212,13 +212,14 @@ static void PowerOff(void)
|
||||||
powon = false; /* 更新关机标志 */
|
powon = false; /* 更新关机标志 */
|
||||||
StopFullTask();
|
StopFullTask();
|
||||||
|
|
||||||
/* 关机前把当前调音台推子写入 NVM 镜像,保证再次开机保持音量 */
|
/* 关机前把当前调音台推子与蓝牙开关写入 NVM,保证再次开机保持 */
|
||||||
{
|
{
|
||||||
NvmParam_Type *nvm = drv_nvm_param_ptr();
|
NvmParam_Type *nvm = drv_nvm_param_ptr();
|
||||||
nvm->param.BandVol = faders[0].val;
|
nvm->param.BandVol = faders[0].val;
|
||||||
nvm->param.StringVol = faders[1].val;
|
nvm->param.StringVol = faders[1].val;
|
||||||
nvm->param.MIcVol = faders[2].val;
|
nvm->param.MIcVol = faders[2].val;
|
||||||
nvm->param.MicRev = faders[3].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();
|
nvm_ret = drv_nvm_save_to_flash();
|
||||||
LOG_I("PWR", "nvm_save=%u", (unsigned)nvm_ret);
|
LOG_I("PWR", "nvm_save=%u", (unsigned)nvm_ret);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ const Touch_AreaTypeDef Touch_SystemSetting_Areas[] =
|
||||||
|
|
||||||
GUI_SWITCH mGuiData_SystemSETTING[] = {
|
GUI_SWITCH mGuiData_SystemSETTING[] = {
|
||||||
{ 0, 0, 2, GUI_VERSION},
|
{ 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) */
|
/* 手册:15/30/45/60 分钟 + 不自动;默认 15 分钟(index 0) */
|
||||||
{ 0, 0, 4, GUI_AUTOCLOSE},
|
{ 0, 0, 4, GUI_AUTOCLOSE},
|
||||||
{ 0, 0, 1, GUI_RESTORE},
|
{ 0, 0, 1, GUI_RESTORE},
|
||||||
|
|
|
||||||
|
|
@ -310,24 +310,25 @@ void UI_GotoCurrentModePage(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 蓝牙图标:设计稿居中 */
|
/* 蓝牙图标:按系统开关显示;关则清空区域不画图标 */
|
||||||
void Show_BL_Icon(uint8_t value)
|
void Show_BL_Icon(uint8_t value)
|
||||||
{
|
{
|
||||||
static int8_t s_bt_pwr = -1;
|
static int8_t s_bt_pwr = -1;
|
||||||
|
uint8_t on = value ? 1u : 0u;
|
||||||
|
|
||||||
/* Fill 终点为开区间,传 W/H 本身;高度须停在分割线之上 */
|
/* Fill 终点为开区间,传 W/H 本身;高度须停在分割线之上 */
|
||||||
LCD_FillByColor(UI0902_BT_X, UI0902_BT_Y,
|
LCD_FillByColor(UI0902_BT_X, UI0902_BT_Y,
|
||||||
UI0902_BT_X + UI0902_BT_W,
|
UI0902_BT_X + UI0902_BT_W,
|
||||||
UI0902_BT_Y + UI0902_BT_H, UI0902_BG_COLOR);
|
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,
|
LCD_WR_PIC_Trans(UI0902_BT_X, UI0902_BT_Y, UI0902_BT_W, UI0902_BT_H,
|
||||||
gImage_UI0902_Bluetooth_11x17, BLACK);
|
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;
|
s_bt_pwr = (int8_t)on;
|
||||||
BSP_BlueToothPowerEnable(value);
|
BSP_BlueToothPowerEnable(on);
|
||||||
}
|
}
|
||||||
UI_DrawStatusSepLine();
|
UI_DrawStatusSepLine();
|
||||||
}
|
}
|
||||||
|
|
@ -1099,8 +1100,10 @@ void RestoreSetting(void)
|
||||||
|
|
||||||
mGuiData[GUI_PLAY_SECTION].Current = 0;
|
mGuiData[GUI_PLAY_SECTION].Current = 0;
|
||||||
|
|
||||||
|
/* 出厂默认蓝牙开(已由 static_value 写入 NVM/GUI) */
|
||||||
mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = 1;
|
mGuiData_SystemSETTING[GUI_BLUETOOTH_SW].Current = 1;
|
||||||
mGuiData[GUI_BL_SW].Current = 1;
|
mGuiData[GUI_BL_SW].Current = 1;
|
||||||
|
nvm->param.BluetoothSW = 1;
|
||||||
BSP_BlueToothPowerEnable(1);
|
BSP_BlueToothPowerEnable(1);
|
||||||
|
|
||||||
ApplyAutoCloseIndex(mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current);
|
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);
|
UI_DrawTriRight((uint16_t)(val_x2 - UI0902_TRI_R_W), chev_cy);
|
||||||
BSP_BlueToothPowerEnable (Group->Current);
|
BSP_BlueToothPowerEnable (Group->Current);
|
||||||
mGuiData[GUI_BL_SW].Current = Group->Current;
|
mGuiData[GUI_BL_SW].Current = Group->Current;
|
||||||
|
nvm->param.BluetoothSW = (uint8_t)(Group->Current ? 1 : 0);
|
||||||
|
drv_nvm_save_to_flash();
|
||||||
break;
|
break;
|
||||||
case GUI_AUTOCLOSE:
|
case GUI_AUTOCLOSE:
|
||||||
/* 0902-07:电源图标;档位按手册 15/30/45/60/不自动 */
|
/* 0902-07:电源图标;档位按手册 15/30/45/60/不自动 */
|
||||||
|
|
|
||||||
|
|
@ -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 分钟 */
|
/* 手册:0=15 / 1=30 / 2=45 / 3=60 / 4=不自动;默认 15 分钟 */
|
||||||
pData->param.AutoCloseTime = 0;
|
pData->param.AutoCloseTime = 0;
|
||||||
pData->param.Transpose = 0;
|
pData->param.Transpose = 0;
|
||||||
|
pData->param.BluetoothSW = 1; /* 出厂默认蓝牙开 */
|
||||||
pData->param.Param1 = 0;
|
pData->param.Param1 = 0;
|
||||||
pData->param.Param2 = 0;
|
pData->param.Param2 = 0;
|
||||||
pData->param.Param3 = 0;
|
pData->param.Param3 = 0;
|
||||||
//pData->param.Language = 0;
|
|
||||||
}
|
}
|
||||||
mGuiData[GUI_SPEED].Current = pData->param.BPM;
|
mGuiData[GUI_SPEED].Current = pData->param.BPM;
|
||||||
mGuiData[GUI_TIMBRE_SELECT].Current = pData->param.Timbre;
|
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)
|
if (pData->param.AutoCloseTime > 4)
|
||||||
pData->param.AutoCloseTime = 0;
|
pData->param.AutoCloseTime = 0;
|
||||||
mGuiData_SystemSETTING[GUI_AUTOCLOSE].Current = pData->param.AutoCloseTime;
|
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/不自动) */
|
/* 开机/出厂:同步自动关机运行时秒表(手册 15/30/45/60/不自动) */
|
||||||
AutoCloseFlag = true;
|
AutoCloseFlag = true;
|
||||||
switch (pData->param.AutoCloseTime)
|
switch (pData->param.AutoCloseTime)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ typedef struct {
|
||||||
uint8_t MicRev;
|
uint8_t MicRev;
|
||||||
uint8_t AutoCloseTime;
|
uint8_t AutoCloseTime;
|
||||||
uint8_t Transpose;
|
uint8_t Transpose;
|
||||||
uint8_t Language;
|
uint8_t BluetoothSW; /* 0=关 1=开;复用原 Language 槽位,布局不变 */
|
||||||
uint8_t Param1;
|
uint8_t Param1;
|
||||||
uint8_t Param2;
|
uint8_t Param2;
|
||||||
uint8_t Param3;
|
uint8_t Param3;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue