📄 process.h~
字号:
right = middle - 1; else if ( longnum > syl_ret[middle].longslash ) left = middle + 1; else { if( shortnum < syl_ret[middle].shortslash ) right = middle - 1; else if ( shortnum > syl_ret[middle].shortslash ) left = middle + 1; else { if(long_minus<syl_ret[middle].longslash_minus ) right = middle - 1; else if (long_minus >syl_ret[middle].longslash_minus ) left = middle + 1; else { if(short_minus<syl_ret[middle].shortslash_minus ) right = middle - 1; else if (short_minus >syl_ret[middle].shortslash_minus ) left = middle + 1; else { right = middle - 1; left = middle + 1; syllabl[count_syl]=syl_ret[middle].syllable; count_syl++; while(right>=0) { if(p1count==syl_ret[right].first&& p2count==syl_ret[right].second&& linenum==syl_ret[right].line&& rownum==syl_ret[right].row&& longnum==syl_ret[middle].longslash&& shortnum==syl_ret[middle].shortslash&& long_minus==syl_ret[middle].longslash_minus&& short_minus==syl_ret[middle].shortslash_minus) { syllabl[count_syl]=syl_ret[right].syllable; right--; count_syl++; } else break; } while(left<SYLLABLE_MAX) { if(p1count==syl_ret[left].first&& p2count==syl_ret[left].second&& linenum==syl_ret[left].line&& rownum==syl_ret[left].row&& longnum==syl_ret[middle].longslash&& shortnum==syl_ret[middle].shortslash&& long_minus==syl_ret[middle].longslash_minus&& short_minus==syl_ret[middle].shortslash_minus) { syllabl[count_syl]=syl_ret[left].syllable; left++; count_syl++; } else break; } } } } } } } } } }*/ /* for(count_syl=0;count_syl<SYLLABLE_MAX ;count_syl++) { if(syl_ret[count_syl].first==firstnum&&syl_ret[count_syl].second==secondnum&& syl_ret[count_syl].line==linenum&&syl_ret[count_syl].row==rownum) //syllable[count_syl]=syl_ret[count_syl].syllable; } */ // translate(syllabl,count_syl); /*------------reset the variable-----------------*/ /* for(i=0;i<p1count;i++) { poi1[i].x=0; poi1[i].y=0; } for(i=0;i<p2count;i++) { poi2[i].x=0; poi2[i].y=0; }
for(i=0;i<6;i++)
{
binarynumber1[i] = 0 ; binarynumber2[i] = 0 ;
}
count=0; // = 0 p1count=0; // = 0 p2count=0; // = 0 linenum =0; //the number of line = 0 rownum =0; //the number of row = 0 longnum = 0; //the number of long slash = 0 shortnum = 0; //the number of short slash = 0 long_minus= 0; //the number of long minus slash = 0 short_minus= 0; //the number of short minus slash = 0 fir_poi_line=0; //声母盲文的首点所在行的点的个数 = 0 fir_poi_row=0; //声母盲文的首点所在列的点的个数 = 0 sec_poi_line=0; //韵母盲文的首点所在行的点的个数 = 0 sec_poi_row=0; //韵母盲文的首点所在列的点的个数 = 0 fir_poi_exist=0; //声母盲文是否存在正规矩阵的首点 1表示存在 = 0 sec_poi_exist=0; //韵母盲文是否存在正规矩阵的首点 1表示存在 = 0 buffer.sem =1; buffer.point_rd=1; buffer.times=0; exec=0;
//number[6]="\0"; */ } } return NULL; }
/*-------------the function to set the value of property---------*/
void * property_set( void * data)
{
TS_RET ts_ret;
int fd,n;
int i; pthread_t *th_b_receive=(pthread_t *)data;
ShowBitmap(0,0,MY_PICTURE_DISPLAY);
fd = open(DEVICE_NAME_TOUCH,O_RDONLY);
if (fd<0)
{
printf(" open device error!\n");
exit(1);
}
/*----------------test-----------------*/
printf("\n--property value setting beging!--\n");
printf("please input six points and fix the property\n");
/*-----------------read value of X,Y from the touchscreen-------------*/
while(afresh)
{
if(buffer.point_rd)
{
n=read(fd,&ts_ret,1);
if(ts_ret.pressure==1)
{ /* if(color) { //ShowBitmap(0,0,MY_PICTURE_DISPLAY); color=1; }*/ pthread_cond_signal(&buffer.timer);
ShowBitmapWithTS(ts_ret.x,ts_ret.y,MY_PICTURE_POINT);
printf("----X:%d----Y:%d----\n",ts_ret.x,ts_ret.y);
point[count_pro].x=ts_ret.x;
point[count_pro].y=ts_ret.y;
count_pro++;
if(count_pro==6) {
ShowBitmap(0,0,MY_PICTURE_DISPLAY); //color = 1; }
}
if(ts_ret.pressure==0)
{
// usleep(900000);
// pthread_mutex_lock(&buffer.lock);
buffer.times = 0;
pthread_cond_signal(&buffer.timer);
// pthread_mutex_unlock(&buffer.lock);
}
/*-------------select to quit the cycle------------*/ /*
if(ts_ret.x>STOP_POINT_R_X&&ts_ret.y<STOP_POINT_R_Y)
{
count_pro = 0;
control = 1;
if(quit_s=1)
{
pthread_cond_signal(&buffer.timer);
}
break;
} */
}
}
close(fd);
pthread_cancel(*th_b_receive);
/*---------------------analyse and calculate the property--------------*/
if(count_pro == 6)
{
if(point[1].x-ERROR<point[0].x&&point[0].x<point[1].x+ERROR)
{
property.pointx=(abs(point[3].x-point[0].x)+
abs(point[4].x-point[1].x)+
abs(point[5].x-point[2].x))/3;
property.pointy=(abs(point[1].y-point[0].y)+
abs(point[2].y-point[1].y)+
abs(point[4].y-point[3].y)+
abs(point[5].y-point[4].y))/4;
}
if(point[1].y-ERROR<point[0].y&&point[0].y<point[1].y+ERROR)
{
property.pointx=(abs(point[1].x-point[0].x)+
abs(point[3].x-point[2].x)+
abs(point[5].x-point[4].x))/3;
property.pointy=(abs(point[2].y-point[0].y)+
abs(point[4].y-point[2].y)+
abs(point[3].y-point[1].y)+
abs(point[5].y-point[3].y))/4;
}
/*---------------------test------------------*/
//printf("the property value below:\n");
//printf("---pointx:%d----pointy:%d---\n",property.pointx,property.pointy);
}
return NULL;
}
/*--------------judge the time is less to the TIME--------------*/ void * overtime( void * data ) { int i; while(quit_s) { if(exec) { if(buffer.times>TIME) { for(i=0;i<count_pro;i++) printf("%d-----X:%d-----Y:%d-----\n",i,point[i].x,point[i].y); printf("warning!!overtime,please input again(six points).\n");//language /*for(i=0;i<6;i++) { point[i].x=0; point[i].y=0; } */ count_pro=0; buffer.times=0; buffer.sem=1; buffer.point_rd=1; exec=0; } } } return NULL; } void * check_pro( void * data ) { int i; pthread_t *th_e_receive=(pthread_t *)data;
while(1) { if(count_pro==6) { afresh=pro_process(point); if (afresh==1) { for(i=0;i<6;i++) printf("%d-----X:%d-----Y:%d-----\n",i,point[i].x,point[i].y); printf("the value of provery error,please input again.\n"); buffer.sem=1; for(i=0;i<6;i++) { point[i].x=0; point[i].y=0; } count_pro=0; buffer.times=0; //sleep(1); buffer.point_rd=1; } else { quit_s=0; for(i=0;i<6;i++) printf("%d-----X:%d-----Y:%d-----\n",i,point[i].x,point[i].y); printf("the value of proverty has finished!\n"); //language pthread_cancel(*th_e_receive); buffer.times=0; //sleep(1); buffer.sem=1; buffer.point_rd=1; break; } } } } /*----------------judge the value of the property is useful------------*/ int pro_process(POINT point_temp[]) { if(abs(point_temp[1].y-point_temp[0].y)>DEFAULTMINDIS) if( point_temp[1].x - ERROR < point_temp[0].x&&point_temp[0].x < point_temp[1].x + ERROR && point_temp[2].x - ERROR < point_temp[1].x&&point_temp[1].x < point_temp[2].x + ERROR && point_temp[4].x - ERROR < point_temp[3].x&&point_temp[3].x < point_temp[4].x + ERROR && point_temp[5].x - ERROR < point_temp[4].x&&point_temp[4].x < point_temp[5].x + ERROR && point_temp[3].y - ERROR < point_temp[0].y&&point_temp[0].y < point_temp[3].y + ERROR && point_temp[4].y - ERROR < point_temp[1].y&&point_temp[1].y < point_temp[4].y + ERROR && point_temp[5].y - ERROR < point_temp[2].y&&point_temp[2].y < point_temp[5].y + ERROR ) return 0; else return 1; else if( point_temp[2].x - ERROR < point_temp[0].x&&point_temp[0].x < point_temp[2].x + ERROR && point_temp[4].x - ERROR < point_temp[2].x&&point_temp[2].x < point_temp[4].x + ERROR && point_temp[3].x - ERROR < point_temp[1].x&&point_temp[1].x < point_temp[3].x + ERROR && point_temp[5].x - ERROR < point_temp[3].x&&point_temp[3].x < point_temp[5].x + ERROR && point_temp[1].y - ERROR < point_temp[0].y&&point_temp[0].y < point_temp[1].y + ERROR && point_temp[3].y - ERROR < point_temp[2].y&&point_temp[2].y < point_temp[3].y + ERROR && point_temp[5].y - ERROR < point_temp[4].y&&point_temp[4].y < point_temp[5].y + ERROR ) return 0; else return 1; } /*-----------------count the time when release the touchscreen-------*/ void * time_count(void * data) { int i; pthread_t *th_a_receive=(pthread_t *)data; while(1) { if(buffer.sem) { pthread_cond_wait(&buffer.timer,&buffer.lock); buffer.sem=0; buffer.times = 0; } //pthread_mutex_lock(&buffer.lock); sleep(1); //delay 1 second buffer.times++; //OSTimeDly(1500); //delay 1 second //pthread_mutex_unlock(&buffer.lock); printf("---%d---\n",buffer.times-1); if(buffer.times-1>=TIME) { if(data!=NULL) pthread_cancel(*th_a_receive); exec = 1; buffer.sem = 1; ShowBitmap(0,0,MY_PICTURE_DISPLAY); // color=1; } } return NULL; } #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -