Test code for the touch display, should output the number 12.

Dependencies:   SPI_TFT_ILI9341 TFT_fonts mbed

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

Files at this revision

API Documentation at this revision

Comitter:
JHutchinson
Date:
Wed May 24 13:53:20 2017 +0000
Parent:
9:6b60556b4cdf
Commit message:
Code slimmed down so we have the necessary components

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6b60556b4cdf -r 0352f75f87c1 main.cpp
--- a/main.cpp	Wed May 24 13:37:07 2017 +0000
+++ b/main.cpp	Wed May 24 13:53:20 2017 +0000
@@ -1,4 +1,3 @@
-// example to test the TFT Display from Mikroelectronika
 
 #include "stdio.h"
 #include "mbed.h"
@@ -9,94 +8,19 @@
 #include "Arial28x28.h"
 #include "font_big.h"
 
-
 Serial pc (USBTX,USBRX);
 
 // the display has a backlight switch on board
-DigitalOut LCD_LED(PTA13);   // may not be needed on mikroelectronika board
-DigitalOut pwr(PTD7); // ditto
+DigitalOut LCD_LED(PTA13);   
+DigitalOut pwr(PTD7); 
 
 // the TFT is connected to SPI pin 5-7
 //SPI_TFT_ILI9341 TFT(p5, p6, p7, p8, p9, p10,"TFT"); // mosi, miso, sclk, cs, reset, dc for lpc1768
 SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTD5, PTD0, PTA13,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z
-//NB better combination to use a coherent 2x4 block for lcd
-//   SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTA16, PTA17, PTC16,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z
-//   DigitalOut LCD_LED(PTC17);
-int touching=0;
-
-// Subroutine to read the x location of the touch point
-// need to set x+ to 3V and ground x- then read analogue voltage on ym
-//nb need to add a check for actual touch as opposed to random crap
-int readX()
-{
-    int delta=0,xv1=0,xv2=0,k=0;
-
-    AnalogIn yp(PTB3);
-    AnalogIn ym(PTB2);
-    DigitalOut xp(PTB0);
-    DigitalOut xm(PTB1);
-
-    xp=1; // set positive sdie of x high
-    xm=0;
-    // dont need to do anyhting to set low side as it should be fine.
-    // but do need to disconnect yp
-    //yp.PinMode(PullNone)
-    for(k=0; k<10; k++) { // make 10 readings to average
-        xv1+=(int)ym.read_u16();  // get value
-        xv2+=(int)yp.read_u16(); // get other value
-    }
-    delta=abs(xv2-xv1)/10;
-    if(delta<300) touching=1;
-    else touching=0;
-    pc.printf("delta=%d \t %d\n\r",delta,touching);
-    xp=0;
-    xm=0;
-    return(xv2/10); //maybe better to return the average of both....
-}
-// subroutine to read y values - has different pin functions ..
-int readY()
-{
-    DigitalOut yp(PTB3);
-    DigitalOut ym(PTB2);
-    AnalogIn xp(PTB0);
-    AnalogIn xm(PTB1);
-
-    yp=1; // set positive sdie of x high
-    ym=0;
-    // dont need to do anyhting to set low side as it should be fine.
-    // but do need to disconnect yp
-    //yp.PinMode(PullNone)
-    int yval=(int)xm.read_u16();  // get value
-
-    yp=0;
-    ym=0;
-    return(yval);
-
-}
-
-void drawbuttons()
-{
-    TFT.fillrect(0,0,50,50,Red);
-    TFT.fillrect(50,0,100,50,Green);
-    TFT.fillrect(100,0,150,50,Blue);
-    TFT.fillrect(150,0,200,50,White);
-    TFT.fillrect(200,0,240,50,Black);
-
-    TFT.rect(0,0,50,50,White);
-    TFT.rect(50,0,100,50,White);
-    TFT.rect(100,0,150,50,White);
-    TFT.rect(150,0,200,50,White);
-    TFT.rect(200,0,240,50,White);
-
-}
-
 
 int main()
 {
-    pc.baud(115200);
     pwr=1;
-    wait(0.2);
-
 
     LCD_LED = 1;            // backlight on
 
@@ -105,14 +29,13 @@
     TFT.background(Black);    // set background to black
     TFT.foreground(White);    // set chars to white
     TFT.cls();                // clear the screen
-
-    //first show the 4 directions
+    
     TFT.set_orientation(0);
     TFT.background(Black);
     TFT.cls();
 
-    TFT.set_font((unsigned char*) Arial12x12);
-    TFT.locate(0,0);
-    printf(" 0 Hello Mbed 0");
+    TFT.set_font((unsigned char*) Arial28x28);
+    TFT.locate(1,1);
+    printf("12");
     
     }
\ No newline at end of file