The Best / Mbed 2 deprecated FT810_LoadJPG

Dependencies:   FT800_3 SDFileSystem mbed

Revision:
0:d53f428d8f41
Child:
1:9221588f4198
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 29 15:33:47 2016 +0000
@@ -0,0 +1,133 @@
+/* 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"
+#include "stdio.h"
+#include "float.h"
+#include "SDFileSystem.h"
+
+#define SAMAPP_DELAY_BTW_APIS (1000)
+#define SAMAPP_ENABLE_DELAY() Ft_Gpu_Hal_Sleep(SAMAPP_DELAY_BTW_APIS)
+#define SAMAPP_ENABLE_DELAY_VALUE(x) Ft_Gpu_Hal_Sleep(x)
+
+FT800 TFT(D11,D12,D13,D9,D8,D14);
+SDFileSystem sd(D11, D12, D13, D10, "sd");
+
+// global Vars
+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                              */
+/* return x_size and y_size of jpg                    */
+
+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.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*/
+
+       /* 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
+}
+
+
+