Reapply master volume at boot/mode-entry/play-start and sync volume bar on settings hub.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuquanjun 2026-09-10 18:58:24 +08:00
parent 295a2a6fa3
commit 4aad989263
8 changed files with 44 additions and 7 deletions

View File

@ -303,6 +303,14 @@ void app_adc_sync_volume(uint16_t val)
app_adc_volume_map_level(val);
}
/* 取当前主音量(复用扫描任务维护的最近一次有效值)。
* ADC
* vol_last0xFFFF */
uint8_t app_adc_get_volume(void)
{
return (vol_last > 127) ? 0 : (uint8_t)vol_last;
}
static void app_adc_volume_process(void)
{
uint16_t val = ADC_ReadChannel(ADC_CHANNEL_1)>>5;

View File

@ -27,4 +27,6 @@ void app_adc_in1_scan_part(uint8_t channel);
bool app_adc_usb_is_plugged(void);
/* 开机/主动采样后同步 vol_last 与 level避免扫描任务误触发或跳变 */
void app_adc_sync_volume(uint16_t val);
/* 取当前主音量0~127供 MasterVolume_Reapply 等重发场景使用 */
uint8_t app_adc_get_volume(void);
#endif

View File

@ -460,6 +460,16 @@ void Send_volume(uint8_t vol)
SendMidiDataToDreamDSP(mMasterSysExVolume,12);
}
/* 重发当前主音量:开机补发 / 进模式主页 / 开始播放前调用。
* Dream SysEx
* "图标低音量、实际音量大" */
void MasterVolume_Reapply(void)
{
uint8_t vol = app_adc_get_volume();
app_adc_sync_volume(vol); /* 兜底刷新 level保证图标与下发值一致 */
Send_volume(vol);
}
void Accomp_UpdatePlayingChord(void)
{
uint8_t midi_note_buff[4] = {0,};
@ -494,6 +504,8 @@ void ADC_IN1_KEY_Handle(uint8_t key,bool on)
case 1: AutoBandTop1_Postamble(0); break;
case 2: AutoBandTop1_Postamble(1); break;
}
/* 前奏/尾奏起奏前补发主音量,保证与图标一致 */
MasterVolume_Reapply();
//AutoBandTop1_Start();
AutoBandTop1_SyncStart();
wk_delay_ms(50);
@ -761,6 +773,10 @@ void Pick_Handle()
note_cnt = GetChordNotesByType(chord_id, chord_type_index_map[chord_id].type, midi_note_buff);
Return_Light_buff(KEY_ID_1629);
/* 首次起奏前补发主音量:防开机 SysEx 丢失后"图标低、实际大" */
if (StartFlag == 0)
MasterVolume_Reapply();
switch(mGuiData[GUI_TAB_INDEX].Current)
{
case 3:

View File

@ -213,6 +213,7 @@ uint8_t GUI_Item_AjustValue(GUI_SWITCH * Group, int8_t Dir);
void GUI_Item_AjustLoopValue(GUI_SWITCH * Group, int8_t Dir);
void Send_volume(uint8_t vol);
void MasterVolume_Reapply(void);
void ADC_IN1_KEY_Handle(uint8_t key,bool on);
void TM1617_Handle(uint8_t key);

View File

@ -163,11 +163,11 @@ void IdleProcess(DisplayTaskMessage_Type msg)
TM1629D_UpdateDisplay(0);
StartTouchTask();
StartScanTask();
/* Dream 上电稍后可能忽略首包 SysEx再发主音量 + 调音台(保持关机前设置) */
/* Dream 上电稍后可能忽略首包 SysEx再发主音量 + 调音台(保持关机前设置)。
* ADC
* MasterVolume_Reapply */
rt_thread_mdelay(400);
vol = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
app_adc_sync_volume(vol);
Send_volume(vol);
MasterVolume_Reapply();
LoadConfig();
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, level, 1, WHITE, GRAY);
break;

View File

@ -243,6 +243,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value)
AutoBandTop1_SetRunVar(mGuiData[ID].Current);
}else
{
/* 触摸起奏前补发主音量,保证实际音量与图标一致 */
MasterVolume_Reapply();
AutoBandTop1_FillinWithIndex(value);
AutoBandTop1_Start();
}

View File

@ -124,6 +124,11 @@ void UI_SystemSet_Process(DisplayTaskMessage_Type msg)
label_top();
break;
case MSG_ID_EC_VOL:
/* 主音量已在 MainTask 下发;此处只刷新状态栏音量条,保证与旋钮一致 */
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
break;
default:
break;
}

View File

@ -54,6 +54,7 @@ void CallUI_Idle(void) {
void CallUI_SongMode(void) {
app_touch_suppress(500);
MasterVolume_Reapply(); /* 进模式补发主音量,防开机 SysEx 丢失后实际音量与图标不符 */
UI_SongMode_Init();
CurrUIProcress = UI_SongMode_Process;
app_log_set_ui_page("Song");
@ -62,6 +63,7 @@ void CallUI_SongMode(void) {
void CallUI_ExpertMode(void) {
app_touch_suppress(500);
MasterVolume_Reapply();
UI_ExpertMode_Init();
// CurrUIProcress = UI_ExpertMode_Process;
CurrUIProcress = UI_SongMode_Process;
@ -71,6 +73,7 @@ void CallUI_ExpertMode(void) {
void CallUI_FreeMode(void) {
app_touch_suppress(500);
MasterVolume_Reapply();
UI_FreeMode_Init();
// CurrUIProcress = UI_FreeMode_Process;
CurrUIProcress = UI_SongMode_Process;