Lib for FTDI FT800 graphic controller "EVE" The API is changed from the FTDI original names. It use smaller names now. DL() will add something to the display list instead of Ft_App_WrCoCmd_Buffer ... The FTDI programmer Guide is also using this commands.
Dependents: FT800_RGB_demo FT800_RGB_demo2 FT800_demo_for_habr Temp_&_RH_at_TFT-demo ... more
Fork of FT800 by
The mbed is talking thru the SPI interface with the graphic engine. We have to set up a list of Commands and send them to the FT800 to get graphics.
Hardware
1. VM800C development modules from FTDI : http://www.ftdichip.com/Products/Modules/VM800C.html
The modules come with different size lcd. 3.5", 4.3" or 5" or without. The picture shows a modified board, because my lcd had a different pinout. The mbed is connected to the pin header on the bottom.
2. EVBEVE-FT800 board from GLYN: http://www.glyn.com/News-Events/Newsletter/Newsletter-2013/October-2013/A-quick-start-for-EVE-Requires-no-basic-knowledge-graphics-sound-and-touch-can-all-be-learned-in-minutes
The module has a 40 pin flex cable connector to connect a display out of the EDT series.
The mbed is connected via the pin header on the left. If you use this board with a EDT display you have to uncomment the #define Inv_Backlite in FT_LCD_Type.h, because the backlight dimming is inverted.
3. ConnectEVE board from MikroElektronika http://www.mikroe.com/add-on-boards/display/connecteve/#headers_10 The board has also a pin header to connect the mbed. - not tested, but it looks like the other boards.
4. ADAM arduino shield http://www.4dsystems.com.au/product/4DLCD_FT843/ Component page : http://mbed.org/components/ADAM/
Works with the NUCLEO boards, but you have to patch three wires.
Connection
We need 5 signals to connect to the mbed. SCK, MOSI and MISO are connected to a SPI channel. SS is the chip select signal and PD work as powerdown. The additional INT signal is not used at the moment. It is possible to generate a interrupt signal, but at the moment you have to poll the status register of the FT800 to see if a command is finished.
Software
This lib is based on the demo code from FTDI. If you want to use it, you have to read the programming manual : http://www.ftdichip.com/Support/Documents/ProgramGuides/FT800%20Programmers%20Guide.pdf
See my demo : http://mbed.org/users/dreschpe/code/FT800_RGB_demo/
Revision 4:363ec27cdfaa, committed 2014-09-20
- Comitter:
- dreschpe
- Date:
- Sat Sep 20 11:35:43 2014 +0000
- Parent:
- 3:392d2c733c68
- Child:
- 5:c0ffdb08b8a5
- Commit message:
- change API
Changed in this revision
--- a/FT_CoPro_Cmds.cpp Fri Sep 19 15:56:15 2014 +0000 +++ b/FT_CoPro_Cmds.cpp Sat Sep 20 11:35:43 2014 +0000 @@ -444,7 +444,7 @@ EndFunc( (FT_CMD_SIZE*3)); } -ft_void_t FT800::Dlstart( ) +ft_void_t FT800::DLstart( ) { StartFunc( FT_CMD_SIZE*1); SendCmd( CMD_DLSTART); @@ -477,7 +477,7 @@ } -ft_void_t FT800::WrCoCmd_Buffer(ft_uint32_t cmd) +ft_void_t FT800::DL(ft_uint32_t cmd) { WrCmd32(cmd); /* Increment the command index */
--- a/FT_Gpu_Hal.cpp Fri Sep 19 15:56:15 2014 +0000 +++ b/FT_Gpu_Hal.cpp Sat Sep 20 11:35:43 2014 +0000 @@ -90,11 +90,12 @@ DispVSync1 = my_DispVSync1; Wr16( REG_VSYNC1, DispVSync1); DispSwizzle = my_DispSwizzle; - //Wr8( REG_SWIZZLE, FT_DispSwizzle); + Wr8( REG_SWIZZLE, DispSwizzle); DispPCLKPol = my_DispPCLKPol; - //Wr8( REG_PCLK_POL, FT_DispPCLKPol); + Wr8( REG_PCLK_POL, DispPCLKPol); + Wr8( REG_CSPREAD, 1); DispPCLK = my_DispPCLK; - //Wr8( REG_PCLK,FT_DispPCLK);//after this display is visible on the LCD + Wr8( REG_PCLK, DispPCLK);//after this display is visible on the LCD Wr16( REG_PWM_HZ, 1000);
--- a/FT_Gpu_Hal.h Fri Sep 19 15:56:15 2014 +0000 +++ b/FT_Gpu_Hal.h Sat Sep 20 11:35:43 2014 +0000 @@ -226,7 +226,7 @@ ft_void_t Keys(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s); ft_void_t Dial(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t val); ft_void_t LoadImage(ft_uint32_t ptr, ft_uint32_t options); - ft_void_t Dlstart(); + ft_void_t DLstart(); ft_void_t Snapshot(ft_uint32_t ptr); ft_void_t ScreenSaver(); ft_void_t Memcrc(ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result); @@ -243,7 +243,7 @@ ft_uint16_t fifo_Freespace( ); - ft_void_t WrCoCmd_Buffer(ft_uint32_t cmd); + ft_void_t DL(ft_uint32_t cmd); ft_void_t WrDlCmd_Buffer(ft_uint32_t cmd); ft_void_t Flush_DL_Buffer(); ft_void_t Flush_Co_Buffer(); @@ -253,6 +253,9 @@ ft_void_t Sound_ON(); ft_void_t Sound_OFF(); + + int Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size); + ft_void_t Calibrate(); }; // end of class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FT_Hal_Utils.cpp Sat Sep 20 11:35:43 2014 +0000 @@ -0,0 +1,82 @@ +#include "FT_Platform.h" +#include "mbed.h" + +/* function to load jpg file from filesystem */ +/* return 0 if jpg is ok */ +/* return x_size and y_size of jpg */ + +int FT800::Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size) +{ + unsigned char pbuff[8291]; + unsigned short marker; + unsigned short length; + unsigned char data[4]; + + ft_uint16_t blocklen; + + FILE *fp = fopen(filename, "r"); + if(fp == NULL) return (-1); // connot open file + + // search for 0xFFC0 marker + fseek(fp, 0, SEEK_END); + unsigned int Fsize = ftell(fp); + fseek(fp, 2, SEEK_SET); + fread(data,4,1,fp); + marker = data[0] << 8 | data[1]; + length = data[2] << 8 | data[3]; + do { + if(marker == 0xFFC0) break; + if(marker & 0xFF00 != 0xFF00) break; + if (fseek(fp, length - 2,SEEK_CUR) != 0) break; + fread(data,4,1,fp); + marker = data[0] << 8 | data[1]; + length = data[2] << 8 | data[3]; + } while(1); + if(marker != 0xFFC0) return (-2); // no FFC0 Marker, wrong format no baseline DCT-based JPEG + fseek(fp, 1,SEEK_CUR); + fread(data,4,1,fp); + *y_size = (data[0] << 8 | data[1]); + *x_size = (data[2] << 8 | data[3]); + + //if(*x_size > DispWidth || *y_size > DispHeight) return (-3); // to big to fit on screen + + fseek(fp, 0, SEEK_SET); + WrCmd32(CMD_LOADIMAGE); // load a JPEG image + WrCmd32(0); //destination address of jpg decode + WrCmd32(0); //output format of the bitmap - default is rgb565 + while(Fsize > 0) { + /* download the data into the command buffer by 8kb one shot */ + blocklen = Fsize>8192?8192:Fsize; + /* copy the data into pbuff and then transfter it to command buffer */ + fread(pbuff,1,blocklen,fp); + Fsize -= blocklen; + /* copy data continuously into command memory */ + WrCmdBuf(pbuff, blocklen); //alignment is already taken care by this api + } + fclose(fp); + + return(0); +} + + +/* calibrate touch */ +ft_void_t FT800::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. */ + /*************************************************************************/ + { + + DLstart(); // start a new display command list + DL(CLEAR_COLOR_RGB(64,64,64)); // set the clear color R, G, B + DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer + DL(COLOR_RGB(0xff,0xff,0xff)); // set the current color R, G, B + Text((DispWidth/2), (DispHeight/2), 27, OPT_CENTER, "Please Tap on the dot"); // draw Text at x,y, font 27, centered + Calibrate(0); // start the calibration of touch screen + Flush_Co_Buffer(); // download the commands into FT800 FIFO + WaitCmdfifo_empty(); // Wait till coprocessor completes the operation + } +} +
--- a/FT_Hal_Utils.h Fri Sep 19 15:56:15 2014 +0000 +++ b/FT_Hal_Utils.h Sat Sep 20 11:35:43 2014 +0000 @@ -17,7 +17,6 @@ #define INVALID_TOUCH_XY 0x8000 #define ABS(x) ((x) > (0) ? (x) : (-x)) - #endif /* _FT_HAL_UTILS_H_ */