Very simple SW using FT800 graphic lib [NO TOUCHSCREEN USED]

Dependencies:   FT800_2 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "FT_Platform.h"
00003 
00004 Ticker timeKeeping;
00005 volatile uint64_t seconds = 0;
00006 
00007 /***********************************************************************************************************************/
00008 /* Declare and initialize FTDI FT800 controller according to SPI lines connected */
00009  
00010 // SLSTK3400A
00011 FT800 TFT (PE10, PE11, PE12, PE13, PB11, PD4); // mosi, miso, sck, ss, int, pd
00012 
00013 // WIZwiki-W7500P
00014 //FT800 TFT (D11, D12, D13, D10, D9, D8); // mosi, miso, sck, ss, int, pd
00015 
00016 // ATSAMD21-XPRO
00017 //FT800 TFT (PA18, PA16, PA19, PA17, PA20, PA21); // mosi, miso, sck, ss, int, pd
00018 
00019 
00020 /***********************************************************************************************************************/
00021 /* Seconds counter */
00022 void secondsCallback(void)
00023 {
00024     seconds ++;
00025 }
00026 
00027 /***********************************************************************************************************************/
00028 /* Construct the screen and downloasd it to the TFT */
00029 void drawTimeScreen(void)
00030 {
00031     TFT.DLstart();
00032     TFT.DL(CLEAR_COLOR_RGB(255, 255, 255));
00033     TFT.DL(CLEAR(1, 1, 1));
00034 
00035     TFT.DL(COLOR_RGB(0, 0, 0));
00036     TFT.Text(11, 15, 30, 0, "Demo-project for habrahabr.ru");
00037     TFT.Text(13, 15 + 40, 28, 0, "Using FT800 library");
00038 
00039     TFT.DL(COLOR_RGB(9, 35, 5));
00040     TFT.DL(BEGIN(RECTS));
00041     TFT.DL(VERTEX2II(11, 105, 0, 0));
00042     TFT.DL(VERTEX2II(11 + 275, 105 + 100, 0, 0));
00043 
00044     TFT.DL(COLOR_RGB(255, 255, 255));
00045     TFT.Text(11 + 10, 105 + 10, 29, 0, "Number of seconds:");
00046     TFT.Number(11 + 10, 105 + 10 + 30, 31, 0, seconds);
00047     
00048     TFT.Clock(390, 105 + 70, 70, 0, 4, 20, (seconds % 60), 0);
00049     
00050     TFT.DL(COLOR_RGB(0, 0, 0));
00051     TFT.Text(11, 240, 28, 0, "e-mail: xk@efo.ru");
00052     
00053     TFT.DL(BEGIN(LINES));
00054     TFT.DL(LINE_WIDTH(8));
00055     TFT.DL(VERTEX2II(11, 15 + 40 + 30, 0, 0));
00056     TFT.DL(VERTEX2II(460, 15 + 40 + 30, 0, 0));
00057     
00058     TFT.DL(DISPLAY());
00059     TFT.Swap();
00060 }
00061 
00062 /***********************************************************************************************************************/
00063 /* Main function */
00064 int main()
00065 {
00066     timeKeeping.attach(&secondsCallback, 1.0f);
00067     while(1) {
00068         drawTimeScreen();
00069     }
00070 }