Program to demonstrate the features of the DisplayModule DM-TFT24-104 display using the UniGraphics library.

Dependencies:   DmTouch_UniGraphic UniGraphic mbed

Fork of DisplayModule24_demo by Whitworth-EN173-2016

main.cpp

Committer:
Geremia
Date:
2015-02-16
Revision:
1:083257298075
Parent:
0:2ccd65a72ab8
Child:
2:2b781c215ac0

File content as of revision 1:083257298075:

#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"
#include "ILI9486.h"

Serial pc(USBTX, USBRX);

//IST3020 LCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"LCD"); // Parallel 8bit, Port, CS, reset, A0, WR, RD for F302
//UC1608 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // 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

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
 //   LCD.set_font((unsigned char*) Terminal6x8);
    
    // mem write/read test
    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
    }
    bool readerror=false;
    for(unsigned short i=0; i<LCD.width(); i++) // verify line
    {
        readback = LCD.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");
    wait(2);

    
    
    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);
    }
}