Programme for Test ConnectEve from Mikroe Its Ok

Dependencies:   mbed FT800okForConnectEvewithLuminosite

Revision:
1:a7076a14694b
Parent:
0:3edc602de5a7
Child:
3:303f91161be0
diff -r 3edc602de5a7 -r a7076a14694b main.cpp
--- a/main.cpp	Sat Jan 04 14:49:06 2014 +0000
+++ b/main.cpp	Sat Sep 20 12:03:54 2014 +0000
@@ -6,161 +6,100 @@
 #include "mbed.h"
 #include "FT_Platform.h"
 
-DigitalOut myled(LED1);
-FT800 TFT(p11,p12,p13,p14,p15,p16);       // the FT800 is connected to SPI 11-13
-
-/* API to demonstrate calibrate widget/functionality */
-ft_void_t CoPro_Widget_Calibrate()
-{
-    /*************************************************************************/
-    /* Below code demonstrates the usage of calibrate function. Calibrate    */
-    /* function will wait untill user presses all the three dots. Only way to*/
-    /* come out of this api is to reset the coprocessor bit.                 */
-    /*************************************************************************/
-    {
-
-        TFT.Ft_Gpu_CoCmd_Dlstart();                                 // start a new display command list
-        TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(64,64,64));       // set the clear color R, G, B
-        TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1));                    // clear buffers -> color buffer,stencil buffer, tag buffer
-        TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff));       // set the current color R, G, B
-        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
-        TFT.Ft_Gpu_CoCmd_Calibrate(0);                              // start the calibration of touch screen
-        TFT.Ft_App_Flush_Co_Buffer();                               // download the commands into FT800 FIFO
-        TFT.Ft_Gpu_Hal_WaitCmdfifo_empty();                         // Wait till coprocessor completes the operation
-    }
-}
-
+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
 
 /***************************************************************************/
 /* Show a Screen with Text for 5 seconds                                   */
 /* A spinner shows the delay                                               */
 /***************************************************************************/
 
-ft_void_t API_Screen(ft_char8_t *str)
+ft_void_t Start_Screen(ft_char8_t *str)
 {
-    TFT.Ft_Gpu_CoCmd_Dlstart();                                   // start a new display command list
-    TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(255,255,255));      // set the clear color to white
-    TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1));                      // clear buffers -> color buffer,stencil buffer, tag buffer
+    TFT.DLstart();                                         // start a new display command list
+    TFT.DL(CLEAR_COLOR_RGB(255,255,255));      // set the clear color to white
+    TFT.DL(CLEAR(1,1,1));                      // clear buffers -> color buffer,stencil buffer, tag buffer
+    TFT.DL(COLOR_RGB(0x80,0x80,0x00));         // set current color
+    TFT.Text((TFT.DispWidth/2), TFT.DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31
+    TFT.DL(COLOR_RGB(0xFF,0x00,0x00));         // change current color
+    TFT.Spinner((TFT.DispWidth/2),TFT.DispHeight/4, 0,0);  // draw a animated spinner
+
+    TFT.DL(DISPLAY());                         // Display the image
+    TFT.Swap();                                            // Swap the current display list
+    TFT.Flush_Co_Buffer();                                 // Download the command list into fifo
+
+    TFT.WaitCmdfifo_empty();                               // Wait till coprocessor completes the operation
+    TFT.Sleep(5000);                                       // Wait 5 s to show
+}
 
-    TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0x80,0x80,0x00));         // set current color
-    TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth/2), TFT.FT_DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31
-    TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xFF,0x00,0x00));         // change current color
-    TFT.Ft_Gpu_CoCmd_Spinner((TFT.FT_DispWidth/2),TFT.FT_DispHeight/4, 0,0); // draw a animated spinner
+// construct the screen and downloasd it to the LCD
+void screen_1(unsigned int r,unsigned int g,unsigned int b)
+{
+    TFT.DLstart();                         // start a new display command list
+    TFT.DL(CLEAR(1,1,1));                  // clear buffers -> color buffer,stencil buffer, tag buffer
+    TFT.DL(COLOR_RGB(0xff,0xff,0xff));     // set current color to white
+    TFT.DL(TAG(1));                        // assign TAG value 1
+    TFT.FgColor(COLOR_RGB(0xff,0,0));      // forground color red
+    TFT.Slider(140,81,310,14,0,r,255);     // slider for red
+    TFT.DL(TAG(2));                        // assign TAG value 2
+    TFT.FgColor(COLOR_RGB(0,0xff,0));      // forground color green
+    TFT.Slider(140,133,310,14,0,g,255);    // slider for green
+    TFT.DL(TAG(3));                        // assign TAG value 3
+    TFT.FgColor(COLOR_RGB(0,0,0xff));      // forground color blue
+    TFT.Slider(139,185,310,14,0,b,255);    // slider for blue
+    TFT.DL(COLOR_RGB(0xff,0x00,0x00));     // set current color to red
+    TFT.Text(82,69,30,0,"R");              // text R
+    TFT.DL(COLOR_RGB(0x00,0xff,0x00));     // set current color to green
+    TFT.Text(82,120,30,0,"G");             // text G
+    TFT.DL(COLOR_RGB(0x00,0x00,0xff));     // set current color to blue
+    TFT.Text(82,174,30,0,"B");             // text B
+    TFT.DL(SCISSOR_XY(10,10));             // define area starting at 10,10
+    TFT.DL(SCISSOR_SIZE(50,50));           // size 50,50
+    TFT.DL(CLEAR_COLOR_RGB(r,g,b));        // set clear color to r,g,b
+    TFT.DL(CLEAR(1,1,1));                  // fill the area
+    TFT.DL(DISPLAY());                     // Display the image
+    TFT.Swap();                            // Swap the current display list
+    TFT.Flush_Co_Buffer();                 // Download the command list into fifo
+    TFT.WaitCmdfifo_empty();               // Wait till coprocessor completes the operation
+}
 
