Demo for FT800 library. 7 sliders are used to control the RGB color, size & position.

Dependencies:   FT800-480x272

HARDWARE:

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 ------------------------------------

https://os.mbed.com/media/uploads/nz/demo-sliders.jpg

Committer:
nz
Date:
Tue Dec 08 14:51:52 2020 +0000
Revision:
4:acb0aea7d4fe
Parent:
3:df5c8ad4d40c
delete mbed_app. json

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nz 1:e4305b342044 1 /*
nz 3:df5c8ad4d40c 2 * Author: Nikolai Zimfer, 2020
nz 1:e4305b342044 3 * MIT License: http://mbed.org/license/mit
nz 1:e4305b342044 4 *
nz 1:e4305b342044 5 * HARDWARE:
nz 1:e4305b342044 6 * Board FRDM-K64F - https://os.mbed.com/platforms/FRDM-K64F/
nz 1:e4305b342044 7 * Display 4.3" 480 x 272 (RVT43ULFNWC03) - https://riverdi.com/product/rvt43ulfnwc0x/
nz 1:e4305b342044 8 * Break Out Board 20 - https://riverdi.com/product/break-out-board-20/
nz 1:e4305b342044 9 * Cable FFC, 0.5mm pitch, 20 pin, 150 mm - https://riverdi.com/product/ffc0520150/
nz 1:e4305b342044 10 *
nz 1:e4305b342044 11 * CONNECTION:
nz 3:df5c8ad4d40c 12 * -----------------------------------
nz 1:e4305b342044 13 * FRDM-K64F Break Out Board
nz 3:df5c8ad4d40c 14 * -----------------------------------
nz 3:df5c8ad4d40c 15 * +3.3V --- Pin 17 BLVDD
nz 3:df5c8ad4d40c 16 * +3.3V --- Pin 1 VDD
nz 3:df5c8ad4d40c 17 * GND --- Pin 2 GND
nz 3:df5c8ad4d40c 18 * D13 (PTD1) SCLK --- Pin 3 SPI SCLK
nz 3:df5c8ad4d40c 19 * D12 (PTD3) MISO --- Pin 4 MISO
nz 3:df5c8ad4d40c 20 * D11 (PTD2) MOSI --- PIN 5 MOSI
nz 3:df5c8ad4d40c 21 * D10 (PTD0) --- Pin 6 CS
nz 3:df5c8ad4d40c 22 * D9 (PTC4) --- Pin 7 INT
nz 3:df5c8ad4d40c 23 * D8 (PTC12) --- Pin 8 PD
nz 3:df5c8ad4d40c 24 * -----------------------------------
nz 1:e4305b342044 25 *
nz 1:e4305b342044 26 * CODE main.cpp
nz 1:e4305b342044 27 * FT800 TFT(D11, D12, D13, D10, D9, D8); // FRDM-K64F, SPI Initialization
nz 1:e4305b342044 28 *
nz 1:e4305b342044 29 * IMAGE:
nz 1:e4305b342044 30 * https://os.mbed.com/media/uploads/nz/demo-sliders.jpg
nz 1:e4305b342044 31 */
nz 1:e4305b342044 32
nz 0:a3a642a3024c 33 #include "mbed.h"
nz 0:a3a642a3024c 34 #include "FT800.h"
nz 0:a3a642a3024c 35
nz 0:a3a642a3024c 36 /*
nz 1:e4305b342044 37 FT800 TFT(MOSI,MISO,SCLK, CS, INT, PD); */
nz 1:e4305b342044 38 FT800 TFT( D11, D12, D13, D10, D9, D8); // FRDM-K64F, SPI Initialization
nz 0:a3a642a3024c 39
nz 0:a3a642a3024c 40 uint32_t color;
nz 0:a3a642a3024c 41 uint8_t r = 64, g = 128, b = 192;
nz 0:a3a642a3024c 42 uint8_t w = 200, h = 200, x = 50, y = 50;
nz 0:a3a642a3024c 43 uint8_t width, height, posx, posy, tag = 0;
nz 0:a3a642a3024c 44
nz 0:a3a642a3024c 45 void screen()
nz 0:a3a642a3024c 46 {
nz 0:a3a642a3024c 47 TFT.finishList();
nz 3:df5c8ad4d40c 48 TFT.DLstart(GRAY,100); // start Display Liste, Backgroundcolor = GRAY,
nz 3:df5c8ad4d40c 49 TFT.tagMask(0); // Backlight brightness = 100 (100/128≈78%)
nz 0:a3a642a3024c 50
nz 0:a3a642a3024c 51 color = (r<<16)|(g<<8)|b;
nz 0:a3a642a3024c 52 width = w/2;
nz 0:a3a642a3024c 53 height = h/2;
nz 0:a3a642a3024c 54 posx = x/2;
nz 0:a3a642a3024c 55 posy = y/2;
nz 0:a3a642a3024c 56
nz 3:df5c8ad4d40c 57 TFT.drawRect(posx, posy, posx + width, posy + height, color, 1);
nz 0:a3a642a3024c 58
nz 0:a3a642a3024c 59 TFT.drawText(150, 2, 29, RED, OPT_FLAT, "R");
nz 3:df5c8ad4d40c 60 TFT.drawText(150, 42, 29, GREEN,OPT_FLAT, "G");
nz 0:a3a642a3024c 61 TFT.drawText(150, 82, 29, BLUE, OPT_FLAT, "B");
nz 0:a3a642a3024c 62 TFT.drawText(150,122, 29, BLACK,OPT_FLAT, "W");
nz 0:a3a642a3024c 63 TFT.drawText(150,162, 29, BLACK,OPT_FLAT, "H");
nz 0:a3a642a3024c 64 TFT.drawText(150,202, 29, BLACK,OPT_FLAT, "X");
nz 0:a3a642a3024c 65 TFT.drawText(150,242, 29, BLACK,OPT_FLAT, "Y");
nz 0:a3a642a3024c 66
nz 0:a3a642a3024c 67 TFT.drawNumber(475, 4, 28, RED, OPT_RIGHTX, r);
nz 3:df5c8ad4d40c 68 TFT.drawNumber(475, 44, 28,GREEN,OPT_RIGHTX, g);
nz 0:a3a642a3024c 69 TFT.drawNumber(475, 84, 28,BLUE, OPT_RIGHTX, b);
nz 0:a3a642a3024c 70 TFT.drawNumber(475,124, 28,BLACK,OPT_RIGHTX, width);
nz 0:a3a642a3024c 71 TFT.drawNumber(475,164, 28,BLACK,OPT_RIGHTX, height);
nz 0:a3a642a3024c 72 TFT.drawNumber(475,204, 28,BLACK,OPT_RIGHTX, posx);
nz 0:a3a642a3024c 73 TFT.drawNumber(475,244, 28,BLACK,OPT_RIGHTX, posy);
nz 0:a3a642a3024c 74
nz 2:d913edc0f712 75 TFT.drawSlider(185, 10, 245,12, OPT_3D, RED, RED, RED, r, 255, 1);
nz 3:df5c8ad4d40c 76 TFT.drawSlider(185, 50, 245,12, OPT_3D, GREEN, GREEN, GREEN, g, 255, 2);
nz 2:d913edc0f712 77 TFT.drawSlider(185, 90, 245,12, OPT_3D, BLUE, BLUE, BLUE, b, 255, 3);
nz 2:d913edc0f712 78 TFT.drawSlider(185,130, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, w, 255, 4);
nz 2:d913edc0f712 79 TFT.drawSlider(185,170, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, h, 255, 5);
nz 2:d913edc0f712 80 TFT.drawSlider(185,210, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, x, 255, 6);
nz 2:d913edc0f712 81 TFT.drawSlider(185,250, 245,12, OPT_3D, DIMGRAY,DIMGRAY,DIMGRAY, y, 255, 7);
nz 0:a3a642a3024c 82
nz 0:a3a642a3024c 83 TFT.DLend();
nz 0:a3a642a3024c 84 }
nz 0:a3a642a3024c 85
nz 0:a3a642a3024c 86 int main()
nz 0:a3a642a3024c 87 {
nz 0:a3a642a3024c 88 TFT.Init();
nz 0:a3a642a3024c 89
nz 3:df5c8ad4d40c 90 TFT.DLstart(GRAY); // start Display Liste (Backgroundcolor = GRAY, Backlight brightness = 100%)
nz 0:a3a642a3024c 91 TFT.runTouchCalibration();
nz 0:a3a642a3024c 92 TFT.DLend();
nz 0:a3a642a3024c 93
nz 0:a3a642a3024c 94 while(1)
nz 0:a3a642a3024c 95 {
nz 0:a3a642a3024c 96 screen();
nz 0:a3a642a3024c 97
nz 0:a3a642a3024c 98 TFT.clearIntFlags();
nz 0:a3a642a3024c 99 tag = TFT.readTag();
nz 0:a3a642a3024c 100
nz 0:a3a642a3024c 101 if(tag != 0)
nz 0:a3a642a3024c 102 {
nz 0:a3a642a3024c 103 if (tag == 1) r = TFT.readValue()>>8;
nz 0:a3a642a3024c 104 if (tag == 2) g = TFT.readValue()>>8;
nz 0:a3a642a3024c 105 if (tag == 3) b = TFT.readValue()>>8;
nz 0:a3a642a3024c 106 if (tag == 4) w = TFT.readValue()>>8;
nz 0:a3a642a3024c 107 if (tag == 5) h = TFT.readValue()>>8;
nz 0:a3a642a3024c 108 if (tag == 6) x = TFT.readValue()>>8;
nz 0:a3a642a3024c 109 if (tag == 7) y = TFT.readValue()>>8;
nz 0:a3a642a3024c 110 }
nz 0:a3a642a3024c 111 }
nz 0:a3a642a3024c 112 }