<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ucos II+ucGUI+s3c2410+LCD+觸摸屏整合

          ucos II+ucGUI+s3c2410+LCD+觸摸屏整合

          作者: 時(shí)間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

          1) 設(shè)置中斷向量,開中斷:

          void SetTSInterrupt(void)

          {

          rADCDLY = (50000);

          rADCCON = (114)|(ADCPRS6)|(73)|(02)|(01)|(0);

          rADCTSC = (08)|(17)|(16)|(05)|(14)|(03)|(02)|(3);

          pISR_ADC = (U32)TSIrqISR; //

          rINTMSK = ~(BIT_ADC);

          rINTSUBMSK = ~(BIT_SUB_TC);

          }

          2) 中斷處理函數(shù):

          static void TSIrqISR(void)

          {

          int i;

          U32 Pt[6];

          rINTSUBMSK |= (BIT_SUB_ADC|BIT_SUB_TC);

          if(rADCDAT0 0x8000)

          {//抬起

          isDown = 0;

          rADCTSC = 0xff; // Set stylus down interrupt

          TX = -1;

          TY = -1; //抬起觸筆時(shí),TX,TY要值成不大于0的數(shù)

          }

          else //按下

          { isDown = 1;

          rADCTSC=(08)|(07)|(06)|(15)|(14)|(13)|(02)|(1);

          for(i=0;i

          for(i=0;i5;i++) //5 times

          {

          rADCCON|=0x1; // Start X-position conversion

          while(rADCCON 0x1); // Check if Enable_start is low

          while(!(0x8000rADCCON)); // Check ECFLG

          Pt[i]=(0x3ffrADCDAT0);

          }

          Pt[5]=(Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;//多次采樣取平均值

          TX = Pt[5];

          rADCTSC=(08)|(07)|(16)|(15)|(04)|(13)|(02)|(2);

          for(i=0;i

          for(i=0;i5;i++) //5 times

          {

          rADCCON|=0x1; // Start Y-position conversion

          while(rADCCON 0x1); // Check if Enable_start is low

          while(!(0x8000rADCCON)); // Check ECFLG

          Pt[i]=(0x3ffrADCDAT1);

          }

          Pt[5]=(Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;// 多次采樣取平均值

          TY = Pt[5];

          rADCTSC=(18)|(17)|(16)|(05)|(14)|(03)|(02)|(3);

          }

          //cprintf(%d,%dn,TX,TY);

          OSMboxPost(TouchMbox, 0);//向處理觸摸進(jìn)程發(fā)消息

          rSUBSRCPND |= BIT_SUB_TC;

          rINTSUBMSK = ~(BIT_SUB_TC); // Unmask sub interrupt (TC)

          ClearPending(BIT_ADC);

          }

          3) 需要的量:

          #define LOOP 1

          #define ADCPRS 0x27

          int TX=0;//觸摸坐標(biāo)x

          int TY=0;//觸摸坐標(biāo)y

          extern OS_EVENT *TouchMbox;

          int isDown;

          4) 觸摸屏校準(zhǔn):

          Ucgui390中,帶有一校準(zhǔn)程序(于TOUCH_Calibrate.c中),可以改寫為我所用(見下文)。

          也可設(shè)置默認(rèn)值,測出左下最小坐標(biāo)minX,minY和右上最大坐標(biāo)maxX,maxY,注意是觸摸坐標(biāo),不是lcd坐標(biāo),如下填寫配置文件GUITouchConf.h:

          #define GUI_TOUCH_AD_LEFT minX

          #define GUI_TOUCH_AD_TOP maxY

          #define GUI_TOUCH_AD_RIGHT maxX

          #define GUI_TOUCH_AD_BOTTOM minY

          #define GUI_TOUCH_SWAP_XY 0

          #define GUI_TOUCH_MIRROR_X 1

          #define GUI_TOUCH_MIRROR_Y 1

          #define TOUCH_NEED_CALIBRATE 0

          3、如下填寫GUIConf.h:

          #define GUI_OS (1) /* Compile with multitasking support */

          #define GUI_SUPPORT_TOUCH (1) /* Support a touch screen (req. win-manager) */

          #define GUI_SUPPORT_UNICODE (1) /* Support mixed ASCII/UNICODE strings */

          #define GUI_SUPPORT_CHINESE (1)

          #define GUI_DEFAULT_FONT GUI_Font6x8

          #define GUI_ALLOC_SIZE 12500 /* Size of dynamic memory ... For WM and memory devices*/

          #define GUI_WINSUPPORT 1 /* Window manager package available */

          #define GUI_SUPPORT_MEMDEV 1 /* Memory devices available */

          #define GUI_SUPPORT_AA 1 /* Anti aliasing available */

          4、ucgui與lcd驅(qū)動(dòng)函數(shù)的連接,即修改LCDWin.c文件:

          在LCDWin.c中,去掉無用的頭文件包含。

          #define SETPIXEL(x, y, c) LCD2410_SetPixel(x, y, c, LCD_DISPLAY_INDEX)

          #define GETPIXEL(x, y) LCD2410_GetPixel(x,y, LCD_DISPLAY_INDEX)

          即將“LCDSIM_XX”改成“LCD2410_XX”,這兩個(gè)函數(shù)位于lcd驅(qū)動(dòng)文件中。

          ……………………………

          #define SETPIXEL(x, y, c)

          if (!_CheckBound(c)) {

          LCD2410_SetPixel(x, y, c, LCD_DISPLAY_INDEX);

          }

          #else

          #define SETPIXEL(x, y, c) LCD2410_SetPixel(x, y, c, LCD_DISPLAY_INDEX)

          #endif

          #define GETPIXEL(x, y) LCD2410_GetPixel(x,y,LCD_DISPLAY_INDEX)

          ……………………………

          static void _XorPixel(int x, int y) {

          unsigned int Index = LCD_L0_GetPixelIndex(x,y);

          LCD2410_SetPixel(x, y, LCD_NUM_COLORS-1-Index, LCD_DISPLAY_INDEX);

          }

          ……………………………

          int LCD_L0_Init(void) {

          return LCD2410_Init();//調(diào)用lcd初始化函數(shù)

          }

          5、某些編譯器(如:ads1.2)不會初始化全局變量,因此做如下事:

          1) 修改如下函數(shù)為:(位于GUICore.c)

          static void _InitContext(GUI_CONTEXT* pContext) {

          memset(pContext,0,sizeof(GUI_CONTEXT));//add



          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();