-    TFT.Ft_App_WrCoCmd_Buffer(DISPLAY());                         // Display the image
-    TFT.Ft_Gpu_CoCmd_Swap();                                      // Swap the current display list
-    TFT.Ft_App_Flush_Co_Buffer();                                 // Download the command list into fifo
+int main()
+{
+    unsigned int r = 0,g = 0,b = 0;
+    ft_uint32_t TrackRegisterVal = 0;              // touch track
+
+    Start_Screen("RGB DEMO START");                // Show start screen
+    TFT.Calibrate();                               // calibrate the touch screen
+
+    /* Set the tracker for the 3 sliders -  define the Area for touching */
+    TFT.Track(131,63,330,48,1);                     // slider r
+    TFT.Track(131,116,333,48,2);                    // slider g
+    TFT.Track(131,168,330,48,3);                    // slider b
+    TFT.Flush_Co_Buffer();                          // Download the commands into fifo
+    TFT.WaitCmdfifo_empty();                        // Wait till coprocessor completes the operation
+    screen_1(r,g,b);                                // paint screen
 
-    TFT.Ft_Gpu_Hal_WaitCmdfifo_empty();                           // Wait till coprocessor completes the operation
-    TFT.Ft_Gpu_Hal_Sleep(5000);                                   // Wait 5 s
+    /* the demo is updating the screen in a endless loop                                    */
+    while(1) {
+        ft_uint8_t tagval = 0;
+        TrackRegisterVal = TFT.Rd32(REG_TRACKER);    // check if one of the tree Slider is touched
+        tagval = TrackRegisterVal & 0xff;
+        if(0 != tagval) {                            // touch -> get new rgb value
+            if(1 == tagval) {                        // the red slider is touched
+                r = TrackRegisterVal>>16;            // get the new value
+                r = r *255/65536;                    // scale it down to 255
+            } else if(2 == tagval) {                 // the green slider is touched
+                g = TrackRegisterVal>>16;            // get new slider value
+                g = g * 255/65536;                   // scale it down to 255
+            } else if(3 == tagval) {                 // the blue slider is touched
+                b = TrackRegisterVal>>16;            // get new slider value
+                b = b * 255/65536;                   // scale it down to 255
+            }
+            screen_1(r,g,b);                         // paint new screen
+            TFT.Sleep(10);                           // wait 10ms for next check
+        }
+
+    }  // end of display loop
 }
 
 
 
