📄 lcd.lst
字号:
171 2 /* Clip Y */
172 2 if (y0 < GUI_Context.ClipRect.y0) {
173 3 Diff = GUI_Context.ClipRect.y0 -y0;
174 3 y0 = GUI_Context.ClipRect.y0;
175 3 pPixel += Diff*BytesPerLine;
176 3 ysize -= Diff;
177 3 }
178 2 if (y1 > GUI_Context.ClipRect.y1) {
C51 COMPILER V8.05a LCD 04/11/2008 14:19:01 PAGE 4
179 3 int Diff = y1-GUI_Context.ClipRect.y1;
180 3 ysize -= Diff;
181 3 }
182 2 if (ysize <=0)
183 2 return;
184 2 /* Clip right side */
185 2 if (x1 > GUI_Context.ClipRect.x1) {
186 3 int Diff = x1-GUI_Context.ClipRect.x1;
187 3 xsize -= Diff;
188 3 }
189 2 /* Clip left side ... (The difficult side ...) */
190 2 Diff =0;
191 2 if (x0 < GUI_Context.ClipRect.x0) {
192 3 Diff = GUI_Context.ClipRect.x0-x0;
193 3 xsize-=Diff;
194 3 switch (BitsPerPixel) {
195 4 case 1:
196 4 pPixel+= (Diff>>3); x0 += (Diff>>3)<<3; Diff &=7;
197 4 break;
198 4 case 2:
199 4 pPixel+= (Diff>>2); x0 += (Diff>>2)<<2; Diff &=3;
200 4 break;
201 4 case 4:
202 4 pPixel+= (Diff>>1); x0 += (Diff>>1)<<1; Diff &=1;
203 4 break;
204 4 case 8:
205 4 pPixel+= Diff; x0 += Diff; Diff=0;
206 4 break;
207 4 case 16:
208 4 pPixel+= (Diff<<1); x0 += Diff; Diff=0;
209 4 break;
210 4 }
211 3 }
212 2 if (xsize <=0)
213 2 return;
214 2 LCDDEV_L0_DrawBitmap (x0,y0, xsize, ysize, BitsPerPixel, BytesPerLine, pPixel, Diff, pTrans);
215 2 } else {
216 2 /**** Handle BITMAP with magnification ***/
217 2 int x,y;
218 2 int yi;
219 2 int Shift = 8-BitsPerPixel;
220 2 for (y=y0, yi=0; yi<ysize; yi++, y+= yMul, pPixel+=BytesPerLine) {
221 3 int yMax = y+yMul-1;
222 3 /* Draw if within clip area (Optimization ... "if" is not required !) */
223 3 if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) {
224 4 int BitsLeft =0;
225 4 int xi;
226 4 const U8* pDataLine = pPixel;
227 4 for (x=x0, xi=0; xi<xsize; xi++, x+=xMul) {
228 5 U8 Index;
229 5 if (!BitsLeft) {
230 6 Data = *pDataLine++;
231 6 BitsLeft =8;
232 6 }
233 5 Index = Data>>Shift;
234 5 Data <<= BitsPerPixel;
235 5 BitsLeft -= BitsPerPixel;
236 5 if (Index | ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) ==0)) {
237 6 LCD_PIXELINDEX OldColor = LCD_COLORINDEX;
238 6 if (pTrans) {
239 7 LCD_COLORINDEX = *(pTrans+Index);
240 7 } else {
C51 COMPILER V8.05a LCD 04/11/2008 14:19:01 PAGE 5
241 7 LCD_COLORINDEX = Index;
242 7 }
243 6 LCD_FillRect(x,y, x+xMul-1, yMax);
244 6 LCD_COLORINDEX = OldColor;
245 6 }
246 5 }
247 4 }
248 3 }
249 2 }
250 1 }
251
252
253
254 /*********************************************************************
255 *
256 * Set Max Clip Rect
257 *
258 **********************************************************************
259 */
260
261 void LCD_SetClipRectMax(void) {
262 1 LCDDEV_L0_GetRect(&GUI_Context.ClipRect);
263 1 }
264
265
266
267 /*
268 *********************************************************
269 * *
270 * LCD_Init : Init the display *
271 * *
272 *********************************************************
273 */
274
275 int LCD_Init(void) {
276 1 int r;
277 1 GUI_DEBUG_LOG("\nLCD_Init...");
278 1 LCD_SetClipRectMax();
279 1 if ((r = LCD_L0_Init()) != 0)
280 1 return r;
281 1 #if LCD_NUM_DISPLAYS > 1
if ((r = LCD_L0_1_Init()) != 0)
return r;
#endif
285 1 LCD_InitLUT();
286 1 /* Clear video memory */
287 1 LCD_SetDrawMode(GUI_DRAWMODE_REV);
288 1 LCD_FillRect(0,0, GUI_XMAX, GUI_YMAX);
289 1 LCD_SetDrawMode(0);
290 1 /* Switch LCD on */
291 1 LCD_On();
292 1 return 0;
293 1 }
294
295
296 /*********************************************************************
297 *
298 * LCD_Index2Color
299 * LCD_Color2Index
300 *
301 **********************************************************************
302 */
C51 COMPILER V8.05a LCD 04/11/2008 14:19:01 PAGE 6
303
304 int LCD_Color2Index (LCD_COLOR Color) {
305 1 return LCDDEV_L0_Color2Index(Color);
306 1 }
307
308 LCD_COLOR LCD_Index2Color (int Index) {
309 1 return LCDDEV_L0_Index2Color(Index);
310 1 }
311
312
313
314 /*********************************************************************
315 *
316 * LCD_SetBkColor
317 * LCD_SetColor
318 *
319 **********************************************************************
320
321 Purpose: Assign color/index to foreground/ background
322 */
323
324
325 void LCD_SetBkColor(GUI_COLOR color) {
326 1 LCD_SetBkColorIndex(LCD_Color2Index(color));
327 1 }
328
329 void LCD_SetColor(GUI_COLOR color) {
330 1 LCD_SetColorIndex(LCD_Color2Index(color));
331 1 }
332
333
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2118 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 61
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -