Sync master volume from EC pot on every page and at boot.
Always Send_volume in MainTask, re-apply after DSP settle, and sync vol_last so UI bar matches Dream gain. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
db03ac501c
commit
ee900b5657
|
|
@ -286,12 +286,8 @@ static void app_adc_hp_process(void)
|
|||
|
||||
/* ==================== ADC1 in6 ==================== */
|
||||
|
||||
static void app_adc_volume_process(void)
|
||||
static void app_adc_volume_map_level(uint16_t val)
|
||||
{
|
||||
uint16_t val = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
|
||||
if(abs((int16_t)vol_last - (int16_t)val) > 2)
|
||||
{
|
||||
vol_last = val;
|
||||
/* 5 格状态栏音量条:0=静音,5=最大 */
|
||||
if (val <= 5) level = 0;
|
||||
else if (val <= 35) level = 1;
|
||||
|
|
@ -299,7 +295,20 @@ static void app_adc_volume_process(void)
|
|||
else if (val <= 95) level = 3;
|
||||
else if (val <= 115) level = 4;
|
||||
else level = 5;
|
||||
}
|
||||
|
||||
void app_adc_sync_volume(uint16_t val)
|
||||
{
|
||||
vol_last = val;
|
||||
app_adc_volume_map_level(val);
|
||||
}
|
||||
|
||||
static void app_adc_volume_process(void)
|
||||
{
|
||||
uint16_t val = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
|
||||
if(abs((int16_t)vol_last - (int16_t)val) > 2)
|
||||
{
|
||||
app_adc_sync_volume(val);
|
||||
MainTask_Sendmsg(MSG_ID_EC_VOL, val, level, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,6 @@ extern uint8_t percentage;
|
|||
void app_adc_scan_all(void);
|
||||
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);
|
||||
#endif
|
||||
|
|
@ -46,21 +46,8 @@ void UI_ExpertMode_Process(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_EC_VOL:
|
||||
// //LCD_ShowString(200, 0, Num_To_String(msg.DataU16[1],buff,3), RED, WHITE, 16, 0);
|
||||
// uint8_t vol = msg.DataU16[1];
|
||||
//// uint8_t level;
|
||||
// if (vol <= 5) level = 0;
|
||||
// else if (vol <= 35) level = 1;
|
||||
// else if (vol <= 65) level = 2;
|
||||
// else if (vol <= 95) level = 3;
|
||||
// else if (vol <= 115) level = 4;
|
||||
// else level = 5;
|
||||
// Draw_Volume_Bar(5, 5, level, 1, WHITE, GRAY);
|
||||
// uint8_t mMasterSysExVolume[12] = { 0xF0, 0x41, 0x00, 0x42, 0x12, 0x40, 0x00, 0x04, 0x64, 0x00, 0x00,0xF7};
|
||||
// memset(mMasterSysExVolume+8,msg.DataU16[1],1);
|
||||
// SendMidiDataToDreamDSP(mMasterSysExVolume,12);
|
||||
//
|
||||
// ResetAutoPowerCount();
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
||||
ResetAutoPowerCount();
|
||||
break;
|
||||
|
||||
case MSG_ID_TOUCH_LONG_REPEAT:
|
||||
|
|
|
|||
|
|
@ -48,20 +48,8 @@ void UI_FreeMode_Process(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_EC_VOL:
|
||||
//LCD_ShowString(200, 0, Num_To_String(msg.DataU16[1],buff,3), RED, WHITE, 16, 0);
|
||||
// uint8_t vol = msg.DataU16[1];
|
||||
//// uint8_t level;
|
||||
// if (vol <= 5) level = 0;
|
||||
// else if (vol <= 35) level = 1;
|
||||
// else if (vol <= 65) level = 2;
|
||||
// else if (vol <= 95) level = 3;
|
||||
// else if (vol <= 115) level = 4;
|
||||
// else level = 5;
|
||||
// Draw_Volume_Bar(5, 5, level, 1, WHITE, GRAY);
|
||||
// uint8_t mMasterSysExVolume[12] = { 0xF0, 0x41, 0x00, 0x42, 0x12, 0x40, 0x00, 0x04, 0x64, 0x00, 0x00,0xF7};
|
||||
// memset(mMasterSysExVolume+8,msg.DataU16[1],1);
|
||||
// SendMidiDataToDreamDSP(mMasterSysExVolume,12);
|
||||
// ResetAutoPowerCount();
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
||||
ResetAutoPowerCount();
|
||||
break;
|
||||
|
||||
case MSG_ID_TOUCH_LONG_REPEAT:
|
||||
|
|
|
|||
26
UI/UI_Idle.c
26
UI/UI_Idle.c
|
|
@ -181,12 +181,7 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
rt_thread_mdelay(1000);
|
||||
LoadConfig();
|
||||
vol = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
|
||||
if (vol <= 5) level = 0;
|
||||
else if (vol <= 35) level = 1;
|
||||
else if (vol <= 65) level = 2;
|
||||
else if (vol <= 95) level = 3;
|
||||
else if (vol <= 115) level = 4;
|
||||
else level = 5;
|
||||
app_adc_sync_volume(vol);
|
||||
Send_volume(vol);
|
||||
|
||||
s_mode_select_focus = 0;
|
||||
|
|
@ -195,6 +190,12 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
TM1629D_UpdateDisplay(0);
|
||||
StartTouchTask();
|
||||
StartScanTask();
|
||||
/* Dream 上电稍后可能忽略首包 SysEx:再发一次与旋钮对齐 */
|
||||
rt_thread_mdelay(400);
|
||||
vol = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
|
||||
app_adc_sync_volume(vol);
|
||||
Send_volume(vol);
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, level, 1, WHITE, GRAY);
|
||||
break;
|
||||
|
||||
case MSG_ID_POWER_OFF:
|
||||
|
|
@ -317,18 +318,9 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
|
||||
case MSG_ID_EC_VOL:
|
||||
{
|
||||
//LCD_ShowString(200, 0, Num_To_String(msg.DataU16[1],buff,3), RED, WHITE, 16, 0);
|
||||
uint8_t vol = msg.ID;
|
||||
if (vol <= 5) level = 0;
|
||||
else if (vol <= 35) level = 1;
|
||||
else if (vol <= 65) level = 2;
|
||||
else if (vol <= 95) level = 3;
|
||||
else if (vol <= 115) level = 4;
|
||||
else level = 5;
|
||||
/* 主音量已在 MainTask 下发;此处只刷新条 */
|
||||
level = msg.HiByte;
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, level, 1, WHITE, GRAY);
|
||||
uint8_t mMasterSysExVolume[12] = { 0xF0, 0x41, 0x00, 0x42, 0x12, 0x40, 0x00, 0x04, 0x64, 0x00, 0x00,0xF7};
|
||||
memset(mMasterSysExVolume+8,msg.ID,1);
|
||||
SendMidiDataToDreamDSP(mMasterSysExVolume,12);
|
||||
ResetAutoPowerCount();
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -222,6 +222,8 @@ void UI_Mixer_Process(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_EC_VOL:
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
||||
ResetAutoPowerCount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ void UI_SongMode_Process(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_EC_VOL:
|
||||
Send_volume(msg.ID);
|
||||
/* 主音量已在 MainTask 下发;此处只刷新条 */
|
||||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -81,9 +81,13 @@ void TaskMainThread_entry(void* parameter)
|
|||
case MSG_ID_LOOP_LIGHT : Loop_Light_Handle(xEvent.ID); break;
|
||||
case MSG_ID_TM1629_KEY : break;
|
||||
case MSG_ID_TM1617_KEY : break;
|
||||
case MSG_ID_EC_VOL:
|
||||
/* 任意页面都先下发主音量,避免 UI 未处理导致屏显与实际脱节 */
|
||||
Send_volume((uint8_t)xEvent.ID);
|
||||
UITask_Sendmsg(xEvent.MessageType, xEvent.ID, xEvent.HiByte, xEvent.LoByte);
|
||||
break;
|
||||
case MSG_ID_TOUCH:
|
||||
case MSG_ID_CHARG:
|
||||
case MSG_ID_EC_VOL:
|
||||
case MSG_ID_TAP_SPEED:
|
||||
case MSG_ID_BP_TRANSPOSE:
|
||||
case MSG_ID_POWOFF_CHARG:
|
||||
|
|
|
|||
Loading…
Reference in New Issue