Using touch screen features of LCD screen.

Dependencies:   DmTouch_UniGraphic UniGraphic mbed

Fork of DisplayModule24_demo by John Larkin

Revision:
0:2ccd65a72ab8
Child:
1:083257298075
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 14 19:56:13 2015 +0000
@@ -0,0 +1,131 @@
+#include "stdio.h"
+#include "mbed.h"
+#include "string"
+#include "Arial12x12.h"
+#include "Arial24x23.h"
+//#include "Terminal6x8.h"
+#include "Arial43x48_numb.h"
+#include "pict.h"
+
+#include "IST3020.h"
+//#include "UC1608.h"
+//#include "ILI9341.h"
+
+Serial pc(USBTX, USBRX);
+
+IST3020 LCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"LCD"); // Parallel8bit, Port, CS, reset, A0, WR, RD for F302
+//UC1608 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // Spi16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
+//ILI9341 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // Spi16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
+
+Timer t;
+
+unsigned short backgroundcolor=Black;
+unsigned short foregroundcolor=White;
+
+char orient=1;
+int main()
+{
+//    LCD.set_contrast(26);//for uc1608
+ //   LCD.set_contrast(46);//for ist3020
+    LCD.set_orientation(orient);
+    int time;
+    pc.baud (115200);
+    pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000);
+    t.start();
+
+   // LCD.claim(stdout);      // send stdout to the LCD display
+    //LCD.claim(stderr);      // send stderr to the LCD display
+    LCD.background(backgroundcolor);    // set background to black
+    LCD.foreground(foregroundcolor);    // set chars to white
+    LCD.cls();                // clear the screen
+    
+    // mem write/read test
+ /*   LCD.locate(0,0);
+    unsigned short readback;
+    unsigned short colorstep = (0x10000/LCD.width())
+    for(unsigned short i=0; i<LCD.width(); i++) LCD.pixel(i,0,i*colorstep); // write line
+    for(unsigned short i=0; i<LCD.width(); i++) // verify line
+    {
+        readback = LCD.pixelread(i,0);
+        if(readback!=i*colorstep) pc.printf("pix %.4X readback %.4X\r\n", i*colorstep, readback);
+    }
+*/
+    
+    
+    while(1)
+    {
+    LCD.set_orientation((orient++)%4);
+//    LCD.set_orientation(2);
+    LCD.cls();
+    LCD.set_font((unsigned char*) Terminal6x8);
+    LCD.locate(0,0);
+    LCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly");
+    pc.printf("  Display Test \r\n");
+    wait(3);
+    t.reset();
+    LCD.cls();
+    time=t.read_us();
+    LCD.locate(2,55);
+    LCD.printf("cls: %.3fms", (float)time/1000);
+    pc.printf("cls: %.3fms\r\n", (float)time/1000);
+    wait(3);
+    LCD.cls();
+    t.reset();
+    // draw some graphics
+    //LCD.cls();
+    LCD.set_font((unsigned char*) Arial24x23);
+    LCD.locate(10,10);
+    LCD.printf("Test");
+
+    LCD.line(0,0,LCD.width()-1,0,foregroundcolor);
+    LCD.line(0,0,0,LCD.height()-1,foregroundcolor);
+    LCD.line(0,0,LCD.width()-1,LCD.height()-1,foregroundcolor);
+
+    LCD.rect(10,30,50,40,foregroundcolor);
+    LCD.fillrect(60,30,100,40,foregroundcolor);
+
+    LCD.circle(150,32,30,foregroundcolor);
+    LCD.fillcircle(140,20,10,foregroundcolor);
+
+    double s;
+
+    for (unsigned short i=0; i<LCD.width(); i++)
+        {
+        s =10 * sin((long double) i / 10 );
+        LCD.pixel(i,40 + (int)s ,foregroundcolor);
+        }
+
+
+    time=t.read_us();
+    LCD.locate(2,55);
+    LCD.set_font((unsigned char*) Terminal6x8);
+    LCD.printf("plot: %.3fms", (float)time/1000);
+    pc.printf("plot: %.3fms\r\n", (float)time/1000);
+    wait(3);
+    LCD.cls();
+    t.reset();
+    Bitmap_s pic = {
+    64, // XSize
+    64, // YSize
+    8, // Bytes in Line
+    burp,  // Pointer to picture data 
+    };
+    LCD.Bitmap_BW(pic,LCD.width()-64,0);
+    time=t.read_us();
+    LCD.locate(2,55);
+    LCD.printf("bmp: %.3fms", (float)time/1000);
+    pc.printf("bmp: %.3fms\r\n", (float)time/1000);
+    wait(3);
+    LCD.cls();
+    LCD.set_font((unsigned char*) Arial43x48_numb, 46, 58, false); //only numbers, variable-width disabled
+    t.reset();
+    LCD.locate(0,0);
+    LCD.printf("%d", 12345);
+    time=t.read_us();
+    LCD.locate(2,55);
+    LCD.set_font((unsigned char*) Terminal6x8);
+    LCD.printf("Big Font speed: %.3fms", (float)time/1000);
+    pc.printf("Big Font speed: %.3fms\r\n", (float)time/1000);
+    wait(3);
+    }
+}
\ No newline at end of file