日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

嵌入式单片机高级篇(二)Stm32F103电阻触摸屏

發(fā)布時(shí)間:2024/1/18 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 嵌入式单片机高级篇(二)Stm32F103电阻触摸屏 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Stm32F103電阻觸摸屏

1、原理:
lcd屏與觸摸屏中間有支撐點(diǎn)將兩層導(dǎo)電涂料隔開(kāi),當(dāng)某點(diǎn)按下時(shí),使得兩層涂料接觸,平常絕緣的兩層導(dǎo)電層在觸摸點(diǎn)位置就有了一個(gè)接觸,控制器偵測(cè)到這個(gè)接通后,其中一面導(dǎo)電層接通У軸方向的5Ⅴ均勻電壓場(chǎng),另一導(dǎo)電層將接觸點(diǎn)的電壓引至控制卡進(jìn)行A/D轉(zhuǎn)換,得到電壓值后與5Ⅴ相比即可得觸摸點(diǎn)的у軸坐標(biāo),同理得出Χ軸的坐標(biāo)
2、驅(qū)動(dòng)芯片XPT2046:
(1)采用SPI三線制通信接口
(2)原理框圖:
利用控制邏輯控制四個(gè)MOS管導(dǎo)通和截止,從而實(shí)現(xiàn)測(cè)量按下的x軸坐標(biāo)以及按下的Y軸坐標(biāo)(XN,YN,XP,YP接觸摸屏)
(3)管腳:
BUSY:高電平,忙
~CS:低電平有效
DIN:上升沿采集數(shù)據(jù)
DCLK:時(shí)鐘線
~PENIRQ:筆接觸引腳,低電平有效
DOUT:下降沿準(zhǔn)備數(shù)據(jù)
(4)時(shí)序圖:
順序圖:
時(shí)序圖:

第一,確認(rèn)初始狀態(tài):
~CS:高電平
DCLK:低電平
DIN:低電平
第二,MCU發(fā)送8位數(shù)據(jù)給XPT2046,XPT2046返回16位數(shù)據(jù)給MCU
根據(jù)時(shí)序圖寫(xiě)偽代碼:

unsigned char SPI_WriteReadByte(unsigned char dat) { unsigned char i = 0; unsigned char temp = 0; unsigned short read_data = 0x00; CS=0; for(i=0;i<8;i++) {SCK=0;temp=((dat&0x80)==0x80)?1:0;dat= dat<<1; SI=temp;SCK=1;//XPT2046開(kāi)始讀數(shù)據(jù)}SCK=0;SCK=1;//此周期是為了過(guò)濾忙信號(hào) for(i=0;i<16;i++) {SCK=0;//xpt2046準(zhǔn)備數(shù)據(jù)delayus(1);//延時(shí),為了使xpt2046將數(shù)據(jù)準(zhǔn)備好SCK=1;//上升沿,MCU開(kāi)始準(zhǔn)備讀取數(shù)據(jù)read_data <<=1;read_data|=(unsigned char)SO; }SCK=0;CS=1; return (read_data>>=4); }

(5)命令:
測(cè)量Y軸坐標(biāo):ox90;測(cè)量X軸坐標(biāo):0xD0;
3、觸摸屏的驅(qū)動(dòng)程序思路:
(1)硬件連接:
(2)程序設(shè)計(jì)思路:

4、電阻式觸摸屏校正:
(1)目的:為了讓觸摸屏和LCD屏建立連接關(guān)系,在觸摸屏上對(duì)應(yīng)圖標(biāo)按下,表示當(dāng)前真的在圖標(biāo)位置按下。
(2)LCD和觸摸屏屬于線性坐標(biāo)系
(3)LCD屏與觸摸屏的線性坐標(biāo)系的原點(diǎn)不在同一位置,且線性關(guān)系不一樣
(4)LCD坐標(biāo):x:0-320 y:0-480;觸摸屏坐標(biāo):x:0-4096 y:0-4096
(5)當(dāng)前兩個(gè)坐標(biāo)系中,X=ax+b;Y=cy+d;需要計(jì)算的值為a、b、c和d。利用一條橫線的兩個(gè)點(diǎn)可求出a和b;利用一條豎線的兩個(gè)點(diǎn)可求出c和d。
計(jì)算公式,求a、b為例(c、d同理):X1=ax1+b;X2=ax2+b;a=(X1-X2)/(x1-x2);b=((X1-X2)-a(x1-x2))/2
具體程序:

tp_dev.xfac=(float)(lcddev.width-40)/(pos_temp[1][0]-pos_temp[0][0]);//得到xfac tp_dev.xoff=(lcddev.width-tp_dev.xfac*(pos_temp[1][0]+pos_temp[0][0]))/2;//得到xoff tp_dev.yfac=(float)(lcddev.height-40)/(pos_temp[2][1]-pos_temp[0][1]);//得到y(tǒng)fac tp_dev.yoff=(lcddev.height-tp_dev.yfac*(pos_temp[2][1]+pos_temp[0][1]))/2;//得到y(tǒng)off

(6)讀取xy坐標(biāo)取平均值程序(讀取5次舍棄最小值與最大值取平均從而提高精度):

u16 TP_Read_XOY(u8 xy) {u16 i, j;u16 buf[5];u16 sum=0;u16 temp;for(i=0;i<5;i++)buf[i]=TP_Read_AD(xy); for(i=0;i<4; i++)//排序{for(j=i+1;j<5;j++){if(buf[i]>buf[j])//升序排列{temp=buf[i];buf[i]=buf[j];buf[j]=temp;}}} sum=0;for(i=1;i<5-1;i++)sum+=buf[i];temp=sum/(3);return temp; }

(7)限定誤差范圍提高精度程序:

//讀取x,y坐標(biāo) //最小值不能少于100. //x,y:讀取到的坐標(biāo)值 //返回值:0,失敗;1,成功。 u8 TP_Read_XY(u16 *x,u16 *y) {u16 xtemp,ytemp; xtemp=TP_Read_XOY(CMD_RDX);ytemp=TP_Read_XOY(CMD_RDY); //if(xtemp<100||ytemp<100)return 0;//讀數(shù)失敗*x=xtemp;*y=ytemp;return 1;//讀數(shù)成功 } //連續(xù)2次讀取觸摸屏IC,且這兩次的偏差不能超過(guò) //ERR_RANGE,滿足條件,則認(rèn)為讀數(shù)正確,否則讀數(shù)錯(cuò)誤. //該函數(shù)能大大提高準(zhǔn)確度 //x,y:讀取到的坐標(biāo)值 //返回值:0,失敗;1,成功。 #define ERR_RANGE 50 //誤差范圍 u8 TP_Read_XY2(u16 *x,u16 *y) {u16 x1,y1;u16 x2,y2;u8 flag; flag=TP_Read_XY(&x1,&y1); if(flag==0)return(0);flag=TP_Read_XY(&x2,&y2); if(flag==0)return(0); if(((x2<=x1&&x1<x2+ERR_RANGE)||(x1<=x2&&x2<x1+ERR_RANGE))//前后兩次采樣在+-50內(nèi)&&((y2<=y1&&y1<y2+ERR_RANGE)||(y1<=y2&&y2<y1+ERR_RANGE))){*x=(x1+x2)/2;*y=(y1+y2)/2;return 1;}else return 0; }

(8)觸摸按鍵掃描程序:

u8 TP_Scan(u8 tp) { if(PEN==0)//有按鍵按下{if(tp)TP_Read_XY2(&tp_dev.x[0],&tp_dev.y[0]);//讀取物理坐標(biāo)else if(TP_Read_XY2(&tp_dev.x[0],&tp_dev.y[0]))//讀取屏幕坐標(biāo){tp_dev.x[0]=tp_dev.xfac*tp_dev.x[0]+tp_dev.xoff;//將結(jié)果轉(zhuǎn)換為屏幕坐標(biāo)tp_dev.y[0]=tp_dev.yfac*tp_dev.y[0]+tp_dev.yoff; } if((tp_dev.sta&TP_PRES_DOWN)==0)//之前沒(méi)有被按下{ tp_dev.sta=TP_PRES_DOWN|TP_CATH_PRES;//按鍵按下 tp_dev.x[4]=tp_dev.x[0];//記錄第一次按下時(shí)的坐標(biāo)tp_dev.y[4]=tp_dev.y[0]; } }else{if(tp_dev.sta&TP_PRES_DOWN)//之前是被按下的{tp_dev.sta&=~(1<<7);//標(biāo)記按鍵松開(kāi) }else//之前就沒(méi)有被按下{tp_dev.x[4]=0;tp_dev.y[4]=0;tp_dev.x[0]=0xffff;tp_dev.y[0]=0xffff;} }return tp_dev.sta&TP_PRES_DOWN;//返回當(dāng)前的觸屏狀態(tài) }

(9)電阻觸摸屏校正程序:

void TP_Adjust(void) { u16 pos_temp[4][2];//坐標(biāo)緩存值u8 cnt=0; u16 d1,d2;u32 tem1,tem2;double fac; u16 outtime=0;cnt=0; POINT_COLOR=BLUE;BACK_COLOR =WHITE;LCD_Clear(WHITE);//清屏 POINT_COLOR=RED;//紅色 LCD_Clear(WHITE);//清屏 POINT_COLOR=BLACK;LCD_ShowString(40,40,160,100,16,(u8*)TP_REMIND_MSG_TBL);//顯示提示信息TP_Drow_Touch_Point(20,20,RED);//畫(huà)點(diǎn)1 tp_dev.sta=0;//消除觸發(fā)信號(hào) tp_dev.xfac=0;//xfac用來(lái)標(biāo)記是否校準(zhǔn)過(guò),所以校準(zhǔn)之前必須清掉!以免錯(cuò)誤 while(1)//如果連續(xù)10秒鐘沒(méi)有按下,則自動(dòng)退出{tp_dev.scan(1);//掃描物理坐標(biāo)if((tp_dev.sta&0xc0)==TP_CATH_PRES)//按鍵按下了一次(此時(shí)按鍵松開(kāi)了.){ outtime=0; tp_dev.sta&=~(1<<6);//標(biāo)記按鍵已經(jīng)被處理過(guò)了.pos_temp[cnt][0]=tp_dev.x[0];pos_temp[cnt][1]=tp_dev.y[0];cnt++; switch(cnt){ case 1: TP_Drow_Touch_Point(20,20,WHITE); //清除點(diǎn)1 TP_Drow_Touch_Point(lcddev.width-20,20,RED); //畫(huà)點(diǎn)2break;case 2:TP_Drow_Touch_Point(lcddev.width-20,20,WHITE); //清除點(diǎn)2TP_Drow_Touch_Point(20,lcddev.height-20,RED); //畫(huà)點(diǎn)3break;case 3:TP_Drow_Touch_Point(20,lcddev.height-20,WHITE); //清除點(diǎn)3TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,RED); //畫(huà)點(diǎn)4break;case 4: //全部四個(gè)點(diǎn)已經(jīng)得到//對(duì)邊相等tem1=abs(pos_temp[0][0]-pos_temp[1][0]);//x1-x2tem2=abs(pos_temp[0][1]-pos_temp[1][1]);//y1-y2tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,2的距離tem1=abs(pos_temp[2][0]-pos_temp[3][0]);//x3-x4tem2=abs(pos_temp[2][1]-pos_temp[3][1]);//y3-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到3,4的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05||d1==0||d2==0)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}tem1=abs(pos_temp[0][0]-pos_temp[2][0]);//x1-x3tem2=abs(pos_temp[0][1]-pos_temp[2][1]);//y1-y3tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,3的距離tem1=abs(pos_temp[1][0]-pos_temp[3][0]);//x2-x4tem2=abs(pos_temp[1][1]-pos_temp[3][1]);//y2-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到2,4的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}//正確了//對(duì)角線相等tem1=abs(pos_temp[1][0]-pos_temp[2][0]);//x1-x3tem2=abs(pos_temp[1][1]-pos_temp[2][1]);//y1-y3tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,4的距離tem1=abs(pos_temp[0][0]-pos_temp[3][0]);//x2-x4tem2=abs(pos_temp[0][1]-pos_temp[3][1]);//y2-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到2,3的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}//正確了//計(jì)算結(jié)果tp_dev.xfac=(float)(lcddev.width-40)/(pos_temp[1][0]-pos_temp[0][0]);//得到xfac tp_dev.xoff=(lcddev.width-tp_dev.xfac*(pos_temp[1][0]+pos_temp[0][0]))/2;//得到xofftp_dev.yfac=(float)(lcddev.height-40)/(pos_temp[2][1]-pos_temp[0][1]);//得到y(tǒng)factp_dev.yoff=(lcddev.height-tp_dev.yfac*(pos_temp[2][1]+pos_temp[0][1]))/2;//得到y(tǒng)off if(abs(tp_dev.xfac)>2||abs(tp_dev.yfac)>2)//觸屏和預(yù)設(shè)的相反了.{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1LCD_ShowString(40,26,lcddev.width,lcddev.height,16,"TP Need readjust!");tp_dev.touchtype=!tp_dev.touchtype;//修改觸屏類型.if(tp_dev.touchtype)//X,Y方向與屏幕相反{CMD_RDX=0X90;CMD_RDY=0XD0; }else //X,Y方向與屏幕相同{CMD_RDX=0XD0;CMD_RDY=0X90; } continue;} POINT_COLOR=BLUE;LCD_Clear(WHITE);//清屏LCD_ShowString(35,110,lcddev.width,lcddev.height,16,"Touch Screen Adjust OK!");//校正完成delay_ms(1000);TP_Save_Adjdata(); LCD_Clear(WHITE);//清屏 return;//校正完成 }}delay_ms(10);outtime++;if(outtime>1000){TP_Get_Adjdata();break;} } }

5、程序源碼(正點(diǎn)原子):
(1)touch.h

#ifndef __TOUCH_H__ #define __TOUCH_H__ #include "sys.h" #include "ott2001a.h" #include "gt9147.h" #include "ft5206.h" // //本程序只供學(xué)習(xí)使用,未經(jīng)作者許可,不得用于其它任何用途 //ALIENTEK STM32開(kāi)發(fā)板 //觸摸屏驅(qū)動(dòng)(支持ADS7843/7846/UH7843/7846/XPT2046/TSC2046/OTT2001A/GT9147/FT5206等)代碼 //正點(diǎn)原子@ALIENTEK //技術(shù)論壇:www.openedv.com //創(chuàng)建日期:2015/1/15 //版本:V1.0 //版權(quán)所有,盜版必究。 //Copyright(C) 廣州市星翼電子科技有限公司 2009-2019 //All rights reserved //#define TP_PRES_DOWN 0x80 //觸屏被按下 #define TP_CATH_PRES 0x40 //有按鍵按下了 #define CT_MAX_TOUCH 5 //電容屏支持的點(diǎn)數(shù),固定為5點(diǎn)//觸摸屏控制器 typedef struct {u8 (*init)(void); //初始化觸摸屏控制器u8 (*scan)(u8); //掃描觸摸屏.0,屏幕掃描;1,物理坐標(biāo); void (*adjust)(void); //觸摸屏校準(zhǔn) u16 x[CT_MAX_TOUCH]; //當(dāng)前坐標(biāo)u16 y[CT_MAX_TOUCH]; //電容屏有最多5組坐標(biāo),電阻屏則用x[0],y[0]代表:此次掃描時(shí),觸屏的坐標(biāo),用//x[4],y[4]存儲(chǔ)第一次按下時(shí)的坐標(biāo). u8 sta; //筆的狀態(tài) //b7:按下1/松開(kāi)0; //b6:0,沒(méi)有按鍵按下;1,有按鍵按下. //b5:保留//b4~b0:電容觸摸屏按下的點(diǎn)數(shù)(0,表示未按下,1表示按下) /觸摸屏校準(zhǔn)參數(shù)(電容屏不需要校準(zhǔn))// float xfac; float yfac;short xoff;short yoff; //新增的參數(shù),當(dāng)觸摸屏的左右上下完全顛倒時(shí)需要用到. //b0:0,豎屏(適合左右為X坐標(biāo),上下為Y坐標(biāo)的TP) // 1,橫屏(適合左右為Y坐標(biāo),上下為X坐標(biāo)的TP) //b1~6:保留. //b7:0,電阻屏 // 1,電容屏 u8 touchtype; }_m_tp_dev;extern _m_tp_dev tp_dev; //觸屏控制器在touch.c里面定義//電阻/電容屏芯片連接引腳 #define PEN PFin(10) //PF10 INT #define DOUT PBin(2) //PB2 MISO #define TDIN PFout(9) //PF9 MOSI #define TCLK PBout(1) //PB1 SCLK #define TCS PFout(11) //PF11 CS //電阻屏函數(shù) void TP_Write_Byte(u8 num); //向控制芯片寫(xiě)入一個(gè)數(shù)據(jù) u16 TP_Read_AD(u8 CMD); //讀取AD轉(zhuǎn)換值 u16 TP_Read_XOY(u8 xy); //帶濾波的坐標(biāo)讀取(X/Y) u8 TP_Read_XY(u16 *x,u16 *y); //雙方向讀取(X+Y) u8 TP_Read_XY2(u16 *x,u16 *y); //帶加強(qiáng)濾波的雙方向坐標(biāo)讀取 void TP_Drow_Touch_Point(u16 x,u16 y,u16 color);//畫(huà)一個(gè)坐標(biāo)校準(zhǔn)點(diǎn) void TP_Draw_Big_Point(u16 x,u16 y,u16 color); //畫(huà)一個(gè)大點(diǎn) void TP_Save_Adjdata(void); //保存校準(zhǔn)參數(shù) u8 TP_Get_Adjdata(void); //讀取校準(zhǔn)參數(shù) void TP_Adjust(void); //觸摸屏校準(zhǔn) void TP_Adj_Info_Show(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2,u16 x3,u16 y3,u16 fac);//顯示校準(zhǔn)信息 //電阻屏/電容屏 共用函數(shù) u8 TP_Scan(u8 tp); //掃描 u8 TP_Init(void); //初始化#endif

(2)touch.c

#include "touch.h" #include "lcd.h" #include "delay.h" #include "stdlib.h" #include "math.h" #include "24cxx.h" _m_tp_dev tp_dev= {TP_Init,TP_Scan,TP_Adjust,0,0, 0,0,0,0, 0,0, }; //默認(rèn)為touchtype=0的數(shù)據(jù). u8 CMD_RDX=0XD0; u8 CMD_RDY=0X90;//SPI寫(xiě)數(shù)據(jù) //向觸摸屏IC寫(xiě)入1byte數(shù)據(jù) //num:要寫(xiě)入的數(shù)據(jù) void TP_Write_Byte(u8 num) { u8 count=0; for(count=0;count<8;count++) { if(num&0x80)TDIN=1; else TDIN=0; num<<=1; TCLK=0; delay_us(1);TCLK=1; //上升沿有效 } } //SPI讀數(shù)據(jù) //從觸摸屏IC讀取adc值 //CMD:指令 //返回值:讀到的數(shù)據(jù) u16 TP_Read_AD(u8 CMD) { u8 count=0; u16 Num=0; TCLK=0; //先拉低時(shí)鐘 TDIN=0; //拉低數(shù)據(jù)線TCS=0; //選中觸摸屏ICTP_Write_Byte(CMD);//發(fā)送命令字delay_us(6);//ADS7846的轉(zhuǎn)換時(shí)間最長(zhǎng)為6usTCLK=0; delay_us(1); TCLK=1; //給1個(gè)時(shí)鐘,清除BUSYdelay_us(1); TCLK=0; for(count=0;count<16;count++)//讀出16位數(shù)據(jù),只有高12位有效 { Num<<=1; TCLK=0; //下降沿有效 delay_us(1); TCLK=1;if(DOUT)Num++; } Num>>=4; //只有高12位有效.TCS=1; //釋放片選 return(Num); } //讀取一個(gè)坐標(biāo)值(x或者y) //連續(xù)讀取READ_TIMES次數(shù)據(jù),對(duì)這些數(shù)據(jù)升序排列, //然后去掉最低和最高LOST_VAL個(gè)數(shù),取平均值 //xy:指令(CMD_RDX/CMD_RDY) //返回值:讀到的數(shù)據(jù) u16 TP_Read_XOY(u8 xy) {u16 i, j;u16 buf[5];u16 sum=0;u16 temp;for(i=0;i<5;i++)buf[i]=TP_Read_AD(xy); for(i=0;i<4; i++)//排序{for(j=i+1;j<5;j++){if(buf[i]>buf[j])//升序排列{temp=buf[i];buf[i]=buf[j];buf[j]=temp;}}} sum=0;for(i=1;i<5-1;i++)sum+=buf[i];temp=sum/(3);return temp; } //讀取x,y坐標(biāo) //最小值不能少于100. //x,y:讀取到的坐標(biāo)值 //返回值:0,失敗;1,成功。 u8 TP_Read_XY(u16 *x,u16 *y) {u16 xtemp,ytemp; xtemp=TP_Read_XOY(CMD_RDX);ytemp=TP_Read_XOY(CMD_RDY); //if(xtemp<100||ytemp<100)return 0;//讀數(shù)失敗*x=xtemp;*y=ytemp;return 1;//讀數(shù)成功 } //連續(xù)2次讀取觸摸屏IC,且這兩次的偏差不能超過(guò) //ERR_RANGE,滿足條件,則認(rèn)為讀數(shù)正確,否則讀數(shù)錯(cuò)誤. //該函數(shù)能大大提高準(zhǔn)確度 //x,y:讀取到的坐標(biāo)值 //返回值:0,失敗;1,成功。 #define ERR_RANGE 50 //誤差范圍 u8 TP_Read_XY2(u16 *x,u16 *y) {u16 x1,y1;u16 x2,y2;u8 flag; flag=TP_Read_XY(&x1,&y1); if(flag==0)return(0);flag=TP_Read_XY(&x2,&y2); if(flag==0)return(0); if(((x2<=x1&&x1<x2+ERR_RANGE)||(x1<=x2&&x2<x1+ERR_RANGE))//前后兩次采樣在+-50內(nèi)&&((y2<=y1&&y1<y2+ERR_RANGE)||(y1<=y2&&y2<y1+ERR_RANGE))){*x=(x1+x2)/2;*y=(y1+y2)/2;return 1;}else return 0; } // //與LCD部分有關(guān)的函數(shù) //畫(huà)一個(gè)觸摸點(diǎn) //用來(lái)校準(zhǔn)用的 //x,y:坐標(biāo) //color:顏色 void TP_Drow_Touch_Point(u16 x,u16 y,u16 color) {POINT_COLOR=color;LCD_DrawLine(x-12,y,x+13,y);//橫線LCD_DrawLine(x,y-12,x,y+13);//豎線LCD_DrawPoint(x+1,y+1);LCD_DrawPoint(x-1,y+1);LCD_DrawPoint(x+1,y-1);LCD_DrawPoint(x-1,y-1);LCD_Draw_Circle(x,y,6);//畫(huà)中心圈 } //畫(huà)一個(gè)大點(diǎn)(2*2的點(diǎn)) //x,y:坐標(biāo) //color:顏色 void TP_Draw_Big_Point(u16 x,u16 y,u16 color) { POINT_COLOR=color;LCD_DrawPoint(x,y);//中心點(diǎn) LCD_DrawPoint(x+1,y);LCD_DrawPoint(x,y+1);LCD_DrawPoint(x+1,y+1); } // //觸摸按鍵掃描 //tp:0,屏幕坐標(biāo);1,物理坐標(biāo)(校準(zhǔn)等特殊場(chǎng)合用) //返回值:當(dāng)前觸屏狀態(tài). //0,觸屏無(wú)觸摸;1,觸屏有觸摸 u8 TP_Scan(u8 tp) { if(PEN==0)//有按鍵按下{if(tp)TP_Read_XY2(&tp_dev.x[0],&tp_dev.y[0]);//讀取物理坐標(biāo)else if(TP_Read_XY2(&tp_dev.x[0],&tp_dev.y[0]))//讀取屏幕坐標(biāo){tp_dev.x[0]=tp_dev.xfac*tp_dev.x[0]+tp_dev.xoff;//將結(jié)果轉(zhuǎn)換為屏幕坐標(biāo)tp_dev.y[0]=tp_dev.yfac*tp_dev.y[0]+tp_dev.yoff; } if((tp_dev.sta&TP_PRES_DOWN)==0)//之前沒(méi)有被按下{ tp_dev.sta=TP_PRES_DOWN|TP_CATH_PRES;//按鍵按下 tp_dev.x[4]=tp_dev.x[0];//記錄第一次按下時(shí)的坐標(biāo)tp_dev.y[4]=tp_dev.y[0]; } }else{if(tp_dev.sta&TP_PRES_DOWN)//之前是被按下的{tp_dev.sta&=~(1<<7);//標(biāo)記按鍵松開(kāi) }else//之前就沒(méi)有被按下{tp_dev.x[4]=0;tp_dev.y[4]=0;tp_dev.x[0]=0xffff;tp_dev.y[0]=0xffff;} }return tp_dev.sta&TP_PRES_DOWN;//返回當(dāng)前的觸屏狀態(tài) } // //保存在EEPROM里面的地址區(qū)間基址,占用14個(gè)字節(jié)(RANGE:SAVE_ADDR_BASE~SAVE_ADDR_BASE+13) #define SAVE_ADDR_BASE 40 //保存校準(zhǔn)參數(shù) void TP_Save_Adjdata(void) {AT24CXX_Write(SAVE_ADDR_BASE,(u8*)&tp_dev.xfac,14); //強(qiáng)制保存&tp_dev.xfac地址開(kāi)始的14個(gè)字節(jié)數(shù)據(jù),即保存到tp_dev.touchtypeAT24CXX_WriteOneByte(SAVE_ADDR_BASE+14,0X0A); //在最后,寫(xiě)0X0A標(biāo)記校準(zhǔn)過(guò)了 } //得到保存在EEPROM里面的校準(zhǔn)值 //返回值:1,成功獲取數(shù)據(jù) // 0,獲取失敗,要重新校準(zhǔn) u8 TP_Get_Adjdata(void) { u8 temp;temp=AT24CXX_ReadOneByte(SAVE_ADDR_BASE+14);//讀取標(biāo)記字,看是否校準(zhǔn)過(guò)! if(temp==0X0A)//觸摸屏已經(jīng)校準(zhǔn)過(guò)了 { AT24CXX_Read(SAVE_ADDR_BASE,(u8*)&tp_dev.xfac,14);//讀取之前保存的校準(zhǔn)數(shù)據(jù) if(tp_dev.touchtype)//X,Y方向與屏幕相反{CMD_RDX=0X90;CMD_RDY=0XD0; }else //X,Y方向與屏幕相同{CMD_RDX=0XD0;CMD_RDY=0X90; } return 1; }return 0; } //提示字符串 u8* const TP_REMIND_MSG_TBL="Please use the stylus click the cross on the screen.The cross will always move until the screen adjustment is completed.";//提示校準(zhǔn)結(jié)果(各個(gè)參數(shù)) void TP_Adj_Info_Show(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2,u16 x3,u16 y3,u16 fac) { POINT_COLOR=RED;LCD_ShowString(40,160,lcddev.width,lcddev.height,16,"x1:");LCD_ShowString(40+80,160,lcddev.width,lcddev.height,16,"y1:");LCD_ShowString(40,180,lcddev.width,lcddev.height,16,"x2:");LCD_ShowString(40+80,180,lcddev.width,lcddev.height,16,"y2:");LCD_ShowString(40,200,lcddev.width,lcddev.height,16,"x3:");LCD_ShowString(40+80,200,lcddev.width,lcddev.height,16,"y3:");LCD_ShowString(40,220,lcddev.width,lcddev.height,16,"x4:");LCD_ShowString(40+80,220,lcddev.width,lcddev.height,16,"y4:"); LCD_ShowString(40,240,lcddev.width,lcddev.height,16,"fac is:"); LCD_ShowNum(40+24,160,x0,4,16); //顯示數(shù)值LCD_ShowNum(40+24+80,160,y0,4,16); //顯示數(shù)值LCD_ShowNum(40+24,180,x1,4,16); //顯示數(shù)值LCD_ShowNum(40+24+80,180,y1,4,16); //顯示數(shù)值LCD_ShowNum(40+24,200,x2,4,16); //顯示數(shù)值LCD_ShowNum(40+24+80,200,y2,4,16); //顯示數(shù)值LCD_ShowNum(40+24,220,x3,4,16); //顯示數(shù)值LCD_ShowNum(40+24+80,220,y3,4,16); //顯示數(shù)值LCD_ShowNum(40+56,240,fac,3,16); //顯示數(shù)值,該數(shù)值必須在95~105范圍之內(nèi).}//觸摸屏校準(zhǔn)代碼 //得到四個(gè)校準(zhǔn)參數(shù) void TP_Adjust(void) { u16 pos_temp[4][2];//坐標(biāo)緩存值u8 cnt=0; u16 d1,d2;u32 tem1,tem2;double fac; u16 outtime=0;cnt=0; POINT_COLOR=BLUE;BACK_COLOR =WHITE;LCD_Clear(WHITE);//清屏 POINT_COLOR=RED;//紅色 LCD_Clear(WHITE);//清屏 POINT_COLOR=BLACK;LCD_ShowString(40,40,160,100,16,(u8*)TP_REMIND_MSG_TBL);//顯示提示信息TP_Drow_Touch_Point(20,20,RED);//畫(huà)點(diǎn)1 tp_dev.sta=0;//消除觸發(fā)信號(hào) tp_dev.xfac=0;//xfac用來(lái)標(biāo)記是否校準(zhǔn)過(guò),所以校準(zhǔn)之前必須清掉!以免錯(cuò)誤 while(1)//如果連續(xù)10秒鐘沒(méi)有按下,則自動(dòng)退出{tp_dev.scan(1);//掃描物理坐標(biāo)if((tp_dev.sta&0xc0)==TP_CATH_PRES)//按鍵按下了一次(此時(shí)按鍵松開(kāi)了.){ outtime=0; tp_dev.sta&=~(1<<6);//標(biāo)記按鍵已經(jīng)被處理過(guò)了.pos_temp[cnt][0]=tp_dev.x[0];pos_temp[cnt][1]=tp_dev.y[0];cnt++; switch(cnt){ case 1: TP_Drow_Touch_Point(20,20,WHITE); //清除點(diǎn)1 TP_Drow_Touch_Point(lcddev.width-20,20,RED); //畫(huà)點(diǎn)2break;case 2:TP_Drow_Touch_Point(lcddev.width-20,20,WHITE); //清除點(diǎn)2TP_Drow_Touch_Point(20,lcddev.height-20,RED); //畫(huà)點(diǎn)3break;case 3:TP_Drow_Touch_Point(20,lcddev.height-20,WHITE); //清除點(diǎn)3TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,RED); //畫(huà)點(diǎn)4break;case 4: //全部四個(gè)點(diǎn)已經(jīng)得到//對(duì)邊相等tem1=abs(pos_temp[0][0]-pos_temp[1][0]);//x1-x2tem2=abs(pos_temp[0][1]-pos_temp[1][1]);//y1-y2tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,2的距離tem1=abs(pos_temp[2][0]-pos_temp[3][0]);//x3-x4tem2=abs(pos_temp[2][1]-pos_temp[3][1]);//y3-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到3,4的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05||d1==0||d2==0)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}tem1=abs(pos_temp[0][0]-pos_temp[2][0]);//x1-x3tem2=abs(pos_temp[0][1]-pos_temp[2][1]);//y1-y3tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,3的距離tem1=abs(pos_temp[1][0]-pos_temp[3][0]);//x2-x4tem2=abs(pos_temp[1][1]-pos_temp[3][1]);//y2-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到2,4的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}//正確了//對(duì)角線相等tem1=abs(pos_temp[1][0]-pos_temp[2][0]);//x1-x3tem2=abs(pos_temp[1][1]-pos_temp[2][1]);//y1-y3tem1*=tem1;tem2*=tem2;d1=sqrt(tem1+tem2);//得到1,4的距離tem1=abs(pos_temp[0][0]-pos_temp[3][0]);//x2-x4tem2=abs(pos_temp[0][1]-pos_temp[3][1]);//y2-y4tem1*=tem1;tem2*=tem2;d2=sqrt(tem1+tem2);//得到2,3的距離fac=(float)d1/d2;if(fac<0.95||fac>1.05)//不合格{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1TP_Adj_Info_Show(pos_temp[0][0],pos_temp[0][1],pos_temp[1][0],pos_temp[1][1],pos_temp[2][0],pos_temp[2][1],pos_temp[3][0],pos_temp[3][1],fac*100);//顯示數(shù)據(jù) continue;}//正確了//計(jì)算結(jié)果tp_dev.xfac=(float)(lcddev.width-40)/(pos_temp[1][0]-pos_temp[0][0]);//得到xfac tp_dev.xoff=(lcddev.width-tp_dev.xfac*(pos_temp[1][0]+pos_temp[0][0]))/2;//得到xofftp_dev.yfac=(float)(lcddev.height-40)/(pos_temp[2][1]-pos_temp[0][1]);//得到y(tǒng)factp_dev.yoff=(lcddev.height-tp_dev.yfac*(pos_temp[2][1]+pos_temp[0][1]))/2;//得到y(tǒng)off if(abs(tp_dev.xfac)>2||abs(tp_dev.yfac)>2)//觸屏和預(yù)設(shè)的相反了.{cnt=0;TP_Drow_Touch_Point(lcddev.width-20,lcddev.height-20,WHITE); //清除點(diǎn)4TP_Drow_Touch_Point(20,20,RED); //畫(huà)點(diǎn)1LCD_ShowString(40,26,lcddev.width,lcddev.height,16,"TP Need readjust!");tp_dev.touchtype=!tp_dev.touchtype;//修改觸屏類型.if(tp_dev.touchtype)//X,Y方向與屏幕相反{CMD_RDX=0X90;CMD_RDY=0XD0; }else //X,Y方向與屏幕相同{CMD_RDX=0XD0;CMD_RDY=0X90; } continue;} POINT_COLOR=BLUE;LCD_Clear(WHITE);//清屏LCD_ShowString(35,110,lcddev.width,lcddev.height,16,"Touch Screen Adjust OK!");//校正完成delay_ms(1000);TP_Save_Adjdata(); LCD_Clear(WHITE);//清屏 return;//校正完成 }}delay_ms(10);outtime++;if(outtime>1000){TP_Get_Adjdata();break;} } } //觸摸屏初始化 //返回值:0,沒(méi)有進(jìn)行校準(zhǔn) // 1,進(jìn)行過(guò)校準(zhǔn) u8 TP_Init(void) { GPIO_InitTypeDef GPIO_InitStructure;//注意,時(shí)鐘使能之后,對(duì)GPIO的操作才有效//所以上拉之前,必須使能時(shí)鐘.才能實(shí)現(xiàn)真正的上拉輸出RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOF, ENABLE); //使能PB,PF端口時(shí)鐘GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; // PB1端口配置GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOB, &GPIO_InitStructure);//B1推挽輸出GPIO_SetBits(GPIOB,GPIO_Pin_1);//上拉GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; // PB2端口配置GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉輸入GPIO_Init(GPIOB, &GPIO_InitStructure);//B2上拉輸入GPIO_SetBits(GPIOB,GPIO_Pin_2);//上拉 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_9; // F9,PF11端口配置GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOF, &GPIO_InitStructure);//PF9,PF11推挽輸出GPIO_SetBits(GPIOF, GPIO_Pin_11|GPIO_Pin_9);//上拉GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // PF10端口配置GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉輸入GPIO_Init(GPIOF, &GPIO_InitStructure);//PF10上拉輸入GPIO_SetBits(GPIOF,GPIO_Pin_10);//上拉 TP_Read_XY(&tp_dev.x[0],&tp_dev.y[0]);//第一次讀取初始化 AT24CXX_Init(); //初始化24CXXif(TP_Get_Adjdata())return 0;//已經(jīng)校準(zhǔn)else //未校準(zhǔn)?{ LCD_Clear(WHITE); //清屏TP_Adjust(); //屏幕校準(zhǔn) } TP_Get_Adjdata(); return 1; }

(3)main.c

#include "led.h" #include "delay.h" #include "key.h" #include "sys.h" #include "lcd.h" #include "usart.h" #include "24cxx.h" #include "w25qxx.h" #include "touch.h" //清空屏幕并在右上角顯示"RST" void Load_Drow_Dialog(void) {LCD_Clear(WHITE); //清屏 POINT_COLOR=BLUE; //設(shè)置字體為藍(lán)色 LCD_ShowString(lcddev.width-24,0,200,16,16,"RST");//顯示清屏區(qū)域POINT_COLOR=RED; //設(shè)置畫(huà)筆藍(lán)色 } //電容觸摸屏專有部分 //畫(huà)水平線 //x0,y0:坐標(biāo) //len:線長(zhǎng)度 //color:顏色 void gui_draw_hline(u16 x0,u16 y0,u16 len,u16 color) {if(len==0)return;LCD_Fill(x0,y0,x0+len-1,y0,color); } //畫(huà)實(shí)心圓 //x0,y0:坐標(biāo) //r:半徑 //color:顏色 void gui_fill_circle(u16 x0,u16 y0,u16 r,u16 color) { u32 i;u32 imax = ((u32)r*707)/1000+1;u32 sqmax = (u32)r*(u32)r+(u32)r/2;u32 x=r;gui_draw_hline(x0-r,y0,2*r,color);for (i=1;i<=imax;i++) {if ((i*i+x*x)>sqmax)// draw lines from outside {if (x>imax) {gui_draw_hline (x0-i+1,y0+x,2*(i-1),color);gui_draw_hline (x0-i+1,y0-x,2*(i-1),color);}x--;}// draw lines from inside (center) gui_draw_hline(x0-x,y0+i,2*x,color);gui_draw_hline(x0-x,y0-i,2*x,color);} } //兩個(gè)數(shù)之差的絕對(duì)值 //x1,x2:需取差值的兩個(gè)數(shù) //返回值:|x1-x2| u16 my_abs(u16 x1,u16 x2) { if(x1>x2)return x1-x2;else return x2-x1; } //畫(huà)一條粗線 //(x1,y1),(x2,y2):線條的起始坐標(biāo) //size:線條的粗細(xì)程度 //color:線條的顏色 void lcd_draw_bline(u16 x1, u16 y1, u16 x2, u16 y2,u8 size,u16 color) {u16 t; int xerr=0,yerr=0,delta_x,delta_y,distance; int incx,incy,uRow,uCol; if(x1<size|| x2<size||y1<size|| y2<size)return; delta_x=x2-x1; //計(jì)算坐標(biāo)增量 delta_y=y2-y1; uRow=x1; uCol=y1; if(delta_x>0)incx=1; //設(shè)置單步方向 else if(delta_x==0)incx=0;//垂直線 else {incx=-1;delta_x=-delta_x;} if(delta_y>0)incy=1; else if(delta_y==0)incy=0;//水平線 else{incy=-1;delta_y=-delta_y;} if( delta_x>delta_y)distance=delta_x; //選取基本增量坐標(biāo)軸 else distance=delta_y; for(t=0;t<=distance+1;t++ )//畫(huà)線輸出 { gui_fill_circle(uRow,uCol,size,color);//畫(huà)點(diǎn) xerr+=delta_x ; yerr+=delta_y ; if(xerr>distance) { xerr-=distance; uRow+=incx; } if(yerr>distance) { yerr-=distance; uCol+=incy; } } } //5個(gè)觸控點(diǎn)的顏色 const u16 POINT_COLOR_TBL[CT_MAX_TOUCH]={RED,GREEN,BLUE,BROWN,GRED}; //電阻觸摸屏測(cè)試函數(shù) void rtp_test(void) {u8 key;u8 i=0; while(1){key=KEY_Scan(0);tp_dev.scan(0); if(tp_dev.sta&TP_PRES_DOWN) //觸摸屏被按下{ if(tp_dev.x[0]<lcddev.width&&tp_dev.y[0]<lcddev.height){ if(tp_dev.x[0]>(lcddev.width-24)&&tp_dev.y[0]<16)Load_Drow_Dialog();//清除else TP_Draw_Big_Point(tp_dev.x[0],tp_dev.y[0],RED); //畫(huà)圖 }}else delay_ms(10); //沒(méi)有按鍵按下的時(shí)候 if(key==KEY0_PRES) //KEY0按下,則執(zhí)行校準(zhǔn)程序{LCD_Clear(WHITE);//清屏TP_Adjust(); //屏幕校準(zhǔn) Load_Drow_Dialog();}i++;if(i%20==0)LED0=!LED0;} } //電容觸摸屏測(cè)試函數(shù) void ctp_test(void) {u8 t=0;u8 i=0; u16 lastpos[5][2]; //記錄最后一次的數(shù)據(jù) while(1){tp_dev.scan(0);for(t=0;t<CT_MAX_TOUCH;t++){if((tp_dev.sta)&(1<<t)){if(tp_dev.x[t]<lcddev.width&&tp_dev.y[t]<lcddev.height){if(lastpos[t][0]==0XFFFF){lastpos[t][0] = tp_dev.x[t];lastpos[t][1] = tp_dev.y[t];}lcd_draw_bline(lastpos[t][0],lastpos[t][1],tp_dev.x[t],tp_dev.y[t],2,POINT_COLOR_TBL[t]);//畫(huà)線lastpos[t][0]=tp_dev.x[t];lastpos[t][1]=tp_dev.y[t];if(tp_dev.x[t]>(lcddev.width-24)&&tp_dev.y[t]<16){Load_Drow_Dialog();//清除}}}else lastpos[t][0]=0XFFFF;}delay_ms(5);i++;if(i%20==0)LED0=!LED0;} }int main(void){ delay_init(); //延時(shí)函數(shù)初始化 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級(jí)分組為組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)uart_init(115200); //串口初始化為115200LED_Init(); //LED端口初始化LCD_Init(); KEY_Init(); tp_dev.init();POINT_COLOR=RED;//設(shè)置字體為紅色 LCD_ShowString(60,50,200,16,16,"ELITE STM32"); LCD_ShowString(60,70,200,16,16,"TOUCH TEST"); LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");LCD_ShowString(60,110,200,16,16,"2015/1/11");LCD_ShowString(60,130,200,16,16,"Press KEY0 to Adjust"); if(tp_dev.touchtype!=0XFF)LCD_ShowString(60,130,200,16,16,"Press KEY0 to Adjust");//電阻屏才顯示delay_ms(1500);Load_Drow_Dialog(); if(tp_dev.touchtype&0X80)ctp_test(); //電容屏測(cè)試else rtp_test(); //電阻屏測(cè)試 }

6、原理總結(jié):
觸摸屏被按下時(shí),兩層導(dǎo)電層導(dǎo)電,通過(guò)adc、spi可以讀取觸摸屏的x、y坐標(biāo)(0-4095),x、y的坐標(biāo)與LCD屏的坐標(biāo)可以通過(guò)公式X=ax+b計(jì)算得出;系數(shù)a、b可以通過(guò)在LCD屏上設(shè)置已知的四個(gè)點(diǎn)計(jì)算得出,同時(shí)這四個(gè)點(diǎn)也可以校準(zhǔn)觸摸屏。

總結(jié)

以上是生活随笔為你收集整理的嵌入式单片机高级篇(二)Stm32F103电阻触摸屏的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。