Demo for the FTDI FT800 "EVE" lib. 3 sliders are used to control the RGB color

Dependencies:   FT800_2 mbed

Fork of FT800_touch_track by Peter Drescher

The program draws three sliders and a color field. You can change the color of the field with the sliders on the touch screen. /media/uploads/dreschpe/rgb.png

Committer:
dreschpe
Date:
Sat Sep 20 15:38:23 2014 +0000
Revision:
2:07f4e7d61702
Parent:
1:a7076a14694b
wrong files in project;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:3edc602de5a7 1 /* Demo for mbed Library for FTDI FT800 Enbedded Video Engine "EVE"
dreschpe 0:3edc602de5a7 2 * based on Original Code Sample from FTDI
dreschpe 0:3edc602de5a7 3 * ported to mbed by Peter Drescher, DC2PD 2014
dreschpe 0:3edc602de5a7 4 * Released under the MIT License: http://mbed.org/license/mit */
dreschpe 0:3edc602de5a7 5
dreschpe 0:3edc602de5a7 6 #include "mbed.h"
dreschpe 0:3edc602de5a7 7 #include "FT_Platform.h"
dreschpe 0:3edc602de5a7 8
dreschpe 1:a7076a14694b 9 FT800 TFT(PA_7,PA_6,PA_5,PC_7,PB_4,PA_9); // mosi, miso, sck, ss, int, pd // the FT800 is connected to SPI 11-13
dreschpe 0:3edc602de5a7 10
dreschpe 0:3edc602de5a7 11 /***************************************************************************/
dreschpe 0:3edc602de5a7 12 /* Show a Screen with Text for 5 seconds */
dreschpe 0:3edc602de5a7 13 /* A spinner shows the delay */
dreschpe 0:3edc602de5a7 14 /***************************************************************************/
dreschpe 0:3edc602de5a7 15
dreschpe 1:a7076a14694b 16 ft_void_t Start_Screen(ft_char8_t *str)
dreschpe 0:3edc602de5a7 17 {
dreschpe 1:a7076a14694b 18 TFT.DLstart(); // start a new display command list
dreschpe 1:a7076a14694b 19 TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white
dreschpe 1:a7076a14694b 20 TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
dreschpe 1:a7076a14694b 21 TFT.DL(COLOR_RGB(0x80,0x80,0x00)); // set current color
dreschpe 1:a7076a14694b 22 TFT.Text((TFT.DispWidth/2), TFT.DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31
dreschpe 1:a7076a14694b 23 TFT.DL(COLOR_RGB(0xFF,0x00,0x00)); // change current color
dreschpe 1:a7076a14694b 24 TFT.Spinner((TFT.DispWidth/2),TFT.DispHeight/4, 0,0); // draw a animated spinner
dreschpe 1:a7076a14694b 25
dreschpe 1:a7076a14694b 26 TFT.DL(DISPLAY()); // Display the image
dreschpe 1:a7076a14694b 27 TFT.Swap(); // Swap the current display list
dreschpe 1:a7076a14694b 28 TFT.Flush_Co_Buffer(); // Download the command list into fifo
dreschpe 1:a7076a14694b 29
dreschpe 1:a7076a14694b 30 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 1:a7076a14694b 31 TFT.Sleep(5000); // Wait 5 s to show
dreschpe 1:a7076a14694b 32 }
dreschpe 0:3edc602de5a7 33
dreschpe 1:a7076a14694b 34 // construct the screen and downloasd it to the LCD
dreschpe 1:a7076a14694b 35 void screen_1(unsigned int r,unsigned int g,unsigned int b)
dreschpe 1:a7076a14694b 36 {
dreschpe 1:a7076a14694b 37 TFT.DLstart(); // start a new display command list
dreschpe 1:a7076a14694b 38 TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
dreschpe 1:a7076a14694b 39 TFT.DL(COLOR_RGB(0xff,0xff,0xff)); // set current color to white
dreschpe 1:a7076a14694b 40 TFT.DL(TAG(1)); // assign TAG value 1
dreschpe 1:a7076a14694b 41 TFT.FgColor(COLOR_RGB(0xff,0,0)); // forground color red
dreschpe 1:a7076a14694b 42 TFT.Slider(140,81,310,14,0,r,255); // slider for red
dreschpe 1:a7076a14694b 43 TFT.DL(TAG(2)); // assign TAG value 2
dreschpe 1:a7076a14694b 44 TFT.FgColor(COLOR_RGB(0,0xff,0)); // forground color green
dreschpe 1:a7076a14694b 45 TFT.Slider(140,133,310,14,0,g,255); // slider for green
dreschpe 1:a7076a14694b 46 TFT.DL(TAG(3)); // assign TAG value 3
dreschpe 1:a7076a14694b 47 TFT.FgColor(COLOR_RGB(0,0,0xff)); // forground color blue
dreschpe 1:a7076a14694b 48 TFT.Slider(139,185,310,14,0,b,255); // slider for blue
dreschpe 1:a7076a14694b 49 TFT.DL(COLOR_RGB(0xff,0x00,0x00)); // set current color to red
dreschpe 1:a7076a14694b 50 TFT.Text(82,69,30,0,"R"); // text R
dreschpe 1:a7076a14694b 51 TFT.DL(COLOR_RGB(0x00,0xff,0x00)); // set current color to green
dreschpe 1:a7076a14694b 52 TFT.Text(82,120,30,0,"G"); // text G
dreschpe 1:a7076a14694b 53 TFT.DL(COLOR_RGB(0x00,0x00,0xff)); // set current color to blue
dreschpe 1:a7076a14694b 54 TFT.Text(82,174,30,0,"B"); // text B
dreschpe 1:a7076a14694b 55 TFT.DL(SCISSOR_XY(10,10)); // define area starting at 10,10
dreschpe 1:a7076a14694b 56 TFT.DL(SCISSOR_SIZE(50,50)); // size 50,50
dreschpe 1:a7076a14694b 57 TFT.DL(CLEAR_COLOR_RGB(r,g,b)); // set clear color to r,g,b
dreschpe 1:a7076a14694b 58 TFT.DL(CLEAR(1,1,1)); // fill the area
dreschpe 1:a7076a14694b 59 TFT.DL(DISPLAY()); // Display the image
dreschpe 1:a7076a14694b 60 TFT.Swap(); // Swap the current display list
dreschpe 1:a7076a14694b 61 TFT.Flush_Co_Buffer(); // Download the command list into fifo
dreschpe 1:a7076a14694b 62 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 1:a7076a14694b 63 }
dreschpe 0:3edc602de5a7 64
dreschpe 1:a7076a14694b 65 int main()
dreschpe 1:a7076a14694b 66 {
dreschpe 1:a7076a14694b 67 unsigned int r = 0,g = 0,b = 0;
dreschpe 1:a7076a14694b 68 ft_uint32_t TrackRegisterVal = 0; // touch track
dreschpe 1:a7076a14694b 69
dreschpe 1:a7076a14694b 70 Start_Screen("RGB DEMO START"); // Show start screen
dreschpe 1:a7076a14694b 71 TFT.Calibrate(); // calibrate the touch screen
dreschpe 1:a7076a14694b 72
dreschpe 1:a7076a14694b 73 /* Set the tracker for the 3 sliders - define the Area for touching */
dreschpe 1:a7076a14694b 74 TFT.Track(131,63,330,48,1); // slider r
dreschpe 1:a7076a14694b 75 TFT.Track(131,116,333,48,2); // slider g
dreschpe 1:a7076a14694b 76 TFT.Track(131,168,330,48,3); // slider b
dreschpe 1:a7076a14694b 77 TFT.Flush_Co_Buffer(); // Download the commands into fifo
dreschpe 1:a7076a14694b 78 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 1:a7076a14694b 79 screen_1(r,g,b); // paint screen
dreschpe 0:3edc602de5a7 80
dreschpe 1:a7076a14694b 81 /* the demo is updating the screen in a endless loop */
dreschpe 1:a7076a14694b 82 while(1) {
dreschpe 1:a7076a14694b 83 ft_uint8_t tagval = 0;
dreschpe 1:a7076a14694b 84 TrackRegisterVal = TFT.Rd32(REG_TRACKER); // check if one of the tree Slider is touched
dreschpe 1:a7076a14694b 85 tagval = TrackRegisterVal & 0xff;
dreschpe 1:a7076a14694b 86 if(0 != tagval) { // touch -> get new rgb value
dreschpe 1:a7076a14694b 87 if(1 == tagval) { // the red slider is touched
dreschpe 1:a7076a14694b 88 r = TrackRegisterVal>>16; // get the new value
dreschpe 1:a7076a14694b 89 r = r *255/65536; // scale it down to 255
dreschpe 1:a7076a14694b 90 } else if(2 == tagval) { // the green slider is touched
dreschpe 1:a7076a14694b 91 g = TrackRegisterVal>>16; // get new slider value
dreschpe 1:a7076a14694b 92 g = g * 255/65536; // scale it down to 255
dreschpe 1:a7076a14694b 93 } else if(3 == tagval) { // the blue slider is touched
dreschpe 1:a7076a14694b 94 b = TrackRegisterVal>>16; // get new slider value
dreschpe 1:a7076a14694b 95 b = b * 255/65536; // scale it down to 255
dreschpe 1:a7076a14694b 96 }
dreschpe 1:a7076a14694b 97 screen_1(r,g,b); // paint new screen
dreschpe 1:a7076a14694b 98 TFT.Sleep(10); // wait 10ms for next check
dreschpe 1:a7076a14694b 99 }
dreschpe 1:a7076a14694b 100
dreschpe 1:a7076a14694b 101 } // end of display loop
dreschpe 0:3edc602de5a7 102 }
dreschpe 0:3edc602de5a7 103
dreschpe 0:3edc602de5a7 104
dreschpe 0:3edc602de5a7 105