Programme for Test ConnectEve from Mikroe Its Ok

Dependencies:   mbed FT800okForConnectEvewithLuminosite

Committer:
dreschpe
Date:
Sat Jan 04 14:49:06 2014 +0000
Revision:
0:3edc602de5a7
Child:
1:a7076a14694b
Demo for FT800 graphic lib; Show automatic track of slider and rotary dial with touch

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 0:3edc602de5a7 9 DigitalOut myled(LED1);
dreschpe 0:3edc602de5a7 10 FT800 TFT(p11,p12,p13,p14,p15,p16); // the FT800 is connected to SPI 11-13
dreschpe 0:3edc602de5a7 11
dreschpe 0:3edc602de5a7 12 /* API to demonstrate calibrate widget/functionality */
dreschpe 0:3edc602de5a7 13 ft_void_t CoPro_Widget_Calibrate()
dreschpe 0:3edc602de5a7 14 {
dreschpe 0:3edc602de5a7 15 /*************************************************************************/
dreschpe 0:3edc602de5a7 16 /* Below code demonstrates the usage of calibrate function. Calibrate */
dreschpe 0:3edc602de5a7 17 /* function will wait untill user presses all the three dots. Only way to*/
dreschpe 0:3edc602de5a7 18 /* come out of this api is to reset the coprocessor bit. */
dreschpe 0:3edc602de5a7 19 /*************************************************************************/
dreschpe 0:3edc602de5a7 20 {
dreschpe 0:3edc602de5a7 21
dreschpe 0:3edc602de5a7 22 TFT.Ft_Gpu_CoCmd_Dlstart(); // start a new display command list
dreschpe 0:3edc602de5a7 23 TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(64,64,64)); // set the clear color R, G, B
dreschpe 0:3edc602de5a7 24 TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
dreschpe 0:3edc602de5a7 25 TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff)); // set the current color R, G, B
dreschpe 0:3edc602de5a7 26 TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth/2), (TFT.FT_DispHeight/2), 27, OPT_CENTER, "Please Tap on the dot"); // draw Text at x,y, font 27, centered
dreschpe 0:3edc602de5a7 27 TFT.Ft_Gpu_CoCmd_Calibrate(0); // start the calibration of touch screen
dreschpe 0:3edc602de5a7 28 TFT.Ft_App_Flush_Co_Buffer(); // download the commands into FT800 FIFO
dreschpe 0:3edc602de5a7 29 TFT.Ft_Gpu_Hal_WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 0:3edc602de5a7 30 }
dreschpe 0:3edc602de5a7 31 }
dreschpe 0:3edc602de5a7 32
dreschpe 0:3edc602de5a7 33
dreschpe 0:3edc602de5a7 34 /***************************************************************************/
dreschpe 0:3edc602de5a7 35 /* Show a Screen with Text for 5 seconds */
dreschpe 0:3edc602de5a7 36 /* A spinner shows the delay */
dreschpe 0:3edc602de5a7 37 /***************************************************************************/
dreschpe 0:3edc602de5a7 38
dreschpe 0:3edc602de5a7 39 ft_void_t API_Screen(ft_char8_t *str)
dreschpe 0:3edc602de5a7 40 {
dreschpe 0:3edc602de5a7 41 TFT.Ft_Gpu_CoCmd_Dlstart(); // start a new display command list
dreschpe 0:3edc602de5a7 42 TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white
dreschpe 0:3edc602de5a7 43 TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
dreschpe 0:3edc602de5a7 44
dreschpe 0:3edc602de5a7 45 TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0x80,0x80,0x00)); // set current color
dreschpe 0:3edc602de5a7 46 TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth/2), TFT.FT_DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31
dreschpe 0:3edc602de5a7 47 TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xFF,0x00,0x00)); // change current color
dreschpe 0:3edc602de5a7 48 TFT.Ft_Gpu_CoCmd_Spinner((TFT.FT_DispWidth/2),TFT.FT_DispHeight/4, 0,0); // draw a animated spinner
dreschpe 0:3edc602de5a7 49
dreschpe 0:3edc602de5a7 50 TFT.Ft_App_WrCoCmd_Buffer(DISPLAY()); // Display the image
dreschpe 0:3edc602de5a7 51 TFT.Ft_Gpu_CoCmd_Swap(); // Swap the current display list
dreschpe 0:3edc602de5a7 52 TFT.Ft_App_Flush_Co_Buffer(); // Download the command list into fifo
dreschpe 0:3edc602de5a7 53
dreschpe 0:3edc602de5a7 54 TFT.Ft_Gpu_Hal_WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 0:3edc602de5a7 55 TFT.Ft_Gpu_Hal_Sleep(5000); // Wait 5 s
dreschpe 0:3edc602de5a7 56 }
dreschpe 0:3edc602de5a7 57
dreschpe 0:3edc602de5a7 58
dreschpe 0:3edc602de5a7 59
dreschpe 0:3edc602de5a7 60 int main()
dreschpe 0:3edc602de5a7 61 {
dreschpe 0:3edc602de5a7 62
dreschpe 0:3edc602de5a7 63 /*************************************************************************/
dreschpe 0:3edc602de5a7 64 /* Below code demonstrates the usage of track function. Track function */
dreschpe 0:3edc602de5a7 65 /* tracks the pen touch on any specific object. Track function supports */
dreschpe 0:3edc602de5a7 66 /* rotary and horizontal/vertical tracks. Rotary is given by rotation */
dreschpe 0:3edc602de5a7 67 /* angle and horizontal/vertucal track is offset position. */
dreschpe 0:3edc602de5a7 68 /*************************************************************************/
dreschpe 0:3edc602de5a7 69 {
dreschpe 0:3edc602de5a7 70 ft_uint32_t TrackRegisterVal = 0;
dreschpe 0:3edc602de5a7 71 ft_uint16_t angleval = 0,slideval = 0,scrollval = 0;
dreschpe 0:3edc602de5a7 72
dreschpe 0:3edc602de5a7 73 API_Screen("DEMO START"); // Show start screen
dreschpe 0:3edc602de5a7 74 CoPro_Widget_Calibrate(); // calibrate the touch screen
dreschpe 0:3edc602de5a7 75
dreschpe 0:3edc602de5a7 76 /* Set the tracker for 3 objects */
dreschpe 0:3edc602de5a7 77 TFT.Ft_Gpu_CoCmd_Track(TFT.FT_DispWidth/2, TFT.FT_DispHeight/2, 1,1, 10);
dreschpe 0:3edc602de5a7 78 TFT.Ft_Gpu_CoCmd_Track(40, (TFT.FT_DispHeight - 40), (TFT.FT_DispWidth - 80),8, 11);
dreschpe 0:3edc602de5a7 79 TFT.Ft_Gpu_CoCmd_Track((TFT.FT_DispWidth - 40), 40, 8,(TFT.FT_DispHeight - 80), 12);
dreschpe 0:3edc602de5a7 80 /* Download the commands into fifo */
dreschpe 0:3edc602de5a7 81 TFT.Ft_App_Flush_Co_Buffer();
dreschpe 0:3edc602de5a7 82
dreschpe 0:3edc602de5a7 83 /* Wait till coprocessor completes the operation */
dreschpe 0:3edc602de5a7 84 TFT.Ft_Gpu_Hal_WaitCmdfifo_empty();
dreschpe 0:3edc602de5a7 85
dreschpe 0:3edc602de5a7 86 /* update the background color continuously for the color change in any of the trackers */
dreschpe 0:3edc602de5a7 87 /* the demo is updating the screen in a endless loop */
dreschpe 0:3edc602de5a7 88 while(1) {
dreschpe 0:3edc602de5a7 89 ft_uint8_t tagval = 0;
dreschpe 0:3edc602de5a7 90 TrackRegisterVal = TFT.Ft_Gpu_Hal_Rd32(REG_TRACKER); // check if one of the tree objectes is touched
dreschpe 0:3edc602de5a7 91 tagval = TrackRegisterVal & 0xff;
dreschpe 0:3edc602de5a7 92 if(0 != tagval) {
dreschpe 0:3edc602de5a7 93 if(10 == tagval) { // the Rotary dial is touched
dreschpe 0:3edc602de5a7 94 angleval = TrackRegisterVal>>16; // get the new angle
dreschpe 0:3edc602de5a7 95 } else if(11 == tagval) { // the vertical slider is touched
dreschpe 0:3edc602de5a7 96 slideval = TrackRegisterVal>>16; // get new slider value
dreschpe 0:3edc602de5a7 97 } else if(12 == tagval) { // the horizontal slider is touched
dreschpe 0:3edc602de5a7 98 scrollval = TrackRegisterVal>>16; // get new slider value
dreschpe 0:3edc602de5a7 99 if((scrollval + 65535/10) > (9*65535/10)) {
dreschpe 0:3edc602de5a7 100 scrollval = (8*65535/10);
dreschpe 0:3edc602de5a7 101 } else if(scrollval < (1*65535/10)) {
dreschpe 0:3edc602de5a7 102 scrollval = 0;
dreschpe 0:3edc602de5a7 103 } else {
dreschpe 0:3edc602de5a7 104 scrollval -= (1*65535/10);
dreschpe 0:3edc602de5a7 105 }
dreschpe 0:3edc602de5a7 106 }
dreschpe 0:3edc602de5a7 107 }
dreschpe 0:3edc602de5a7 108 /* Display a rotary dial, horizontal slider and vertical scroll */
dreschpe 0:3edc602de5a7 109
dreschpe 0:3edc602de5a7 110 TFT.Ft_App_WrCoCmd_Buffer(CMD_DLSTART); // start a new display command list
dreschpe 0:3edc602de5a7 111
dreschpe 0:3edc602de5a7 112 {
dreschpe 0:3edc602de5a7 113 // calculate the new background color based on the sliders and
dreschpe 0:3edc602de5a7 114 ft_int32_t tmpval0,tmpval1,tmpval2; // the rotary
dreschpe 0:3edc602de5a7 115 ft_uint8_t angval,sldval,scrlval;
dreschpe 0:3edc602de5a7 116
dreschpe 0:3edc602de5a7 117 tmpval0 = (ft_int32_t)angleval*255/65536;
dreschpe 0:3edc602de5a7 118 tmpval1 = (ft_int32_t)slideval*255/65536;
dreschpe 0:3edc602de5a7 119 tmpval2 = (ft_int32_t)scrollval*255/65536;
dreschpe 0:3edc602de5a7 120
dreschpe 0:3edc602de5a7 121 angval = tmpval0&0xff;
dreschpe 0:3edc602de5a7 122 sldval = tmpval1&0xff;
dreschpe 0:3edc602de5a7 123 scrlval = tmpval2&0xff;
dreschpe 0:3edc602de5a7 124 TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(angval,sldval,scrlval)); // set the new clear color
dreschpe 0:3edc602de5a7 125 }
dreschpe 0:3edc602de5a7 126 TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
dreschpe 0:3edc602de5a7 127 TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff)); // set current color to white
dreschpe 0:3edc602de5a7 128
dreschpe 0:3edc602de5a7 129 /* Draw dial with 3d effect */
dreschpe 0:3edc602de5a7 130 TFT.Ft_Gpu_CoCmd_FgColor(0x00ff00); // forground color green
dreschpe 0:3edc602de5a7 131 TFT.Ft_Gpu_CoCmd_BgColor(0x800000); // background color
dreschpe 0:3edc602de5a7 132 TFT.Ft_App_WrCoCmd_Buffer(TAG(10)); // assign TAG value 10
dreschpe 0:3edc602de5a7 133 TFT.Ft_Gpu_CoCmd_Dial((TFT.FT_DispWidth/2), (TFT.FT_DispHeight/2), (TFT.FT_DispWidth/8), 0, angleval); // draw dial at display center, dial point at angleval
dreschpe 0:3edc602de5a7 134
dreschpe 0:3edc602de5a7 135 /* Draw slider with 3d effect */
dreschpe 0:3edc602de5a7 136 TFT.Ft_Gpu_CoCmd_FgColor(0x00a000); // forground color green
dreschpe 0:3edc602de5a7 137 TFT.Ft_Gpu_CoCmd_BgColor(0x800000); // background color
dreschpe 0:3edc602de5a7 138 TFT.Ft_App_WrCoCmd_Buffer(TAG(11)); // assign TAG value 11
dreschpe 0:3edc602de5a7 139 TFT.Ft_Gpu_CoCmd_Slider(40, (TFT.FT_DispHeight - 40), (TFT.FT_DispWidth - 80),8, 0, slideval, 65535); // draw Slider, position slideval, max 65535
dreschpe 0:3edc602de5a7 140
dreschpe 0:3edc602de5a7 141 /* Draw scroll with 3d effect */
dreschpe 0:3edc602de5a7 142 TFT.Ft_Gpu_CoCmd_FgColor(0x00a000); // forground color green
dreschpe 0:3edc602de5a7 143 TFT.Ft_Gpu_CoCmd_BgColor(0x000080); // background color
dreschpe 0:3edc602de5a7 144 TFT.Ft_App_WrCoCmd_Buffer(TAG(12)); // assign TAG value 11
dreschpe 0:3edc602de5a7 145 TFT.Ft_Gpu_CoCmd_Scrollbar((TFT.FT_DispWidth - 40), 40, 8, (TFT.FT_DispHeight - 80), 0, scrollval, (65535*0.2), 65535); // draw scrollbar , position scrollval, max 65535
dreschpe 0:3edc602de5a7 146
dreschpe 0:3edc602de5a7 147 TFT.Ft_Gpu_CoCmd_FgColor(TAG_MASK(0)); // reset TAG_MASK
dreschpe 0:3edc602de5a7 148 TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff)); // change current color to white
dreschpe 0:3edc602de5a7 149 TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth/2), ((TFT.FT_DispHeight/2) + (TFT.FT_DispWidth/8) + 8), 26, OPT_CENTER, "Rotary track"); // display text
dreschpe 0:3edc602de5a7 150 TFT.Ft_Gpu_CoCmd_Text(((TFT.FT_DispWidth/2)), ((TFT.FT_DispHeight - 40) + 8 + 8), 26, OPT_CENTER, "Horizontal track"); // display text
dreschpe 0:3edc602de5a7 151 TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth - 40), 20, 26, OPT_CENTER, "Vertical track"); // display text
dreschpe 0:3edc602de5a7 152
dreschpe 0:3edc602de5a7 153 TFT.Ft_App_WrCoCmd_Buffer(DISPLAY()); // Display the image
dreschpe 0:3edc602de5a7 154 TFT.Ft_Gpu_CoCmd_Swap(); // Swap the current display list
dreschpe 0:3edc602de5a7 155
dreschpe 0:3edc602de5a7 156 TFT.Ft_App_Flush_Co_Buffer(); // Download the commands into fifo
dreschpe 0:3edc602de5a7 157
dreschpe 0:3edc602de5a7 158 TFT.Ft_Gpu_Hal_WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
dreschpe 0:3edc602de5a7 159
dreschpe 0:3edc602de5a7 160 TFT.Ft_Gpu_Hal_Sleep(10); // wait 10ms
dreschpe 0:3edc602de5a7 161 } // end of display loop
dreschpe 0:3edc602de5a7 162
dreschpe 0:3edc602de5a7 163
dreschpe 0:3edc602de5a7 164 }
dreschpe 0:3edc602de5a7 165
dreschpe 0:3edc602de5a7 166 }