453 lines
16 KiB
C
453 lines
16 KiB
C
#include "includes.h"
|
||
extern uint8_t CurrentMode;
|
||
|
||
|
||
static uint8_t transpose[5] = {0xF0, 0x51, 0x05, 0x0A, 0xF7};
|
||
static uint8_t Speed[6] = {0xF0, 0x51, 0x03, 0x00, 0x00, 0xF7};
|
||
|
||
void Draw_Tab_Mode_Menu(const LEBEL_UI *UI, GUI_SWITCH *Group)
|
||
{
|
||
/* 0819:TAB 字号 11;0902:紧凑圆角条,选中常亮蓝,文字垂直居中 */
|
||
const uint16_t tab_w = UI0902_TAB_W;
|
||
const uint16_t tab_h = UI0902_TAB_H;
|
||
const uint8_t tab_r = UI0902_RADIUS_TAB;
|
||
const uint8_t tab_font = UI0902_FONT_LABEL;
|
||
const uint16_t start_x = UI0902_MARGIN_X;
|
||
const uint16_t start_y = UI->y;
|
||
const uint16_t gap = UI0902_TAB_GAP;
|
||
const uint16_t text_y = start_y + (tab_h - tab_font) / 2;
|
||
const uint16_t inset = 3;
|
||
uint16_t color_sel_bg = COLOR_GRAD_MID;
|
||
uint16_t color_unsel_bg = UI0902_ROW_BG;
|
||
uint16_t color_text = UI->Text_fc;
|
||
uint16_t x1 = start_x;
|
||
uint16_t x2 = start_x + tab_w + gap;
|
||
|
||
if(Group->Current == 1)
|
||
{
|
||
LCD_FillRoundRect(x1, start_y, tab_w, tab_h, tab_r, color_unsel_bg);
|
||
LCD_FillRoundRect(x2, start_y, tab_w, tab_h, tab_r, color_sel_bg);
|
||
|
||
LCD_ShowChinese_AutoAlign(
|
||
x1 + inset, x1 + tab_w - inset, text_y,
|
||
(const uint8_t*)"\xBD\xDA\xD7\xE0\xC0\xE0\xD0\xCD",
|
||
LCD_ALIGN_CENTER, color_text, color_unsel_bg, 0, tab_font);
|
||
LCD_ShowChinese_AutoAlign(
|
||
x2 + inset, x2 + tab_w - inset, text_y,
|
||
(const uint8_t *)"\xB1\xBE\xB5\xD8\xC7\xFA\xC4\xBF",
|
||
LCD_ALIGN_CENTER, color_text, color_sel_bg, 0, tab_font);
|
||
}
|
||
else
|
||
{
|
||
LCD_FillRoundRect(x1, start_y, tab_w, tab_h, tab_r, color_sel_bg);
|
||
LCD_FillRoundRect(x2, start_y, tab_w, tab_h, tab_r, color_unsel_bg);
|
||
|
||
LCD_ShowChinese_AutoAlign(
|
||
x1 + inset, x1 + tab_w - inset, text_y,
|
||
(const uint8_t*)"\xBD\xDA\xD7\xE0\xC0\xE0\xD0\xCD",
|
||
LCD_ALIGN_CENTER, color_text, color_sel_bg, 0, tab_font);
|
||
LCD_ShowChinese_AutoAlign(
|
||
x2 + inset, x2 + tab_w - inset, text_y,
|
||
(const uint8_t *)"\xB1\xBE\xB5\xD8\xC7\xFA\xC4\xBF",
|
||
LCD_ALIGN_CENTER, color_text, color_unsel_bg, 0, tab_font);
|
||
}
|
||
}
|
||
|
||
void Show_home_UI(void)
|
||
{
|
||
UI_ClearFocus();
|
||
LCD_FillByColor(0,0,240,320,UI0902_BG_COLOR);
|
||
label_top();
|
||
label_Tranzpose_ui(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]);
|
||
label_Speed_ui(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]);
|
||
label_ModeSelece_ui(&UI_Label[GUI_MODE_PARAM],&mGuiData[GUI_MODE_PARAM]);
|
||
label_TimbreSelece_ui(&UI_Label[GUI_TIMBRE_SELECT], &mGuiData[GUI_TIMBRE_SELECT]);
|
||
label_PlaySection_ui(&UI_Label[GUI_PLAY_SECTION], &mGuiData[GUI_PLAY_SECTION]);
|
||
label_Tab_Select_ui(&UI_Label[GUI_PLAY_SECTION], &mGuiData[GUI_TAB_INDEX]);
|
||
//LCD_WR_REG(0x29); // Display ON:恢复扫描,整页<E695B4>?间呈<E997B4>?
|
||
//LCD_BLK_Set();
|
||
}
|
||
|
||
int8_t delta = 0;
|
||
void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value)
|
||
{
|
||
uint8_t last_value;
|
||
NvmParam_Type * nvm = drv_nvm_param_ptr();
|
||
if(FLAG == 1 || FLAG == -1)
|
||
{
|
||
switch(ID)
|
||
{
|
||
case GUI_TRANSPOSE:
|
||
{
|
||
last_value = mGuiData[ID].Current;
|
||
GUI_Item_AjustLoopValue(&mGuiData[ID], FLAG);
|
||
|
||
if (!UI_SetFocus(GUI_TRANSPOSE))
|
||
Refresh_Transpose(&UI_Label[ID], &mGuiData[ID]);
|
||
// label_Tranzpose_ui(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]);
|
||
if(nvm->param.Transpose != mGuiData[ID].Current)
|
||
{
|
||
nvm->param.Transpose = mGuiData[ID].Current;
|
||
}
|
||
transpose[3] = mGuiData[ID].Current;
|
||
USART4_SendData(transpose,sizeof(transpose));
|
||
|
||
|
||
int8_t new_trans = mGuiData[GUI_TRANSPOSE].Current;
|
||
delta = new_trans - last_value;
|
||
|
||
USE_MIDI.Midi_1 += delta;
|
||
USE_MIDI.Midi_2 += delta;
|
||
USE_MIDI.Midi_3 += delta;
|
||
USE_MIDI.Midi_4 += delta;
|
||
USE_MIDI.Midi_5 += delta;
|
||
USE_MIDI.Midi_6 += delta;
|
||
|
||
if(StartFlag)
|
||
{
|
||
switch(mGuiData[GUI_TAB_INDEX].Current)
|
||
{
|
||
case 0: /* 万能:和弦走向转调触发 */
|
||
{
|
||
uint8_t midi = 0x3c;
|
||
midi += mGuiData[GUI_TRANSPOSE].Current;
|
||
AutoBandTop1_Note_On(midi,0x3c);
|
||
}
|
||
break;
|
||
case 1: /* 专业 */
|
||
case 2: /* 普通 */
|
||
/* 音师:快转调只换和弦音,伴奏不重头 */
|
||
Accomp_UpdatePlayingChord();
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
break;
|
||
case GUI_SPEED:
|
||
{
|
||
last_value = mGuiData[ID].Current;
|
||
GUI_Item_AjustValue(&mGuiData[ID], FLAG);
|
||
|
||
if (!UI_SetFocus(GUI_SPEED))
|
||
Refresh_Transpose(&UI_Label[ID], &mGuiData[ID]);
|
||
|
||
Speed[3] = mGuiData[ID].Current / 128;
|
||
Speed[4] = mGuiData[ID].Current % 128;
|
||
USART4_SendData(Speed,sizeof(Speed));
|
||
|
||
if(nvm->param.BPM != mGuiData[ID].Current)
|
||
{
|
||
nvm->param.BPM = mGuiData[ID].Current;
|
||
}
|
||
AutoBandTop1_ChangeBPM(mGuiData[ID].Current); // AutoBand 模块未加入工程
|
||
|
||
}
|
||
break;
|
||
case GUI_MODE_PARAM:
|
||
{
|
||
GUI_SWITCH *pCurData =NULL;
|
||
uint8_t tab = (uint8_t)mGuiData[GUI_TAB_INDEX].Current;
|
||
|
||
if (tab == 0)
|
||
pCurData = &ParamGuiData[ALL_MODE_PARAM];
|
||
else if (mGuiData[GUI_AUTOBAND_SW].Current)
|
||
pCurData = &ParamGuiData[EXPRESS_MODE_PARAM];
|
||
else
|
||
pCurData = &ParamGuiData[SONG_MODE_PARAM];
|
||
|
||
last_value = pCurData->Current;
|
||
GUI_Item_AjustLoopValue(pCurData, FLAG);
|
||
if (!UI_SetFocus(GUI_MODE_PARAM))
|
||
show_Param(&UI_Label[GUI_MODE_PARAM], pCurData);
|
||
|
||
UI_ApplyToneAddress();
|
||
if (tab == 0)
|
||
AutoBandTop1_LoadPresetItemFromFlash(ParamGuiData[ALL_MODE_PARAM].Current);
|
||
else if (mGuiData[GUI_AUTOBAND_SW].Current)
|
||
AutoBandTop1_LoadPresetItemFromFlash(ParamGuiData[EXPRESS_MODE_PARAM].Current);
|
||
else
|
||
AutoBandTop1_LoadPresetItemFromFlash(ParamGuiData[SONG_MODE_PARAM].Current);
|
||
|
||
if (tab == 0)
|
||
nvm->param.Param3 = ParamGuiData[ALL_MODE_PARAM].Current;
|
||
else if (mGuiData[GUI_AUTOBAND_SW].Current)
|
||
nvm->param.Param2 = ParamGuiData[EXPRESS_MODE_PARAM].Current;
|
||
else
|
||
nvm->param.Param1 = ParamGuiData[SONG_MODE_PARAM].Current;
|
||
}
|
||
break;
|
||
case GUI_TIMBRE_SELECT:
|
||
last_value = mGuiData[ID].Current;
|
||
GUI_Item_AjustLoopValue(&mGuiData[ID], FLAG);
|
||
UI_SetFocus(GUI_TIMBRE_SELECT);
|
||
Refresh_StringTimbre(last_value, &UI_Label[ID], &mGuiData[ID]);
|
||
|
||
uint8_t ReturnTimbre[8] = {0xF0,0x60,0x03,0x05,0x00,0x00,0x00,0xF7};
|
||
ReturnTimbre[6] = mGuiData[GUI_TIMBRE_SELECT].Current;
|
||
USART4_SendData(ReturnTimbre,sizeof(ReturnTimbre));
|
||
|
||
if(nvm->param.Timbre != mGuiData[ID].Current)
|
||
{
|
||
nvm->param.Timbre = mGuiData[ID].Current;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
if(ID == GUI_AUTOBAND_SW)
|
||
{
|
||
/* 万能无节奏/本地 TAB,忽略该触控 */
|
||
if (mGuiData[GUI_TAB_INDEX].Current == 0)
|
||
return;
|
||
mGuiData[ID].Current = value;
|
||
UI_ReloadTonePreset();
|
||
if (!UI_SetFocus(GUI_MODE_PARAM))
|
||
label_ModeSelece_ui(&UI_Label[GUI_MODE_PARAM],&mGuiData[GUI_MODE_PARAM]);
|
||
return;
|
||
}
|
||
else if(ID==GUI_PLAY_SECTION)
|
||
{
|
||
if(mGuiData[ID].Current != value)
|
||
{
|
||
mGuiData[ID].Current = value;
|
||
AutoBandTop1_SetRunVar(mGuiData[ID].Current);
|
||
}else
|
||
{
|
||
AutoBandTop1_FillinWithIndex(value);
|
||
AutoBandTop1_Start();
|
||
}
|
||
if (!UI_SetFocus(GUI_PLAY_SECTION))
|
||
Refresh_SectionSelect(last_value, &UI_Label[ID], &mGuiData[ID]);
|
||
return;
|
||
}
|
||
else if(ID == GUI_NAV_BAR)
|
||
{
|
||
UI_NavBar_Action(value);
|
||
return;
|
||
}
|
||
else if(ID==GUI_TAB_INDEX)
|
||
{
|
||
if(mGuiData[ID].Current != value)
|
||
{
|
||
mGuiData[ID].Current = value;
|
||
|
||
app_tm1629_all_on(LED_COLOR_G);
|
||
switch(mGuiData[ID].Current)
|
||
{
|
||
case 0: /* 万能 → 3.bin / 本地→2.bin */
|
||
if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current)
|
||
break;
|
||
StartFlag = 0;
|
||
AutoBandTop1_Stop();
|
||
UI_ReloadTonePreset(); /* 切换模式必须换库,避免专业仍播万能数据 */
|
||
break;
|
||
|
||
case 1: /* 专业 → 1.bin / 本地→2.bin */
|
||
if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current)
|
||
break;
|
||
StartFlag = 0;
|
||
AutoBandTop1_Stop();
|
||
UI_ReloadTonePreset();
|
||
break;
|
||
|
||
case 2: /* 普通 → 1.bin */
|
||
if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current)
|
||
break;
|
||
StartFlag = 0;
|
||
AutoBandTop1_Stop();
|
||
UI_ReloadTonePreset();
|
||
break;
|
||
}
|
||
Refresh_TabSelect_ui(&UI_Label[ID], &mGuiData[ID]);
|
||
}
|
||
return;
|
||
}
|
||
else if(ID==GUI_BL_SW)
|
||
{
|
||
mGuiData[ID].Current = !mGuiData[ID].Current;
|
||
Show_BL_Icon(mGuiData[GUI_BL_SW].Current);
|
||
return;
|
||
}
|
||
}
|
||
|
||
|
||
void UI_SongMode_Init(void)
|
||
{
|
||
CurrentMode = 0;
|
||
//mGuiData[GUI_AUTOBAND_SW].Current = 0;
|
||
mGuiData[GUI_TAB_INDEX].Current = 0;
|
||
mGuiData[GUI_TAB_LAST_INDEX].Current = mGuiData[GUI_TAB_INDEX].Current;
|
||
UI_ReloadTonePreset(); /* TAB=万能 后再加载 3.bin */
|
||
Show_home_UI();
|
||
pCurrentTouch_Area = Touch_Areas;
|
||
|
||
}
|
||
|
||
void UI_SongMode_Process(DisplayTaskMessage_Type msg)
|
||
{
|
||
NvmParam_Type * nvm = drv_nvm_param_ptr();
|
||
|
||
switch(msg.MessageType)
|
||
{
|
||
case MSG_ID_TOUCH:
|
||
{
|
||
uint8_t hit = 0U;
|
||
for(uint8_t k=0; k<TOUCH_AREA_NUM; k++)
|
||
{
|
||
if( msg.HiByte >= pCurrentTouch_Area[k].x_min && msg.HiByte <= pCurrentTouch_Area[k].x_max &&
|
||
msg.LoByte >= pCurrentTouch_Area[k].y_min && msg.LoByte <= pCurrentTouch_Area[k].y_max )
|
||
{
|
||
hit = 1U;
|
||
LOG_I("UI", "song hit area=%u id=%u val=%u x=%u y=%u",
|
||
(unsigned)k, (unsigned)pCurrentTouch_Area[k].ID,
|
||
(unsigned)pCurrentTouch_Area[k].Value,
|
||
(unsigned)msg.HiByte, (unsigned)msg.LoByte);
|
||
Touch_Action(pCurrentTouch_Area[k].Flag,pCurrentTouch_Area[k].ID,k,pCurrentTouch_Area[k].Value);
|
||
ResetAutoPowerCount();
|
||
break;
|
||
}
|
||
}
|
||
if (!hit) {
|
||
LOG_I("UI", "song miss x=%u y=%u",
|
||
(unsigned)msg.HiByte, (unsigned)msg.LoByte);
|
||
}
|
||
}
|
||
break;
|
||
|
||
case MSG_ID_BATTERY_VALUE:
|
||
Draw_Status_Battery_Icon(percentage);
|
||
break;
|
||
|
||
case MSG_ID_EC_VOL:
|
||
/* 主音量已在 MainTask 下发;此处只刷新条 */
|
||
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
|
||
break;
|
||
|
||
case MSG_ID_TAP_SPEED:
|
||
//last_value = mGuiData[GUI_SPEED].Current;
|
||
mGuiData[GUI_SPEED].Current = msg.ID;
|
||
if (!UI_SetFocus(GUI_SPEED))
|
||
Refresh_Transpose(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]);
|
||
AutoBandTop1_ChangeBPM(mGuiData[GUI_SPEED].Current);
|
||
if(nvm->param.BPM != mGuiData[GUI_SPEED].Current)
|
||
{
|
||
nvm->param.BPM = mGuiData[GUI_SPEED].Current;
|
||
}
|
||
|
||
Speed[3] = mGuiData[GUI_SPEED].Current / 128;
|
||
Speed[4] = mGuiData[GUI_SPEED].Current % 128;
|
||
USART4_SendData(Speed,sizeof(Speed));
|
||
//
|
||
// ResetAutoPowerCount();
|
||
break;
|
||
case MSG_ID_TOUCH_LONG_REPEAT:
|
||
{
|
||
/* 长按顶栏(y<28)返回三键模式选择页 */
|
||
if (msg.LoByte < 28)
|
||
{
|
||
UI_ReturnToModeSelect();
|
||
break;
|
||
}
|
||
for(uint8_t k=0; k<TOUCH_AREA_NUM; k++)
|
||
{
|
||
if( msg.HiByte >= pCurrentTouch_Area[k].x_min && msg.HiByte <= pCurrentTouch_Area[k].x_max &&
|
||
msg.LoByte >= pCurrentTouch_Area[k].y_min && msg.LoByte <= pCurrentTouch_Area[k].y_max )
|
||
{
|
||
if(pCurrentTouch_Area[k].ID == GUI_SPEED)
|
||
{
|
||
int flag = pCurrentTouch_Area[k].Flag;
|
||
uint8_t last = mGuiData[GUI_SPEED].Current;
|
||
|
||
if(flag == 1)
|
||
{
|
||
if(mGuiData[GUI_SPEED].Current < 260)
|
||
{
|
||
mGuiData[GUI_SPEED].Current += 10;
|
||
if(mGuiData[GUI_SPEED].Current > 260)
|
||
mGuiData[GUI_SPEED].Current = 260;
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
else if(flag == -1)
|
||
{
|
||
if(mGuiData[GUI_SPEED].Current > 40)
|
||
{
|
||
mGuiData[GUI_SPEED].Current -= 10;
|
||
if(mGuiData[GUI_SPEED].Current < 40)
|
||
mGuiData[GUI_SPEED].Current = 40;
|
||
}else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
// <20>?有数值真正改变,才执行全套刷新、串口、伴奏更<E5A58F>?
|
||
if(last != mGuiData[GUI_SPEED].Current)
|
||
{
|
||
Refresh_Transpose(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]);
|
||
|
||
if(nvm->param.BPM != mGuiData[GUI_SPEED].Current)
|
||
{
|
||
nvm->param.BPM = mGuiData[GUI_SPEED].Current;
|
||
}
|
||
uint8_t Speed[6] = {0xF0, 0x51, 0x03, 0x00, 0x00, 0xF7};
|
||
Speed[3] = mGuiData[GUI_SPEED].Current / 128;
|
||
Speed[4] = mGuiData[GUI_SPEED].Current % 128;
|
||
USART4_SendData(Speed,sizeof(Speed));
|
||
AutoBandTop1_ChangeBPM(mGuiData[GUI_SPEED].Current);
|
||
}
|
||
// 超时计数无<E695B0>?<3F>变不变都可以重<E4BBA5>?,看你需<E4BDA0>?
|
||
//ResetAutoPowerCount();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case MSG_ID_BP_TRANSPOSE:
|
||
{
|
||
uint8_t lastvalue = mGuiData[GUI_TRANSPOSE].Current;
|
||
if(mGuiData[GUI_TRANSPOSE].Current != msg.ID)
|
||
{
|
||
mGuiData[GUI_TRANSPOSE].Current = msg.ID;
|
||
if (!UI_SetFocus(GUI_TRANSPOSE))
|
||
Refresh_Transpose(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]);
|
||
}
|
||
|
||
if(nvm->param.Transpose != mGuiData[GUI_TRANSPOSE].Current)
|
||
{
|
||
nvm->param.Transpose = mGuiData[GUI_TRANSPOSE].Current;
|
||
}
|
||
transpose[3] = mGuiData[GUI_TRANSPOSE].Current;
|
||
USART4_SendData(transpose,5);
|
||
|
||
int8_t new_trans = mGuiData[GUI_TRANSPOSE].Current;
|
||
delta = new_trans - lastvalue; /* 使用正确<E6ADA3>???? lastvalue */
|
||
|
||
USE_MIDI.Midi_1 += delta;
|
||
USE_MIDI.Midi_2 += delta;
|
||
USE_MIDI.Midi_3 += delta;
|
||
USE_MIDI.Midi_4 += delta;
|
||
USE_MIDI.Midi_5 += delta;
|
||
USE_MIDI.Midi_6 += delta;
|
||
if(/*KEY_ID_1629 != 0 && */StartFlag && KEY_ID_1629 != 22 && KEY_ID_1629 != 23)
|
||
{
|
||
/* 音师:快转调只换和弦音,伴奏不重头 */
|
||
Accomp_UpdatePlayingChord();
|
||
}
|
||
ResetAutoPowerCount();
|
||
}
|
||
break;
|
||
case MSG_ID_CHARG:
|
||
Show_Battery_Icon(msg.ID);
|
||
break;
|
||
}
|
||
//drv_nvm_save_to_flash();
|
||
}
|
||
|
||
|