2026-08-26 07:26:58 +08:00
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
extern const Touch_AreaTypeDef *pCurrentTouch_Area;
|
2026-08-31 06:10:13 +08:00
|
|
|
|
static int8_t s_mixer_focus = -1;
|
2026-08-26 07:26:58 +08:00
|
|
|
|
|
2026-09-04 14:43:32 +08:00
|
|
|
|
/* 0902-06 调音台:返回 + 标题;无底栏 */
|
2026-09-02 13:37:25 +08:00
|
|
|
|
const Touch_AreaTypeDef Touch_Mixer_Areas[] = {
|
2026-09-04 14:43:32 +08:00
|
|
|
|
{ 0, 44, 0, 40, 0, 0, GUI_CANCEL, NULL },
|
2026-08-26 07:26:58 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-09-02 13:37:25 +08:00
|
|
|
|
#define TOUCH_BTN_NUM (sizeof(Touch_Mixer_Areas)/sizeof(Touch_AreaTypeDef))
|
2026-08-26 07:26:58 +08:00
|
|
|
|
|
2026-09-05 21:30:59 +08:00
|
|
|
|
/* 左→右 伴奏|弦|麦|麦混响;Flash 标签按内容挂接(13伴奏/14弦/15麦/16麦混响) */
|
2026-09-02 13:37:25 +08:00
|
|
|
|
static const uint32_t s_fader_label[4][3] = { /* addr, w, h */
|
|
|
|
|
|
{ UI0902_TXT_MIXER_BAND_ADDR, UI0902_TXT_MIXER_BAND_W, UI0902_TXT_MIXER_BAND_H },
|
|
|
|
|
|
{ UI0902_TXT_MIXER_GUITAR_ADDR, UI0902_TXT_MIXER_GUITAR_W, UI0902_TXT_MIXER_GUITAR_H },
|
|
|
|
|
|
{ UI0902_TXT_MIXER_MIC_ADDR, UI0902_TXT_MIXER_MIC_W, UI0902_TXT_MIXER_MIC_H },
|
|
|
|
|
|
{ UI0902_TXT_MIXER_VOCALFX_ADDR, UI0902_TXT_MIXER_VOCALFX_W, UI0902_TXT_MIXER_VOCALFX_H },
|
|
|
|
|
|
};
|
2026-08-26 07:26:58 +08:00
|
|
|
|
|
|
|
|
|
|
// ============================================================
|
2026-09-03 11:58:08 +08:00
|
|
|
|
// ????????????????????? / ?????????????
|
2026-08-26 07:26:58 +08:00
|
|
|
|
// ============================================================
|
|
|
|
|
|
void DrawFader(Fader_t *f)
|
|
|
|
|
|
{
|
2026-09-02 13:37:25 +08:00
|
|
|
|
uint16_t cx = f->x + f->w / 2;
|
|
|
|
|
|
uint16_t slider_y;
|
|
|
|
|
|
LCD_FillByColor(cx - 20, f->y, cx + 20, f->y + f->h + 30, UI0902_BG_COLOR);
|
|
|
|
|
|
LCD_WR_PIC_FROM_FLASH(cx - 15, f->y, 31, 215, UI0902_MIXER_TRACK_ADDR);
|
|
|
|
|
|
LCD_WR_PIC_FROM_FLASH_Trans(cx - s_fader_label[f->id][1] / 2, f->y + f->h + 8,
|
|
|
|
|
|
(uint16_t)s_fader_label[f->id][1], (uint16_t)s_fader_label[f->id][2],
|
|
|
|
|
|
s_fader_label[f->id][0]);
|
|
|
|
|
|
slider_y = CalcSliderY(f);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
DrawFaderSlider(f, slider_y);
|
|
|
|
|
|
f->prev_slider_y = slider_y;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-05 21:56:14 +08:00
|
|
|
|
/* 四路推子写入 NVM 参数(仅 RAM;落盘由 save 调用方决定) */
|
|
|
|
|
|
static void SyncMixerFadersToNvm(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-26 07:26:58 +08:00
|
|
|
|
void DrawAllFaders(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
|
DrawFader(&faders[i]);
|
|
|
|
|
|
}
|
2026-09-05 21:56:14 +08:00
|
|
|
|
SyncMixerFadersToNvm();
|
2026-08-26 07:26:58 +08:00
|
|
|
|
drv_nvm_save_to_flash();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-09 16:33:03 +08:00
|
|
|
|
/* 0902-06:圆钮定位半径 = 色条半宽;填充略大以盖住柱端抗锯齿白边(夹紧不画出柱外) */
|
|
|
|
|
|
#define MIXER_KNOB_R 15
|
|
|
|
|
|
#define MIXER_KNOB_FILL_R 16
|
|
|
|
|
|
#define MIXER_TRACK_HALF_W 15
|
|
|
|
|
|
|
|
|
|
|
|
/* 与柱端半圆同形的实心圆钮:顶/底档位与色条圆角完美贴合,无虚线白边 */
|
|
|
|
|
|
static void DrawMixerKnob(uint16_t cx, uint16_t cy)
|
|
|
|
|
|
{
|
|
|
|
|
|
int16_t dy;
|
|
|
|
|
|
int32_t r2 = (int32_t)MIXER_KNOB_FILL_R * (int32_t)MIXER_KNOB_FILL_R;
|
|
|
|
|
|
for (dy = -(int16_t)MIXER_KNOB_R; dy <= (int16_t)MIXER_KNOB_R; dy++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int32_t xx = r2 - (int32_t)dy * (int32_t)dy;
|
|
|
|
|
|
int16_t dx = 0;
|
|
|
|
|
|
int16_t half;
|
|
|
|
|
|
if (xx < 0)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
while ((int32_t)(dx + 1) * (dx + 1) <= xx)
|
|
|
|
|
|
dx++;
|
|
|
|
|
|
half = dx;
|
|
|
|
|
|
if (half > (int16_t)MIXER_TRACK_HALF_W)
|
|
|
|
|
|
half = (int16_t)MIXER_TRACK_HALF_W;
|
|
|
|
|
|
LCD_FillByColor((uint16_t)(cx - half), (uint16_t)(cy + dy),
|
|
|
|
|
|
(uint16_t)(cx + half + 1), (uint16_t)(cy + dy + 1),
|
|
|
|
|
|
COLOR_GRAD_MID);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-09-03 08:15:34 +08:00
|
|
|
|
|
2026-08-26 07:26:58 +08:00
|
|
|
|
static void DrawFaderSlider(Fader_t *f, uint16_t slider_y)
|
|
|
|
|
|
{
|
2026-09-02 13:37:25 +08:00
|
|
|
|
uint16_t cx = f->x + f->w / 2;
|
|
|
|
|
|
uint16_t ly = f->y + f->h + 8;
|
2026-09-04 14:43:32 +08:00
|
|
|
|
uint16_t cy = (uint16_t)(slider_y + MIXER_KNOB_R);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
char buf[8];
|
2026-09-09 16:33:03 +08:00
|
|
|
|
DrawMixerKnob(cx, cy);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
sprintf(buf, "%d", f->val);
|
2026-09-09 16:33:03 +08:00
|
|
|
|
LCD_ShowString_AutoAlign((uint16_t)(cx - 10), (uint16_t)(cx + 10),
|
2026-09-04 14:43:32 +08:00
|
|
|
|
(uint16_t)(cy - 5),
|
|
|
|
|
|
(uint8_t*)buf, LCD_ALIGN_CENTER, WHITE, COLOR_GRAD_MID, 0, 11);
|
2026-09-02 13:37:25 +08:00
|
|
|
|
LCD_FillByColor(cx - 15, ly + 17, cx + 15, ly + 19, UI0902_BG_COLOR);
|
|
|
|
|
|
if (s_mixer_focus == (int8_t)f->id)
|
2026-09-04 14:43:32 +08:00
|
|
|
|
LCD_FillByColor(cx - 15, ly + 17, cx + 15, ly + 19, COLOR_GRAD_MID);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
}
|
2026-09-02 13:37:25 +08:00
|
|
|
|
|
2026-08-26 07:26:58 +08:00
|
|
|
|
// ============================================================
|
2026-09-03 11:58:08 +08:00
|
|
|
|
// ???????????????????????????????????? Flash ????
|
2026-08-26 07:26:58 +08:00
|
|
|
|
// ============================================================
|
|
|
|
|
|
static void UpdateFaderSlider(Fader_t *f)
|
|
|
|
|
|
{
|
2026-09-02 13:37:25 +08:00
|
|
|
|
uint16_t cx = f->x + f->w / 2;
|
2026-08-26 07:26:58 +08:00
|
|
|
|
uint16_t new_y = CalcSliderY(f);
|
|
|
|
|
|
if (f->prev_slider_y == new_y) return;
|
2026-09-02 13:37:25 +08:00
|
|
|
|
LCD_WR_PIC_FROM_FLASH(cx - 15, f->y, 31, 215, UI0902_MIXER_TRACK_ADDR);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
DrawFaderSlider(f, new_y);
|
|
|
|
|
|
f->prev_slider_y = new_y;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdateFaderByTouch(int idx, uint16_t y)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint8_t val_127;
|
|
|
|
|
|
uint8_t STR_val;
|
|
|
|
|
|
if (idx < 0 || idx > 3) return;
|
|
|
|
|
|
Fader_t *f = &faders[idx];
|
2026-08-31 06:10:13 +08:00
|
|
|
|
if (s_mixer_focus != (int8_t)idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
int8_t prev = s_mixer_focus;
|
|
|
|
|
|
s_mixer_focus = (int8_t)idx;
|
|
|
|
|
|
if (prev >= 0 && prev <= 3)
|
|
|
|
|
|
DrawFaderSlider(&faders[prev], faders[prev].prev_slider_y);
|
|
|
|
|
|
}
|
2026-08-26 07:26:58 +08:00
|
|
|
|
uint16_t y_min = f->y;
|
|
|
|
|
|
uint16_t y_max = f->y + f->h;
|
2026-09-02 13:37:25 +08:00
|
|
|
|
if (y < y_min + 8) {
|
2026-08-26 07:26:58 +08:00
|
|
|
|
f->val = 10;
|
|
|
|
|
|
}
|
2026-09-02 13:37:25 +08:00
|
|
|
|
else if (y > y_max - 8) {
|
2026-08-26 07:26:58 +08:00
|
|
|
|
f->val = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
int32_t val_raw = 10 - ((int32_t)(y - y_min) * 10) / (y_max - y_min);
|
|
|
|
|
|
if(val_raw < 0) val_raw = 0;
|
|
|
|
|
|
if(val_raw > 10) val_raw = 10;
|
|
|
|
|
|
f->val = val_raw;
|
|
|
|
|
|
}
|
|
|
|
|
|
UpdateFaderSlider(f);
|
2026-08-31 06:10:13 +08:00
|
|
|
|
DrawFaderSlider(f, f->prev_slider_y);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
switch(idx) {
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
val_127 = (f->val * 127) / 10;
|
|
|
|
|
|
SendVolumeChangeMidiEvent(1,val_127);
|
|
|
|
|
|
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);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
STR_val = (f->val * 127) / 10;
|
|
|
|
|
|
SendVolumeChangeMidiEvent(0,STR_val);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
AW816_Set_Volume(MIC_VOL_MAP[f->val]);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
AW816_Set_Reverb(f->val * 10);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2026-09-05 21:56:14 +08:00
|
|
|
|
/* 即时生效同时更新 NVM 镜像;返回/关机时落盘 */
|
|
|
|
|
|
SyncMixerFadersToNvm();
|
2026-08-26 07:26:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================
|
2026-09-09 16:33:03 +08:00
|
|
|
|
// 滑块顶边 Y:val0/10 时圆心落在色条底/顶半圆中心,两端对称贴合
|
2026-08-26 07:26:58 +08:00
|
|
|
|
// ============================================================
|
|
|
|
|
|
static uint16_t CalcSliderY(Fader_t *f)
|
|
|
|
|
|
{
|
2026-09-09 16:33:03 +08:00
|
|
|
|
uint16_t top_cy = (uint16_t)(f->y + MIXER_KNOB_R);
|
|
|
|
|
|
uint16_t bot_cy = (uint16_t)(f->y + f->h - 1 - MIXER_KNOB_R);
|
|
|
|
|
|
uint16_t cy = (uint16_t)(bot_cy - ((uint32_t)(bot_cy - top_cy) * f->val) / 10);
|
|
|
|
|
|
return (uint16_t)(cy - MIXER_KNOB_R);
|
2026-08-26 07:26:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CheckTouchFader(uint16_t x, uint16_t y)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
|
Fader_t *f = &faders[i];
|
|
|
|
|
|
if (x >= f->x - 10 && x <= f->x + f->w + 10 &&
|
|
|
|
|
|
y >= f->y && y <= f->y + f->h) {
|
|
|
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-03 08:15:34 +08:00
|
|
|
|
// ==================== ????? ====================
|
2026-08-26 07:26:58 +08:00
|
|
|
|
void UI_Mixer_Init(void)
|
|
|
|
|
|
{
|
2026-08-31 06:10:13 +08:00
|
|
|
|
s_mixer_focus = -1;
|
|
|
|
|
|
UI_ClearFocus();
|
2026-09-02 13:37:25 +08:00
|
|
|
|
LCD_FillByColor(0, 0, 240, 320, UI0902_BG_COLOR);
|
2026-09-04 14:43:32 +08:00
|
|
|
|
UI_DrawSubPageHeader((const uint8_t*)"\xB5\xF7\xD2\xF4\xCC\xA8");
|
2026-08-26 07:26:58 +08:00
|
|
|
|
DrawAllFaders();
|
2026-09-02 13:37:25 +08:00
|
|
|
|
pCurrentTouch_Area = Touch_Mixer_Areas;
|
2026-08-26 07:26:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-03 08:15:34 +08:00
|
|
|
|
// ==================== ???????? ====================
|
2026-08-26 07:26:58 +08:00
|
|
|
|
void UI_Mixer_Process(DisplayTaskMessage_Type msg)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint16_t tx,ty;
|
|
|
|
|
|
int fader_idx;
|
|
|
|
|
|
switch(msg.MessageType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case MSG_ID_TOUCH:
|
|
|
|
|
|
tx = msg.HiByte;
|
|
|
|
|
|
ty = msg.LoByte;
|
|
|
|
|
|
|
2026-09-03 08:15:34 +08:00
|
|
|
|
// 1. ?????????
|
2026-08-26 07:26:58 +08:00
|
|
|
|
fader_idx = CheckTouchFader(tx, ty);
|
|
|
|
|
|
if (fader_idx >= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateFaderByTouch(fader_idx, ty);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-04 14:43:32 +08:00
|
|
|
|
// 2. 返回 → 设置入口
|
2026-08-26 07:26:58 +08:00
|
|
|
|
for(uint8_t i=0; i<TOUCH_BTN_NUM; i++)
|
|
|
|
|
|
{
|
2026-09-02 13:37:25 +08:00
|
|
|
|
if( tx >= Touch_Mixer_Areas[i].x_min && tx <= Touch_Mixer_Areas[i].x_max &&
|
|
|
|
|
|
ty >= Touch_Mixer_Areas[i].y_min && ty <= Touch_Mixer_Areas[i].y_max )
|
|
|
|
|
|
{
|
2026-09-05 21:56:14 +08:00
|
|
|
|
if (Touch_Mixer_Areas[i].ID == GUI_CANCEL) {
|
|
|
|
|
|
SyncMixerFadersToNvm();
|
|
|
|
|
|
drv_nvm_save_to_flash();
|
2026-09-04 14:43:32 +08:00
|
|
|
|
MenuPage_SystemSetting_Proc();
|
2026-09-05 21:56:14 +08:00
|
|
|
|
}
|
2026-08-26 07:26:58 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ResetAutoPowerCount();
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case MSG_ID_EC_VOL:
|
2026-09-06 07:15:04 +08:00
|
|
|
|
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
|
|
|
|
|
ResetAutoPowerCount();
|
2026-08-26 07:26:58 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|