-int main()
-{
-
-    /*************************************************************************/
-    /* Below code demonstrates the usage of track function. Track function   */
-    /* tracks the pen touch on any specific object. Track function supports  */
-    /* rotary and horizontal/vertical tracks. Rotary is given by rotation    */
-    /* angle and horizontal/vertucal track is offset position.               */
-    /*************************************************************************/
-    {
-        ft_uint32_t TrackRegisterVal = 0;
-        ft_uint16_t angleval = 0,slideval = 0,scrollval = 0;
-
-        API_Screen("DEMO  START");                  // Show start screen
-        CoPro_Widget_Calibrate();                   // calibrate the touch screen
-
-        /* Set the tracker for 3 objects */
-        TFT.Ft_Gpu_CoCmd_Track(TFT.FT_DispWidth/2, TFT.FT_DispHeight/2, 1,1, 10);
-        TFT.Ft_Gpu_CoCmd_Track(40, (TFT.FT_DispHeight - 40), (TFT.FT_DispWidth - 80),8, 11);
-        TFT.Ft_Gpu_CoCmd_Track((TFT.FT_DispWidth - 40), 40, 8,(TFT.FT_DispHeight - 80), 12);
-        /* Download the commands into fifo */
-        TFT.Ft_App_Flush_Co_Buffer();
-
-        /* Wait till coprocessor completes the operation */
-        TFT.Ft_Gpu_Hal_WaitCmdfifo_empty();
-
-        /* update the background color continuously for the color change in any of the trackers */
-        /* the demo is updating the screen in a endless loop                                    */
-        while(1) {
-            ft_uint8_t tagval = 0;
-            TrackRegisterVal = TFT.Ft_Gpu_Hal_Rd32(REG_TRACKER);    // check if one of the tree objectes is touched
-            tagval = TrackRegisterVal & 0xff;
-            if(0 != tagval) {
-                if(10 == tagval) {                                  // the Rotary dial is touched
-                    angleval = TrackRegisterVal>>16;                // get the new angle
-                } else if(11 == tagval) {                           // the vertical slider is touched
-                    slideval = TrackRegisterVal>>16;                // get new slider value
-                } else if(12 == tagval) {                           // the horizontal slider is touched
-                    scrollval = TrackRegisterVal>>16;               // get new slider value
-                    if((scrollval + 65535/10) > (9*65535/10)) {
-                        scrollval = (8*65535/10);
-                    } else if(scrollval < (1*65535/10)) {
-                        scrollval = 0;
-                    } else {
-                        scrollval -= (1*65535/10);
-                    }
-                }
-            }
-            /* Display a rotary dial, horizontal slider and vertical scroll */
-
-            TFT.Ft_App_WrCoCmd_Buffer(CMD_DLSTART);                     // start a new display command list
-
-            {
-                // calculate the new background color based on the sliders and
-                ft_int32_t tmpval0,tmpval1,tmpval2;                     // the rotary
-                ft_uint8_t angval,sldval,scrlval;
-
-                tmpval0 = (ft_int32_t)angleval*255/65536;
-                tmpval1 = (ft_int32_t)slideval*255/65536;
-                tmpval2 = (ft_int32_t)scrollval*255/65536;
-
-                angval = tmpval0&0xff;
-                sldval = tmpval1&0xff;
-                scrlval = tmpval2&0xff;
-                TFT.Ft_App_WrCoCmd_Buffer(CLEAR_COLOR_RGB(angval,sldval,scrlval)); // set the new clear color
-            }
-            TFT.Ft_App_WrCoCmd_Buffer(CLEAR(1,1,1));                               // clear buffers -> color buffer,stencil buffer, tag buffer
-            TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff));                  // set current color to white
-
-            /* Draw dial with 3d effect */
-            TFT.Ft_Gpu_CoCmd_FgColor(0x00ff00);                                    // forground color green
-            TFT.Ft_Gpu_CoCmd_BgColor(0x800000);                                    // background color
-            TFT.Ft_App_WrCoCmd_Buffer(TAG(10));                                    // assign TAG value 10
-            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
-
-            /* Draw slider with 3d effect */
-            TFT.Ft_Gpu_CoCmd_FgColor(0x00a000);                                     // forground color green
-            TFT.Ft_Gpu_CoCmd_BgColor(0x800000);                                     // background color
-            TFT.Ft_App_WrCoCmd_Buffer(TAG(11));                                     // assign TAG value 11
-            TFT.Ft_Gpu_CoCmd_Slider(40, (TFT.FT_DispHeight - 40), (TFT.FT_DispWidth - 80),8, 0, slideval, 65535);  // draw Slider, position slideval, max 65535
-
-            /* Draw scroll with 3d effect */
-            TFT.Ft_Gpu_CoCmd_FgColor(0x00a000);                                     // forground color green
-            TFT.Ft_Gpu_CoCmd_BgColor(0x000080);                                     // background color
-            TFT.Ft_App_WrCoCmd_Buffer(TAG(12));                                     // assign TAG value 11
-            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
-
-            TFT.Ft_Gpu_CoCmd_FgColor(TAG_MASK(0));                                  // reset TAG_MASK
-            TFT.Ft_App_WrCoCmd_Buffer(COLOR_RGB(0xff,0xff,0xff));                   // change current color to white
-            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
-            TFT.Ft_Gpu_CoCmd_Text(((TFT.FT_DispWidth/2)), ((TFT.FT_DispHeight - 40) + 8 + 8), 26, OPT_CENTER, "Horizontal track");           // display text
-            TFT.Ft_Gpu_CoCmd_Text((TFT.FT_DispWidth - 40), 20, 26, OPT_CENTER, "Vertical track");                                            // display text
-
-            TFT.Ft_App_WrCoCmd_Buffer(DISPLAY());                                   // Display the image
-            TFT.Ft_Gpu_CoCmd_Swap();                                                // Swap the current display list
-
-            TFT.Ft_App_Flush_Co_Buffer();                                           // Download the commands into fifo
-
-            TFT.Ft_Gpu_Hal_WaitCmdfifo_empty();                                     // Wait till coprocessor completes the operation
-
-            TFT.Ft_Gpu_Hal_Sleep(10);                                               // wait 10ms
-        }  // end of display loop
-
-
-    }
-
-}