#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) { // ===================== TAB 閰嶇疆鍙傛暟 ===================== const uint16_t tab_w = 80; // TAB瀹藉�???? const uint16_t tab_h = 20; // TAB楂樺�???? const uint8_t tab_r = 5; // 鍦嗚�???? //const uint8_t space = 3; // 闂�?�窛 const uint16_t start_x = UI->x; // 璧峰X const uint16_t start_y = UI->y; // 璧峰Y const uint16_t text_y = UI->y + 2; // 鏂囧�????Y // ===================== 棰滆壊瀹氫�???? ===================== uint16_t color_sel_bg = UI_IsFocused(GUI_MODE_PARAM) ? COLOR_PRIMARY : COLOR_NORMAL_BG; uint16_t color_unsel_bg = COLOR_NORMAL_BG; uint16_t color_text = UI->Text_fc; // 鏂囧瓧棰滆�?? // 鏄剧ず锛氳嚜鍔ㄤ即濂忓紑 / �????? if(Group->Current == 1) { LCD_FillRoundRect(start_x, start_y, tab_w, tab_h, tab_r, color_unsel_bg); LCD_FillRoundRect(start_x+tab_w +10, start_y, tab_w, tab_h, tab_r, color_sel_bg); LCD_ShowChinese_AutoAlign( start_x, start_x + tab_w, text_y, (const uint8_t*)"\xBD\xDA\xD7\xE0\xC0\xE0\xD0\xCD", UI->Text_Align, color_text, color_unsel_bg, 0, 16 ); LCD_ShowChinese_AutoAlign( start_x + tab_w + 15, start_x + tab_w + tab_w, text_y, (const uint8_t *)"\xB1\xBE\xB5\xD8\xC7\xFA\xC4\xBF", UI->Text_Align, color_text, color_sel_bg, 0, 16 ); } else { LCD_FillRoundRect(start_x, start_y, tab_w, tab_h, tab_r, color_sel_bg); LCD_FillRoundRect(start_x+tab_w +10, start_y, tab_w, tab_h, tab_r, color_unsel_bg); LCD_ShowChinese_AutoAlign( start_x, start_x + tab_w, text_y, (const uint8_t*)"\xBD\xDA\xD7\xE0\xC0\xE0\xD0\xCD", //节�?�类�? UI->Text_Align, color_text, color_sel_bg, 0, 16 ); LCD_ShowChinese_AutoAlign( start_x + tab_w + 15, start_x + tab_w + tab_w, text_y, (const uint8_t *)"\xB1\xBE\xB5\xD8\xC7\xFA\xC4\xBF", //�?地曲�? UI->Text_Align, color_text, color_unsel_bg, 0, 16 ); } } void Show_home_UI(void) { UI_ClearFocus(); LCD_FillByColor(0,0,240,320,BLACK); 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:恢复扫描,整页�?间呈�? //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; uint8_t midi_note_buff[4] = {0,}; 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 2: { uint8_t midi = 0x3c; midi += mGuiData[GUI_TRANSPOSE].Current; AutoBandTop1_Note_On(midi,0x3c); // AutoBand 模块未加入工程 } break; case 1: { AutoBandTop1_SetPiecePlayMode(1,0,480); // AutoBand 模块未加入工程 AutoBandTop1_StartWithNotes(midi_note_buff,GetChordNotesByType(KEY_ID_1629,chord_type_index_map[KEY_ID_1629].type,midi_note_buff)); AutoBandTop1_SetLoopMode(0,1); } break; case 0: { AutoBandTop1_SetPiecePlayMode(1,0,480); // AutoBand 模块未加入工程 AutoBandTop1_StartWithNotes(midi_note_buff,GetChordNotesByType(KEY_ID_1629,chord_type_index_map[KEY_ID_1629].type,midi_note_buff)); } 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; switch(mGuiData[GUI_TAB_INDEX].Current) { case 0: case 1: if(mGuiData[GUI_AUTOBAND_SW].Current) { pCurData = &ParamGuiData[EXPRESS_MODE_PARAM]; } else { pCurData = &ParamGuiData[SONG_MODE_PARAM]; } break; case 2: pCurData = &ParamGuiData[ALL_MODE_PARAM]; break; } last_value = pCurData->Current; GUI_Item_AjustLoopValue(pCurData, FLAG); if (!UI_SetFocus(GUI_MODE_PARAM)) show_Param(&UI_Label[GUI_MODE_PARAM], pCurData); switch(mGuiData[GUI_TAB_INDEX].Current) { case 0: case 1: if(mGuiData[GUI_AUTOBAND_SW].Current) { AutoBandTop1_LoadPresetItemFromFlash(0); } else { AutoBandTop1_LoadPresetItemFromFlash(ParamGuiData[SONG_MODE_PARAM].Current); } break; case 2: AutoBandTop1_LoadPresetItemFromFlash(ParamGuiData[ALL_MODE_PARAM].Current); break; } switch(mGuiData[GUI_TAB_INDEX].Current) { case 0: nvm->param.Param1 = ParamGuiData[SONG_MODE_PARAM].Current; break; // 姝屾�???? case 1: nvm->param.Param2 = ParamGuiData[EXPRESS_MODE_PARAM].Current; break; // 涓撳�???? case 2: nvm->param.Param3 = ParamGuiData[ALL_MODE_PARAM].Current; break; // 涓囪�???? } } 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) { mGuiData[ID].Current = value; if(mGuiData[GUI_AUTOBAND_SW].Current) { ADDRESS = 0x0009EB5B; }else { ADDRESS = 0x00000000; } 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_TAB_INDEX) { if(mGuiData[ID].Current != value) { mGuiData[ID].Current = value; app_tm1629_all_on(LED_COLOR_G); switch(mGuiData[ID].Current) { case 0: if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current) break; StartFlag = 0; AutoBandTop1_Stop(); if(mGuiData[GUI_AUTOBAND_SW].Current) { ADDRESS = 0x0009EB5F; } else { ADDRESS = 0x00000000; } break; case 1: if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current) break; StartFlag = 0; AutoBandTop1_Stop(); if(mGuiData[GUI_AUTOBAND_SW].Current) { ADDRESS = 0x0009EB5F; } else { ADDRESS = 0x00000000; } break; case 2: if(mGuiData[GUI_TAB_LAST_INDEX].Current == mGuiData[ID].Current) break; StartFlag = 0; AutoBandTop1_Stop(); ADDRESS = 0x0009598F; 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; Show_home_UI(); pCurrentTouch_Area = Touch_Areas; } void UI_SongMode_Process(DisplayTaskMessage_Type msg) { uint8_t midi_note_buff[4] = {0,}; NvmParam_Type * nvm = drv_nvm_param_ptr(); switch(msg.MessageType) { case MSG_ID_TOUCH: for(uint8_t k=0; k= 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 ) { Touch_Action(pCurrentTouch_Area[k].Flag,pCurrentTouch_Area[k].ID,k,pCurrentTouch_Area[k].Value); ResetAutoPowerCount(); break; } } break; case MSG_ID_BATTERY_VALUE: Draw_Status_Battery_Icon(percentage); break; case MSG_ID_EC_VOL: Send_volume(msg.ID); Draw_Volume_Bar(5, 5, 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= 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; } } // �?有数值真正改变,才执行全套刷新、串口、伴奏更�? 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); } // 超时计数无�?�变不变都可以重�?,看你需�? //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; /* 使用正确�???? 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) { AutoBandTop1_SetPiecePlayMode(1,0,480); AutoBandTop1_StartWithNotes(midi_note_buff,GetChordNotesByType(KEY_ID_1629,chord_type_index_map[KEY_ID_1629].type,midi_note_buff)); AutoBandTop1_SetLoopMode(0,1); AutoBandTop1_StartWithNotes(midi_note_buff,GetChordNotesByType(KEY_ID_1629,chord_type_index_map[KEY_ID_1629].type,midi_note_buff)); } ResetAutoPowerCount(); } break; case MSG_ID_CHARG: Show_Battery_Icon(msg.ID); break; } //drv_nvm_save_to_flash(); }