Ivaylo Iltchev / DISCO-F429ZI_ExportTemplate1

Dependencies:   LCD_DISCO_F429ZI LCD_LOG_DISCO TS_DISCO_F429ZI mbed-dev

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include <stdio.h>
00003 #include "TS_DISCO_F429ZI.h"
00004 #include "LCD_DISCO_F429ZI.h"
00005 #include "LCD_LOG_DISCO.h"
00006 
00007 LCD_DISCO_F429ZI lcd;
00008 TS_DISCO_F429ZI ts;
00009 LCDLog lcdlog("lcdlog");
00010 
00011 extern "C" {
00012     int LCD_LOG_write(uint8_t* text);
00013 }
00014 
00015 int main()
00016 {
00017     TS_StateTypeDef TS_State;
00018     uint16_t x = 0, y = 0;
00019 
00020     lcdlog.Init(stdout, "TOUCHSCREEN DEMO");
00021 
00022     if (ts.Init(lcd.GetXSize(), lcd.GetYSize()) != TS_OK)
00023     {
00024         lcdlog.Footer("INIT FAIL\n");
00025     } else {
00026         lcdlog.Footer("INIT OK");
00027     }
00028 
00029     printf("** Start **\n");
00030     while(1)
00031     {
00032         ts.GetState(&TS_State);
00033         if (TS_State.TouchDetected)
00034         {
00035             if (x != TS_State.X || y != TS_State.Y) {
00036                 x = TS_State.X;
00037                 y = TS_State.Y;
00038                 printf("x=%03d y=%03d\n", x, y);
00039             }
00040         }
00041         wait_ms(5);
00042     }
00043 }