Displays JPG named Logo from SD card

Dependencies:   FT800_3 SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
montgojj
Date:
Fri Aug 05 18:59:54 2016 +0000
Parent:
0:d53f428d8f41
Commit message:
Releasing everything for final work day.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d53f428d8f41 -r 9221588f4198 main.cpp
--- a/main.cpp	Tue Mar 29 15:33:47 2016 +0000
+++ b/main.cpp	Fri Aug 05 18:59:54 2016 +0000
@@ -1,7 +1,3 @@
-/* Demo for mbed Library for FTDI FT800  Enbedded Video Engine "EVE"
- * to show jpg file handling
- * c by Peter Drescher, DC2PD 2014
- * Released under the MIT License: http://mbed.org/license/mit */
 #include "mbed.h"
 #include "FT_Platform.h"
 #include "FT_color.h"
@@ -20,64 +16,6 @@
 unsigned int r, b, g;
 char buffer[50];
 
-
-void hsv2rgb(double H,double S, double V)
-{
-    double f,h,p,q,t;
-    int i;
-    if( S == 0.0) {
-        r = V * 255;  
-        g = V * 255;
-        b = V * 255;
-        return;
-    }
-    if(H > 480.0) H = 0.0;   // check values
-    if(S > 1.0) S = 1.0; 
-    if(S < 0.0) S = 0.0;
-    if(V > 1.0) V = 1.0;
-    if(V < 0.0) V = 0.0;
-    
-    h = H / 60.0;
-    i = (int) h;
-    f = h - i;
-    p = V * (1.0 - S);
-    q = V * (1.0 - (S * f));
-    t = V * (1.0 - (S * (1.0 - f)));
- 
-    switch(i) {
-        case 0:
-            r = V * 255;  
-            g = t * 255;
-            b = p * 255;
-            break;
-        case 1:
-            r = q * 255;
-            g = V * 255;
-            b = p * 255;
-            break;
-        case 2:
-            r = p * 255;
-            g = V * 255;
-            b = t * 255;
-            break;
-        case 3:
-            r = p * 255;
-            g = q * 255;
-            b = V * 255;
-            break;
-        case 4:
-            r = t * 255;
-            g = p * 255;
-            b = V * 255;
-            break;
-        case 5:
-        default:
-            r = V * 255;
-            g = p * 255;
-            b = q * 255;
-            break;
-    }  
-}
 /* function to load jpg file from internal filesystem */
 /* into FT800 buffer and decode JPG to bitmap         */        
 /* return 0 if jpg is ok                              */
@@ -86,47 +24,68 @@
 int main()
 {
     ft_int16_t x_size,y_size;
-    int err;
-    
-    TFT.MemWrite(REG_ROTATE, 1);
-    TFT.Rotate(1);
-    
-    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 buffe
 
-    err = TFT.Load_jpg("/sd/Logo.jpg",& x_size,& y_size);      // load graphic data into buffer and decode jpg to bitmap
-    if(err != 0) {                                           // something is wrong - display error   
-        TFT.DL(COLOR_RGB(0,0,0));         // set current color
-        TFT.Text(TFT.DispWidth/2, TFT.DispHeight/2, 25, OPT_CENTERX, "Error"); // draw Text with font 31
-        TFT.Number(50,50,25,OPT_SIGNED,err);
-
-    } else {   // jpg is loaded and decoded into bitmap
+    TFT.MemWrite(REG_ROTATE,1);
+    TFT.Rotate(1);
+    //TFT.Calibrate();                               // calibrate the touch screen
+    TFT.DLstart();
+    TFT.DL(CLEAR_COLOR_RGB(255,255,255));
+    TFT.DL(CLEAR(1,1,1));
+    
+    TFT.DL(BITMAP_HANDLE(0));
+    TFT.Load_jpg("/sd/Logo.jpg",& x_size,& y_size, 0);  
+    
+    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(); 
 
+    TFT.Track(225, 375, 350, 30, 1);
+    TFT.Flush_Co_Buffer();                         // Download the commands into fifo
+    TFT.WaitCmdfifo_empty();                       // Wait till coprocessor completes the operation
+    while(1) {
+        TFT.DLstart();
+        TFT.DL(CLEAR_COLOR_RGB(255,255,255));
+        TFT.DL(CLEAR(1,1,1));
         TFT.DL(BEGIN(BITMAPS));
-        TFT.LoadIdentity();
-        //TFT.Ft_Gpu_CoCmd_Rotate((45*65536/360));//rotate by 45 degrees anticlock wise
-        //TFT.Ft_Gpu_CoCmd_Scale(32768,32768);//scale by  2x2
-        TFT.SetMatrix();
-        TFT.DL(VERTEX2F(0,0));
-
-        /*TFT.DL(DISPLAY());                         // Display the image
+        TFT.DL(VERTEX2II(512,50,0,0));          //Write logo (bitmap handle 0) to pixel 512
+        TFT.DL(VERTEX_TRANSLATE_X(50*16));      //Translate by 50 pixels
+        TFT.DL(VERTEX2II(511,200,0,0));         //Write logo
+        TFT.DL(VERTEX_TRANSLATE_X(0*16));       //Translate back
+        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.WaitCmdfifo_empty();                               // Wait till coprocessor completes the operation
+        
+        
+        
+        
+        
+        /*ft_uint8_t tagval = 0;
+        TrackRegisterVal = TFT.Rd32(REG_TRACKER);    // check if one of the two tracking fields is touched
+        tagval = TrackRegisterVal & 0xff; 
+        
+        
+        TFT.DL(COLOR_RGB(0x00,0x7C,0xC4));
+        TFT.Text(265, 200, 31, 0, "ITV 1 Pressure");
+        TFT.DL(BEGIN(RECTS));
+        TFT.DL(VERTEX2F(300*16,265*16));
+        TFT.DL(VERTEX2F(505*16,330*16));
+        TFT.DL(END());
+        TFT.DL(COLOR_RGB(255,255,255));
+        sprintf(buffer, "%.1f", ITVpressure1_feedback);
+        TFT.Text(325,275,31,0,buffer);
+        TFT.Text(415, 275, 31, 0, " PSI");
+        ITVpressure1_feedback =  0;
+        TFT.DL(COLOR_RGB(255,255,255));
+ 
+        TFT.FgColor(COLOR_RGB(0,124,196));
+        TFT.BgColor(COLOR_RGB(0,124,196));
+        TFT.DL(TAG(1));                        // assign TAG value 1
+        TFT.Slider(225,375,350,30,0,ITVpressure1_user_input,65535);*/
 
-       /* wait(2);
-        TFT.DL(BEGIN(BITMAPS));
-        TFT.LoadIdentity();
-        //TFT.Ft_Gpu_CoCmd_Rotate((45*65536/360));//rotate by 45 degrees anticlock wise
-        //TFT.Ft_Gpu_CoCmd_Scale(32768,32768);//scale by  2x2
-        TFT.SetMatrix();
-        TFT.DL(VERTEX2F(0,0));*/
+        
     }
-    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
 }