|
@@
-1,260
+1,272
|
|
1
|
/*------------------------------------------------------------------------------
|
|
1
|
/*------------------------------------------------------------------------------
|
|
2
|
-- This file is a part of the libuc, microcontroler library
|
|
2
|
-- This file is a part of the libuc, microcontroler library
|
|
3
|
-- Copyright (C) 2012, Alexis Jeandet
|
|
3
|
-- Copyright (C) 2012, Alexis Jeandet
|
|
4
|
--
|
|
4
|
--
|
|
5
|
-- This program is free software; you can redistribute it and/or modify
|
|
5
|
-- This program is free software; you can redistribute it and/or modify
|
|
6
|
-- it under the terms of the GNU General Public License as published by
|
|
6
|
-- it under the terms of the GNU General Public License as published by
|
|
7
|
-- the Free Software Foundation; either version 3 of the License, or
|
|
7
|
-- the Free Software Foundation; either version 3 of the License, or
|
|
8
|
-- (at your option) any later version.
|
|
8
|
-- (at your option) any later version.
|
|
9
|
--
|
|
9
|
--
|
|
10
|
-- This program is distributed in the hope that it will be useful,
|
|
10
|
-- This program is distributed in the hope that it will be useful,
|
|
11
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-- GNU General Public License for more details.
|
|
13
|
-- GNU General Public License for more details.
|
|
14
|
--
|
|
14
|
--
|
|
15
|
-- You should have received a copy of the GNU General Public License
|
|
15
|
-- You should have received a copy of the GNU General Public License
|
|
16
|
-- along with this program; if not, write to the Free Software
|
|
16
|
-- along with this program; if not, write to the Free Software
|
|
17
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
-------------------------------------------------------------------------------
|
|
18
|
-------------------------------------------------------------------------------
|
|
19
|
-- Author : Alexis Jeandet
|
|
19
|
-- Author : Alexis Jeandet
|
|
20
|
-- Mail : alexis.jeandet@gmail.com
|
|
20
|
-- Mail : alexis.jeandet@gmail.com
|
|
21
|
-------------------------------------------------------------------------------*/
|
|
21
|
-------------------------------------------------------------------------------*/
|
|
22
|
#include <ili9328.h>
|
|
22
|
#include <ili9328.h>
|
|
23
|
#include <stdio.h>
|
|
23
|
#include <stdio.h>
|
|
24
|
#include <stddef.h>
|
|
24
|
#include <stddef.h>
|
|
25
|
#include <core.h>
|
|
25
|
#include <core.h>
|
|
26
|
#include <math.h>
|
|
26
|
#include <math.h>
|
|
27
|
|
|
27
|
|
|
28
|
#ifdef __OPTIMIZED_MATH
|
|
28
|
#ifdef __OPTIMIZED_MATH
|
|
29
|
#include <optimised_math.h>
|
|
29
|
#include <optimised_math.h>
|
|
30
|
#endif
|
|
30
|
#endif
|
|
31
|
|
|
31
|
|
|
32
|
#define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++);
|
|
32
|
#define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++);
|
|
33
|
|
|
33
|
|
|
34
|
void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress)
|
|
34
|
void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress)
|
|
35
|
{
|
|
35
|
{
|
|
36
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress);
|
|
36
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress);
|
|
37
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress);
|
|
37
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress);
|
|
38
|
}
|
|
38
|
}
|
|
39
|
|
|
39
|
|
|
40
|
void ili9328refreshenable(struct LCD_t* LCD,int enable)
|
|
40
|
void ili9328refreshenable(struct LCD_t* LCD,int enable)
|
|
41
|
{
|
|
41
|
{
|
|
42
|
if(enable)
|
|
42
|
if(enable)
|
|
43
|
{
|
|
43
|
{
|
|
44
|
//LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018);
|
|
44
|
//LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018);
|
|
45
|
}
|
|
45
|
}
|
|
46
|
else
|
|
46
|
else
|
|
47
|
{
|
|
47
|
{
|
|
48
|
//LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008);
|
|
48
|
//LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008);
|
|
49
|
|
|
49
|
|
|
50
|
}
|
|
50
|
}
|
|
51
|
}
|
|
51
|
}
|
|
52
|
|
|
52
|
|
|
53
|
void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H)
|
|
53
|
void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H)
|
|
54
|
{
|
|
54
|
{
|
|
55
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)X);
|
|
55
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)X);
|
|
56
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)Y);
|
|
56
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)Y);
|
|
57
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X);
|
|
57
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X);
|
|
58
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(W+X-1));
|
|
58
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(W+X-1));
|
|
59
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y);
|
|
59
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y);
|
|
60
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1));
|
|
60
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1));
|
|
61
|
}
|
|
61
|
}
|
|
62
|
|
|
62
|
|
|
63
|
void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height)
|
|
63
|
void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height)
|
|
64
|
{
|
|
64
|
{
|
|
65
|
if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height)))
|
|
65
|
if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height)))
|
|
66
|
{
|
|
66
|
{
|
|
67
|
ili9328setFrame(LCD,Xpos,Ypos,Width,Height);
|
|
67
|
ili9328setFrame(LCD,Xpos,Ypos,Width,Height);
|
|
68
|
LCD->interface->writeGRAM(buffer,Width*Height);
|
|
68
|
LCD->interface->writeGRAM(buffer,Width*Height);
|
|
69
|
}
|
|
69
|
}
|
|
70
|
}
|
|
70
|
}
|
|
71
|
|
|
71
|
|
|
|
|
|
72
|
void ili9328paintFilCircMidPoint(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
|
|
|
|
|
73
|
{
|
|
|
|
|
74
|
if(contSz<r)
|
|
|
|
|
75
|
{
|
|
|
|
|
76
|
for(int i=0;i<(r/2);i++)
|
|
|
|
|
77
|
{
|
|
|
|
|
78
|
|
|
|
|
|
79
|
}
|
|
|
|
|
80
|
}
|
|
|
|
|
81
|
|
|
|
|
|
82
|
}
|
|
|
|
|
83
|
|
|
72
|
void ili9328paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
|
|
84
|
void ili9328paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
|
|
73
|
{
|
|
85
|
{
|
|
74
|
if(contSz<r)
|
|
86
|
if(contSz<r)
|
|
75
|
{
|
|
87
|
{
|
|
76
|
uint16_t tmp1[16];
|
|
88
|
uint16_t tmp1[16];
|
|
77
|
uint16_t tmp2[16];
|
|
89
|
uint16_t tmp2[16];
|
|
78
|
int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem;
|
|
90
|
int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem;
|
|
79
|
for(int i=0;i<16;i++)tmp1[i]=fillColor;
|
|
91
|
for(int i=0;i<16;i++)tmp1[i]=fillColor;
|
|
80
|
for(int i=0;i<16;i++)tmp2[i]=contColor;
|
|
92
|
for(int i=0;i<16;i++)tmp2[i]=contColor;
|
|
81
|
/* Y = b +/- sqrt[r^2 - (x - a)^2] */
|
|
93
|
/* Y = b +/- sqrt[r^2 - (x - a)^2] */
|
|
82
|
for(int32_t line=-r;line<r;line++)
|
|
94
|
for(int32_t line=-r;line<r;line++)
|
|
83
|
{
|
|
95
|
{
|
|
84
|
#ifdef __OPTIMIZED_MATH
|
|
96
|
#ifdef __OPTIMIZED_MATH
|
|
85
|
Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) );
|
|
97
|
Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) );
|
|
86
|
Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) );
|
|
98
|
Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) );
|
|
87
|
#else
|
|
99
|
#else
|
|
88
|
Val1 = sqrt( (double)(rr - ((line)*(line))) );
|
|
100
|
Val1 = sqrt( (double)(rr - ((line)*(line))) );
|
|
89
|
Val2 = sqrt( (double)(rr2 - ((line)*(line))) );
|
|
101
|
Val2 = sqrt( (double)(rr2 - ((line)*(line))) );
|
|
90
|
#endif
|
|
102
|
#endif
|
|
91
|
X1=Xpos - Val1;
|
|
103
|
X1=Xpos - Val1;
|
|
92
|
contSz2= Val1-Val2;
|
|
104
|
contSz2= Val1-Val2;
|
|
93
|
ili9328setFrame(LCD,X1,line+Ypos,2*Val1,1);
|
|
105
|
ili9328setFrame(LCD,X1,line+Ypos,2*Val1,1);
|
|
94
|
rem=(contSz2)%16;
|
|
106
|
rem=(contSz2)%16;
|
|
95
|
if(rem)LCD->interface->writeGRAM(tmp2,rem);
|
|
107
|
if(rem)LCD->interface->writeGRAM(tmp2,rem);
|
|
96
|
for(int i=rem;i<(contSz2);i+=16)
|
|
108
|
for(int i=rem;i<(contSz2);i+=16)
|
|
97
|
{
|
|
109
|
{
|
|
98
|
LCD->interface->writeGRAM(tmp2,16);
|
|
110
|
LCD->interface->writeGRAM(tmp2,16);
|
|
99
|
}
|
|
111
|
}
|
|
100
|
|
|
112
|
|
|
101
|
W=2*Val1;
|
|
113
|
W=2*Val1;
|
|
102
|
if(W>(2*contSz2))
|
|
114
|
if(W>(2*contSz2))
|
|
103
|
{
|
|
115
|
{
|
|
104
|
W-=2*contSz2;
|
|
116
|
W-=2*contSz2;
|
|
105
|
rem=(W)%16;
|
|
117
|
rem=(W)%16;
|
|
106
|
if(rem)LCD->interface->writeGRAM(tmp1,rem);
|
|
118
|
if(rem)LCD->interface->writeGRAM(tmp1,rem);
|
|
107
|
for(int i=rem;i<(W);i+=16)
|
|
119
|
for(int i=rem;i<(W);i+=16)
|
|
108
|
{
|
|
120
|
{
|
|
109
|
LCD->interface->writeGRAM(tmp1,16);
|
|
121
|
LCD->interface->writeGRAM(tmp1,16);
|
|
110
|
}
|
|
122
|
}
|
|
111
|
}
|
|
123
|
}
|
|
112
|
|
|
124
|
|
|
113
|
rem=(contSz2)%16;
|
|
125
|
rem=(contSz2)%16;
|
|
114
|
if(rem)LCD->interface->writeGRAM(tmp2,rem);
|
|
126
|
if(rem)LCD->interface->writeGRAM(tmp2,rem);
|
|
115
|
for(int i=rem;i<(contSz2);i+=16)
|
|
127
|
for(int i=rem;i<(contSz2);i+=16)
|
|
116
|
{
|
|
128
|
{
|
|
117
|
LCD->interface->writeGRAM(tmp2,16);
|
|
129
|
LCD->interface->writeGRAM(tmp2,16);
|
|
118
|
}
|
|
130
|
}
|
|
119
|
}
|
|
131
|
}
|
|
120
|
}
|
|
132
|
}
|
|
121
|
}
|
|
133
|
}
|
|
122
|
|
|
134
|
|
|
123
|
|
|
135
|
|
|
124
|
|
|
136
|
|
|
125
|
|
|
137
|
|
|
126
|
void ili9328paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
|
|
138
|
void ili9328paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
|
|
127
|
{
|
|
139
|
{
|
|
128
|
ili9328setFrame(LCD,Xpos,Ypos,w,h);
|
|
140
|
ili9328setFrame(LCD,Xpos,Ypos,w,h);
|
|
129
|
uint16_t tmp[32];
|
|
141
|
uint16_t tmp[32];
|
|
130
|
for(int i=0;i<32;i++)tmp[i]=fillColor;
|
|
142
|
for(int i=0;i<32;i++)tmp[i]=fillColor;
|
|
131
|
for(int i=0;i<(h*w);i+=32)
|
|
143
|
for(int i=0;i<(h*w);i+=32)
|
|
132
|
{
|
|
144
|
{
|
|
133
|
LCD->interface->writeGRAM(tmp,32);
|
|
145
|
LCD->interface->writeGRAM(tmp,32);
|
|
134
|
}
|
|
146
|
}
|
|
135
|
int rem=(w*h)%32;
|
|
147
|
int rem=(w*h)%32;
|
|
136
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
148
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
137
|
if(contSz)
|
|
149
|
if(contSz)
|
|
138
|
{
|
|
150
|
{
|
|
139
|
ili9328setFrame(LCD,Xpos,Ypos,w,contSz);
|
|
151
|
ili9328setFrame(LCD,Xpos,Ypos,w,contSz);
|
|
140
|
for(int i=0;i<32;i++)tmp[i]=contColor;
|
|
152
|
for(int i=0;i<32;i++)tmp[i]=contColor;
|
|
141
|
rem=(w*contSz)%32;
|
|
153
|
rem=(w*contSz)%32;
|
|
142
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
154
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
143
|
for(int i=rem;i<(w*contSz);i+=32)
|
|
155
|
for(int i=rem;i<(w*contSz);i+=32)
|
|
144
|
{
|
|
156
|
{
|
|
145
|
LCD->interface->writeGRAM(tmp,32);
|
|
157
|
LCD->interface->writeGRAM(tmp,32);
|
|
146
|
}
|
|
158
|
}
|
|
147
|
|
|
159
|
|
|
148
|
ili9328setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz);
|
|
160
|
ili9328setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz);
|
|
149
|
rem=(w*contSz)%32;
|
|
161
|
rem=(w*contSz)%32;
|
|
150
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
162
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
151
|
for(int i=rem;i<(w*contSz);i+=32)
|
|
163
|
for(int i=rem;i<(w*contSz);i+=32)
|
|
152
|
{
|
|
164
|
{
|
|
153
|
LCD->interface->writeGRAM(tmp,32);
|
|
165
|
LCD->interface->writeGRAM(tmp,32);
|
|
154
|
}
|
|
166
|
}
|
|
155
|
|
|
167
|
|
|
156
|
ili9328setFrame(LCD,Xpos,Ypos,contSz,h);
|
|
168
|
ili9328setFrame(LCD,Xpos,Ypos,contSz,h);
|
|
157
|
rem=(h*contSz)%32;
|
|
169
|
rem=(h*contSz)%32;
|
|
158
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
170
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
159
|
for(int i=rem;i<(h*contSz);i+=32)
|
|
171
|
for(int i=rem;i<(h*contSz);i+=32)
|
|
160
|
{
|
|
172
|
{
|
|
161
|
LCD->interface->writeGRAM(tmp,32);
|
|
173
|
LCD->interface->writeGRAM(tmp,32);
|
|
162
|
}
|
|
174
|
}
|
|
163
|
|
|
175
|
|
|
164
|
ili9328setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h);
|
|
176
|
ili9328setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h);
|
|
165
|
rem=(h*contSz)%32;
|
|
177
|
rem=(h*contSz)%32;
|
|
166
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
178
|
if(rem)LCD->interface->writeGRAM(tmp,rem);
|
|
167
|
for(int i=rem;i<(h*contSz);i+=32)
|
|
179
|
for(int i=rem;i<(h*contSz);i+=32)
|
|
168
|
{
|
|
180
|
{
|
|
169
|
LCD->interface->writeGRAM(tmp,32);
|
|
181
|
LCD->interface->writeGRAM(tmp,32);
|
|
170
|
}
|
|
182
|
}
|
|
171
|
}
|
|
183
|
}
|
|
172
|
}
|
|
184
|
}
|
|
173
|
|
|
185
|
|
|
174
|
void ili9328paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color)
|
|
186
|
void ili9328paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color)
|
|
175
|
{
|
|
187
|
{
|
|
176
|
int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0;
|
|
188
|
int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0;
|
|
177
|
uint16_t tmp[w];
|
|
189
|
uint16_t tmp[w];
|
|
178
|
uint16_t linenum=0,charnum=0;
|
|
190
|
uint16_t linenum=0,charnum=0;
|
|
179
|
uint8_t line=0;
|
|
191
|
uint8_t line=0;
|
|
180
|
while(*buffer)
|
|
192
|
while(*buffer)
|
|
181
|
{
|
|
193
|
{
|
|
182
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
|
|
194
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
|
|
183
|
LCD->interface->readGRAM(tmp,w);
|
|
195
|
LCD->interface->readGRAM(tmp,w);
|
|
184
|
for(int i=0;i<(h*w);i++)
|
|
196
|
for(int i=0;i<(h*w);i++)
|
|
185
|
{
|
|
197
|
{
|
|
186
|
if( ((i%w)==0) ) //read current line to apply text pixmap
|
|
198
|
if( ((i%w)==0) ) //read current line to apply text pixmap
|
|
187
|
{
|
|
199
|
{
|
|
188
|
if(linenum++>0)
|
|
200
|
if(linenum++>0)
|
|
189
|
{
|
|
201
|
{
|
|
190
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum -h,w,1);
|
|
202
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum -h,w,1);
|
|
191
|
LCD->interface->writeGRAM(tmp,w);
|
|
203
|
LCD->interface->writeGRAM(tmp,w);
|
|
192
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1);
|
|
204
|
ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1);
|
|
193
|
LCD->interface->readGRAM(tmp,w);
|
|
205
|
LCD->interface->readGRAM(tmp,w);
|
|
194
|
pix=0;
|
|
206
|
pix=0;
|
|
195
|
}
|
|
207
|
}
|
|
196
|
}
|
|
208
|
}
|
|
197
|
if((pix%8) == 0)
|
|
209
|
if((pix%8) == 0)
|
|
198
|
{
|
|
210
|
{
|
|
199
|
line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
|
|
211
|
line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
|
|
200
|
}
|
|
212
|
}
|
|
201
|
if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
|
|
213
|
if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
|
|
202
|
pix++;
|
|
214
|
pix++;
|
|
203
|
line>>=1;
|
|
215
|
line>>=1;
|
|
204
|
}
|
|
216
|
}
|
|
205
|
linenum=0;
|
|
217
|
linenum=0;
|
|
206
|
tableoffset=0;
|
|
218
|
tableoffset=0;
|
|
207
|
charnum++;
|
|
219
|
charnum++;
|
|
208
|
buffer++;
|
|
220
|
buffer++;
|
|
209
|
}
|
|
221
|
}
|
|
210
|
}
|
|
222
|
}
|
|
211
|
|
|
223
|
|
|
212
|
int ili9328init(struct LCD_t* LCD)
|
|
224
|
int ili9328init(struct LCD_t* LCD)
|
|
213
|
{
|
|
225
|
{
|
|
214
|
if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL))
|
|
226
|
if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL))
|
|
215
|
{
|
|
227
|
{
|
|
216
|
LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h)
|
|
228
|
LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h)
|
|
217
|
LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h)
|
|
229
|
LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h)
|
|
218
|
LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); // Entry Mode (R03h)
|
|
230
|
LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); // Entry Mode (R03h)
|
|
219
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0202);
|
|
231
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0202);
|
|
220
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000);
|
|
232
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000);
|
|
221
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On
|
|
233
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On
|
|
222
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h)
|
|
234
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h)
|
|
223
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
|
|
235
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
|
|
224
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h)
|
|
236
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h)
|
|
225
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h)
|
|
237
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h)
|
|
226
|
delay_100us(10);
|
|
238
|
delay_100us(10);
|
|
227
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h)
|
|
239
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h)
|
|
228
|
delay_100us(10);
|
|
240
|
delay_100us(10);
|
|
229
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
|
|
241
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
|
|
230
|
delay_100us(10);
|
|
242
|
delay_100us(10);
|
|
231
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h)
|
|
243
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h)
|
|
232
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h)
|
|
244
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h)
|
|
233
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h)
|
|
245
|
LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h)
|
|
234
|
delay_100us(500);
|
|
246
|
delay_100us(500);
|
|
235
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1
|
|
247
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1
|
|
236
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2
|
|
248
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2
|
|
237
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3
|
|
249
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3
|
|
238
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4
|
|
250
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4
|
|
239
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5
|
|
251
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5
|
|
240
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6
|
|
252
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6
|
|
241
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7
|
|
253
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7
|
|
242
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8
|
|
254
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8
|
|
243
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9
|
|
255
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9
|
|
244
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10
|
|
256
|
LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10
|
|
245
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h)
|
|
257
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h)
|
|
246
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, 240 - 1); // Window Horizontal RAM Address End (R51h)
|
|
258
|
LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, 240 - 1); // Window Horizontal RAM Address End (R51h)
|
|
247
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h)
|
|
259
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h)
|
|
248
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, 320 - 1); // Window Vertical RAM Address End (R53h)
|
|
260
|
LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, 320 - 1); // Window Vertical RAM Address End (R53h)
|
|
249
|
LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h)
|
|
261
|
LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h)
|
|
250
|
LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE
|
|
262
|
LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE
|
|
251
|
LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h)
|
|
263
|
LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h)
|
|
252
|
// Display On
|
|
264
|
// Display On
|
|
253
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h)
|
|
265
|
LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h)
|
|
254
|
delay_100us(500);
|
|
266
|
delay_100us(500);
|
|
255
|
LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x0038);
|
|
267
|
LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x0038);
|
|
256
|
}
|
|
268
|
}
|
|
257
|
return 0;
|
|
269
|
return 0;
|
|
258
|
}
|
|
270
|
}
|
|
259
|
|
|
271
|
|
|
260
|
|
|
272
|
|