?? process.h
字號:
{
matrix.matrix_point[1].x=matrix.matrix_point[0].x;
matrix.matrix_point[1].y=matrix.matrix_point[0].y-property.pointy;
matrix.matrix_point[2].x=matrix.matrix_point[0].x;
matrix.matrix_point[2].y=matrix.matrix_point[1].y-property.pointy;
matrix.matrix_point[3].x=matrix.matrix_point[0].x+property.pointx;
matrix.matrix_point[3].y=matrix.matrix_point[0].y;
matrix.matrix_point[4].x=matrix.matrix_point[0].x+property.pointx;
matrix.matrix_point[4].y=matrix.matrix_point[1].y;
matrix.matrix_point[5].x=matrix.matrix_point[0].x+property.pointx;
matrix.matrix_point[5].y=matrix.matrix_point[2].y;
}
/*****************translate the blind character*****************/
void translate(char *syllable[],int count_syl)
{
int i; int number; //選擇音節
/*while(SYLLALE_LIST!=EOF)
{
}
while(syl_ret!=NULL)
{
}*/
if(count_syl==0)
printf("sorry!don't find the syllable.\n"); //use language function
else if(count_syl==1)
{
printf("find a syllable.\n");
printf("-%s-\n",syllable[0]);
}
else
{
printf("display all syllables on the touchscreen.\n");
for(i=0;i<count_syl;i++)
{
printf("%d : %s \n",i+1,syllable[i]);
} printf("please choose the number of syllable.\n"); scanf("%d",&number); //while(1) //{ switch(number) { case 1: //syllable[0]) break; case 2: //syllable[1]) break; case 3: if(count_syl>=2) //syllable[2]) break; else printf("ERROR!please input the number again.\n"); default: printf("ERROR!please input the number again.\n"); }
//} }
}
/*--------------int to char 轉換-----------------*/ char to_char(int NO) { return 48+NO; }
/***************receive the points from the touchscreen***********/
/*************** two group of points:poi1 poi2****************/
/*when you click on the screen,the function will save the data include the
value of the X AND the Y,when you touch the touchscreen,the calculagragh
will begin with the 0, when the value is 2,the program will make sure all
the points,and start to process the data,find the right syllables. In the
end, it will initialize all variables.*/
/*----------------the function to receive the points-------------*/
void * point_receive(void * data)
{
TS_RET ts_ret;
int fd,n,i; /* static int j; j=colorchange; if(j) { ShowBitmap(0,0,MY_PICTURE_DISPLAY);
colorchange=0;
} */ ShowBitmap(0,0,MY_PICTURE_DISPLAY);
fd = open(DEVICE_NAME_TOUCH,O_RDONLY);
if (fd<0)
{
printf(" open device error!\n");
exit(1);
}
/*-----------------------test-----------------------*/
/* for(i=0;i<6;i++)
printf("----X:%d----Y:%d----\n",poi1[i].x,poi1[i].y);
for(i=0;i<6;i++)
printf("----X:%d----Y:%d----\n",poi2[i].x,poi2[i].y);
*/
printf("\n--blind points program begin!--\n");
/*-----------------read value of X,Y from the touchscreen-------------*/
while(1)
{
if(buffer.point_rd)
{
n=read(fd,&ts_ret,1);
if(ts_ret.pressure==1)
{
/*if(color) { // ShowBitmap(0,0,MY_PICTURE_DISPLAY); color=0; }*/
pthread_cond_signal(&buffer.timer);
printf("----X:%d----Y:%d----\n",ts_ret.x,ts_ret.y);
ShowBitmapWithTS(ts_ret.x,ts_ret.y,MY_PICTURE_POINT);
if(poi2[0].x==0&&poi2[0].y==0) //think
{
if (count==0)
{
poi1[p1count].x=ts_ret.x;
poi1[p1count].y=ts_ret.y;
p1count++;
}
else
{
if(ts_ret.x<POINTS_TO_POINTS||ts_ret.x-poi1[count-1].x<property.pointx )
{//區分聲方盲點和韻方盲點
poi1[p1count].x=ts_ret.x;
poi1[p1count].y=ts_ret.y;
p1count++;
}
else //exceed the maxnum
{
poi2[p2count].x=ts_ret.x;
poi2[p2count].y=ts_ret.y;
p2count++;
}
}
}
else
{
poi2[p2count].x=ts_ret.x;
poi2[p2count].y=ts_ret.y;
p2count++;
}
count++;
}
/*-----------begin time-----------------------*/
if(ts_ret.pressure==0)
{
buffer.times = 0;
pthread_cond_signal(&buffer.timer);
}
/*---------select the area to quit input---------*/ /*
if(ts_ret.x>STOP_POINT_R_X&&ts_ret.y<STOP_POINT_R_Y)
{
count=0;
p1count=0;
p2count=0;
exec=0;
control = 1;
if(quit_s=1)
{
pthread_cond_signal(&buffer.timer);
}
break;
}
*/
}
}
close(fd);
return NULL;
}
/*----------------the function to process the points------------*/ void * process(void * data ) //caluculate the line and row { pthread_t *th_b_receive=(pthread_t *)data; int i,j; int left ; //the left position int right; //the right position //int up,down; int linenum =0; //the number of line int rownum =0; //the number of row int longnum = 0; //the number of long slash int shortnum = 0; //the number of short slash int long_minus= 0; //the number of long minus slash int short_minus= 0; //the number of short minus slash int fir_poi_line=0; //聲母盲文的首點所在行的點的個數 int fir_poi_row=0; //聲母盲文的首點所在列的點的個數 int sec_poi_line=0; //韻母盲文的首點所在行的點的個數 int sec_poi_row=0; //韻母盲文的首點所在列的點的個數 int fir_poi_exist=0; //聲母盲文是否存在正規矩陣的首點 1表示存在 int sec_poi_exist=0; //韻母盲文是否存在正規矩陣的首點 1表示存在 matrix_set(); /* for(i=0;i<6;i++) { printf("%d matrix->X:%d matrix->Y:%d\n",i+1, matrix.matrix_point[i].x,matrix.matrix_point[i].y); } */ while(1) { int count_syl=0;
int binarynumber1[6]; //盲文 例:101000,哪位為1表示盲文所打的點有效 int binarynumber2[6]; //盲文 例:101000,哪位為1表示盲文所打的點有效
char number1[6]="\0"; //盲文 例:123456 char number2[6]="\0"; //盲文 例:123456 char data[15]="\0"; //包含盲文里的一切信息 // char character[20]="\0"; //漢字輸出
for(i=0;i<6;i++)
{
binarynumber1[i] = 0 ; binarynumber2[i] = 0 ;
} /*-----------------confirm the points by the time-------------------*/ if(exec) { pthread_cancel(*th_b_receive); //pthread_cond_wait(&buffer.exe,&buffer.lock); /*-----------------------test-----------------------*/ for(i=0;i<p1count;i++) printf("1-----X:%d-----Y:%d-----\n",poi1[i].x,poi1[i].y); for(i=0;i<p2count;i++) printf("2-----X:%d-----Y:%d-----\n",poi2[i].x,poi2[i].y); /*----------------------test---------------------------*/ printf("--process begin!--\n"); /* poi1[0].x=827;poi1[0].y=1604; poi1[1].x=1442;poi1[1].y=2775; poi1[2].x=1393;poi1[2].y=1963; // poi1[3].x=3071;poi1[3].y=2731; // poi1[4].x=2972;poi1[4].y=2202; // poi1[1].x=2988;poi1[1].y=1192; */ if(p1count)
for(i=0;i<3;i++)
{
if(!activation(poi1,p1count,i,binarynumber1))
{
continue;
}
else
{
getnumber(binarynumber1,number1); break;
}
}
if(p2count) for(i=0;i<3;i++)
{
if(!activation(poi2,p2count,i,binarynumber2))
{
continue;
}
else
{
getnumber(binarynumber2,number2); break;
}
} printf("number1--%s\n",number1); printf("number2--%s\n",number2); /*---------------calculate the variable :linenum,rownum,longnum, shortnum,long_minus,short_minus,fir_poi_line, fir_poi_row,sec_poi_line,sec_poi_row, fir_poi_exist,sec_poi_exist--------------------*/ if(p1count) { for(i=0;i<SYLLABLE_MAX;i++) if(strcmp(List[i].number,number1)==0) { p1count=List[i].point_num; linenum=List[i].line; rownum=List[i].row; longnum=List[i].longslash; shortnum=List[i].shortslash; long_minus=List[i].longslash_minus; short_minus=List[i].shortslash_minus; fir_poi_line=List[i].head_line_num; fir_poi_row=List[i].head_row_num; fir_poi_exist=List[i].head_exist; break; } if(p2count) { for(i=0;i<SYLLABLE_MAX;i++) if(strcmp(List[i].number,number2)==0) { p2count=List[i].point_num; linenum+=List[i].line; rownum+=List[i].row; longnum+=List[i].longslash; shortnum+=List[i].shortslash; long_minus+=List[i].longslash_minus; short_minus+=List[i].shortslash_minus; sec_poi_line=List[i].head_line_num; sec_poi_row=List[i].head_row_num; sec_poi_exist=List[i].head_exist; break; } } } data[0]=to_char(p1count); data[1]=to_char(p2count); data[2]=to_char(linenum); data[3]=to_char(rownum); data[4]=to_char(longnum); data[5]=to_char(shortnum); data[6]=to_char(long_minus); data[7]=to_char(short_minus); data[8]=to_char(fir_poi_line); data[9]=to_char(fir_poi_row); data[10]=to_char(sec_poi_line); data[11]=to_char(sec_poi_row); data[12]=to_char(fir_poi_exist); data[13]=to_char(sec_poi_exist); data[14]='\0'; ShowBitmap(0,0,MY_PICTURE_DISPLAY); printf("data--%s\n",data); blind_db(data, blind_character); //printf("\ncharacter:%s\n\n",character); // pthread_exit((void *)1); break; /*---------------------find the syllable--------------------------*/ /* left = 0; right = SYLLABLE_MAX - 1; while(left <= right) { int middle = (left+right)/2; if ( p1count < syl_ret[middle].first ) right = middle - 1; else if ( p1count > syl_ret[middle].first ) left = middle + 1; else { if ( p2count < syl_ret[middle].second ) right = middle - 1; else if ( p2count > syl_ret[middle].second ) left = middle + 1; else { if( linenum < syl_ret[middle].line ) right = middle - 1; else if ( linenum > syl_ret[middle].line ) left = middle + 1; else { if ( rownum < syl_ret[middle].row ) right = middle - 1; else if ( rownum > syl_ret[middle].row ) left = middle + 1; else { if(longnum<syl_ret[middle].longslash )
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -