basic functional test of FT810 LCD via SPI

Dependencies:   FT810 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*  Curtis Mattull
00002     10/1/16
00003     This simple program tests LCD SPI functionality
00004 */
00005 #include "mbed.h"
00006 #include "FT_Platform.h"
00007 
00008 void    screen1(uint32_t tracker, uint8_t tag);
00009 void    rotate_screen(uint8_t val);
00010 // create an LCD object
00011 FT800 TFT( PTD6, PTD7, PTD5, PTD4, PTB19, PTA1);
00012 //       ( mosi, miso, sclk,   ss,  intr,  pd );
00013 RawSerial terminal(USBTX, USBRX);    // computer to mbed board
00014 int main(void)
00015 {
00016     terminal.baud(9600);
00017     printf("main entered\r\n");
00018     rotate_screen(1);
00019     set_time(0);  // Set RTC time to 0
00020     
00021     //draw screen
00022     for(;;)
00023     {
00024 //        screen1(0x0,0x0);
00025         wait(1);
00026     }
00027  
00028     return 0;
00029 }
00030 
00031 
00032 void rotate_screen(uint8_t val)
00033 {
00034     if (val == 0)
00035     {
00036         TFT.MemWrite(REG_ROTATE, 1);    // rotate screen
00037         TFT.Rotate(1);
00038         TFT.Flush_Co_Buffer();          // Download the command list into fifo
00039         TFT.WaitCmdfifo_empty();        // Wait till coprocessor completes the operation
00040     }
00041 }
00042 
00043 
00044 void screen1(uint32_t tracker, uint8_t tag)
00045 {
00046     printf("screen1 entered\r\n");
00047     time_t seconds = time(NULL);
00048 
00049     //start new display list
00050     TFT.DLstart();                                                      // start a new display command list
00051     TFT.DL(CLEAR_COLOR_RGB(255,255,255));                               // set the clear color to white
00052     TFT.DL(CLEAR(1,1,1));                                               // clear buffers -> color buffer,stencil buffer, tag buffer
00053 
00054     TFT.DL(TAG(0));                         // assign TAG value 0 to everything else
00055 
00056     //title text
00057     TFT.DL(COLOR_RGB(0, 0, 0));
00058     TFT.Text((TFT.DispWidth/2), TFT.DispHeight/8, 28, OPT_CENTERX, "test\0");        // draw Text with font 31
00059 
00060     // time
00061     TFT.Text((TFT.DispWidth/4), TFT.DispHeight*7/8, 28, OPT_CENTERX, "Run time [s]: \0");        // draw Text with font 31
00062     TFT.Number((TFT.DispWidth/2), (TFT.DispHeight*7/8),28,OPT_CENTERX, seconds);
00063 
00064     //author text
00065     TFT.DL(COLOR_RGB(0x00,  0x00,   0x00));
00066     TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), 28, OPT_CENTERX, "by Curtis Mattull\0");            // draw Text with font 31
00067 
00068     //display the screen
00069     TFT.DL(DISPLAY());                     // display the image
00070     TFT.Swap();                            // swap the current display list
00071     TFT.Flush_Co_Buffer();                 // download the command list into fifo
00072     TFT.WaitCmdfifo_empty();               // wait till coprocessor completes the operation
00073 
00074 }