Control TouchScreen ADS7843

Dependents:   Touch_Example Example_Menu_LCD_TFT

Files at this revision

API Documentation at this revision

Comitter:
Suky
Date:
Fri Feb 04 03:00:35 2011 +0000
Parent:
0:5d8d6a976b8b
Commit message:

Changed in this revision

Touch.h Show annotated file Show diff for this revision Revisions of this file
diff -r 5d8d6a976b8b -r 63a925e2a3d2 Touch.h
--- a/Touch.h	Sun Jan 16 14:08:38 2011 +0000
+++ b/Touch.h	Fri Feb 04 03:00:35 2011 +0000
@@ -15,7 +15,7 @@
 ///////////////////////////////////////////////////////////////////////////
 ////                                                                   ////
 ////                                                                   ////
-////        (C) Copyright 201 www.micros-designs.com.ar                ////
+////        (C) Copyright 2011 www.micros-designs.com.ar               ////
 //// Este código puede ser usado, modificado y distribuido libremente  ////
 //// sin eliminar esta cabecera y  sin garantía de ningún tipo.        ////
 ////                                                                   ////
@@ -46,43 +46,43 @@
     MyTouch.vTestTouchPanel(&Coordenadas);
     // Coordenadas dentro del rango de pantalla LCD:
     if((Coordenadas.x>TOUCH_X_MIN && Coordenadas.x<TOUCH_X_MAX) && (Coordenadas.y>TOUCH_Y_MIN && Coordenadas.y<TOUCH_Y_MAX)){
-	    // Cambio de coordenada y escala:
-	    Temp=Coordenadas.y;
-	    Coordenadas.y=((float)((255-TOUCH_X_MIN)-Coordenadas.x)*(320.0/(TOUCH_X_MAX-TOUCH_X_MIN)));
-	    Coordenadas.x=((float)(Temp-TOUCH_Y_MIN)*(240.0/(TOUCH_Y_MAX-TOUCH_Y_MIN)));
-	    kbhit_irq=1;
+        // Cambio de coordenada y escala:
+        Temp=Coordenadas.y;
+        Coordenadas.y=((float)((255-TOUCH_X_MIN)-Coordenadas.x)*(320.0/(TOUCH_X_MAX-TOUCH_X_MIN)));
+        Coordenadas.x=((float)(Temp-TOUCH_Y_MIN)*(240.0/(TOUCH_Y_MAX-TOUCH_Y_MIN)));
+        kbhit_irq=1;
     }
 }
 // **********************************************************************
 int main(){
 
     //MyTouch.vInitADS7843(USE_12BITS,NULL);
-	MyTouch.vInitADS7843(USE_8BITS,&vISRTouchIRQ);
+    MyTouch.vInitADS7843(USE_8BITS,&vISRTouchIRQ);
 
-	Led1=0;
-	Led2=0;
+    Led1=0;
+    Led2=0;
 
-	while(1){
-		Led2=!Led2;
-		if(kbhit_irq==1){
-			kbhit_irq=0;
-			if((Coordenadas.x<235 && Coordenadas.x>135) && (Coordenadas.y<320 && Coordenadas.y>250)){
-				Led1=!Led1;
-			}
-		}
-		wait_ms(300);
-	}
+    while(1){
+        Led2=!Led2;
+        if(kbhit_irq==1){
+            kbhit_irq=0;
+            if((Coordenadas.x<235 && Coordenadas.x>135) && (Coordenadas.y<320 && Coordenadas.y>250)){
+                Led1=!Led1;
+            }
+        }
+        wait_ms(300);
+    }
 }
 // **********************************************************************
 */
 #include "mbed.h"
 // **********************************************************************
-#define USE_12BITS			12
-#define USE_8BITS			8
-#define ENABLE_INTERRUPT	1
-#define DISABLE_INTERRUPT	0
+#define USE_12BITS            12
+#define USE_8BITS            8
+#define ENABLE_INTERRUPT    1
+#define DISABLE_INTERRUPT    0
 // **********************************************************************
-typedef unsigned short     		UINT_COORDxy;
+typedef unsigned short             UINT_COORDxy;
 typedef struct {
     UINT_COORDxy    x;
     UINT_COORDxy    y;
@@ -91,20 +91,20 @@
 class TouchScreenADS7843 {
 public:
     TouchScreenADS7843(PinName PIN_SDO,PinName PIN_SDI,PinName PIN_CLK,PinName PIN_CS,PinName PIN_IRQ);
-    virtual void vInitADS7843(unsigned char Bits,void (*fptr)(void));
-    virtual void vSetResolution(unsigned char Bits);
-    virtual void vTestTouchPanel(TOUCH_DATA *Data);
-    virtual void vEnableSetInterrupt(void (*fptr)(void));
-    virtual void vDisableInterrupt(void);
-    virtual bool bReadPinIRQ(void);
+    void vInitADS7843(unsigned char Bits,void (*fptr)(void));
+    void vSetResolution(unsigned char Bits);
+    void vTestTouchPanel(TOUCH_DATA *Data);
+    void vEnableSetInterrupt(void (*fptr)(void));
+    void vDisableInterrupt(void);
+    bool bReadPinIRQ(void);
 protected:
-#define 	__delay_CLK_ADS7843() 	wait_us(1)
-#define 	ADS7843_READ_X_8        0x98 // IRQ Enable     
-#define 	ADS7843_READ_Y_8        0xD8
-#define 	ADS7843_READ_X_12       0x90 // IRQ Enable
-#define 	ADS7843_READ_Y_12       0xD0
-    DigitalOut 	_PIN_SDI,_PIN_CS,_PIN_CLK;
-    DigitalIn 	_PIN_SDO,_PIN_IRQ;
+#define     __delay_CLK_ADS7843()     wait_us(1)
+#define     ADS7843_READ_X_8        0x98 // IRQ Enable     
+#define     ADS7843_READ_Y_8        0xD8
+#define     ADS7843_READ_X_12       0x90 // IRQ Enable
+#define     ADS7843_READ_Y_12       0xD0
+    DigitalOut     _PIN_SDI,_PIN_CS,_PIN_CLK;
+    DigitalIn     _PIN_SDO,_PIN_IRQ;
     InterruptIn ADS7843_Event_Touch;
     unsigned char Resolution;
     virtual UINT_COORDxy ADS7843WriteAndReadData(unsigned char Data);