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
------------------------------------
main.cpp
- Committer:
- nz
- Date:
- 2020-12-08
- Revision:
- 4:acb0aea7d4fe
- Parent:
- 3:df5c8ad4d40c
File content as of revision 4:acb0aea7d4fe:
/* * Author: Nikolai Zimfer, 2020 * MIT License: http://mbed.org/license/mit * * HARDWARE: * Board FRDM-K64F - https://os.mbed.com/platforms/FRDM-K64F/ * Display 4.3" 480 x 272 (RVT43ULFNWC03) - https://riverdi.com/product/rvt43ulfnwc0x/ * Break Out Board 20 - https://riverdi.com/product/break-out-board-20/ * Cable FFC, 0.5mm pitch, 20 pin, 150 mm - https://riverdi.com/product/ffc0520150/ * * 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 * ----------------------------------- * * CODE main.cpp * FT800 TFT(D11, D12, D13, D10, D9, D8); // FRDM-K64F, SPI Initialization * * IMAGE: * https://os.mbed.com/media/uploads/nz/demo-sliders.jpg */ #include "mbed.h" #include "FT800.h" /* FT800 TFT(MOSI,MISO,SCLK, CS, INT, PD); */ FT800 TFT( D11, D12, D13, D10, D9, D8); // FRDM-K64F, SPI Initialization 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); // start Display Liste, Backgroundcolor = GRAY, TFT.tagMask(0); // Backlight brightness = 100 (100/128≈78%) 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, GREEN,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,GREEN,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, RED, RED, r, 255, 1); TFT.drawSlider(185, 50, 245,12, OPT_3D, GREEN, GREEN, GREEN, g, 255, 2); TFT.drawSlider(185, 90, 245,12, OPT_3D, BLUE, BLUE, BLUE, b, 255, 3); TFT.drawSlider(185,130, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, w, 255, 4); TFT.drawSlider(185,170, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, h, 255, 5); TFT.drawSlider(185,210, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, x, 255, 6); TFT.drawSlider(185,250, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, y, 255, 7); TFT.DLend(); } int main() { TFT.Init(); TFT.DLstart(GRAY); // start Display Liste (Backgroundcolor = GRAY, Backlight brightness = 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; } } }