예제 #1
0
//----读取触摸点坐标-----------------------------------------------------------
//功能: 读取stmpe811采集到的触摸点坐标,如果有多点,则平均之
//参数: touch_data,采集到的坐标
//返回: 1=触摸笔按下,0=触摸笔提起,
//-----------------------------------------------------------------------------
static ufast_t read_touch_data(struct SingleTouchMsg *touch_data)
{
     static s32 x=0,y=0,z=0;

    touch_data->display = NULL;
    if(ts_is_down())
    {

        x =ts_get_x_data_raw();
        y =ts_get_y_data_raw();
        z =1;
        ts_translate_data(&x,&y);
        touch_data->x =x;
        touch_data->y =y;
        touch_data->z = z;

        return 1;
    }
    else
    {
        touch_data->z = 0;
        return 0;
    }

}
예제 #2
0
static bool_t   ts_get_data_raw(s32 *x,s32 *y)
{
    if(ts_is_down())
    {
        x=ts_get_x_data_raw();
        y=ts_get_y_data_raw();
        return true;
    }
    return false;
}
예제 #3
0
//----读取触摸点坐标-----------------------------------------------------------
//功能: 读取stmpe811采集到的触摸点坐标,如果有多点,则平均之
//参数: touch_data,采集到的坐标
//返回: 1=触摸笔按下,0=触摸笔提起,
//-----------------------------------------------------------------------------
static ufast_t read_touch_data(struct tagSingleTouchMsg *touch_data)
{
	 static s32 x=0,y=0,z=0;

	if(ts_is_down())
	{

		x =ts_get_x_data_raw();
		y =ts_get_y_data_raw();
		z =1;
		ts_translate_data(&x,&y);
		touch_data->x =x;
		touch_data->y =y;
        touch_data->z = z;

        return 1;

	}
	MouseInput(x,y,0);
	return 0;

}
예제 #4
0
//----触摸屏校准---------------------------------------------------------------
//功能: 触摸屏的尺寸可能与液晶可显示区域不完全一致,安装也可能有偏差,需要计算
//      校准系数和偏移量。为获得更高精度,使用定点小数。
//参数: display_name,本触摸屏对应的显示器名(资源名)
//返回: 无
//-----------------------------------------------------------------------------
void touch_ratio_adjust(struct GkWinRsc *desktop)
{

    struct SingleTouchMsg touch_xyz0,touch_xyz1;
    FILE *touch_init;
    s32 limit_left,limit_top,limit_right,limit_bottom,pen_down_time,step;

    if((touch_init = fopen("sys:\\touch_init.dat","r")) != NULL)
    {

        fread(&ts_cfg_data,sizeof(TS_CFG_DATA),1,touch_init);
    }
    else
    {
        limit_left = desktop->left;
        limit_top = desktop->top;
        limit_right = desktop->right;
        limit_bottom = desktop->bottom;
    //    GK_ApiCreateGkwin(desktop,desktop,limit_left,limit_top,limit_right,limit_bottom,
    //                      CN_COLOR_WHITE,CN_WINBUF_BUF,"&tg_touch_adjust",CN_R3_SRCCOPY,0);
    //    GK_ApiSetPrio(desktop,-1,CN_GK_SYNC);
        GK_ApiFillWin(desktop,CN_COLOR_WHITE,0);

        GK_ApiDrawText(desktop,NULL,NULL,limit_left+10,limit_top+50,
                            "触摸屏矫正",21,CN_COLOR_BLUE,CN_R2_COPYPEN,0);
        GK_ApiDrawText(desktop,NULL,NULL,limit_left+10,limit_top+70,
                            "请准确点击十字交叉点",21,CN_COLOR_BLUE,CN_R2_COPYPEN,0);

        step=0;
        while(step<4)
        {
            s32 adx,ady;

            if(step>0)
            {
                clr_cursor(desktop,ts_cal_ref_pos[step-1][0],ts_cal_ref_pos[step-1][1]);
            }
            draw_cursor(desktop,ts_cal_ref_pos[step][0],ts_cal_ref_pos[step][1]);

            while(ts_is_down())
            {
                Djy_DelayUs(100*mS);
            }
            pen_down_time=0;
            while(1)
            {
                if(ts_is_down())
                {

                    adx=ts_get_x_data_raw();
                    ady=ts_get_y_data_raw();
                    if(pen_down_time++>5)
                    {
                        break;
                    }
                }
                else
                {
                    pen_down_time=0;
                }
                Djy_DelayUs(100*mS);
            }

            switch(step)
            {
            case 0:
                ts_cfg_data.LUAdx =adx;
                ts_cfg_data.LUAdy =ady;
                break;

            case 1:
                ts_cfg_data.RUAdx =adx;
                ts_cfg_data.RUAdy =ady;
                break;

            case 2:
                ts_cfg_data.RDAdx =adx;
                ts_cfg_data.RDAdy =ady;
                break;

            case 3:
                ts_cfg_data.LDAdx =adx;
                ts_cfg_data.LDAdy =ady;
                break;

            }
            printf("ts_cal[%d]: %04X,%04X\r\n",step,adx,ady);
            step++;
        }

        GK_ApiFillWin(desktop,CN_COLOR_WHITE,0);
        GK_ApiSyncShow(1000*mS);
        while(ts_is_down())
        {
            Djy_DelayUs(100*mS);
        }
        Djy_DelayUs(500*mS);

    //    GK_DestroyWin(desktop);
        touch_init = fopen("sys:\\touch_init.dat","w+");
        fwrite(&ts_cfg_data,sizeof(TS_CFG_DATA),1,touch_init);
    }
    fclose(touch_init);

}