📄 9325tp.lst
字号:
268 2 for(j=0;j<260;j++);
269 2 }
270 1 }
271
272
273
274 /*----------------------------------------------------------------
275 液晶初始化
276 ----------------------------------------------------------------*/
277 void ILI9325_Initial(void)
278 {
279 1 CS=1;
280 1 delayms(5);
281 1 RES=0;
282 1 delayms(5);
283 1 RES=1;
284 1 delayms(50);
285 1 Write_Cmd_Data(0x0001,0x0100);
286 1 Write_Cmd_Data(0x0002,0x0700);
287 1 Write_Cmd_Data(0x0003,0x1030);
288 1 Write_Cmd_Data(0x0004,0x0000);
289 1 Write_Cmd_Data(0x0008,0x0207);
290 1 Write_Cmd_Data(0x0009,0x0000);
291 1 Write_Cmd_Data(0x000A,0x0000);
292 1 Write_Cmd_Data(0x000C,0x0000);
293 1 Write_Cmd_Data(0x000D,0x0000);
294 1 Write_Cmd_Data(0x000F,0x0000);
295 1 //power on sequence VGHVGL
296 1 Write_Cmd_Data(0x0010,0x0000);
297 1 Write_Cmd_Data(0x0011,0x0007);
298 1 Write_Cmd_Data(0x0012,0x0000);
299 1 Write_Cmd_Data(0x0013,0x0000);
300 1 //vgh
301 1 Write_Cmd_Data(0x0010,0x1290);
C51 COMPILER V7.06 9325TP 07/12/2010 23:49:26 PAGE 6
302 1 Write_Cmd_Data(0x0011,0x0227);
303 1 //delayms(100);
304 1 //vregiout
305 1 Write_Cmd_Data(0x0012,0x001d); //0x001b
306 1 //delayms(100);
307 1 //vom amplitude
308 1 Write_Cmd_Data(0x0013,0x1500);
309 1 //delayms(100);
310 1 //vom H
311 1 Write_Cmd_Data(0x0029,0x0018);
312 1 Write_Cmd_Data(0x002B,0x000D);
313 1
314 1 //gamma
315 1 Write_Cmd_Data(0x0030,0x0004);
316 1 Write_Cmd_Data(0x0031,0x0307);
317 1 Write_Cmd_Data(0x0032,0x0002);// 0006
318 1 Write_Cmd_Data(0x0035,0x0206);
319 1 Write_Cmd_Data(0x0036,0x0408);
320 1 Write_Cmd_Data(0x0037,0x0507);
321 1 Write_Cmd_Data(0x0038,0x0204);//0200
322 1 Write_Cmd_Data(0x0039,0x0707);
323 1 Write_Cmd_Data(0x003C,0x0405);// 0504
324 1 Write_Cmd_Data(0x003D,0x0F02);
325 1 //ram
326 1 Write_Cmd_Data(0x0050,0x0000);
327 1 Write_Cmd_Data(0x0051,0x00EF);
328 1 Write_Cmd_Data(0x0052,0x0000);
329 1 Write_Cmd_Data(0x0053,0x013F);
330 1 Write_Cmd_Data(0x0060,0xA700);
331 1 Write_Cmd_Data(0x0061,0x0001);
332 1 Write_Cmd_Data(0x006A,0x0000);
333 1 //
334 1 Write_Cmd_Data(0x0080,0x0000);
335 1 Write_Cmd_Data(0x0081,0x0000);
336 1 Write_Cmd_Data(0x0082,0x0000);
337 1 Write_Cmd_Data(0x0083,0x0000);
338 1 Write_Cmd_Data(0x0084,0x0000);
339 1 Write_Cmd_Data(0x0085,0x0000);
340 1 //
341 1 Write_Cmd_Data(0x0090,0x0010);
342 1 Write_Cmd_Data(0x0092,0x0600);
343 1 Write_Cmd_Data(0x0093,0x0003);
344 1 Write_Cmd_Data(0x0095,0x0110);
345 1 Write_Cmd_Data(0x0097,0x0000);
346 1 Write_Cmd_Data(0x0098,0x0000);
347 1 Write_Cmd_Data(0x0007,0x0133);
348 1
349 1
350 1
351 1 // Write_Cmd_Data(0x0022);//
352 1 }
353
354 /*----------------------------------------------------------------
355 画点
356 输入参数:x,y 需要画点坐标
357 color 点的颜色
358 ----------------------------------------------------------------*/
359 void Put_pixel(uchar x,uchar y,unsigned int color)
360 {
361 1 LCD_SetPos(x,x,y,y);
362 1 Write_Data_U16(color);
363 1 }
C51 COMPILER V7.06 9325TP 07/12/2010 23:49:26 PAGE 7
364
365 /*----------------------------------------------------------------
366 设置坐标
367 ----------------------------------------------------------------*/
368 static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
369 {
370 1 Write_Cmd_Data(WINDOW_XADDR_START,x0);
371 1 Write_Cmd_Data(WINDOW_XADDR_END,x1);
372 1 Write_Cmd_Data(WINDOW_YADDR_START,y0);
373 1 Write_Cmd_Data(WINDOW_YADDR_END,y1);
374 1 Write_Cmd_Data(GRAM_XADDR,x0);
375 1 Write_Cmd_Data(GRAM_YADDR,y0);
376 1 Write_Cmd (0x00,0x22);//LCD_WriteCMD(GRAMWR);
377 1 }
378 /*----------------------------------------------------------------
379 在屏幕上画线
380 输入参数: 起始坐标X0,Y0,终止坐标X1,Y1
381 color 线颜色
382 ----------------------------------------------------------------*/
383 void Line( uchar X0,
384 uchar Y0,
385 uchar X1,
386 uchar Y1,
387 unsigned int color)
388 {
389 1 int dx = X1 - X0;
390 1 int dy = Y1 - Y0;
391 1 int P = 2 * dy - dx;
392 1 int dobDy = 2 * dy;
393 1 int dobD = 2 * (dy - dx);
394 1 int PointX = 0,PointY = 0;
395 1 int incx = 0,incy = 0;
396 1 int distance = 0,xerr = 0,yerr = 0;
397 1 unsigned int i = 0;
398 1
399 1 if(dx == 0) //k=1斜率为1
400 1 {
401 2 PointX = X0;
402 2 if(Y0 < Y1)
403 2 {
404 3 PointY = Y0;
405 3 }
406 2 else
407 2 {
408 3 PointY = Y1;
409 3 }
410 2 for(i = 0;i <= ((Y0<Y1) ? (Y1-Y0) : (Y0-Y1));i++)
411 2 {
412 3
413 3 Put_pixel(PointX,PointY,color);
414 3 PointY++;
415 3 }
416 2 return;
417 2 }
418 1 if(dy == 0) //k=0斜率为0
419 1 {
420 2 PointY = Y0;
421 2 if(X0 < X1)
422 2 {
423 3 PointX = X0;
424 3 }
425 2 else
C51 COMPILER V7.06 9325TP 07/12/2010 23:49:26 PAGE 8
426 2 {
427 3 PointX = X1;
428 3 }
429 2 for(i = 0;i <= ((X0<X1) ? (X1-X0) : (X0-X1));i++)
430 2 {
431 3
432 3 Put_pixel(PointX,PointY,color);
433 3 PointX++;
434 3 }
435 2 return;
436 2 }
437 1
438 1 if(dx > 0)
439 1 incx = 1;
440 1 else if(dx == 0)
441 1 incx = 0;
442 1 else
443 1 incx = -1;
444 1
445 1 if(dy > 0)
446 1 incy = 1;
447 1 else if(dy == 0)
448 1 incy = 0;
449 1 else
450 1 incy = -1;
451 1
452 1 dx = ((X0>X1) ? (X0-X1) : (X1-X0));
453 1 dy = ((Y0>Y1) ? (Y0-Y1) : (Y1-Y0));
454 1
455 1 if(dx>dy) distance=dx;
456 1 else distance=dy;
457 1
458 1 PointX = X0;
459 1 PointY = Y0;
460 1 for(i=0;i<=distance+1;i++)
461 1 {
462 2
463 2 Put_pixel(PointX,PointY,color);
464 2 xerr+=dx;
465 2 yerr+=dy;
466 2 if(xerr>distance)
467 2 {
468 3 xerr-=distance;
469 3 PointX+=incx;
470 3 }
471 2 if(yerr>distance)
472 2 {
473 3 yerr-=distance;
474 3 PointY+=incy;
475 3 }
476 2 }
477 1 }
478 /*---------------------------------------------------------------------------
479 绘制矩形框
480 输入参数:矩形的起始位置left,top
481 矩形的结束位置right,bottom
482 矩形框的颜色color
483
484 -----------------------------------------------------------------------------*/
485 void Rectangle( uchar left,
486 uchar top,
487 uchar right,
C51 COMPILER V7.06 9325TP 07/12/2010 23:49:26 PAGE 9
488 uchar bottom,
489 unsigned int color)
490 {
491 1 Line(left,top,right,top,color);
492 1 Line(left,top,left,bottom,color);
493 1 Line(right,top,right,bottom,color);
494 1 Line(left,bottom,right,bottom,color);
495 1 }
496 /*---------------------------------------------------------------------------
497 绘制平面矩形
498 输入参数:矩形的起始位置left,top
499 矩形的结束位置right,bottom
500 矩形框的颜色color
501 -----------------------------------------------------------------------------*/
502 void Bar( uchar left,
503 uchar top,
504 uchar right,
505 uchar bottom,
506 unsigned int color)
507 {
508 1 uchar i = 0,k = 0;
509 1 for(k = top;k < bottom;k++)
510 1 {
511 2 for(i = left+1;i <= right;i++)
512 2 {
513 3 LCD_SetPos(i,i,k,k);
514 3 Write_Data_U16(color);
515 3 }
516 2 }
517 1 }
518 /*---------------------------------------------------------------------------
519 向LCD发送一个0--255的数值
520 -----------------------------------------------------------------------------*/
521 void LCDShow_uCharNumber( uchar x,
522 uchar y,
523 uchar uCharNumber,
524 unsigned int forecolor,
525 unsigned int bkcolor)
526 {
527 1 LCD_PutChar(x,y,uCharNumber/100+'0',forecolor,bkcolor);
528 1 LCD_PutChar(x+8,y,uCharNumber/10%10+'0',forecolor,bkcolor);
529 1 LCD_PutChar(x+16,y,uCharNumber%10+'0',forecolor,bkcolor);
530 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2091 ----
CONSTANT SIZE = 2993 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 125
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 + -