K1Guitar/UI/UI_SystemSet.c

136 lines
4.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "includes.h"
/* 0902-11 设置入口:调音台 / 系统设置 两大入口 + 底栏设置高亮 */
const Touch_AreaTypeDef Touch_SetingSelect_Areas[] = {
/* 调音台卡片 */
{ UI0902_HUB_CARD_X, (uint16_t)(UI0902_HUB_CARD_X + UI0902_HUB_CARD_W - 1),
UI0902_HUB_CARD_Y0, (uint16_t)(UI0902_HUB_CARD_Y0 + UI0902_HUB_CARD_H - 1),
0, 0, GUI_SETING_SELECT1, NULL },
/* 系统设置卡片 */
{ UI0902_HUB_CARD_X, (uint16_t)(UI0902_HUB_CARD_X + UI0902_HUB_CARD_W - 1),
UI0902_HUB_CARD_Y1, (uint16_t)(UI0902_HUB_CARD_Y1 + UI0902_HUB_CARD_H - 1),
0, 0, GUI_SETING_SELECT3, NULL },
/* 底栏四键:与 Touch_Areas 共用 UI0902_NAV_* 几何 */
{ UI0902_NAV_X0(0), UI0902_NAV_X1(0), UI0902_NAV_Y0, UI0902_NAV_Y1, 0, UI0902_NAV_UNIVERSAL, GUI_NAV_BAR, NULL },
{ UI0902_NAV_X0(1), UI0902_NAV_X1(1), UI0902_NAV_Y0, UI0902_NAV_Y1, 0, UI0902_NAV_NORMAL, GUI_NAV_BAR, NULL },
{ UI0902_NAV_X0(2), UI0902_NAV_X1(2), UI0902_NAV_Y0, UI0902_NAV_Y1, 0, UI0902_NAV_EXPERT, GUI_NAV_BAR, NULL },
{ UI0902_NAV_X0(3), UI0902_NAV_X1(3), UI0902_NAV_Y0, UI0902_NAV_Y1, 0, UI0902_NAV_SETTING, GUI_NAV_BAR, NULL },
};
#define TOUCH_AREA_SETING_SELECT_NUM (sizeof(Touch_SetingSelect_Areas)/sizeof(Touch_AreaTypeDef))
static void UI_Hub_DrawCard(uint16_t y, const uint8_t *icon, uint16_t icon_w, uint16_t icon_h,
const uint8_t *title_gbk)
{
uint16_t x = UI0902_HUB_CARD_X;
uint16_t w = UI0902_HUB_CARD_W;
uint16_t h = UI0902_HUB_CARD_H;
uint16_t cy = y + h / 2;
uint16_t text_y = y + (h - UI0902_HUB_FONT) / 2;
uint16_t icon_x = x + 22;
uint16_t icon_y = y + (h - icon_h) / 2;
LCD_FillRoundRect(x, y, w, h, UI0902_RADIUS_CARD, UI0902_ROW_BG);
LCD_WR_PIC_Trans(icon_x, icon_y, icon_w, icon_h, icon, BLACK);
/* 标题相对卡片水平居中(略偏右给左侧图标留空) */
LCD_ShowChinese_AutoAlign(
x + 56, x + w - 36, text_y, title_gbk,
LCD_ALIGN_CENTER, WHITE, UI0902_ROW_BG, 0, UI0902_HUB_FONT);
LCD_DrawChevron_Right((uint16_t)(x + w - 24), cy, 6, 2, WHITE);
}
void Touch_Seting_Select_Action(int8_t FLAG, uint8_t ID, uint8_t areaIndex, uint8_t value)
{
(void)FLAG;
(void)areaIndex;
if (ID == GUI_NAV_BAR)
{
if (value == UI0902_NAV_SETTING)
return; /* 已在设置入口 */
UI_NavBar_Action(value);
return;
}
switch (ID)
{
case GUI_SETING_SELECT1:
MenuPage_Mixer_Proc();
break;
case GUI_SETING_SELECT3:
MenuPage_Setting_Proc(); /* 系统设置明细 0902-07 */
break;
default:
break;
}
}
void UI_DrawSysModeSelectScreen(void)
{
LCD_FillByColor(0, 0, 240, 320, UI0902_BG_COLOR);
label_top();
/* 调音台0907 素材 1334x33 推子图标) */
UI_Hub_DrawCard(UI0902_HUB_CARD_Y0, gImage_mixer, 34, 33,
(const uint8_t *)"\xB5\xF7\xD2\xF4\xCC\xA8");
/* 系统设置0907 素材 1433x33 齿轮图标) */
UI_Hub_DrawCard(UI0902_HUB_CARD_Y1, gImage_SystemSetting, 33, 33,
(const uint8_t *)"\xCF\xB5\xCD\xB3\xC9\xE8\xD6\xC3");
Draw_Bottom_Bar(UI0902_NAV_SETTING, 0);
}
void UI_SystemSet_Init(void)
{
UI_ClearFocus();
pCurrentTouch_Area = Touch_SetingSelect_Areas;
UI_DrawSysModeSelectScreen();
app_log_set_ui_page("SetHub");
LOG_I("UI", "page SettingsHub");
}
void UI_SystemSet_Process(DisplayTaskMessage_Type msg)
{
static uint32_t s_last_touch_ms;
switch (msg.MessageType)
{
case MSG_ID_TOUCH:
{
uint32_t now = rt_tick_get() * 1000U / RT_TICK_PER_SECOND;
uint8_t k;
if (now - s_last_touch_ms < 250U)
break;
s_last_touch_ms = now;
for (k = 0; k < TOUCH_AREA_SETING_SELECT_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)
{
Touch_Seting_Select_Action(pCurrentTouch_Area[k].Flag,
pCurrentTouch_Area[k].ID, k,
pCurrentTouch_Area[k].Value);
ResetAutoPowerCount();
break;
}
}
}
break;
case MSG_ID_BATTERY_VALUE:
label_top();
break;
case MSG_ID_EC_VOL:
/* 主音量已在 MainTask 下发;此处只刷新状态栏音量条,保证与旋钮一致 */
Draw_Volume_Bar(UI0902_VOL_X, UI0902_VOL_Y, msg.HiByte, 1, WHITE, GRAY);
break;
default:
break;
}
}