version 2022

Dependencies:   mbed FT800_Lib_perso

Committer:
schnf30
Date:
Wed Feb 09 07:35:00 2022 +0000
Revision:
0:7d1a18c6b9d8
version 2022

Who changed what in which revision?

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