基于stm32的简易计算器设计毕业设计论文内容摘要:

pos_temp[4][2]。 //存放4个调试点的坐标值X和Y的数组 u8 t=0。 //记录数组的行 u16 d1,d2。 u32 tem1,tem2。 float fac。 u16 outtime=0。 t=0。 Lcd_Clear_All(WHITE)。 //清屏 Tp_Draw_Adjustpoint(20, 20, amp。 Adjust_pen)。 Lcd_Display_String(100, 120, (char *)Click The Adjust Point To Adjust Touch Pad., amp。 Adjust_pen)。 = 0。 //消除触发信号 // = 0。 //xfac用来标记是否校准过,所以校准之前必须清掉!以免错误 while(1) //如果连续10秒钟没有按下,则自动退出 { Tp_Scan(touchpad_add)。 //扫描物理坐标 if(Adjust_flag == 1) //可以进行测试操作,即按键满足了(按下抬起)的操作 { outtime=0。 Adjust_flag=0。 //测试标志位清0 pos_temp[t][0]=。 pos_temp[t][1]=。 //记录测试点的坐标 t++。 switch(t) { case 1: //得到了第1个测试点 Tp_Draw_Adjustpoint(20,20,amp。 Clear_adjust_pen)。 //清除点1 Tp_Draw_Adjustpoint(460,20,amp。 Adjust_pen)。 //画点2 break。 case 2: //得到了第2个测试点 Tp_Draw_Adjustpoint(460,20,amp。 Clear_adjust_pen)。 //清除点2 Tp_Draw_Adjustpoint(20,300,amp。 Adjust_pen)。 //画点3 break。 case 3: //得到了第3个测试点 Tp_Draw_Adjustpoint(20,300,amp。 Clear_adjust_pen)。 //清除3 Tp_Draw_Adjustpoint(460,300,amp。 Adjust_pen)。 //画点4 break。 case 4: //4个测试点的坐标值已经全部获取 //对边相等 tem1=abs(pos_temp[0][0]pos_temp[1][0])。 //x1x2 tem2=abs(pos_temp[0][1]pos_temp[1][1])。 //y1y2 tem1*=tem1。 tem2*=tem2。 d1=sqrt(tem1+tem2)。 //得到1,2的距离 tem1=abs(pos_temp[2][0]pos_temp[3][0])。 //x3x4 tem2=abs(pos_temp[2][1]pos_temp[3][1])。 //y3y4 tem1*=tem1。 tem2*=tem2。 d2=sqrt(tem1+tem2)。 //得到3,4的距离 fac=(float)d1/d2。 if(fac||fac||d1==0||d2==0) //不合格 { t=0。 //一定注意要清0,重新开始调试 Tp_Draw_Adjustpoint(460,300,amp。 Clear_adjust_pen)。 //清除点4 Tp_Draw_Adjustpoint(20,20,amp。 Adjust_pen)。 //画点1 continue。 //直接跳出本次while循环,重新开始调试 } tem1=abs(pos_temp[0][0]pos_temp[2][0])。 //x1x3 tem2=abs(pos_temp[0][1]pos_temp[2][1])。 //y1y3 tem1*=tem1。 tem2*=tem2。 d1=sqrt(tem1+tem2)。 //得到1,3的距离 tem1=abs(pos_temp[1][0]pos_temp[3][0])。 //x2x4 tem2=abs(pos_temp[1][1]pos_temp[3][1])。 //y2y4 tem1*=tem1。 tem2*=tem2。 d2=sqrt(tem1+tem2)。 //得到2,4的距离 fac=(float)d1/d2。 if(fac||fac)//不合格 { t=0。 //一定注意要清0,重新开始调试 Tp_Draw_Adjustpoint(460,300,amp。 Clear_adjust_pen)。 //清除点4 Tp_Draw_Adjustpoint(20,20,amp。 Adjust_pen)。 //画点1 continue。 //直接跳出本次while循环,重新开始调试 }//正确了 //对角线相等 tem1=abs(pos_temp[1][0]pos_temp[2][0])。 //x1x3 tem2=abs(pos_temp[1][1]pos_temp[2][1])。 //y1y3 tem1*=tem1。 tem2*=tem2。 d1=sqrt(tem1+tem2)。 //得到1,4的距离 tem1=abs(pos_temp[0][0]pos_temp[3][0])。 //x2x4 tem2=abs(pos_temp[0][1]pos_temp[3][1])。 //y2y4 tem1*=tem1。 tem2*=tem2。 d2=sqrt(tem1+tem2)。 //得到2,3的距离 fac=(float)d1/d2。 if(fac||fac)//不合格 { t=0。 //一定注意要清0,重新开始调试 Tp_Draw_Adjustpoint(460,300,amp。 Clear_adjust_pen)。 //清除点4 Tp_Draw_Adjustpoint(20,20,amp。 Adjust_pen)。 //画点1 continue。 //直接跳出本次while循环,重新开始调试 }//正确了 =(float)(48040)/(pos_temp[1][0]pos_temp[0][0])。 //得到xfacx方向的触摸地址与屏幕地址的比例系数 printf(%f\r\n,)。 //打印xfac =(*(pos_temp[1][0]+pos_temp[0][0]))/2。 //得到xoff printf(%d\r\n,)。 //打印xoff =(float)(32040)/(pos_temp[2][1]pos_temp[0][1])。 //得到yfacy方向的触摸地址与屏幕地址的比例系数 printf(%f\r\n,)。 //打印yfac =(*(pos_temp[2][1]+pos_temp[0][1]))/2。 //得到yoff printf(%d\r\n,)。 //打印yoff if(abs()2||abs()2)//触屏和预设的相反了. { t=0。 Lcd_Clear_All(WHITE)。 Lcd_Display_String(100,120, (char *)Adjust Failed, Try Again!, amp。 Adjust_pen)。 Tp_Draw_Adjustpoint(460,300,amp。 Clear_adjust_pen)。 //清除点4 Tp_Draw_Adjustpoint(20,20,amp。 Adjust_pen)。 //画点1 = (==P_DIR_HOR)? P_DIR_VER:P_DIR_HOR。 //修改触屏类型. if() //X,Y方向与屏幕相反 { = 0x90。 = 0xD0。 }else //X,Y方向与屏幕相同 { = 0xD0。 = 0x90。 } continue。 } Lcd_Clear_All(WHITE)。 //清屏 Lcd_Display_String(100,120, (char*)Adjust OK!, amp。 Adjust_pen)。 _delay_ms(1000)。 Lcd_Clear_All(WHITE)。 //清屏 return 0。 //校正完成 } } _delay_ms(10)。 outtime++。 if(outtime1000) { Lcd_Clear_All(WHITE)。 //清屏 Lcd_Display_String(100, 120, (char*)Adjust timeout., amp。 Adjust_pen)。 _delay_ms(1000)。 Lcd_Clear_All(WHITE)。 //清屏 break。 } } return 0。 }include /*定义缓冲区*/struct{ u8 buffer[50]。 u8 size。 }cal。 u8 show_flag=0。 /*屏幕参数*/extern TOUCH_PAD_PARAM Tpad_param。 //键盘u8 table[16]={39。 739。 ,39。 439。 ,39。 139。 ,39。 039。 , 39。 839。 ,39。 539。 ,39。 239。 ,39。 .39。 , 39。 939。 ,39。 639。 ,39。 339。 ,39。 =39。 , 39。 /39。 ,39。 *39。 ,39。 39。 ,39。 +39。 }。 //笔的属性static LCD_PEN pen = { RED, WHITE, P_S32, P_SET_NOBRUSH, P_DIR_HOR }。 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Function: Cal_Clear_All * Description:清显示框函数 * Input: color 颜色 * Output: NULL * Return: NULL * Others: NULL * * * * * * * * * * * * * * * * * * * * * * * * * * * * */static void Cal_Clear_All(u16 color){ int。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。