From 27cf30cbe42916db11fd946104ce311740cbb1f2 Mon Sep 17 00:00:00 2001 From: yuquanjun Date: Mon, 31 Aug 2026 06:10:13 +0800 Subject: [PATCH] Align UI focus colors with 0819 spec and fix J-Link flash script usage. Only the focused control uses the blue gradient; unfocused widgets use the dark normal background. Drop invalid Commander commands from IAR jlink_script_file to stop V5.10m parse popups. Co-authored-by: Cursor --- .../device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h | 21 +- Global/Global.c | 4 +- UI/UI_FreeMode.c | 6 +- UI/UI_Idle.c | 104 ++--- UI/UI_Mixer.c | 16 +- UI/UI_Setting.c | 7 +- UI/UI_Setting.h | 1 + UI/UI_SongMode.c | 32 +- UI/UI_SystemSet.c | 32 +- UI/UI_SystemSet.h | 1 + UI/UI_global.c | 423 ++++++++---------- UI/UI_global.h | 6 + UI/UI_idle.h | 1 + device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c | 148 ++---- device/LCD_ILI9341/Drv_ILI9341_Lcd_App.h | 2 + device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h | 21 +- tools/JLinkSettings.ini | 6 +- tools/flash_app.bat | 25 ++ tools/jlink_connect.jlink | 7 + tools/jlink_flash_app.jlink | 9 + tools/jlink_hidedevid.jlink | 3 +- tools/jlink_hidedevid.jlinkscript | 10 + tools/reset_run.jlink | 7 + 23 files changed, 403 insertions(+), 489 deletions(-) create mode 100644 tools/flash_app.bat create mode 100644 tools/jlink_connect.jlink create mode 100644 tools/jlink_flash_app.jlink create mode 100644 tools/jlink_hidedevid.jlinkscript create mode 100644 tools/reset_run.jlink diff --git a/AT32F403ARCT7_BOOT/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h b/AT32F403ARCT7_BOOT/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h index cdcfe2d..98e7a0e 100644 --- a/AT32F403ARCT7_BOOT/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h +++ b/AT32F403ARCT7_BOOT/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h @@ -58,15 +58,15 @@ #define BLACK 0x0000 #define BLUE 0x001F #define COLOR_PRIMARY 0x1B9F // #1D73FF MiSans UI 主色 -#define COLOR_GRAD_START 0x039D // #003AEE -#define COLOR_GRAD_MID 0x2A5A // #354FD6 -#define COLOR_GRAD_END 0x4B1F // #5561F8 -#define COLOR_BG_START 0x0849 // #0E1537 -#define COLOR_BG_END 0x3189 // #2F3647 -#define COLOR_MIXER_RED 0xFB2D // #F85E4B -#define COLOR_MIXER_ORANGE 0xFD26 // #F59C2C -#define COLOR_MIXER_YELLOW 0xFF6E // #F3D939 -#define COLOR_MIXER_GREEN 0x071F // #13E17F +#define COLOR_GRAD_START 0x01D5 // #003AAE 规范渐变起始(深蓝) +#define COLOR_GRAD_MID 0x029A // #034FD6 规范渐变中间 +#define COLOR_GRAD_END 0x431E // #4161F8 规范渐变结束(中蓝) +#define COLOR_BG_START 0x10A6 // #0E1535 屏幕背景渐变顶 +#define COLOR_BG_END 0x31A9 // #2F3647 屏幕背景渐变底 +#define COLOR_MIXER_RED 0xF2E9 // #F85E4B 弦音色槽位红 +#define COLOR_MIXER_ORANGE 0xF4C5 // #F59C2C 伴奏槽位橙 +#define COLOR_MIXER_YELLOW 0xF6C7 // #F3D939 导奏槽位黄 +#define COLOR_MIXER_GREEN 0x170F // #13E17F 鼓音槽位绿 #define BRED 0XF81F #define GRED 0XFFE0 #define GBLUE 0X07FF @@ -87,7 +87,8 @@ #define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色) -#define DARKLGRAY 0x5AEB/*0x2988*//*0x1926*//*0x252E*//*0X2B12*/ +#define DARKLGRAY 0x2968 // #292C42 控件未选中(暗蓝灰,对应规范非焦点背景) +#define COLOR_NORMAL_BG DARKLGRAY /* 控件普通状态背景 */ #define BUTTON_COLOR /*0x5AEB*/BLACK #define START_COLOR COLOR_GRAD_START diff --git a/Global/Global.c b/Global/Global.c index f116c9f..1f7f0fd 100644 --- a/Global/Global.c +++ b/Global/Global.c @@ -33,8 +33,8 @@ GUI_SWITCH ParamGuiData[] = const LEBEL_UI UI_Label[] = { - {5, 115, 30, 60, (const uint8_t*)"\xD2\xC6\xB5\xF7", LCD_ALIGN_CENTER, WHITE,BLACK,11, LCD_ALIGN_CENTER,WHITE,BLACK,11, GUI_TRANSPOSE}, - {125,110, 30, 60, (const uint8_t*)"\xCB\xD9\xB6\xC8", LCD_ALIGN_CENTER, WHITE,BLACK,11, LCD_ALIGN_CENTER,WHITE,BLACK,11, GUI_SPEED}, + {5, 115, 30, 60, (const uint8_t*)"\xD2\xC6\xB5\xF7", LCD_ALIGN_CENTER, WHITE,BLACK,11, LCD_ALIGN_CENTER,WHITE,BLACK,16, GUI_TRANSPOSE}, + {125,110, 30, 60, (const uint8_t*)"\xCB\xD9\xB6\xC8", LCD_ALIGN_CENTER, WHITE,BLACK,11, LCD_ALIGN_CENTER,WHITE,BLACK,16, GUI_SPEED}, {5, 230, 95, 55, (const uint8_t*)"\xB8\xE8\xC7\xFA\xD1\xA1\xD2\xE9", LCD_ALIGN_LEFT,WHITE,BLACK,11,LCD_ALIGN_CENTER,WHITE,BLACK,13,GUI_MODE_PARAM}, {5, 230, 155,55, (const uint8_t*)"\xCF\xD2\xD2\xF4\xC9\xAB\xD1\xA1\xD2\xE9",LCD_ALIGN_LEFT,WHITE,BLACK,11,LCD_ALIGN_CENTER,WHITE,BLACK,13,GUI_TIMBRE_SELECT}, {5, 230, 210,55, (const uint8_t*)"\xD1\xDD\xD7\xE0\xB6\xCE\xC2\xE4",LCD_ALIGN_LEFT,WHITE,BLACK,11,LCD_ALIGN_CENTER,WHITE,BLACK,13,GUI_PLAY_SECTION}, diff --git a/UI/UI_FreeMode.c b/UI/UI_FreeMode.c index faffa49..6a1491e 100644 --- a/UI/UI_FreeMode.c +++ b/UI/UI_FreeMode.c @@ -41,7 +41,8 @@ void UI_FreeMode_Process(DisplayTaskMessage_Type msg) { //uint8_t last_value = mGuiData[GUI_SPEED].Current; mGuiData[GUI_SPEED].Current = msg.ID; - Refresh_Transpose(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]); + if (!UI_SetFocus(GUI_SPEED)) + Refresh_Transpose(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]); uint8_t Speed[6] = {0xF0, 0x51, 0x03, 0x00, 0x00, 0xF7}; Speed[3] = mGuiData[GUI_SPEED].Current / 128; Speed[4] = mGuiData[GUI_SPEED].Current % 128; @@ -136,7 +137,8 @@ void UI_FreeMode_Process(DisplayTaskMessage_Type msg) if(mGuiData[GUI_TRANSPOSE].Current != msg.ID) { mGuiData[GUI_TRANSPOSE].Current = msg.ID; - Refresh_Transpose(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]); + if (!UI_SetFocus(GUI_TRANSPOSE)) + Refresh_Transpose(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]); } if(nvm->param.Transpose != mGuiData[GUI_TRANSPOSE].Current) { diff --git a/UI/UI_Idle.c b/UI/UI_Idle.c index 45b08d8..aa686fc 100644 --- a/UI/UI_Idle.c +++ b/UI/UI_Idle.c @@ -24,76 +24,63 @@ void RGB_Y_TO_G() #define UI_MODE_TEXT_COLOR 0xFFFF #define UI_MODE_FONT_SIZE 16 -void UI_DrawModeSelectScreen(void) +/* 模式选择页焦点:0=万能 1=普通 2=专业,默认选中万能(与规范一致) */ +static uint8_t s_mode_select_focus = 0; + +static void UI_DrawModeSelectButton(uint16_t y, const uint8_t *text, + const uint8_t *icon, uint8_t focused) { - - // 1. ���䱳������ҡ���ɫ????? -// LCD_FillGradient(0, 0, 240, 320, 0x5AEB, 0x0000); - LCD_FillByColor(0, 0, 240, 320, BLACK); - - label_top(); - - // 2. ��ť������???=220 ???????=87 Բ???=10 ���ɫ��??????? const uint16_t btn_w = 220; const uint16_t btn_h = 87; const uint16_t btn_r = 10; - const uint16_t btn_x = (240 - btn_w) / 2; // 10 - //const uint16_t btn_color = /*DARKLGRAY*//*0x2988*/BLACK; // ���??????? + const uint16_t btn_x = (240 - btn_w) / 2; + uint16_t text_y = y + (btn_h - UI_MODE_FONT_SIZE) / 2; + uint16_t text_x; - // 3. ���� 3 ???????��ť��Y=40����??????? 5�����һ???????��ť�ײ���� 9px - // ��ť Y: 40, 132, 224 + if (focused) + { + LCD_FillRoundRectGradient(btn_x, y, btn_w, btn_h, btn_r, + START_COLOR, END_COLOR); + } + else + { + LCD_FillRoundRect(btn_x, y, btn_w, btn_h, btn_r, COLOR_NORMAL_BG); + } - //LCD_DrawLine(0, 30, 240, 30, btn_color); - - - - // ����ģʽ��Y=40??????? - //LCD_FillRoundRect(btn_x, 40, btn_w, btn_h, btn_r, btn_color); -// LCD_FillRoundRectGradient(btn_x, 40, btn_w, btn_h, btn_r, 0XC618,0x5AEB); - LCD_FillRoundRectGradient(btn_x, 40, btn_w, btn_h, btn_r, START_COLOR, END_COLOR); - - - - - uint16_t x1 = LCD_ShowChinese_AutoAlign_Gradient( + /* 叠加绘制文字,避免在渐变底上打出实心色块 */ + text_x = LCD_ShowChinese_AutoAlign( btn_x, btn_x + btn_w, - 40 + (btn_h - UI_MODE_FONT_SIZE) / 2, - (uint8_t*)"\xCD\xF2\xC4\xDC\xC4\xA3\xCA\xBD", //����ģʽ + text_y, + text, LCD_ALIGN_CENTER, UI_MODE_TEXT_COLOR, - START_COLOR, END_COLOR, - UI_MODE_FONT_SIZE - ); - LCD_WR_PIC(x1-45, 40 + (btn_h - UI_MODE_FONT_SIZE) / 2-5,40,30,gImage_FreeMode_Icon_40_30); - - // ר???ģʽ��Y=132??????? -// LCD_FillRoundRect(btn_x, 132, btn_w, btn_h, btn_r, btn_color); - LCD_FillRoundRectGradient(btn_x, 132, btn_w, btn_h, btn_r, START_COLOR, END_COLOR); - uint16_t x2 = LCD_ShowChinese_AutoAlign_Gradient( - btn_x, btn_x + btn_w, - 132 + (btn_h - UI_MODE_FONT_SIZE) / 2, - (uint8_t *)"\xC6\xD5\xCD\xA8\xC4\xA3\xCA\xBD", // ��ͨģʽ - LCD_ALIGN_CENTER, - UI_MODE_TEXT_COLOR, - START_COLOR, END_COLOR, - UI_MODE_FONT_SIZE + BLACK, + 1, + UI_MODE_FONT_SIZE ); - LCD_WR_PIC(x2-45, 132 + (btn_h - UI_MODE_FONT_SIZE) / 2-5,40,30,gImage_NormalMode_Icon_40_30); + LCD_WR_PIC_Trans(text_x - 45, text_y - 5, 40, 30, icon, BLACK); +} - // ����ģʽ��Y=224??????? -// LCD_FillRoundRect(btn_x, 224, btn_w, btn_h, btn_r, btn_color); - LCD_FillRoundRectGradient(btn_x, 224, btn_w, btn_h, btn_r, START_COLOR, END_COLOR); - uint16_t x3 = LCD_ShowChinese_AutoAlign_Gradient( - btn_x, btn_x + btn_w, - 224 + (btn_h - UI_MODE_FONT_SIZE) / 2, - (const uint8_t *)"\xD7\xA8\xD2\xB5\xC4\xA3\xCA\xBD", // רҵģʽ - LCD_ALIGN_CENTER, - UI_MODE_TEXT_COLOR, - START_COLOR, END_COLOR, - UI_MODE_FONT_SIZE - ); +void UI_DrawModeSelectScreen(void) +{ + UI_ClearFocus(); + s_mode_select_focus = 0; - LCD_WR_PIC(x3-45, 224 + (btn_h - UI_MODE_FONT_SIZE) / 2-5,40,30,gImage_ExpressMode_Icon_40_30); + LCD_FillByColor(0, 0, 240, 320, BLACK); + label_top(); + + UI_DrawModeSelectButton(40, + (const uint8_t *)"\xCD\xF2\xC4\xDC\xC4\xA3\xCA\xBD", + gImage_FreeMode_Icon_40_30, + s_mode_select_focus == 0); + UI_DrawModeSelectButton(132, + (const uint8_t *)"\xC6\xD5\xCD\xA8\xC4\xA3\xCA\xBD", + gImage_NormalMode_Icon_40_30, + s_mode_select_focus == 1); + UI_DrawModeSelectButton(224, + (const uint8_t *)"\xD7\xA8\xD2\xB5\xC4\xA3\xCA\xBD", + gImage_ExpressMode_Icon_40_30, + s_mode_select_focus == 2); } const Touch_AreaTypeDef Touch_ModeSelect_Areas[] = { @@ -144,6 +131,7 @@ void LoadConfig() void Touch_Mode_Select_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex) { StartTask(); + s_mode_select_focus = (uint8_t)FLAG; mGuiData[GUI_TAB_INDEX].Current = ID; InModeFlag = true; // �ٽ����ٽ��� diff --git a/UI/UI_Mixer.c b/UI/UI_Mixer.c index ed0380f..c5f7ae7 100644 --- a/UI/UI_Mixer.c +++ b/UI/UI_Mixer.c @@ -1,5 +1,6 @@ #include "includes.h" extern const Touch_AreaTypeDef *pCurrentTouch_Area; +static int8_t s_mixer_focus = -1; // ==================== ��ť���� ==================== #define BTN_Y 275 // ��ť��ʼY #define BTN_H 40 // ��ť�߶� @@ -125,10 +126,11 @@ static void DrawFaderGrooveAt(Fader_t *f, uint16_t y_start, uint16_t y_end) static void DrawFaderSlider(Fader_t *f, uint16_t slider_y) { uint16_t x = f->x, w = f->w, slider_h = 20; + uint16_t bg = (s_mixer_focus == (int8_t)f->id) ? COLOR_PRIMARY : COLOR_NORMAL_BG; char buf[8]; - LCD_FillRoundRect(x+5, slider_y, w-10, slider_h, 5, COLOR_PRIMARY); + LCD_FillRoundRect(x+5, slider_y, w-10, slider_h, 5, bg); sprintf(buf, "%d", f->val); - LCD_ShowString_AutoAlign(x, x + w, slider_y, (uint8_t*)buf, LCD_ALIGN_CENTER, FADER_TEXT, COLOR_PRIMARY, 0, 15); + LCD_ShowString_AutoAlign(x, x + w, slider_y, (uint8_t*)buf, LCD_ALIGN_CENTER, FADER_TEXT, bg, 0, 15); } // ============================================================ // 完整重绘滑块(槽背景 + 刻度线 + 滑块) @@ -157,6 +159,13 @@ void UpdateFaderByTouch(int idx, uint16_t y) uint8_t STR_val; if (idx < 0 || idx > 3) return; Fader_t *f = &faders[idx]; + 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); + } uint16_t y_min = f->y; uint16_t y_max = f->y + f->h; if (y < y_min + 8) { // 闈犺繎椤堕儴 鈫?鐩存帴10 @@ -173,6 +182,7 @@ void UpdateFaderByTouch(int idx, uint16_t y) f->val = val_raw; } UpdateFaderSlider(f); + DrawFaderSlider(f, f->prev_slider_y); // 闊抽噺杈撳嚭 switch(idx) { case 0: @@ -270,6 +280,8 @@ int CheckTouchFader(uint16_t x, uint16_t y) // ==================== ��ʼ�� ==================== void UI_Mixer_Init(void) { + s_mixer_focus = -1; + UI_ClearFocus(); // LCD_WR_REG(0x28); // Display OFF UI_DrawTop_TiaoYinTai(); DrawAllFaders(); diff --git a/UI/UI_Setting.c b/UI/UI_Setting.c index 31cd7ed..0af52b8 100644 --- a/UI/UI_Setting.c +++ b/UI/UI_Setting.c @@ -184,12 +184,14 @@ void Touch_SystemSettingAction(int8_t FLAG, uint8_t ID, uint8_t areaIndex, uint8 { case GUI_BLUETOOTH_SW: GUI_Item_AjustValue(&mGuiData_SystemSETTING[ID], FLAG); - RefreshSystemSetting(last_value, &SystemSetting[ID], &mGuiData_SystemSETTING[ID]); + if (!UI_SetFocus(ID)) + RefreshSystemSetting(last_value, &SystemSetting[ID], &mGuiData_SystemSETTING[ID]); break; case GUI_AUTOCLOSE: GUI_Item_AjustLoopValue(&mGuiData_SystemSETTING[ID], FLAG); - RefreshSystemSetting(last_value, &SystemSetting[ID], &mGuiData_SystemSETTING[ID]); + if (!UI_SetFocus(ID)) + RefreshSystemSetting(last_value, &SystemSetting[ID], &mGuiData_SystemSETTING[ID]); break; case GUI_RESTORE: @@ -202,6 +204,7 @@ void Touch_SystemSettingAction(int8_t FLAG, uint8_t ID, uint8_t areaIndex, uint8 void UI_Setting_Init(void) { + UI_ClearFocus(); // LCD_WR_REG(0x28); // Display OFF UI_DrawTop_SystemSetting(); DrawSystemSetting(); diff --git a/UI/UI_Setting.h b/UI/UI_Setting.h index 3a238db..8dbba65 100644 --- a/UI/UI_Setting.h +++ b/UI/UI_Setting.h @@ -3,6 +3,7 @@ extern GUI_SWITCH mGuiData_SystemSETTING[]; +extern LEBEL_UI SystemSetting[]; void UI_DrawTop_TiaoYinTai(void); diff --git a/UI/UI_SongMode.c b/UI/UI_SongMode.c index 8b74b6c..1bb2323 100644 --- a/UI/UI_SongMode.c +++ b/UI/UI_SongMode.c @@ -17,8 +17,8 @@ void Draw_Tab_Mode_Menu(const LEBEL_UI *UI, GUI_SWITCH *Group) const uint16_t text_y = UI->y + 2; // 鏂囧�????Y // ===================== 棰滆壊瀹氫�???? ===================== - uint16_t color_sel_bg = COLOR_PRIMARY; // 选中背景 - uint16_t color_unsel_bg = DARKLGRAY; // 鏈�????変腑鑳屾�???? + 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; // 鏂囧瓧棰滆�?? // 鏄剧ず锛氳嚜鍔ㄤ即濂忓紑 / �????? @@ -104,9 +104,8 @@ void Draw_Tab_Mode_Menu(const LEBEL_UI *UI, GUI_SWITCH *Group) void Show_home_UI(void) { - //LCD_BLK_Clr(); - //LCD_WR_REG(0x28); // Display OFF:关�?�?描,隐藏后续绘制过程 - LCD_FillByColor(0,0,240,320,BLACK); // 刷背�? + 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]); @@ -133,7 +132,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) last_value = mGuiData[ID].Current; GUI_Item_AjustLoopValue(&mGuiData[ID], FLAG); - Refresh_Transpose(&UI_Label[ID], &mGuiData[ID]); + 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) { @@ -188,7 +188,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) last_value = mGuiData[ID].Current; GUI_Item_AjustValue(&mGuiData[ID], FLAG); - Refresh_Transpose(&UI_Label[ID], &mGuiData[ID]); + if (!UI_SetFocus(GUI_SPEED)) + Refresh_Transpose(&UI_Label[ID], &mGuiData[ID]); Speed[3] = mGuiData[ID].Current / 128; Speed[4] = mGuiData[ID].Current % 128; @@ -222,6 +223,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) } 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: @@ -245,13 +248,12 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) break; // 涓撳�???? case 2: nvm->param.Param3 = ParamGuiData[ALL_MODE_PARAM].Current; break; // 涓囪�???? } - show_Param(&UI_Label[GUI_MODE_PARAM], pCurData); } 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}; @@ -277,7 +279,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) { ADDRESS = 0x00000000; } - label_ModeSelece_ui(&UI_Label[GUI_MODE_PARAM],&mGuiData[GUI_MODE_PARAM]); + 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) @@ -291,7 +294,8 @@ void Touch_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex,uint8_t value) AutoBandTop1_FillinWithIndex(value); AutoBandTop1_Start(); } - Refresh_SectionSelect(last_value, &UI_Label[ID], &mGuiData[ID]); + if (!UI_SetFocus(GUI_PLAY_SECTION)) + Refresh_SectionSelect(last_value, &UI_Label[ID], &mGuiData[ID]); return; } else if(ID==GUI_TAB_INDEX) @@ -397,7 +401,8 @@ void UI_SongMode_Process(DisplayTaskMessage_Type msg) case MSG_ID_TAP_SPEED: //last_value = mGuiData[GUI_SPEED].Current; mGuiData[GUI_SPEED].Current = msg.ID; - Refresh_Transpose(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]); + 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) { @@ -476,7 +481,8 @@ void UI_SongMode_Process(DisplayTaskMessage_Type msg) if(mGuiData[GUI_TRANSPOSE].Current != msg.ID) { mGuiData[GUI_TRANSPOSE].Current = msg.ID; - Refresh_Transpose(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]); + if (!UI_SetFocus(GUI_TRANSPOSE)) + Refresh_Transpose(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]); } if(nvm->param.Transpose != mGuiData[GUI_TRANSPOSE].Current) diff --git a/UI/UI_SystemSet.c b/UI/UI_SystemSet.c index 0973563..b48a2f1 100644 --- a/UI/UI_SystemSet.c +++ b/UI/UI_SystemSet.c @@ -200,55 +200,47 @@ void UI_DrawSysModeSelectScreen(void) const uint16_t btn_h = 87; const uint16_t btn_r = 10; const uint16_t btn_x = (240 - btn_w) / 2; // 10 - const uint16_t btn_color = /*DARKLGRAY*//*0x2988*/BLACK; // 深灰�????? - - // 3. 排列 3 �?????按钮:Y=40,间�????? 5,最后一�?????按钮底部距底 9px - // 按钮 Y: 40, 132, 224 + const uint16_t btn_color = COLOR_NORMAL_BG; LCD_DrawLine(0, 30, 240, 30, btn_color); - - - // 调音台(Y=40+20 -// LCD_FillRoundRect(btn_x, 40+20, btn_w, btn_h, btn_r, btn_color); - LCD_FillRoundRectGradient(btn_x, 40+20, btn_w, btn_h, btn_r, START_COLOR, END_COLOR); + LCD_FillRoundRect(btn_x, 40+20, btn_w, btn_h, btn_r, btn_color); LCD_DrawChevron_Right(200, 105, 15, 3, WHITE); - uint16_t x1 = LCD_ShowChinese_AutoAlign_Gradient( + uint16_t x1 = LCD_ShowChinese_AutoAlign( btn_x, btn_x + btn_w, 40 + (btn_h - 24) / 2+20, (uint8_t*)"\xB5\xF7\xD2\xF4\xCC\xA8", LCD_ALIGN_CENTER, UI_SET_MODE_TEXT_COLOR, - START_COLOR, END_COLOR, - + btn_color, + 0, 24 ); - LCD_WR_PIC(x1-45, 40 + (btn_h - 24) / 2+10,40,40,gImage_mixer); + LCD_WR_PIC_Trans(x1-45, 40 + (btn_h - 24) / 2+10,40,40,gImage_mixer, BLACK); - // 系统设置(Y=132+20 -// LCD_FillRoundRect(btn_x, 132+20, btn_w, btn_h, btn_r, btn_color); - LCD_FillRoundRectGradient(btn_x, 132+20, btn_w, btn_h, btn_r, START_COLOR, END_COLOR); + LCD_FillRoundRect(btn_x, 132+20, btn_w, btn_h, btn_r, btn_color); LCD_DrawChevron_Right(200, 195, 15, 3, WHITE); - uint8_t x2 = LCD_ShowChinese_AutoAlign_Gradient( + uint8_t x2 = LCD_ShowChinese_AutoAlign( btn_x, btn_x + btn_w, 132 + (btn_h - 24) / 2+20, (uint8_t*)"\xCF\xB5\xCD\xB3\xC9\xE8\xD6\xC3", LCD_ALIGN_CENTER, UI_SET_MODE_TEXT_COLOR, - START_COLOR, END_COLOR, - + btn_color, + 0, 24 ); - LCD_WR_PIC(x2-45, 132 + (btn_h - 24) / 2+10,40,40,gImage_SystemSetting); + LCD_WR_PIC_Trans(x2-45, 132 + (btn_h - 24) / 2+10,40,40,gImage_SystemSetting, BLACK); } void UI_SystemSet_Init(void) { + UI_ClearFocus(); // LCD_WR_REG(0x28); // Display OFF pCurrentTouch_Area = Touch_SetingSelect_Areas; UI_DrawSysModeSelectScreen(); diff --git a/UI/UI_SystemSet.h b/UI/UI_SystemSet.h index a1aa6fc..22f74cd 100644 --- a/UI/UI_SystemSet.h +++ b/UI/UI_SystemSet.h @@ -10,6 +10,7 @@ typedef enum { +void UI_DrawSysModeSelectScreen(void); void UI_SystemSet_Init(void); void UI_SystemSet_Process(DisplayTaskMessage_Type msg); diff --git a/UI/UI_global.c b/UI/UI_global.c index 114082a..05b8f74 100644 --- a/UI/UI_global.c +++ b/UI/UI_global.c @@ -72,7 +72,85 @@ void CallUI_RestoreSelect(void) { UI_Restore_Select_Init(); } - +static uint8_t s_ui_focus_id = UI_FOCUS_NONE; + +static uint8_t UI_NormalizeFocusId(uint8_t widget_id) +{ + if (widget_id == GUI_AUTOBAND_SW) + return GUI_MODE_PARAM; + return widget_id; +} + +static void UI_RedrawWidget(uint8_t id) +{ + if (CurrUIProcress == UI_SongMode_Process) + { + switch (id) + { + case GUI_TRANSPOSE: + label_Tranzpose_ui(&UI_Label[GUI_TRANSPOSE], &mGuiData[GUI_TRANSPOSE]); + break; + case GUI_SPEED: + label_Speed_ui(&UI_Label[GUI_SPEED], &mGuiData[GUI_SPEED]); + break; + case GUI_MODE_PARAM: + label_ModeSelece_ui(&UI_Label[GUI_MODE_PARAM], &mGuiData[GUI_MODE_PARAM]); + break; + case GUI_TIMBRE_SELECT: + label_TimbreSelece_ui(&UI_Label[GUI_TIMBRE_SELECT], &mGuiData[GUI_TIMBRE_SELECT]); + break; + case GUI_PLAY_SECTION: + label_PlaySection_ui(&UI_Label[GUI_PLAY_SECTION], &mGuiData[GUI_PLAY_SECTION]); + break; + default: + break; + } + } + else if (CurrUIProcress == UI_Setting_Process) + { + if (id <= GUI_RESTORE) + Draw_System_Item_List(&SystemSetting[id], &mGuiData_SystemSETTING[id]); + } +} + +void UI_ClearFocus(void) +{ + s_ui_focus_id = UI_FOCUS_NONE; +} + +uint8_t UI_IsFocused(uint8_t widget_id) +{ + return (s_ui_focus_id == UI_NormalizeFocusId(widget_id)) ? 1 : 0; +} + +void UI_GetFocusGrad(uint8_t widget_id, uint16_t *c_top, uint16_t *c_bot) +{ + if (UI_IsFocused(widget_id)) + { + *c_top = START_COLOR; + *c_bot = END_COLOR; + } + else + { + *c_top = COLOR_NORMAL_BG; + *c_bot = COLOR_NORMAL_BG; + } +} + +uint8_t UI_SetFocus(uint8_t widget_id) +{ + uint8_t prev = s_ui_focus_id; + widget_id = UI_NormalizeFocusId(widget_id); + if (prev == widget_id) + return 0; + s_ui_focus_id = widget_id; + if (prev != UI_FOCUS_NONE) + UI_RedrawWidget(prev); + if (widget_id != UI_FOCUS_NONE) + UI_RedrawWidget(widget_id); + return 1; +} + void label_top() { const uint16_t btn_color = /*DARKLGRAY*/0x2988; // 深灰�????? @@ -144,13 +222,16 @@ void show_Param(const LEBEL_UI *UI, GUI_SWITCH *Group) char NumBuf[8] = {0}; uint16_t text_y = UI->y + 25+5+5; uint8_t idx = Group->Current + 1; + uint16_t c_top, c_bot; + + UI_GetFocusGrad(GUI_MODE_PARAM, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x+25, UI->y+20+5, UI->x + UI->w-40-(UI->x+25), UI->h-20, 0, - START_COLOR, END_COLOR + c_top, c_bot ); // 拼接序号 1. 2. 3. @@ -195,26 +276,28 @@ void show_Param(const LEBEL_UI *UI, GUI_SWITCH *Group) void Refresh_Transpose(const LEBEL_UI *UI, GUI_SWITCH * Group) { + uint16_t c_top, c_bot; + UI_GetFocusGrad(UI->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x+30, UI->y + 20, 25 + 10+10+5, 20, 0, - START_COLOR, END_COLOR + c_top, c_bot ); char Textstr1[20] = {0,}; GET_Num_Str(Group->Current,0,Textstr1,Group->Id); LCD_ShowString_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, // 坐标 UI->x+UI->w, UI->y + 17, (const uint8_t*)Textstr1, UI->Text_Align, UI->Text_fc, - START_COLOR, - END_COLOR, + c_top, + c_bot, UI->Text_size ); } @@ -222,13 +305,15 @@ void Refresh_Transpose(const LEBEL_UI *UI, GUI_SWITCH * Group) void Refresh_StringTimbre(uint8_t last_data,const LEBEL_UI *UI, GUI_SWITCH * Group) { + uint16_t c_top, c_bot; + UI_GetFocusGrad(UI->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x + 40, UI->y + 25, UI->x + UI->w - 40 - (UI->x + 40), UI->y + 25 + UI->Text_size + 5 -(UI->y + 25), 0, - START_COLOR, END_COLOR + c_top, c_bot ); char Textstr1[20] = {0,}; char NumBuf[8] = {0}; @@ -316,106 +401,103 @@ void Refresh_Mode1Select(uint8_t last_data, LEBEL_UI *UI, GUI_SWITCH *Group) void label_Tranzpose_ui(const LEBEL_UI *UI,GUI_SWITCH * Group) { uint8_t Textstr[20] = {0}; + uint16_t c_top, c_bot; + UI_GetFocusGrad(UI->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x, UI->y, - UI->w, // 小写 w + UI->w, UI->h, 10, - START_COLOR, - END_COLOR + c_top, + c_bot ); - // 显示�?�? LCD_ShowChinese_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y+5, UI->p, UI->Tab_Align, UI->Tab_fc, - START_COLOR, - END_COLOR, -// UI->Tab_size - 12 + c_top, + c_bot, + UI->Tab_size ); - LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-20, 12, WHITE, BUTTON_COLOR); - LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-20, 12, WHITE, BUTTON_COLOR); - // 获取数字字�?�串 + LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-20, 12, WHITE, c_top); + LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-20, 12, WHITE, c_top); GET_Num_Str(mGuiData[UI->Id].Current, 0, (char*)Textstr, UI->Id); - // 显示文本 LCD_ShowString_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y + 17, Textstr, UI->Text_Align, UI->Text_fc, - START_COLOR, - END_COLOR, + c_top, + c_bot, UI->Text_size ); LCD_ShowString_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y + 17+25, (const uint8_t*)"KEY", UI->Text_Align, UI->Text_fc, - START_COLOR, - END_COLOR, - 16 + c_top, + c_bot, + 12 ); } void label_Speed_ui(const LEBEL_UI *UI,GUI_SWITCH * Group) { uint8_t Textstr[20] = {0}; + uint16_t c_top, c_bot; + UI_GetFocusGrad(UI->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x, UI->y, - UI->w, // 小写 w + UI->w, UI->h, 10, - START_COLOR, END_COLOR + c_top, c_bot ); - // 显示�?�? LCD_ShowChinese_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y+5, UI->p, UI->Tab_Align, UI->Tab_fc, - START_COLOR, - END_COLOR, + c_top, + c_bot, UI->Tab_size ); - LCD_DrawMinus_RoundBox(UI->x+10+5+5, UI->y+UI->h-20, 30,5, WHITE, BLACK); - LCD_DrawPlus_RoundBox(UI->x+UI->w+10-25-5, UI->y+UI->h-20, 30,5, WHITE, BLACK); - // 获取数字字�?�串 + LCD_DrawMinus_RoundBox(UI->x+10+5+5, UI->y+UI->h-20, 30,5, WHITE, c_top); + LCD_DrawPlus_RoundBox(UI->x+UI->w+10-25-5, UI->y+UI->h-20, 30,5, WHITE, c_top); GET_Num_Str(mGuiData[UI->Id].Current, 0, (char*)Textstr, UI->Id); - // 显示文本 LCD_ShowString_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y + 17, Textstr, UI->Text_Align, UI->Text_fc, - START_COLOR, - END_COLOR, + c_top, + c_bot, UI->Text_size ); LCD_ShowString_AutoAlign_Gradient( - UI->x, // 坐标�? + UI->x, UI->x+UI->w, UI->y + 17+25, (const uint8_t*)"BPM", UI->Text_Align, UI->Text_fc, - START_COLOR, - END_COLOR, - 16 + c_top, + c_bot, + 12 ); } // �޸��棺ȥ������д���autobandֵ��ֻ������ȷ�IJ�����ʾ @@ -423,22 +505,24 @@ void label_ModeSelece_ui(const LEBEL_UI *UI,GUI_SWITCH * Group) { char *str; GUI_SWITCH *paramCurData = NULL; + uint16_t c_top, c_bot; + UI_GetFocusGrad(GUI_MODE_PARAM, &c_top, &c_bot); switch(mGuiData[GUI_TAB_INDEX].Current) { case 0: paramCurData = &ParamGuiData[SONG_MODE_PARAM]; break; case 1: paramCurData = &ParamGuiData[EXPRESS_MODE_PARAM]; break; case 2: paramCurData = &ParamGuiData[ALL_MODE_PARAM]; break; } - LCD_FillRoundRectGradient(UI->x, UI->y+20+5, UI->w, UI->h-20, 10,START_COLOR, END_COLOR); + LCD_FillRoundRectGradient(UI->x, UI->y+20+5, UI->w, UI->h-20, 10, c_top, c_bot); switch(mGuiData[GUI_TAB_INDEX].Current) { case 0:case 1: Draw_Tab_Mode_Menu(UI, &mGuiData[GUI_AUTOBAND_SW]); break; case 2: str = (char*)"\xBA\xCD\xCF\xD2\xD7\xDF\xCF\xF2"; - LCD_ShowChinese_AutoAlign_Gradient( + LCD_ShowChinese_AutoAlign( UI->x, UI->x+UI->w, UI->y+5+5, - (uint8_t *)str, UI->Tab_Align, UI->Tab_fc, UI->Tab_bc, 0, UI->Tab_size + (uint8_t *)str, UI->Tab_Align, UI->Tab_fc, BLACK, 0, UI->Tab_size ); break; } @@ -455,11 +539,9 @@ void label_ModeSelece_ui(const LEBEL_UI *UI,GUI_SWITCH * Group) break; case 2: paramCurData = &ParamGuiData[ALL_MODE_PARAM]; break; } - // ��ʾ��ǰģʽ����ֵ����һ�Σ����ᱻautobandֵ���ǣ� show_Param(&UI_Label[GUI_MODE_PARAM], paramCurData); - // �������� - LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-15-2+5, 12, WHITE, BUTTON_COLOR); - LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-15-2+5, 12, WHITE, BUTTON_COLOR); + LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-15-2+5, 12, WHITE, c_top); + LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-15-2+5, 12, WHITE, c_top); } void label_TimbreSelece_ui(const LEBEL_UI *UI, GUI_SWITCH * Group) @@ -468,42 +550,40 @@ void label_TimbreSelece_ui(const LEBEL_UI *UI, GUI_SWITCH * Group) char NumBuf[8] = {0}; uint16_t text_y = UI->y + 25; uint8_t idx = mGuiData[UI->Id].Current + 1; + uint16_t c_top, c_bot; + UI_GetFocusGrad(UI->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x, UI->y+20, UI->w, UI->h-20, 10, - START_COLOR, END_COLOR + c_top, c_bot ); - LCD_ShowChinese_AutoAlign_Gradient( + LCD_ShowChinese_AutoAlign( UI->x, UI->x+UI->w, UI->y+5, UI->p, UI->Tab_Align, UI->Tab_fc, - START_COLOR, - END_COLOR, + BLACK, + 0, UI->Tab_size ); - LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-20+3, 12, WHITE, BUTTON_COLOR); - LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-20+3, 12, WHITE, BUTTON_COLOR); + LCD_DrawArrow_Left(UI->x+10+5+5, UI->y+UI->h-20+3, 12, WHITE, c_top); + LCD_DrawArrow_Right(UI->x+UI->w+10-25-5, UI->y+UI->h-20+3, 12, WHITE, c_top); LCD_FillRoundRectGradient( UI->x + 40, UI->y+20, UI->x + UI->w - 40 - UI->x - 40 , UI->h-20, 0, - START_COLOR, END_COLOR + c_top, c_bot ); - // 拼接序号 1. 2. 3. sprintf(NumBuf, "%d.", idx); - // 计算数字宽度 uint16_t num_w = (strlen(NumBuf)) * (UI->Text_size / 2); - // 获取音色中文 GET_Num_Str(mGuiData[UI->Id].Current, 0, (char*)Textstr, UI->Id); - // 先渲染中文,拿到中文起始X坐标 uint32_t chinese_start_x = LCD_ShowChinese_AutoAlign_Gradient( UI->x + num_w, UI->x + UI->w, @@ -511,15 +591,13 @@ void label_TimbreSelece_ui(const LEBEL_UI *UI, GUI_SWITCH * Group) (const uint8_t*)Textstr, UI->Text_Align, UI->Text_fc, - START_COLOR, END_COLOR, + c_top, c_bot, UI->Text_size ); - // 序号X uint16_t num_x = chinese_start_x - num_w - 5; - // 绘制左侧数字序号 LCD_ShowString_AutoAlign_Gradient(num_x, num_x + num_w, text_y+3, (const uint8_t *)NumBuf, LCD_ALIGN_LEFT, UI->Text_fc, - START_COLOR, END_COLOR, UI->Text_size); + c_top, c_bot, UI->Text_size); switch(Group->Id) { case GUI_TIMBRE_SELECT: @@ -615,182 +693,35 @@ void label_Tab_Select_ui(const LEBEL_UI *UI,GUI_SWITCH * Group) void Draw_Tab_Section_Menu(const LEBEL_UI *UI, TAB_SECTION_INDEX select_tab) { - // ===================== TAB 配置参数 ===================== - const uint16_t tab_w = 50; // TAB宽度 - const uint16_t tab_h = 24 + 11; // TAB高度 - const uint8_t tab_r = 5; // 圆�?? - const uint8_t space = 3; // 间距 - const uint16_t start_x = UI->x + 10; // 起�?�X - const uint16_t start_y = UI->y + 28 - 6; // 起�?�Y - const uint16_t text_y = UI->y + 28 - 3; // 文字Y - // ===================== 颜色定义 ===================== - uint16_t color_sel_bg = COLOR_PRIMARY; // 选中背景 -// uint16_t color_unsel_bg = BLACK; // �?选中背景 - uint16_t color_text = UI->Text_fc; // 文字颜色 + const uint16_t tab_w = 50; + const uint16_t tab_h = 24 + 11; + const uint8_t tab_r = 5; + const uint8_t space = 3; + const uint16_t start_x = UI->x + 10; + const uint16_t start_y = UI->y + 28 - 6; + const uint16_t text_y = UI->y + 28 - 3; + const char *nums[4] = {"1", "2", "3", "4"}; + uint8_t focused = UI_IsFocused(GUI_PLAY_SECTION); + uint8_t i; - if(select_tab == TAB_A) + for (i = 0; i < 4; i++) { - LCD_FillRoundRect(start_x, - start_y, - tab_w, - tab_h, - tab_r, - color_sel_bg); - LCD_ShowString_AutoAlign_Gradient( - start_x, - start_x + tab_w, - text_y, - (const uint8_t*)"1", - UI->Text_Align, - color_text, - color_sel_bg, color_sel_bg, - 24 - ); - }else - { - LCD_FillRoundRectGradient( - start_x, - start_y, - tab_w, - tab_h, - tab_r, - START_COLOR, END_COLOR - ); - LCD_ShowString_AutoAlign_Gradient( - start_x, - start_x + tab_w, - text_y, - (const uint8_t*)"1", - UI->Text_Align, - color_text, - START_COLOR, END_COLOR, - 24 - ); + uint16_t x = start_x + i * (tab_w + space); + uint16_t bg = (focused && (select_tab == i)) ? COLOR_PRIMARY : COLOR_NORMAL_BG; + LCD_FillRoundRect(x, start_y, tab_w, tab_h, tab_r, bg); + LCD_ShowString_AutoAlign( + x, x + tab_w, text_y, + (const uint8_t*)nums[i], + UI->Text_Align, + WHITE, + bg, + 0, + 24 + ); } - - if(select_tab == TAB_B) - { - LCD_FillRoundRect(start_x + tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - color_sel_bg); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space, - start_x + tab_w + space + tab_w, - text_y, - (const uint8_t*)"2", - UI->Text_Align, - color_text, - color_sel_bg, color_sel_bg, - 24 - ); - }else - { - LCD_FillRoundRectGradient( - start_x + tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - START_COLOR, END_COLOR - ); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space, - start_x + tab_w + space + tab_w, - text_y, - (const uint8_t*)"2", - UI->Text_Align, - color_text, - START_COLOR, END_COLOR, - 24 - ); - } - - if(select_tab == TAB_C) - { - LCD_FillRoundRect(start_x + tab_w + space + tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - color_sel_bg); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space + tab_w + space, - start_x + tab_w + space + tab_w + space + tab_w, - text_y, - (const uint8_t*)"3", - UI->Text_Align, - color_text, - color_sel_bg, color_sel_bg, - 24 - ); - }else - { - LCD_FillRoundRectGradient( - start_x + tab_w + space + tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - START_COLOR, END_COLOR - ); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space + tab_w + space, - start_x + tab_w + space + tab_w + space + tab_w, - text_y, - (const uint8_t*)"3", - UI->Text_Align, - color_text, - START_COLOR, END_COLOR, - 24 - ); - } - if(select_tab == TAB_D) - { - LCD_FillRoundRect(start_x + tab_w + space + tab_w + space+ tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - color_sel_bg); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space + tab_w + space+ tab_w + space, - start_x + tab_w + space + tab_w + space + tab_w+ tab_w + space, - text_y, - (const uint8_t*)"4", - UI->Text_Align, - color_text, - color_sel_bg, color_sel_bg, - 24 - ); - }else - { - LCD_FillRoundRectGradient( - start_x + tab_w + space + tab_w + space+ tab_w + space, - start_y, - tab_w, - tab_h, - tab_r, - START_COLOR, END_COLOR - ); - LCD_ShowString_AutoAlign_Gradient( - start_x + tab_w + space + tab_w + space+ tab_w + space, - start_x + tab_w + space + tab_w + space + tab_w+ tab_w + space, - text_y, - (const uint8_t*)"4", - UI->Text_Align, - color_text, - START_COLOR, END_COLOR, - 24 - ); - } - } - void GET_ParamNum_Str(int16_t NUM, uint8_t ValidLen, char* Str, uint8_t hasSign) { // int16_t Value; @@ -974,35 +905,37 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group) { NvmParam_Type * nvm = drv_nvm_param_ptr(); char Info[40]; + uint16_t c_top, c_bot; + UI_GetFocusGrad(Group->Id, &c_top, &c_bot); LCD_FillRoundRectGradient( UI->x, UI->y, 220, UI->h, 5, - START_COLOR, END_COLOR + c_top, c_bot ); - LCD_ShowChinese_AutoAlign_Gradient(UI->x+35,UI->x+UI->w,UI->y+UI->h/2-8,UI->p,UI->Tab_Align,UI->Tab_fc,START_COLOR, END_COLOR,UI->Tab_size); + LCD_ShowChinese_AutoAlign_Gradient(UI->x+35,UI->x+UI->w,UI->y+UI->h/2-8,UI->p,UI->Tab_Align,UI->Tab_fc,c_top, c_bot,UI->Tab_size); switch(Group->Id) { case GUI_VERSION: LCD_WR_PIC(UI->x+10, UI->y+18,20,20,gImage_FimewareVection); sprintf (Info, "%d.%d.%d", Version[0], Version[1],Version[2]); - LCD_ShowString_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)Info,LCD_ALIGN_CENTER, UI->Text_fc,START_COLOR, END_COLOR,11); + LCD_ShowString_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)Info,LCD_ALIGN_CENTER, UI->Text_fc,c_top, c_bot,11); break; case GUI_BLUETOOTH_SW: LCD_WR_PIC(UI->x+10, UI->y+18,20,20,gImage_BlueTooth); - LCD_DrawArrow_Left(UI->x+100+10+5, UI->y+UI->h/2-8+12-5, 12, WHITE, GRAY); - LCD_DrawArrow_Right(UI->x+100+95, UI->y+UI->h/2-8+12-5, 12, WHITE, GRAY); + LCD_DrawArrow_Left(UI->x+100+10+5, UI->y+UI->h/2-8+12-5, 12, WHITE, c_top); + LCD_DrawArrow_Right(UI->x+100+95, UI->y+UI->h/2-8+12-5, 12, WHITE, c_top); if(Group->Current) { - LCD_ShowChinese_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)"\xBF\xAA",LCD_ALIGN_CENTER, UI->Text_fc,START_COLOR, END_COLOR,11); + LCD_ShowChinese_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)"\xBF\xAA",LCD_ALIGN_CENTER, UI->Text_fc,c_top, c_bot,11); }else { - LCD_ShowChinese_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)"\xB9\xD8",LCD_ALIGN_CENTER, UI->Text_fc,START_COLOR, END_COLOR,11); + LCD_ShowChinese_AutoAlign_Gradient(UI->x+100,UI->x+100+110, UI->y+UI->h/2-8-5,(const uint8_t*)"\xB9\xD8",LCD_ALIGN_CENTER, UI->Text_fc,c_top, c_bot,11); } BSP_BlueToothPowerEnable (Group->Current); mGuiData[GUI_BL_SW].Current = Group->Current; break; case GUI_AUTOCLOSE: - LCD_DrawArrow_Left(UI->x+100+10+5, UI->y+UI->h/2-8+12-5, 12, WHITE, GRAY); - LCD_DrawArrow_Right(UI->x+100+95, UI->y+UI->h/2-8+12-5, 12, WHITE, GRAY); + LCD_DrawArrow_Left(UI->x+100+10+5, UI->y+UI->h/2-8+12-5, 12, WHITE, c_top); + LCD_DrawArrow_Right(UI->x+100+95, UI->y+UI->h/2-8+12-5, 12, WHITE, c_top); LCD_WR_PIC(UI->x+10, UI->y+18,20,20,gImage_AutoClose); switch(Group->Current) { diff --git a/UI/UI_global.h b/UI/UI_global.h index c38f52d..8bd7d26 100644 --- a/UI/UI_global.h +++ b/UI/UI_global.h @@ -31,6 +31,12 @@ void CallUI_RestoreSelect(void); #define UI_STATUS_BATTERY_X 180 #define UI_STATUS_BATTERY_H 11 #define UI_STATUS_BATTERY_Y ((UI_STATUS_BAR_H - UI_STATUS_BATTERY_H) / 2) +#define UI_FOCUS_NONE 0xFF + +void UI_ClearFocus(void); +uint8_t UI_IsFocused(uint8_t widget_id); +uint8_t UI_SetFocus(uint8_t widget_id); +void UI_GetFocusGrad(uint8_t widget_id, uint16_t *c_top, uint16_t *c_bot); void Draw_Status_Battery_Icon(uint8_t battery_percent); void Show_Battery_Icon(uint8_t flag); diff --git a/UI/UI_idle.h b/UI/UI_idle.h index a41310f..40dc2d6 100644 --- a/UI/UI_idle.h +++ b/UI/UI_idle.h @@ -8,6 +8,7 @@ typedef enum { extern const Touch_AreaTypeDef Touch_ModeSelect_Areas[]; +extern void UI_DrawModeSelectScreen(void); extern void IdleProcess(DisplayTaskMessage_Type xEvent); diff --git a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c index 2ce78d5..389e48a 100644 --- a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c +++ b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c @@ -150,6 +150,30 @@ void LCD_WR_PIC(uint16_t x, uint16_t y, uint16_t length, uint16_t width, const u } } +/* 跳过 key_color 像素,用于图标透明底(常见 key=BLACK) */ +void LCD_WR_PIC_Trans(uint16_t x, uint16_t y, uint16_t length, uint16_t width, + const uint8_t data[], uint16_t key_color) +{ + uint32_t total_pixels = (uint32_t)length * width; + uint8_t key_h = (uint8_t)(key_color >> 8); + uint8_t key_l = (uint8_t)(key_color & 0xFF); + uint32_t i; + + if (total_pixels == 0) + return; + + for (i = 0; i < total_pixels; i++) + { + uint8_t hi = data[i * 2]; + uint8_t lo = data[i * 2 + 1]; + if (hi == key_h && lo == key_l) + continue; + LCD_DrawPoint((uint16_t)(x + (i % length)), + (uint16_t)(y + (i / length)), + (uint16_t)((hi << 8) | lo)); + } +} + /****************************************************************************** 函数说明:从W25Q128外部Flash读取图片数据并显示 入口数据:x,y 显示起始坐标 @@ -1501,53 +1525,15 @@ uint16_t LCD_ShowString_AutoAlign_Gradient(uint16_t x1, uint16_t x2, uint16_t y, /****************************************************************************** -// ===================================================================== -// 旧版 LCD_DrawArrow_Left / LCD_DrawArrow_Right(保留以备回滚) -// 仅画箭头,无背景框 -// ===================================================================== -//void LCD_DrawArrow_Left(uint16_t x, uint16_t y, uint8_t size, uint16_t color) -//{ -// int16_t i; -// for(i = 0; i < size; i++) -// { -// LCD_DrawLine( -// x - i, -// y - size + i, -// x - i, -// y + size - i, -// color -// ); -// } -//} -//void LCD_DrawArrow_Right(uint16_t x, uint16_t y, uint8_t size, uint16_t color) -//{ -// int16_t i; -// for(i = 0; i < size; i++) -// { -// LCD_DrawLine( -// x + i, -// y - size + i, -// x + i, -// y + size - i, -// color -// ); -// } -//} -// ===================================================================== -// 新版 LCD_DrawArrow_Left / LCD_DrawArrow_Right -// 新增 bg_color 参数:圆角正方形背景框的颜色 -// 背景框为正方形,边长 = 2*size + 8,圆角半径 = 3 -// 箭头居中显示在背景框内 -// ===================================================================== + 函数说明:圆角框 + 左箭头。bg_color 为框背景(普通态灰色 / 焦点蓝色) +******************************************************************************/ void LCD_DrawArrow_Left(uint16_t x, uint16_t y, uint8_t size, uint16_t color, uint16_t bg_color) { - // 圆角正方形背景框 - int16_t box_side = size * 2 + 8; + int16_t box_side = size * 2 + 5; int16_t box_x = x - box_side / 2; int16_t box_y = y - box_side / 2; LCD_FillRoundRect(box_x, box_y, box_side, box_side, 3, bg_color); - // 箭头顶部(居中) int16_t i; for(i = 0; i < size; i++) { @@ -1563,65 +1549,11 @@ void LCD_DrawArrow_Left(uint16_t x, uint16_t y, uint8_t size, uint16_t color, ui void LCD_DrawArrow_Right(uint16_t x, uint16_t y, uint8_t size, uint16_t color, uint16_t bg_color) { - // 圆角正方形背景框 - int16_t box_side = size * 2 + 8; + int16_t box_side = size * 2 + 5; int16_t box_x = x - box_side / 2; int16_t box_y = y - box_side / 2; LCD_FillRoundRect(box_x, box_y, box_side, box_side, 3, bg_color); - // 箭头顶部(居中) - int16_t i; - for(i = 0; i < size; i++) - { - LCD_DrawLine( - x + i, - y - size + i, - x + i, - y + size - i, - color - ); - } -} - -// ===================================================================== -// 新版 LCD_DrawArrow_Left / LCD_DrawArrow_Right -// 新增 bg_color 参数:圆角正方形背景框的颜色 -// 背景框为正方形,边长 = 2*size + 8,圆角半径 = 3 -// 箭头居中显示在背景框内 -// ===================================================================== - * */ -void LCD_DrawArrow_Left(uint16_t x, uint16_t y, uint8_t size, uint16_t color, uint16_t bg_color) -{ - // 圆角正方形背景框 - int16_t box_side = size * 2+5; - int16_t box_x = x - box_side / 2; - int16_t box_y = y - box_side / 2; -// LCD_FillRoundRect(box_x, box_y, box_side, box_side, 3, bg_color); - LCD_FillRoundRectGradient(box_x, box_y, box_side, box_side, 3,START_COLOR,END_COLOR); - - // 箭头顶部(居中) - int16_t i; - for(i = 0; i < size; i++) - { - LCD_DrawLine( - x - i, - y - size + i, - x - i, - y + size - i, - color - ); - } -} - -void LCD_DrawArrow_Right(uint16_t x, uint16_t y, uint8_t size, uint16_t color, uint16_t bg_color) -{ - // 圆角正方形背景框 - int16_t box_side = size * 2+5; - int16_t box_x = x - box_side / 2; - int16_t box_y = y - box_side / 2; -// LCD_FillRoundRect(box_x, box_y, box_side, box_side, 3, bg_color); - LCD_FillRoundRectGradient(box_x, box_y, box_side, box_side, 3,START_COLOR,END_COLOR); - // 箭头顶部(居中) int16_t i; for(i = 0; i < size; i++) { @@ -1671,17 +1603,7 @@ void LCD_DrawPlus_RoundBox(uint16_t x, uint16_t y, uint8_t size, uint8_t radius, uint8_t box_h = size; // 框高度 uint8_t line_w = 4; // 线条粗细 - // 1. 画圆角填充背景框 -// LCD_FillRoundRect( -// x - box_w/2, // 左 -// y - box_h/2, // 上 -// box_w, // 宽 -// box_h, // 高 -// radius, // 圆角 -// bg_color // 背景颜色(灰色) -// ); - - LCD_FillRoundRectGradient(x - box_w/2, y - box_h/2, box_w, box_h, radius,START_COLOR,END_COLOR); + LCD_FillRoundRect(x - box_w/2, y - box_h/2, box_w, box_h, radius, bg_color); // 2. 画水平居中横线 for(i = 0; i < line_w; i++) @@ -1719,17 +1641,7 @@ void LCD_DrawMinus_RoundBox(uint16_t x, uint16_t y, uint8_t size, uint8_t radius uint8_t box_h = size; uint8_t line_w = 2; - // 1. 画圆角填充背景框 -// LCD_FillRoundRect( -// x - box_w/2, -// y - box_h/2, -// box_w, -// box_h, -// radius, -// bg_color -// ); - - LCD_FillRoundRectGradient(x - box_w/2, y - box_h/2, box_w, box_h, radius,START_COLOR,END_COLOR); + LCD_FillRoundRect(x - box_w/2, y - box_h/2, box_w, box_h, radius, bg_color); // 2. 画水平居中横线 for(i = 0; i < line_w; i++) diff --git a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.h b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.h index 46f1d17..a0a37a8 100644 --- a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.h +++ b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.h @@ -26,6 +26,8 @@ extern void LCD_FillRoundRectGradient(uint16_t x, uint16_t y, uint16_t w, uint16 extern void LCD_FillGradient(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color_top, uint16_t color_bottom); extern void LCD_WR_PIC(uint16_t x, uint16_t y, uint16_t length, uint16_t width, const uint8_t data[]); +extern void LCD_WR_PIC_Trans(uint16_t x, uint16_t y, uint16_t length, uint16_t width, + const uint8_t data[], uint16_t key_color); extern void LCD_WR_PIC_FROM_FLASH(uint16_t x, uint16_t y, uint16_t length, uint16_t width, uint32_t flash_addr); extern void LCD_DrawPoint(uint16_t x, uint16_t y, uint16_t color); //在指定位置画一个点 extern void LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); //在指定位置画一条线 diff --git a/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h b/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h index cdcfe2d..98e7a0e 100644 --- a/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h +++ b/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h @@ -58,15 +58,15 @@ #define BLACK 0x0000 #define BLUE 0x001F #define COLOR_PRIMARY 0x1B9F // #1D73FF MiSans UI 主色 -#define COLOR_GRAD_START 0x039D // #003AEE -#define COLOR_GRAD_MID 0x2A5A // #354FD6 -#define COLOR_GRAD_END 0x4B1F // #5561F8 -#define COLOR_BG_START 0x0849 // #0E1537 -#define COLOR_BG_END 0x3189 // #2F3647 -#define COLOR_MIXER_RED 0xFB2D // #F85E4B -#define COLOR_MIXER_ORANGE 0xFD26 // #F59C2C -#define COLOR_MIXER_YELLOW 0xFF6E // #F3D939 -#define COLOR_MIXER_GREEN 0x071F // #13E17F +#define COLOR_GRAD_START 0x01D5 // #003AAE 规范渐变起始(深蓝) +#define COLOR_GRAD_MID 0x029A // #034FD6 规范渐变中间 +#define COLOR_GRAD_END 0x431E // #4161F8 规范渐变结束(中蓝) +#define COLOR_BG_START 0x10A6 // #0E1535 屏幕背景渐变顶 +#define COLOR_BG_END 0x31A9 // #2F3647 屏幕背景渐变底 +#define COLOR_MIXER_RED 0xF2E9 // #F85E4B 弦音色槽位红 +#define COLOR_MIXER_ORANGE 0xF4C5 // #F59C2C 伴奏槽位橙 +#define COLOR_MIXER_YELLOW 0xF6C7 // #F3D939 导奏槽位黄 +#define COLOR_MIXER_GREEN 0x170F // #13E17F 鼓音槽位绿 #define BRED 0XF81F #define GRED 0XFFE0 #define GBLUE 0X07FF @@ -87,7 +87,8 @@ #define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色) -#define DARKLGRAY 0x5AEB/*0x2988*//*0x1926*//*0x252E*//*0X2B12*/ +#define DARKLGRAY 0x2968 // #292C42 控件未选中(暗蓝灰,对应规范非焦点背景) +#define COLOR_NORMAL_BG DARKLGRAY /* 控件普通状态背景 */ #define BUTTON_COLOR /*0x5AEB*/BLACK #define START_COLOR COLOR_GRAD_START diff --git a/tools/JLinkSettings.ini b/tools/JLinkSettings.ini index a03c98d..c71856b 100644 --- a/tools/JLinkSettings.ini +++ b/tools/JLinkSettings.ini @@ -1,8 +1,4 @@ [GENERAL] HideDeviceSelection = 1 - [CPU] -Device="Cortex-M4" - -[FLASH] -Device="Cortex-M4" +Device = Cortex-M4 diff --git a/tools/flash_app.bat b/tools/flash_app.bat new file mode 100644 index 0000000..e096322 --- /dev/null +++ b/tools/flash_app.bat @@ -0,0 +1,25 @@ +@echo off +REM Flash YNGJ-GT1-M app via IAR cspybat (AT32 flash loader). +REM Do NOT pass Commander-style .jlink files to --jlink_script_file. + +setlocal +set ROOT=%~dp0.. +set OUT=%ROOT%\project\IAR_V7.4\YNGJ-GT1-M\Exe\YNGJ-GT1-M.out +set GEN=%ROOT%\project\IAR_V7.4\settings\YNGJ-GT1-M.YNGJ-GT1-M.general.xcl +set DRV=%ROOT%\project\IAR_V7.4\settings\YNGJ-GT1-M.YNGJ-GT1-M.driver.xcl +set CSPY="C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\common\bin\cspybat" +set STAGE=C:\Temp\k1flash + +if not exist "%OUT%" ( + echo ERROR: missing %OUT% - build first + exit /b 1 +) + +mkdir "%STAGE%" 2>nul +copy /Y "%OUT%" "%STAGE%\YNGJ-GT1-M.out" >nul + +%CSPY% -f "%GEN%" "--debug_file=%STAGE%\YNGJ-GT1-M.out" --download_only --backend -f "%DRV%" +if errorlevel 1 exit /b 1 + +"C:\Program Files\SEGGER\JLink_V818\JLink.exe" -CommandFile "%~dp0reset_run.jlink" +exit /b %ERRORLEVEL% diff --git a/tools/jlink_connect.jlink b/tools/jlink_connect.jlink new file mode 100644 index 0000000..5c86fec --- /dev/null +++ b/tools/jlink_connect.jlink @@ -0,0 +1,7 @@ +si SWD +speed 100 +device STM32F407VG +r +connect +halt +exit diff --git a/tools/jlink_flash_app.jlink b/tools/jlink_flash_app.jlink new file mode 100644 index 0000000..48edaae --- /dev/null +++ b/tools/jlink_flash_app.jlink @@ -0,0 +1,9 @@ +si SWD +speed 4000 +device Cortex-M4 +connect +halt +loadbin "c:\Users\qjyu\Documents\SoundWalker\一诺国际吉他\Code\YNGJ-GT1-M - AT32F403ARCT7\project\IAR_V7.4\YNGJ-GT1-M\Exe\YNGJ-GT1-M.bin", 0x08008000 +r +g +exit diff --git a/tools/jlink_hidedevid.jlink b/tools/jlink_hidedevid.jlink index 66bbce9..7a7f15f 100644 --- a/tools/jlink_hidedevid.jlink +++ b/tools/jlink_hidedevid.jlink @@ -1,2 +1 @@ -HideDeviceSelection 1 -Device Cortex-M4 +HideDeviceSelection = 1 diff --git a/tools/jlink_hidedevid.jlinkscript b/tools/jlink_hidedevid.jlinkscript new file mode 100644 index 0000000..747ff48 --- /dev/null +++ b/tools/jlink_hidedevid.jlinkscript @@ -0,0 +1,10 @@ +/********************************************************************* +* J-Link script for IAR C-SPY / AT32F403A +* Hides unknown-device selection dialog (DEV_ID 0x241). +* NOTE: This must be JLinkScript syntax, NOT Commander commands. +**********************************************************************/ + +int ConfigTargetSettings(void) { + JLINK_ExecCommand("HideDeviceSelection = 1"); + return 0; +} diff --git a/tools/reset_run.jlink b/tools/reset_run.jlink new file mode 100644 index 0000000..07516df --- /dev/null +++ b/tools/reset_run.jlink @@ -0,0 +1,7 @@ +si SWD +speed 4000 +device Cortex-M4 +connect +r +g +exit