Using touch screen features of LCD screen.
Dependencies: DmTouch_UniGraphic UniGraphic mbed
Fork of DisplayModule24_demo by
Diff: main.cpp
- Revision:
- 4:818956c30cae
- Parent:
- 3:65af1a9fedda
- Child:
- 5:c69049e461b7
diff -r 65af1a9fedda -r 818956c30cae main.cpp --- a/main.cpp Thu Feb 19 00:39:57 2015 +0000 +++ b/main.cpp Mon Feb 23 23:40:04 2015 +0000 @@ -6,20 +6,24 @@ //#include "Terminal6x8.h" #include "Arial43x48_numb.h" #include "pict.h" +#include "pavement_48x34.h" //#include "IST3020.h" //#include "UC1608.h" #include "ILI9341.h" //#include "ILI9486.h" //#include "TFT_MIPI.h" +//#include "SSD1306.h" Serial pc(USBTX, USBRX); -//IST3020 LCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"LCD", 192, 64); // Parallel 8bit, Port, CS, reset, A0, WR, RD for F302 -//UC1608 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD", 240, 120); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc -ILI9341 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc -//ILI9486 LCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"LCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401 -//TFT_MIPI LCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"LCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401 +//IST3020 myLCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"myLCD", 192, 64); // Parallel 8bit, Port, CS, reset, A0, WR, RD for F302 +//UC1608 myLCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"myLCD", 240, 120); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc +ILI9341 myLCD(SPI_16, 12000000, D11, D12, D13, D10, D9, D8,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc +//ILI9341 myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401 +//ILI9486 myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401 +//TFT_MIPI myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401 +//SSD1306 myLCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"myLCD", 240, 120); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc Timer t; @@ -29,99 +33,101 @@ char orient=1; int main() { -// LCD.set_contrast(26);//for uc1608 - // LCD.set_contrast(46);//for ist3020 - LCD.set_orientation(orient); +// myLCD.set_contrast(26);//for uc1608 + // myLCD.set_contrast(46);//for ist3020 + myLCD.set_orientation(orient); int time, time2; 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 - // LCD.set_font((unsigned char*) Terminal6x8); - LCD.locate(0,30); - LCD.printf("Display ID: %.8X\r\n", LCD.tftID); + // myLCD.claim(stdout); // send stdout to the LCD display + //myLCD.claim(stderr); // send stderr to the LCD display + myLCD.background(backgroundcolor); // set background to black + myLCD.foreground(foregroundcolor); // set chars to white + myLCD.cls(); // clear the screen + // myLCD.set_font((unsigned char*) Terminal6x8); + myLCD.locate(0,30); + myLCD.printf("Display ID: %.8X\r\n", myLCD.tftID); + pc.printf("Display ID: %.8X\r\n", myLCD.tftID); // mem write/read test unsigned short readback; - unsigned short colorstep = (0x10000/LCD.width()); - for(unsigned short i=0; i<LCD.width(); i++) + unsigned short colorstep = (0x10000/myLCD.width()); + for(unsigned short i=0; i<myLCD.width(); i++) { - LCD.pixel(i,0,i*colorstep); // write line + myLCD.pixel(i,0,i*colorstep); // write line } bool readerror=false; - for(unsigned short i=0; i<LCD.width(); i++) // verify line + for(unsigned short i=0; i<myLCD.width(); i++) // verify line { - readback = LCD.pixelread(i,0); + readback = myLCD.pixelread(i,0); if(readback!=i*colorstep) { readerror=true; pc.printf("pix %.4X readback %.4X\r\n", i*colorstep, readback); } } - LCD.locate(0,10); - LCD.printf("pixelread test %s\r\n", readerror ? "FAIL":"PASS"); + myLCD.locate(0,10); + myLCD.printf("pixelread test %s\r\n", readerror ? "FAIL":"PASS"); wait(2); while(1) { - LCD.set_orientation((orient++)%4); -// LCD.set_orientation(2); - LCD.cls(); - LCD.set_font((unsigned char*) Terminal6x8,32,127,false); //variable width disabled - LCD.locate(0,0); - LCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly 00__"); - LCD.set_font((unsigned char*) Terminal6x8); - // LCD.locate(0,0); - LCD.printf("\r\nDisplay Test\r\nSome text just to see if auto carriage return works correctly 00__"); + myLCD.set_orientation((orient++)%4); +// myLCD.set_orientation(2); + myLCD.cls(); + myLCD.set_font((unsigned char*) Terminal6x8,32,127,false); //variable width disabled + myLCD.locate(0,0); + myLCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly 00__"); + myLCD.set_font((unsigned char*) Terminal6x8); + // myLCD.locate(0,0); + myLCD.printf("\r\nDisplay Test\r\nSome text just to see if auto carriage return works correctly 00__"); pc.printf(" Display Test \r\n"); wait(3); t.reset(); - LCD.cls(); + myLCD.cls(); time=t.read_us(); - LCD.locate(2,55); - LCD.printf("cls: %.3fms", (float)time/1000); + myLCD.locate(2,55); + myLCD.printf("cls: %.3fms", (float)time/1000); pc.printf("cls: %.3fms\r\n", (float)time/1000); wait(3); - LCD.cls(); + + myLCD.cls(); t.reset(); // draw some graphics - //LCD.cls(); - LCD.set_font((unsigned char*) Arial24x23); - LCD.locate(10,10); - LCD.printf("Test"); + //myLCD.cls(); + myLCD.set_font((unsigned char*) Arial24x23); + myLCD.locate(10,10); + myLCD.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); + myLCD.line(0,0,myLCD.width()-1,0,foregroundcolor); + myLCD.line(0,0,0,myLCD.height()-1,foregroundcolor); + myLCD.line(0,0,myLCD.width()-1,myLCD.height()-1,foregroundcolor); - LCD.rect(10,30,50,40,foregroundcolor); - LCD.fillrect(60,30,100,40,foregroundcolor); + myLCD.rect(10,30,50,40,foregroundcolor); + myLCD.fillrect(60,30,100,40,foregroundcolor); - LCD.circle(150,32,30,foregroundcolor); - LCD.fillcircle(140,20,10,foregroundcolor); + myLCD.circle(150,32,30,foregroundcolor); + myLCD.fillcircle(140,20,10,foregroundcolor); double s; - for (unsigned short i=0; i<LCD.width(); i++) + for (unsigned short i=0; i<myLCD.width(); i++) { s =10 * sin((long double) i / 10 ); - LCD.pixel(i,40 + (int)s ,foregroundcolor); + myLCD.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); + myLCD.locate(2,55); + myLCD.set_font((unsigned char*) Terminal6x8); + myLCD.printf("plot: %.3fms", (float)time/1000); pc.printf("plot: %.3fms\r\n", (float)time/1000); wait(3); - LCD.cls(); + myLCD.cls(); t.reset(); Bitmap_s pic = { 64, // XSize @@ -129,80 +135,92 @@ 8, // Bytes in Line burp, // Pointer to picture data }; - LCD.Bitmap_BW(pic,LCD.width()-64,0); + myLCD.Bitmap_BW(pic,myLCD.width()-64,0); time=t.read_us(); - LCD.locate(2,55); - LCD.printf("bmp: %.3fms", (float)time/1000); + myLCD.locate(2,55); + myLCD.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 + myLCD.cls(); + myLCD.set_font((unsigned char*) Arial43x48_numb, 46, 58, false); //only numbers, variable-width disabled t.reset(); - LCD.locate(0,0); - LCD.printf("%d", 12345); + myLCD.locate(0,0); + myLCD.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); + myLCD.locate(2,55); + myLCD.set_font((unsigned char*) Terminal6x8); + myLCD.printf("Big Font speed: %.3fms", (float)time/1000); pc.printf("Big Font speed: %.3fms\r\n", (float)time/1000); wait(3); // sparse pixels test - LCD.cls(); - LCD.FastWindow(false); + myLCD.cls(); + myLCD.FastWindow(true); t.reset(); for(unsigned int i=0; i<20000; i++) { - LCD.pixel((i+(i*89)%LCD.width()), (i+(i*61)%LCD.height()), White); + myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White); } - LCD.copy_to_lcd(); + myLCD.copy_to_lcd(); time=t.read_us(); - LCD.cls(); - LCD.FastWindow(true); + myLCD.cls(); + myLCD.FastWindow(false); t.reset(); for(unsigned int i=0; i<20000; i++) { - LCD.pixel((i+(i*89)%LCD.width()), (i+(i*61)%LCD.height()), White); + myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White); } - LCD.copy_to_lcd(); + myLCD.copy_to_lcd(); time2=t.read_us(); - LCD.locate(2,55); - LCD.printf("std: %.3fms fastw: %.3fms", (float)time/1000, (float)time2/1000); - pc.printf("std: %.3fms fastw: %.3fms\r\n", (float)time/1000, (float)time2/1000); + myLCD.locate(2,55); + myLCD.printf("std: %.3fms fastw: %.3fms", (float)time2/1000, (float)time/1000); + pc.printf("std: %.3fms fastw: %.3fms\r\n", (float)time2/1000, (float)time/1000); wait(3); // scroll test, only for TFT - LCD.cls(); - LCD.set_font((unsigned char*) Arial24x23); - LCD.locate(10,10); - LCD.printf("Scrolling"); - LCD.rect(0,0,LCD.width()-1,LCD.height()-1,White); - LCD.rect(1,1,LCD.width()-2,LCD.height()-2,Blue); - LCD.setscrollarea(0,LCD.sizeY()); + myLCD.cls(); + myLCD.set_font((unsigned char*) Arial24x23); + myLCD.locate(10,10); + myLCD.printf("Scrolling"); + myLCD.rect(0,0,myLCD.width()-1,myLCD.height()-1,White); + myLCD.rect(1,1,myLCD.width()-2,myLCD.height()-2,Blue); + myLCD.setscrollarea(0,myLCD.sizeY()); wait(1); - LCD.scroll(1); //up 1 + myLCD.scroll(1); //up 1 wait(1); - LCD.scroll(0); //center + myLCD.scroll(0); //center wait(1); - LCD.scroll(LCD.sizeY()-1); //down 1 + myLCD.scroll(myLCD.sizeY()-1); //down 1 wait(1); - LCD.scroll(LCD.sizeY()); // same as 0, center + myLCD.scroll(myLCD.sizeY()); // same as 0, center wait(1); - LCD.scroll(LCD.sizeY()>>1); // half screen + myLCD.scroll(myLCD.sizeY()>>1); // half screen wait(1); - LCD.scrollreset(); // center + myLCD.scrollreset(); // center wait(1); - for(unsigned short i=1; i<=LCD.sizeY(); i++) + for(unsigned short i=1; i<=myLCD.sizeY(); i++) { - LCD.scroll(i); + myLCD.scroll(i); wait_ms(2); } wait(2); // color inversion for(unsigned short i=0; i<=8; i++) { - LCD.invert(i&1); + myLCD.invert(i&1); wait_ms(200); } wait(2); - + // bmp 16bit test + myLCD.cls(); + t.reset(); + for(int y=0; y<myLCD.height(); y+=34) + { + for(int x=0; x<myLCD.width(); x+=48) myLCD.Bitmap(x,y,48,34,(unsigned char *)pavement_48x34); + } + time=t.read_us(); + myLCD.locate(2,55); + myLCD.set_font((unsigned char*) Terminal6x8); + myLCD.printf("Bmp speed: %.3fms", (float)time/1000); + pc.printf("Bmp speed: %.3fms\r\n", (float)time/1000); + wait(2); } } \ No newline at end of file