Ejemplo con TFT ili9341
Dependencies: mbed SPI_TFT_ILI9341 LCD_fonts UTouch
Diff: main.cpp
- Revision:
- 0:96ca69863b24
diff -r 000000000000 -r 96ca69863b24 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 05 03:31:14 2020 +0000 @@ -0,0 +1,76 @@ +#include "mbed.h" +#include "SPI_TFT_ILI9341.h" +#include "string" +#include "Arial12x12.h" +#include "Arial24x23.h" +#include "Arial_9.h" +#include "Small_6.h" +//#include "Arial28x28.h" +//#include "font_big.h" +#include "UTouch.h" +#include "stdio.h" +char buffer[10]; +extern unsigned char p1[]; // the mbed logo +// the TFT is connected to SPI pin 5-7 +SPI_TFT_ILI9341 TFT(D11,D12,D13,D10,D9,D8,"TFT"); +UTouch myTouch(A0, A1,D7, D5, D4); +DigitalOut led(D14); +int main(){ + led=1; +TFT.claim(stdout); // send stdout to the TFT display +//TFT.claim(stderr); // send stderr to the TFT display +TFT.set_orientation(1); +TFT.background(Blue); // set background to black +TFT.foreground(White); // set chars to white +TFT.cls(); // clear the screen +//first show the 4 directions +TFT.set_orientation(0); +TFT.cls(); +TFT.set_font((unsigned char*) Arial12x12); +TFT.locate(0,10); +printf(" BEE-LOCATOR 0"); +TFT.set_orientation(1); +TFT.locate(0,10); +printf(" BEE-LOCATOR 1"); +TFT.set_orientation(2); +TFT.locate(0,10); +printf(" BEE-LOCATOR 2"); +TFT.set_orientation(3); +TFT.locate(0,10); +printf(" BEE-LOCATOR 3"); +TFT.set_orientation(1); +TFT.set_font((unsigned char*) Arial24x23); +TFT.locate(75,50); +TFT.printf("INFUSO"); +TFT.rect(90,190,210,100,Red); +TFT.locate(110,135); +TFT.printf("OFF"); +myTouch.InitTouch(); +myTouch.SetPrecision(PREC_LOW); +float x=0,y=0; +while(1){ +if (myTouch.DataAvailable()) +{ +if(myTouch.Read()) +{ +x = myTouch.GetX(); +y = myTouch.GetY(); +TFT.locate(30,50); +sprintf (buffer, "%.0f , %.0f ", x, y); +TFT.printf(buffer); +TFT.rect(90,190,210,100,Red); +if (y>100&&x>90&&y<190&&x<210){ +TFT.fillrect(90,190,210,100,Blue); +TFT.rect(90,190,210,100,Red); +TFT.locate(100,135); +TFT.printf(" ON"); +}else +TFT.rect(90,190,210,100,Blue); +TFT.rect(90,190,210,100,Red); +TFT.locate(120,135); +TFT.printf("Off"); + +} +} +} +} \ No newline at end of file