-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathft232_tft.c
170 lines (137 loc) · 5.05 KB
/
ft232_tft.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*-----------------------------------------------------------------------------
Based on: libftdi - A library (using libusb) to talk to FTDI's UART/FIFO chips
Original Source: https://www.intra2net.com/en/developer/libftdi/
by:
www.intra2net.com 2003-2017 Intra2net AG
1. It loops showing 24bit_color BMP files onto a LCD display connected with Widora via FT232H.
2. Original 24bit color BMP file shall show just up-right in Windows' Painter.
3. Copy libftdi1.so to /usr/lib, make a soft link of libftdi1.so.2 to it.
compile:
./openwrt-gcc -L. -lftdi1 -lusb-1.0 -o ft232_tft ft232_tft.c
usage:
./ft232_tft path
Midas Zhou
-------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "include/ftdi.h"//bitbang ops
#include "ft232.h" //open_ft232(), clos_ft232(); mpss op.
#include "fbmp_op.h" //bmp file operations
/*===================== MAIN ======================*/
int main(int argc, char **argv)
{
int ret;
int i,k;
struct timeval tm_start,tm_end;
int time_use;
//---BMP file
int fp; //file handler
char str_bmpf_path[128]; //directory for BMP files
char str_bmpf_file[STRBUFF];// full path+name for a BMP file.
int Ncount=-1; //--index number of picture displayed
//---- check argv[] ---------
if(argc != 2)
{
printf("input parameter error!\n");
printf("Usage: %s path \n",argv[0]);
return -1;
}
//----- init ft232 ---------
if(usb_init_ft232()<0){
printf("Fail to initialize ft232!\n");
close_ft232();
return -1;
}
//----- Init ILI9488 and turn on display -----
LCD_INIT_ILI9488(); //--set default FXLFMT_RGB888
/*--------------------- Set Pixle Format ---------------------------
default input from bmpfile: RGB888 (from ffmpeg output)
default output to ili9488: RGB888 (output to LCD)
-------------------------------------------------------------------------*/
//---CASE... input: RGB565 , output: RGB565 ---- WORSE !!! !!! !!!
/*
FBMP_PxlFmt=PXLFMT_RGB565;//888;//565; //BMP file format
//----- MUSE adjust RGB order here ------
LCD_Write_Cmd(0x36); //memory data access control
LCD_Write_Data(0x68); // oder: BGR, see fbmp_op.h for bits exchange.
LCD_Set_PxlFmt16bit();
*/
//---CASE... input: RGB888 , output: RGB565 ---- BAD !!! !!!
/*
FBMP_PxlFmt=PXLFMT_RGB888;
LCD_Set_PxlFmt16bit();
*/
//---CASE... input: RGB888 , output: RGB888 ---- GOOD !!!
FBMP_PxlFmt=PXLFMT_RGB888;
LCD_Set_PxlFmt24bit();
//<<<<<<<<<<<<< refresh GRAPHIC BUFFER test >>>>>>>>>>>>>>>>
uint32_t tmpd=1;
/*
while(1)
{
if(tmpd ==0 ) tmpd=1;
tmpd=tmpd<<1;
for(i=0;i<480*320;i++){
g_GBuffer[i][0]=tmpd & 0xff;
g_GBuffer[i][1]=((tmpd & 0xff00)>>8);
g_GBuffer[i][2]=((tmpd & 0xff0000)>>16);
}
gettimeofday(&tm_start,NULL);
LCD_Write_Cmd(0x22);//all pixels off
// LCD_Write_Cmd(0x28);//display off
LCD_Write_GBuffer();
// LCD_Write_Cmd(0x23);//all pixels on
// LCD_Write_Cmd(0x29);//display on
LCD_Write_Cmd(0x13);//normal display mode on
usleep(200000);
gettimeofday(&tm_end,NULL);
time_use=(tm_end.tv_sec-tm_start.tv_sec)*1000+(tm_end.tv_usec-tm_start.tv_usec)/1000;
printf(" ------ finish refreshing whole graphic buffer, time_use=%dms ----- \n",time_use);
}
*/
//<<<<<<<<<<<<<<<<< BMP FILE TEST >>>>>>>>>>>>>>>>>>
//strcpy(str_bmpf_path,"/tmp");//set directory
strcpy(str_bmpf_path,argv[1]);
while(1) //loop showing BMP files in a directory
{
//-------------- reload total_numbe after one round show ---------
printf("BMP file Ncount =%d \n",Ncount);
if( Ncount < 0)
{
//---- find out all BMP files in specified path
Find_BMP_files(str_bmpf_path);
printf("\n\n========== reload BMP file, totally %d BMP-files found. ============\n",g_BMP_file_total);
if(g_BMP_file_total == 0){
printf("\n No BMP file found! \n");
return -3;
}
Ncount=g_BMP_file_total-1; //---reset Ncount, [Nount] starting from 0
}
//----- load BMP file path -------------
sprintf(str_bmpf_file,"%s/%s",str_bmpf_path,g_BMP_file_name[Ncount]);
printf("str = %s\n",str_bmpf_file);
Ncount--;
//------ show the bmp file and count time -------
gettimeofday(&tm_start,NULL);
show_bmpf(str_bmpf_file);
gettimeofday(&tm_end,NULL);
time_use=(tm_end.tv_sec-tm_start.tv_sec)*1000+(tm_end.tv_usec-tm_start.tv_usec)/1000;
printf(" \n ------ finish loading a file, time_use=%dms ----- \n",time_use);
//
usleep(60000);
// sleep(3); //---hold on for a while
}
//<<<<<<<<<<<<<<< color block test >>>>>>>>>>>>>
uint8_t color_buf[3];
color_buf[0]=0xff;color_buf[1]=0x00;color_buf[2]=0x00;
LCD_ColorBox(0,0,30,300,color_buf);
color_buf[0]=0x00;color_buf[1]=0xff;color_buf[2]=0x00;
LCD_ColorBox(30,0,30,300,color_buf);
color_buf[0]=0x00;color_buf[1]=0x00;color_buf[2]=0xff;
LCD_ColorBox(60,0,30,300,color_buf);
//----- free and close ft232 usb device -----
close_ft232();
//----- free pinmap and close ILI9488 -----
close_ili9488();
return ret;
}