typedef struct menu_sitem_info_s {
uint8_t osd_type; //0:SpiOSD 1:FontOSD..failed. not using
void (*pPressFun)(U8, U8, U8); //linked function
uint32_t x,y; //start x, start y
uint8_t align; //align type
//struct IMAGE_ITEM_INFO *image; //focused image
//struct IMAGE_ITEM_INFO *image1; //pressed image
IMAGE_ITEM_INFO *image; //focused image
IMAGE_ITEM_INFO *image1; //pressed image
uint8_t image_type; //0:Background, icon, ....., fSOD info
uint8_t win; //upper:fosd, bottom:sosd
uint32_t lut; //lut start offset 1110207 become 9bit
uint8_t up,left,down,right; //navi_key
U16 button_id;//根据数组位置
uint8_t button_mouse_id;//根据按键数量从0(X)开始,根据该ID与设置值对比来显示已被设置的
uint8_t press_button_ID;//附加的按中状态,数组中的位置,显示已经被设置了条目
UIRECTPOINT osd_dest;//触摸区域
} menu_sitem_info_t;
osd_type;//OSD 类型
#define TYPE_SOSD 0 //normal SOSD item
#define TYPE_FOSD 1 //normal FOSD item
#define TYPE_BG 2 //SOSD FIXED Background
#define TYPE_MBG 3 //SOSD MOVING Background
#define TYPE_SLIDE 4 //SOSD Slide area
#define TYPE_BOX 5 //SOSD BOX area
void (*pPressFun)(U8, U8, U8);//链接函数,触摸UI后就指定到这个函数处理,显示触摸UI或触摸后的逻辑处理
uint32_t x,y;//图片在屏幕中显示时,开始画UI的坐标点
uint8_t align;//画UI时相对于屏幕的一种对齐方式
#define ALIGN_TOPLEFT 0
#define ALIGN_TOPMIDDLE 1
#define ALIGN_TOPRIGHT 2
#define ALIGN_CENTER 3
#define ALIGN_BOTTOMLEFT 4
#define ALIGN_BOTTOMRIGHT 5
#define ALIGN_BOTTOMMIDDLE 6
IMAGE_ITEM_INFO *image;//focused image鼠标焦点所在的UI
IMAGE_ITEM_INFO *image1; //pressed image本来位置所需画面的UI
typedef struct __IMAGE_ITEM_INFO_STRUCT__
{
uint8_t type; //(1)有压缩的格式//(0)没压缩的格式
/*0:LUT+Image, 1:Header+LUT+Image, 2:Image Only, 3:LTU Only, 4:Header Only*/
uint32_t addr; /*Absolute Location On SPI Flash*/
IMAGE_INFO *info;
uint8_t alpha; /*Alpha Index, 0xFF:Ignore*///透明属性0x7f全透,
BYTE rledata_cnt; //压缩值
uint16_t w;
uint16_t h;
} IMAGE_ITEM_INFO;
uint8_t image_type; //0:Background, icon, ....., fSOD info
//图片在UI逻辑里的属性,是背景图片、图标图片、数字图片、字体图片
uint8_t win;//选择画UI的窗口
//upper:fosd, bottom:sosd
uint32_t lut;// 两组色表:A:256 B:512 ;可以拆分出来A:128 128 B:256 256
//lut start offset 1110207 become 9bit
uint8_t up,left,down,right; //navi_key
//按键方向所需要画的UI 所在数组的位置 Items[] ;
U16 button_id;//根据数组位置
//本身在数组Items[] 中的位置
uint8_t button_mouse_id;//根据按键数量从0(X)开始,根据该ID与设置值对比来显示已被设置的
uint8_t press_button_ID;//附加的按中状态,数组中的位置,显示已经被设置了条目
UIRECTPOINT osd_dest;//触摸区域
typedef struct
{
WORD left;//边界位置
WORD top;
WORD Right;
WORD Bottom;
} UIRECTPOINT, *LPUIRECTPOINT;
typedef struct menu_page_info_s {
// uint8_t type; //menu_type move_left2right, popup,...
// uint8_t focus; //focused item number
uint8_t select; //current selected item number. for input_page aspect_page...
// uint8_t item_start;
// uint8_t item_total; // for touch area check. not include bg, and select bar.
menu_sitem_info_t *items; //sosd item
// menu_fitem_info_t *texts; //fosd item
} menu_page_info_t;
menu_sitem_info_t *items; //sosd item//画一组逻辑UI 组 所在的数组,
uint8_t select; //初始UI在数组中的位置
typedef void(*CLICKCALLBACK)(U8, U8, U8);//回调函数 触摸后或者按键后调用处理的函数
typedef struct
{
U16 button_id;//数组所在位置
UIRECTPOINT osd_dest;//触摸查询区域
//UIRECTPOINT osd_dest_Aux1;
//UIRECTPOINT BackupBuff_src;
//UIRECTPOINT BackupBuff_src_Aux1;
CLICKCALLBACK pFunItem;//回调处理函数
BYTE uUP;//上下左右确认按键处理 画所在数组位置的UI
BYTE uDN;
BYTE uLEFT;
BYTE uRIGHT;
BYTE uPosIndex;
} GUI_PAGE_ITEM;
typedef struct
{
//DrawPageCALLBACK pFunDrawPage;
GUI_PAGE_ITEM *pItem; //在哪个数组
BYTE button_status; //初始化所画UI的位置
} GUI_PAGE;
for(int i=0;i<=0xfe;i++)//窗口设置透明属性,0~0xFE寄存器//如果要有通透感觉,不要好像有一层东西,
//那么0寄存器就要全透。
{
SpiOsdPixelAlphaAttr_user(SOSD_WIN3,i,0X68);//透明值:0x68;
}
SpiOsdPixelAlphaAttr_user(SOSD_WIN3,0,0X7f); //0寄存器全透
/*******************************************************************************************************/
User_PositionProcess(X_pos,Y_pos,byTouchStatus);//触摸点击处理,触摸UI处理
{
for (i = 0; curr_menu[i].osd_dest.left!= U16_MAX; i++)
{
if (Xpos > curr_menu[i].osd_dest.left
&& Xpos < curr_menu[i].osd_dest.Right)
{
if (Ypos > curr_menu[i].osd_dest.top
&& Ypos < curr_menu[i].osd_dest.Bottom)
{
break;
}
}
}
if (curr_menu[i].osd_dest.left == U16_MAX)
{
return FALSE;
}
FS_key_num=curr_menu[i].button_id;
FS_key_mouse_index=curr_menu[i].button_mouse_id;
if (Action == MSG_ACTION_PRESSED)
{//printf("\r\nACTION_PRESSED");
}
else if (Action == MSG_ACTION_BOUNCE)
{//printf("\r\nACTION_BOUNCE");
}
else if (Action == MSG_ACTION_KEEP)
{//printf("\r\nACTION_KEEP");
}
else if (Action == MSG_ACTION_MOVE)
{//printf("\r\nACTION_MOVE");
}
else if (Action == MSG_ACTION_MOVE_BOUNCE)
{//printf("\r\nACTION_MOVE_BOUNCE");
}
curr_menu[i].pPressFun(0, i, Action);//回调处理函数
return TRUE;
}
void ctp_coord_read(void)
{
// CTP_i2cBurstReadBytes(gGT911_ADR,0x81,0x4e, I2C_buff, 6);
touch_i2cBurstReadBytes(gGT911_adr,0x81,0x4e, I2C_buff, 6);
x_count=I2C_buff[2]|(I2C_buff[3]<<8);
X_pos=x_count;
y_count=I2C_buff[4]|(I2C_buff[5]<<8);
Y_pos=y_count*480/800;
i2C_send_pos_buff[0]=I2C_buff[0];//status
i2C_send_pos_buff[1]=X_pos;//I2C_buff[2];//low x,
i2C_send_pos_buff[2]=X_pos>>8;//I2C_buff[3];//hi x
i2C_send_pos_buff[3]=Y_pos;//I2C_buff[4];//low y
i2C_send_pos_buff[4]=Y_pos>>8;//I2C_buff[5];//hi y
byTouch_buff = I2C_buff[0]&0x87;;
point_num = I2C_buff[0]&0x0f;
I2C_buff[0]=0;//0x7f;//
//CTP_i2cBurstWriteBytes(gGT911_ADR,0x81,0x4e, &I2C_buff[0], 1);
touch_i2cBurstWriteBytes(gGT911_adr,0x81,0x4e, &I2C_buff[0], 1);
}
void TouchMoveDeal(u8 status,u16 x_p,u16 y_p)
{
u8 byTouch_buff;
//u8 byTouchStatus;
static u8 PreTouchStatus =0xff;
static WORD X_POS_count=0xffff;
static WORD Y_POS_count=0xffff;
BYTE x_dir=0,y_dir=0;
BYTE x_value=0,y_value=0;
BYTE move_press=0;
u16 X_POS;
u16 Y_POS;
X_POS = x_p;
Y_POS = y_p;
byTouch_buff = status;
if((byTouch_buff==0))
byTouchStatus=MSG_ACTION_BOUNCE;
else if(byTouch_buff==128&&(PreTouchStatus==MSG_ACTION_KEEP))
byTouchStatus=MSG_ACTION_BOUNCE;
else if(byTouch_buff==129&&(PreTouchStatus==MSG_ACTION_BOUNCE))//if(byTouchStatus==PreTouchStatus)
{
byTouchStatus=MSG_ACTION_PRESSED;
X_POS_count=X_POS;
Y_POS_count=Y_POS;
}
else if(byTouch_buff==129)//if(byTouchStatus==PreTouchStatus)
{
byTouchStatus=MSG_ACTION_KEEP;
}
else
{
byTouchStatus=MSG_ACTION_BOUNCE;
}
if(byTouchStatus==MSG_ACTION_BOUNCE||byTouchStatus==MSG_ACTION_KEEP)
{
if(X_POS_count!=0xffff)
{
if(X_POS>X_POS_count)
{
if((X_POS-X_POS_count)>40)
{
x_dir=TOUCHMOVERIGHT;
x_value=X_POS-X_POS_count;
}
}
else if((X_POS_count-X_POS)>40)
{
x_dir=TOUCHMOVELEFT;
x_value=X_POS_count-X_POS;
}
if(Y_POS>Y_POS_count)
{
if((Y_POS-Y_POS_count)>30)
{
y_dir=TOUCHMOVEDOWN;
y_value=Y_POS-Y_POS_count;
}
}
else if((Y_POS_count-Y_POS)>30)
{
y_dir=TOUCHMOVEUP;
y_value=Y_POS_count-Y_POS;
}
if(x_dir)
{
if(y_dir)
{
if(x_value>(y_value+10))
{
byTouch_moveStatus=x_dir;
move_press=1;
}
else
{
byTouch_moveStatus=y_dir;
move_press=1;
}
}
else
{
byTouch_moveStatus=x_dir;
move_press=1;
}
}
else
{
if(y_dir)
{
byTouch_moveStatus=y_dir;
move_press=1;
}
}
if(!((byTouchStatus==MSG_ACTION_KEEP)&&(move_press==0)))
{
X_POS_count=0xffff;
Y_POS_count=0xffff;
}
}
}
if(PreTouchStatus!=byTouchStatus)
{
Touch_on_Click=1;
PreTouchStatus=byTouchStatus;
if(byTouchStatus==MSG_ACTION_PRESSED)
{
/*
if(!U8Tiemr_connect_press)
{
U8Tiemr_connect_press=250;
connect_press_one=1;
}
else
{
connect_press=1;
byTouch_moveStatus=TOUCHPRESSEDDB;
U8Tiemr_connect_press=0;
connect_press_one=0;
}
*/
}
else if(byTouchStatus==MSG_ACTION_BOUNCE)
{
if(gDoubleClickTimeCnt != 0)
{
byTouch_moveStatus=TOUCHPRESSEDDB;
}
gDoubleClickTimeCnt = 300; //间隔时间
}
}
else if(byTouchStatus==MSG_ACTION_KEEP)
{
Touch_on_Click=1;
}
}
void Process_Double_POS()
{
static uint8_t touch_status = 0;
static uint8_t pre_byTouch_buff = 0;
static uint8_t double_falg = 0;
if(point_num > 0)
{
touch_i2cBurstReadBytes(gGT911_adr,0x81,0x4f, &touch_I2C_buff[1], point_num*8);
X_POS=touch_I2C_buff[3]<<8|touch_I2C_buff[2];
Y_POS= (touch_I2C_buff[5]<<8|touch_I2C_buff[4])*6/10;
X1_POS = (touch_I2C_buff[11]<<8)|touch_I2C_buff[10];
Y1_POS = ((touch_I2C_buff[13]<<8)|touch_I2C_buff[12])*6/10;
}
if(byTouch_buff ==0)
{
;//touch_status=POINT_1_BOUNCE;//POINT_ALL_BOUNCE;
}
else if(byTouch_buff == 0x81 && pre_byTouch_buff==0x00 ||
byTouch_buff == 0x81 && pre_byTouch_buff==0x80)
{
touch_status=POINT_1_PRESSED;
double_falg = 0;
}
else if((byTouch_buff == 0x82 && pre_byTouch_buff==0x81) ||
(byTouch_buff == 0x82 && pre_byTouch_buff==0x80) ||
(byTouch_buff == 0x82 && pre_byTouch_buff==0x0))
{
touch_status=POINT_2_PRESSED;
double_falg = 1;
}
else if(byTouch_buff == 0x81 && pre_byTouch_buff==0x81)
{
touch_status=POINT_1_KEEP;
}
else if(byTouch_buff == 0x82 && pre_byTouch_buff==0x82)
{
touch_status=POINT_2_KEEP;
double_falg = 1;
}
else if(byTouch_buff == 0x81 && pre_byTouch_buff==0x82)
{
touch_status=POINT_2_BOUNCE; //两点,有一点弹起
}
else if(byTouch_buff == 0x80 && pre_byTouch_buff==0x82)
{
touch_status=POINT_ALL_BOUNCE; //
}
else if(byTouch_buff == 0x80 && pre_byTouch_buff==0x81)
{
touch_status=POINT_1_BOUNCE;
}
else if(byTouch_buff == 0x80 && pre_byTouch_buff==0x80)
{
touch_status=POINT_1_BOUNCE;
}
else
{
touch_status=POINT_ALL_BOUNCE;
}
pre_byTouch_buff = byTouch_buff;
}
BOOL User_PositionProcess(WORD Xpos, WORD Ypos, U8 Action)
{
U8 i;
for (i = 0; curr_menu[i].osd_dest.left!= U16_MAX; i++)
{
if (Xpos > curr_menu[i].osd_dest.left
&& Xpos < curr_menu[i].osd_dest.Right)
{
if (Ypos > curr_menu[i].osd_dest.top
&& Ypos < curr_menu[i].osd_dest.Bottom)
{
break;
}
}
}
if (curr_menu[i].osd_dest.left == U16_MAX)
{
return FALSE;
}
FS_key_num=curr_menu[i].button_id;
FS_key_mouse_index=curr_menu[i].button_mouse_id;
if (Action == MSG_ACTION_PRESSED)
{//printf("\r\nACTION_PRESSED");
}
else if (Action == MSG_ACTION_BOUNCE)
{//printf("\r\nACTION_BOUNCE");
}
else if (Action == MSG_ACTION_KEEP)
{//printf("\r\nACTION_KEEP");
}
else if (Action == MSG_ACTION_MOVE)
{//printf("\r\nACTION_MOVE");
}
else if (Action == MSG_ACTION_MOVE_BOUNCE)
{//printf("\r\nACTION_MOVE_BOUNCE");
}
curr_menu[i].pPressFun(0, i, Action);
return TRUE;
}
GUI程序设计框架要点
最新推荐文章于 2022-05-30 18:27:25 发布