⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process.h~

📁 it is about embeded system
💻 H~
📖 第 1 页 / 共 4 页
字号:

  /*****************author : DONG Shengdong********************/   /****************** process the points********************/ #ifndef _PROCESS_H #define _PROCESS_H /*--------------------initialize the struction---------------*/ #include  "math.h" #include  "string.h" #include  "loadbmp.h" #include  "blind_ime_more.h"  
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////全局变量以及宏定义////////////////////////////////// /*--------------------initialize the struction---------------*/  #define DEVICE_NAME_TOUCH "/dev/touchscreen/0raw" #define MY_PICTURE_DISPLAY "./res/girl.bmp" #define MY_PICTURE_POINT  "./res/point.bmp" #define TIME                   1 #define DEFAULTLINEDISTANCE    500 #define DEFAULTROWDISTANCE     600 #define SYLLABLE_MAX           43 #define ERROR                  200 #define POINTRADIUS            200                           #define PROPERTY_CLICK_X       600 #define PROPERTY_CLICK_Y       600 #define STOP_POINT_R_X         3000 #define STOP_POINT_R_Y         500 #define POINTS_TO_POINTS       2000   #define MAX_PROPERTY_VALUE     800 #define DEFAULTMINDIS          160 #define TANX_ERROR             0.1 #define BENCHMARK_POINT_X      2000 #define BENCHMARK_POINT_Y      3000 #define DISTANCE_CHANGE_CONSTANT 20 #define DISTANCE_CHANGE        5 #define ANGLE_CHANGE_CONSTANT  5 #define EXTEND_TO                800 #define EXTEND_TO_MIN            200/*************signal of control the time**********/ struct counttime {   pthread_mutex_t lock;   pthread_cond_t timer;   pthread_cond_t exe;   int times;   int sem;   int point_rd; };/*************the struct of proverty*************/ struct PRO{  unsigned short pointx;  unsigned short pointy;   };/*********the information of blind points***********/  typedef struct{  unsigned short x;  unsigned short y;  }POINT;/**************six points matrix******************/  typedef struct {    POINT matrix_point[6];  unsigned short distance_change;  double radian_change;  }MATRIX; /*****read the X and Y of value from touchscreen*****/  typedef struct {  unsigned short pressure;  unsigned short x;  unsigned short y;  unsigned short pad;  }TS_RET; struct counttime buffer;            //instancing the signal struct PRO  property;               //instancing the property POINT poi1[12],poi2[12],point[6]; MATRIX matrix; int count; int p1count;               //the number of  first group int p2count;               //the number of  second group int exec;                  //control the overtime int afresh;              //control the property circle int count_pro;          //the number of points of perperty int quit_s;             //send signal to quit int color;                 //颜色刷新 int colorchange=1; char blind_character[20];  
 /*************the list of syllable***************/ typedef struct {  char number[6];  unsigned short point_num;   //the number of the first group of blind character  unsigned short line;        //the number of line  unsigned short row;         //the number of row  unsigned short longslash;   //the number of long slash  unsigned short shortslash;  //the number of short slash  unsigned short longslash_minus;  //the number of minus long slash  unsigned short shortslash_minus;  //the number of minus short slash  unsigned short head_line_num;  unsigned short head_row_num;  unsigned short head_exist;     }SYL_RET;  SYL_RET List[SYLLABLE_MAX]={	{"12",	  2,  0,	1,  0,	0,  0,	0,  1,	2,	1},	{"13",	  2,  0,	0,  0,	0,  0,	0,  1,	2,	1},	{"14",	  2,  1,	0,  0,	0,  0,	0,  2,	1,	1},	{"15",	  2,  0,	0,  0,	1,  0,	0,  1,	1,	1},	{"16",	  2,  0,	1,  0,	0,  0,	0,  1,	1,	1},	{"24",	  2,  0,	0,  0,	0,  0,	1,  1,	1,	0},	{"34",	  2,  0,	0,  0,	0,  1,	0,  1,	1,	0},	{"123",	  3,  0,	2,  0,	0,  0,	0,  1,	3,	1},	{"124",   3,  1,	1,  0,	0,  0,	1,  2,	2,	1},	{"125",   3,  1,	1,  0,	1,  0,	0,  1,	2,	1},	{"126",	  3,  0,	1,  1,	1,  0,	0,  1,	2,	1},	{"134",	  3,  1,	0,  0,	0,  1,	0,  2,	2,	1},	{"135",	  3,  0,	0,  0,	1,  0,	1,  1,	2,	1},	{"136",	  3,  1,	0,  1,	0,  0,	0,  1,	2,	1},	{"145",	  3,  1,	1,  0,	1,  0,	0,  2,	1,	1},	{"146",	  3,  1,	0,  1,	0,  0,	0,  2,	1,	1},	{"156",	  3,  0,	1,  1,	1,  0,	0,  1,	1,	1},	{"234",	  3,  0,	1,  0,	0,  1,	1,  1,	2,	0},	{"245",	  3,  1,	1,  0,	0,  0,	1,  2,	1,	0},	{"246",	  3,  0,	0,  0,	1,  0,	1,  1,	1,	0},	{"345",	  3,  0,	1,  0,	0,  1,	1,  1,	1,	0},	{"346",	  3,  1,	0,  0,	0,  1,	0,  2,	1,	0},	{"1234",  4,  1,	2,  0,	0,  1,	1,  2,	3,	1},	{"1235",  4,  1,	2,  0,	1,  0,	1,  1,	3,	1},	{"1236",  4,  1,	2,  1,	1,  0,	0,  1,	3,	1},	{"1245",  4,  2,	2,  0,	1,  0,	1,  2,	2,	1},	{"1246",  4,  1,	1,  1,	1,  0,	1,  2,	2,	1},	{"1256",  4,  1,	2,  1,	2,  0,	0,  1,	2,	1},	{"1345",  4,  1,	1,  0,	1,  1,	1,  2,	2,	1},	{"1346",  4,  2,	0,  1,	0,  1,	0,  2,	2,	1},	{"1356",  4,  1,	1,  1,	1,  0,	1,  1,	2,	1},	{"1456",  4,  1,	2,  1,	1,  0,	0,  2,	1,	1},	{"2345",  4,  1,	2,  0,	0,  1,	2,  2,	2,	0},	{"2346",  4,  1,	1,  0,	1,  1,	1,  1,	2,	0},	{"2456",  4,  1,	2,  0,	1,  0,	1,  2,	1,	0},	{"3456",  4,  1,	2,  0,	0,  1,	1,  2,	1,	0},	{"12345", 5,  2,	3,  0,	1,  1,	2,  2,	3,	1},	{"12346", 5,  2,	2,  1,	1,  1,	1,  2,	3,	1},	{"12356", 5,  2,	3,  1,	2,  0,	1,  1,	3,	1},	{"12456", 5,  2,	3,  1,	2,  0,	1,  2,	2,	1},	{"13456", 5,  2,	2,  1,	1,  1,	1,  2,	2,	1},	{"23456", 5,  2,	3,  0,	1,  1,	2,  2,	2,	0},	{"123456",6,  3,	4,  1,	2,  1,	2,  2,	3,	1}  };
/////////////////////////////////////////////////////////////////////////////////////////////////
 /*-------------the head of the function---------*/ void init(); void initpro(); void initpoint();            //initialize the value of points groups is 0 void initmatrix(); void varinit(); int activation(POINT poival[],int pointcount,int aim,int binary[]); void getnumber(int binarynumber[],char number[]); void  matrix_set(); char to_char(int NO); void * point_receive(void * data); void * process(void * data ); void * property_set( void * data); void * overtime( void * data ); void * check_pro( void * data ); int pro_process(POINT point_temp[]); void * time_count(void * data);   ////////////////////////////////////////////////////////////////////////////////////////////// /*-----------the function to initialize the struct value---------*/  void init()  {   pthread_mutex_init(&buffer.lock,NULL); /* mutex ensuring exclusive access to change the value of times */   pthread_cond_init(&buffer.timer,NULL);  /* signaled when times is 0 */   pthread_cond_init(&buffer.exe,NULL);   buffer.times = 0;                       /* the initial value */   buffer.sem = 1;   buffer.point_rd =1;  }  /*-----------the function to initialize value of property--------------*/  void initpro()  {   property.pointx = DEFAULTLINEDISTANCE;   property.pointy = DEFAULTROWDISTANCE;   } /*---------the function to initialize value of matrix points---------*/  void initmatrix()  {      matrix.matrix_point[0].x=BENCHMARK_POINT_X;   matrix.matrix_point[0].y=BENCHMARK_POINT_Y;  } /*------------the function to initialize the value of points----*/  void initpoint()  {   int i;    /*---------------------initialize the POINT---------------------------*/   for(i=0;i<12;i++)   {        poi1[i].x=0;     poi1[i].y=0;     poi2[i].x=0;     poi2[i].y=0;     if(i<6)     {      point[i].x=0;      point[i].y=0;     }   }   }    void varinit()  {    count=0;    p1count=0;               //the number of  first group    p2count=0;               //the number of  second group    exec=0;                  //control the overtime    afresh = 1;              //control the property circle    count_pro  = 0;          //the number of points of perperty    quit_s  = 1;             //send signal to quit    //color=0;                 //颜色刷新    strcpy(blind_character,"\0");  }
 
 ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////功能函数定义///////////////////////////////     /*--------------以首点为基点将盲文点整体平移至正规6点规阵------------*/     /*------matrix为盲文点移动到正规矩阵相应的第n个点 --------*/

  /*----以正规矩阵的首点延长或缩短所打盲文点(除首点)判断是否经过        正规矩阵的其它的点,并确定是哪个点------------------------*/        int activation(POINT poival[],int pointcount,int aim,int binary[])   {  //////////////////////////////////////////////////////////////////////////  ///////////////////////////////变量声明集合/////////////////////////////////     int i,val; ////////////////////循环次数     int pointnum;                //直线延长过程所经过的点数     int pointnumanother;          //第2点和第6点的判断     int poiline;                  //判断盲文是否存在两个点和标准点在同一条直线上     int sign;                    //经过第二点的标志     int two;                    //两次经过第二点的标志     int three;                   //三次经过第二点的标志     int four;                    //四次经过第二点的标志     unsigned short x_temp;       //临时变量     unsigned short y_temp;       //临时变量
     unsigned short x_move;       //盲文点X轴移动的距离
     unsigned short y_move;       //盲文点Y轴移动的距离     unsigned short x_standard;     //正规矩阵的首点的X轴值     unsigned short y_standard;     //正规矩阵的首点的Y轴值     unsigned short x_change;      //延长或缩小所得到的新坐标X值     unsigned short y_change;      //延长或缩小所得到的新坐标Y值     unsigned short max_extend;    //X轴坐标值最大可扩展的数值     unsigned short step_extend;    //X轴坐值一次可扩展的数值     unsigned short divide_1_x;    //盲点中,经过第二点一次时的X值     unsigned short divide_1_y;    //盲点中,经过第二点一次时的Y值     unsigned short divide_2_x;    //盲点中,经过第二点两次时的X值     unsigned short divide_2_y;    //盲点中,经过第二点两次时的Y值     unsigned short divide_3_x;    //盲点中,经过第二点三次时的X值     unsigned short divide_3_y;    //盲点中,经过第二点三次时的Y值     double  dis1;                //当直线延长得到两个点时就比较dis离哪个点最近就激活相应点     double  dis2;                //当直线延长得到两个点时就比较dis离哪个点最近就激活相应点     double A;                   //直线系数 例:Ax+y=B     double B;                   //直线系数 例:Ax+y=B     double distance;              //测试到个点的距离     int binarynumber[6];          //盲文     例:101000,哪位为1表示盲文所打的点有效     POINT poi[6];         /////////////////////////变量初始化     pointnumanother=0;     poiline =0;     two =0;     three =0;     four =0;     for(i=0;i<pointcount;i++)     {       poi[i].x=poival[i].x;       poi[i].y=poival[i].y;     }    
      x_move = poi[0].x - matrix.matrix_point[aim].x;
      y_move = poi[0].y - matrix.matrix_point[aim].y;
  

    for(i=0;i<pointcount;i++)    //盲文整体平移
    {
     
     poi[i].x=poi[i].x-x_move;
     poi[i].y=poi[i].y-y_move;

    }        /*for(i=0;i<6;i++)    printf("m x:%d,m y:%d\n", matrix.matrix_point[i].x,matrix.matrix_point[i].y);*/     for(i=0;i<pointcount;i++)     printf("poi[i].x%d--poi[i].y%d-\n",poi[i].x,poi[i].y);     for(val=1;val<pointcount;val++)      {      ///////////////变量在循环之前赋值        dis1 = 0;        dis2 = 0;	pointnum = 0;          x_standard = matrix.matrix_point[aim].x;        y_standard = matrix.matrix_point[aim].y;        x_change   = x_standard;        y_change   = y_standard;                    x_temp     = poi[val].x;        y_temp     = poi[val].y;        sign=0;        for(i=0;i<6;i++)
		     
           binarynumber[i] = 0 ;      /*-------------------计算直线的系数---------------*/        if(x_standard-x_temp!=0)        {          A = (double)(y_temp-y_standard)/(x_standard-x_temp);	  B = A*x_standard+y_standard;        }        /*-----直线以DISTANCE_CHANGE_CONSTANT为单位延长----*/      /*-----DISTANCE_REDUCE------*/       // printf("A:%f--B:%f\n",A,B);        if(A>15)          {             max_extend=100;             step_extend=1;          }        else if(A>10)          {             max_extend=200;             step_extend=2;          }        else if(A>5)          {             max_extend=400;             step_extend=5;          }        else if(A>3)          {             max_extend=600;             step_extend=10;          }        else if(A>1)          {             max_extend=700;             step_extend=15;          }          else if(A>=0)          {             max_extend=EXTEND_TO;             step_extend=DISTANCE_CHANGE_CONSTANT;          }                else if(A>-1)          {             max_extend=EXTEND_TO;             step_extend=DISTANCE_CHANGE_CONSTANT;          }        else if(A>-3)          {             max_extend=700;             step_extend=15;          }         else if(A>-5)          {             max_extend=600;             step_extend=10;          }                  else if(A>-10)          {             max_extend=400;             step_extend=5;           }        else if(A>=-15)          {             max_extend=200;             step_extend=2;           }        else          {             max_extend=100;             step_extend=1;          }                                            //printf("begin-%d\n",val);        while(x_change-x_standard<=max_extend&&x_standard-x_change<=max_extend)	           {              if(x_standard<x_temp)  //向X轴正方向延长              {                     x_change = x_change+step_extend;	        y_change = B-A*x_change;               // printf("x_change:%d---y_change:%d\n",x_change,y_change);                                        }              else if(x_standard>x_temp) //向X轴负方向延长              {               x_change = x_change-step_extend;	       y_change = B-A*x_change;              // printf("x_change:%d---y_change:%d\n",x_change,y_change);              }              else                    //向Y轴负方向延长              {               x_change = x_standard;               y_change = y_change-DISTANCE_CHANGE_CONSTANT;               if(y_change<1000)                  break;              }              /*                      for(i=0;i<6;i++)              {               distance=sqrt((double)(x_change-matrix.matrix_point[i].x)*                                     (x_change-matrix.matrix_point[i].x)+                                     (y_change-matrix.matrix_point[i].y)*                                     (y_change-matrix.matrix_point[i].y));               printf("distance:%f\n",distance);              }               printf("end\n");             */           /*--------正规矩阵第1个点的区域范围-------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -