Demo for FT800 library. 7 sliders are used to control the RGB color, size & position.
HARDWARE:
- Board FRDM-K64F
- Display TFT 4.3" 480 x 272 (RVT43ULFNWC03)
- Break Out Board 20
- Cable FFC, 0.5mm pitch, 20 pin, 150 mm
CONNECTION:
------------------------------------
FRDM-K64F Break Out Board
------------------------------------
+3.3V --- Pin 17 BLVDD
+3.3V --- Pin 1 VDD
GND --- Pin 2 GND
D13 (PTD1) SCLK --- Pin 3 SPI SCLK
D12 (PTD3) MISO --- Pin 4 MISO
D11 (PTD2) MOSI --- PIN 5 MOSI
D10 (PTD0) --- Pin 6 CS
D9 (PTC4) --- Pin 7 INT
D8 (PTC12) --- Pin 8 PD
------------------------------------
Diff: main.cpp
- Revision:
- 0:a3a642a3024c
- Child:
- 1:e4305b342044
diff -r 000000000000 -r a3a642a3024c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 03 23:14:50 2020 +0000 @@ -0,0 +1,80 @@ +#include "mbed.h" +#include "FT800.h" + +/* +FT800 TFT(MOSI,MISO, SCK, CS, INT, PD); */ +FT800 TFT( D11, D12, D13, D10, D9, D8); // FRDM-K64F + +uint32_t color; +uint8_t r = 64, g = 128, b = 192; +uint8_t w = 200, h = 200, x = 50, y = 50; +uint8_t width, height, posx, posy, tag = 0; + +void screen() +{ + TFT.finishList(); + TFT.DLstart(GRAY,100); + TFT.tagMask(0); + + color = (r<<16)|(g<<8)|b; + width = w/2; + height = h/2; + posx = x/2; + posy = y/2; + + TFT.drawRect(posx, posy, posx+width, posy+height, color, 1); + + TFT.drawText(150, 2, 29, RED, OPT_FLAT, "R"); + TFT.drawText(150, 42, 29, LIME, OPT_FLAT, "G"); + TFT.drawText(150, 82, 29, BLUE, OPT_FLAT, "B"); + TFT.drawText(150,122, 29, BLACK,OPT_FLAT, "W"); + TFT.drawText(150,162, 29, BLACK,OPT_FLAT, "H"); + TFT.drawText(150,202, 29, BLACK,OPT_FLAT, "X"); + TFT.drawText(150,242, 29, BLACK,OPT_FLAT, "Y"); + + TFT.drawNumber(475, 4, 28, RED, OPT_RIGHTX, r); + TFT.drawNumber(475, 44, 28,LIME, OPT_RIGHTX, g); + TFT.drawNumber(475, 84, 28,BLUE, OPT_RIGHTX, b); + TFT.drawNumber(475,124, 28,BLACK,OPT_RIGHTX, width); + TFT.drawNumber(475,164, 28,BLACK,OPT_RIGHTX, height); + TFT.drawNumber(475,204, 28,BLACK,OPT_RIGHTX, posx); + TFT.drawNumber(475,244, 28,BLACK,OPT_RIGHTX, posy); + + TFT.drawSlider(185, 10, 245,12, OPT_3D, RED, WHITE, RED, r, 255, 1); + TFT.drawSlider(185, 50, 245,12, OPT_3D, LIME, WHITE, LIME, g, 255, 2); + TFT.drawSlider(185, 90, 245,12, OPT_3D, BLUE, WHITE, BLUE, b, 255, 3); + TFT.drawSlider(185,130, 245,12, OPT_3D, DIMGRAY,WHITE,DIMGRAY, w, 255, 4); + TFT.drawSlider(185,170, 245,12, OPT_3D, DIMGRAY,WHITE,DIMGRAY, h, 255, 5); + TFT.drawSlider(185,210, 245,12, OPT_3D, DIMGRAY,WHITE,DIMGRAY, x, 255, 6); + TFT.drawSlider(185,250, 245,12, OPT_3D, DIMGRAY,WHITE,DIMGRAY, y, 255, 7); + + TFT.DLend(); +} + +int main() +{ + TFT.Init(); + + TFT.DLstart(GRAY,100); + TFT.runTouchCalibration(); + TFT.DLend(); + + while(1) + { + screen(); + + TFT.clearIntFlags(); + tag = TFT.readTag(); + + if(tag != 0) + { + if (tag == 1) r = TFT.readValue()>>8; + if (tag == 2) g = TFT.readValue()>>8; + if (tag == 3) b = TFT.readValue()>>8; + if (tag == 4) w = TFT.readValue()>>8; + if (tag == 5) h = TFT.readValue()>>8; + if (tag == 6) x = TFT.readValue()>>8; + if (tag == 7) y = TFT.readValue()>>8; + } + } +} \ No newline at end of file