282 lines
8.7 KiB
C
282 lines
8.7 KiB
C
#include "includes.h"
|
||
|
||
uint8_t CurrentMode = 0;
|
||
|
||
void RGB_Y_TO_R()
|
||
{
|
||
app_tm1629_all_on(LED_COLOR_YELL);
|
||
rt_thread_delay(1000);
|
||
app_tm1629_all_on(LED_COLOR_R);
|
||
}
|
||
|
||
void RGB_Y_TO_G()
|
||
{
|
||
app_tm1629_all_on(LED_COLOR_YELL);
|
||
rt_thread_delay(1000);
|
||
app_tm1629_all_on(LED_COLOR_G);
|
||
}
|
||
|
||
#define UI_MODE_SCREEN_WIDTH 240
|
||
#define UI_MODE_SCREEN_HEIGHT 320
|
||
|
||
#define UI_MODE_BG_COLOR 0x1925
|
||
#define UI_MODE_LINE_COLOR DARKBLUE
|
||
#define UI_MODE_TEXT_COLOR 0xFFFF
|
||
/* PDF 标注 MiSans-Medium 21;字库无 21,用 28 与 40x30 图标比例接近标注稿 */
|
||
#define UI_MODE_FONT_SIZE 28
|
||
#define UI_MODE_ICON_W 40
|
||
#define UI_MODE_ICON_H 30
|
||
#define UI_MODE_ICON_TEXT_GAP 8
|
||
/* 汉字墨心略偏上;下移与图标光心平齐(过大易显得文字偏下) */
|
||
#define UI_MODE_TEXT_OPTICAL_DY 2
|
||
|
||
/* 模式选择页焦点: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)
|
||
{
|
||
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;
|
||
const uint16_t text_w = (uint16_t)(4 * UI_MODE_FONT_SIZE);
|
||
const uint16_t group_w = (uint16_t)(UI_MODE_ICON_W + UI_MODE_ICON_TEXT_GAP + text_w);
|
||
const uint16_t group_x = (uint16_t)(btn_x + (btn_w - group_w) / 2);
|
||
const uint16_t mid_y = (uint16_t)(y + btn_h / 2);
|
||
const uint16_t icon_y = (uint16_t)(mid_y - UI_MODE_ICON_H / 2);
|
||
const uint16_t text_y = (uint16_t)(mid_y - UI_MODE_FONT_SIZE / 2 + UI_MODE_TEXT_OPTICAL_DY);
|
||
const uint16_t text_x = (uint16_t)(group_x + UI_MODE_ICON_W + UI_MODE_ICON_TEXT_GAP);
|
||
|
||
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_WR_PIC_Trans(group_x, icon_y, UI_MODE_ICON_W, UI_MODE_ICON_H, icon, BLACK);
|
||
LCD_ShowChinese_AutoAlign(
|
||
text_x, (uint16_t)(text_x + text_w - 1),
|
||
text_y,
|
||
text,
|
||
LCD_ALIGN_LEFT,
|
||
UI_MODE_TEXT_COLOR,
|
||
BLACK,
|
||
1,
|
||
UI_MODE_FONT_SIZE
|
||
);
|
||
}
|
||
|
||
void UI_DrawModeSelectScreen(void)
|
||
{
|
||
UI_ClearFocus();
|
||
s_mode_select_focus = 0;
|
||
pCurrentTouch_Area = Touch_ModeSelect_Areas;
|
||
|
||
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[] = {
|
||
// Xmin, Xmax, Ymin, Ymax, flag, ID, action
|
||
{ 10, 229, 40, 126, 0, 0, GUI_MODE_SELECT3, NULL }, //<2F><><EFBFBD><EFBFBD>
|
||
{ 10, 229, 132, 218, 1, 0, GUI_MODE_SELECT1, NULL }, //????/<2F><><EFBFBD><EFBFBD>
|
||
{ 10, 229, 224, 310, 2, 0, GUI_MODE_SELECT2, NULL }, //רҵ/ר???
|
||
};
|
||
|
||
#define TOUCH_AREA_MODE_SELECT_NUM (sizeof(Touch_ModeSelect_Areas)/sizeof(Touch_AreaTypeDef))
|
||
|
||
/* Timbre_index <20><><EFBFBD><EFBFBD> midi_tables.h <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||
extern uint8_t channel;
|
||
extern uint8_t level;
|
||
extern bool powon;
|
||
extern bool InModeFlag;
|
||
extern int16_t MIC_VOL_MAP[10];
|
||
extern int8_t delta;
|
||
extern STRING_MIDI USE_MIDI;
|
||
void LoadConfig()
|
||
{
|
||
SendProgramChangeMidiEvent(0,Timbre_index[mGuiData[GUI_TIMBRE_SELECT].Current]);
|
||
|
||
uint8_t val_127 = (faders[0].val * 127) / 20;
|
||
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);
|
||
|
||
SendVolumeChangeMidiEvent(0,faders[1].val);
|
||
|
||
AW816_Set_Volume(MIC_VOL_MAP[faders[2].val]);
|
||
|
||
AW816_Set_Reverb(faders[3].val * 10);
|
||
}
|
||
|
||
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;
|
||
// <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>
|
||
switch(ID)
|
||
{
|
||
case 0:
|
||
if(mGuiData[GUI_AUTOBAND_SW].Current)
|
||
{
|
||
ADDRESS = 0x0009EB5F;
|
||
}
|
||
else
|
||
{
|
||
ADDRESS = 0x0001B8F0;
|
||
}
|
||
|
||
MenuPage_SongMode_Proc();
|
||
|
||
break;
|
||
case 1:
|
||
if(mGuiData[GUI_AUTOBAND_SW].Current)
|
||
{
|
||
ADDRESS = 0x0009EB5F;
|
||
}
|
||
else
|
||
{
|
||
// ADDRESS = 0x0001B8F0;
|
||
ADDRESS = 0x00000000;
|
||
}
|
||
MenuPage_ExpertMode_Proc();
|
||
break;
|
||
case 2:
|
||
ADDRESS = 0x0009598F;
|
||
MenuPage_FreeMode_Proc();
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
extern uint8_t bat_init_done;
|
||
void IdleProcess(DisplayTaskMessage_Type msg)
|
||
{
|
||
uint8_t vol;
|
||
switch (msg.MessageType)
|
||
{
|
||
case MSG_ID_POWER_ON :
|
||
LCD_BLK_Set();
|
||
LCD_FillByColor(0, 0, 240, 320, WHITE);
|
||
LCD_WR_PIC_FROM_FLASH(40, 80, 168, 155, 0x00000000);
|
||
BSP_SelectAdcChannel(6);
|
||
wk_delay_ms(1000);
|
||
LoadConfig();
|
||
vol = ADC_ReadChannel(ADC_CHANNEL_1)>>5;
|
||
if (vol <= 5) level = 0;
|
||
else if (vol <= 35) level = 1;
|
||
else if (vol <= 65) level = 2;
|
||
else if (vol <= 95) level = 3;
|
||
else if (vol <= 115) level = 4;
|
||
else level = 5;
|
||
Send_volume(vol);
|
||
|
||
UI_DrawModeSelectScreen();
|
||
TM1629D_AllLedOn(LED_COLOR_G);
|
||
TM1629D_UpdateDisplay(0);
|
||
StartTouchTask();
|
||
StartScanTask();
|
||
break;
|
||
|
||
case MSG_ID_POWER_OFF:
|
||
/* 关机:熄屏 + 关背光 */
|
||
LCD_BLK_Clr();
|
||
LCD_FillByColor(0, 0, 240, 320, BLACK);
|
||
break;
|
||
|
||
case MSG_ID_CHARG:
|
||
Show_Battery_Icon(msg.ID);
|
||
break;
|
||
|
||
case MSG_ID_TOUCH:
|
||
for(uint8_t k=0; k<TOUCH_AREA_MODE_SELECT_NUM; k++)
|
||
{
|
||
if( msg.HiByte >= Touch_ModeSelect_Areas[k].x_min && msg.HiByte <= Touch_ModeSelect_Areas[k].x_max &&
|
||
msg.LoByte >= Touch_ModeSelect_Areas[k].y_min && msg.LoByte <= Touch_ModeSelect_Areas[k].y_max )
|
||
{
|
||
Touch_Mode_Select_Action(Touch_ModeSelect_Areas[k].Flag,Touch_ModeSelect_Areas[k].ID,k);
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
|
||
case MSG_ID_BATTERY_VALUE:
|
||
Draw_Status_Battery_Icon(msg.ID);
|
||
break;
|
||
|
||
case MSG_ID_POWOFF_CHARG:
|
||
{
|
||
static bool flag = 0;
|
||
if(flag == 0)
|
||
{
|
||
BSP_MainPowerEnable(1);
|
||
LCD_WR_REG(0x29); //Display on
|
||
|
||
LCD_WR_PIC_FROM_FLASH(40, 50, 160, 190, 0x0000CB70);
|
||
LCD_BLK_Set();
|
||
flag = 1;
|
||
}
|
||
if(usb_charging_state)
|
||
{
|
||
uint8_t Info[10] = {0,};
|
||
sprintf ((char*)Info, "%d%%", msg.ID);
|
||
LCD_ShowString_AutoAlign(0,240,250,Info,LCD_ALIGN_CENTER,WHITE,BLACK,0,28);
|
||
}
|
||
//else
|
||
//BSP_MainPowerEnable(0);
|
||
}
|
||
break;
|
||
|
||
case MSG_ID_EC_VOL:
|
||
{
|
||
//LCD_ShowString(200, 0, Num_To_String(msg.DataU16[1],buff,3), RED, WHITE, 16, 0);
|
||
uint8_t vol = msg.ID;
|
||
if (vol <= 5) level = 0;
|
||
else if (vol <= 35) level = 1;
|
||
else if (vol <= 65) level = 2;
|
||
else if (vol <= 95) level = 3;
|
||
else if (vol <= 115) level = 4;
|
||
else level = 5;
|
||
Draw_Volume_Bar(5, 5, level, 1, WHITE, GRAY);
|
||
uint8_t mMasterSysExVolume[12] = { 0xF0, 0x41, 0x00, 0x42, 0x12, 0x40, 0x00, 0x04, 0x64, 0x00, 0x00,0xF7};
|
||
memset(mMasterSysExVolume+8,msg.ID,1);
|
||
SendMidiDataToDreamDSP(mMasterSysExVolume,12);
|
||
ResetAutoPowerCount();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|