標(biāo)題: ILI9163的51單片機(jī)驅(qū)動(dòng)程序 含有基本驅(qū)動(dòng)和基本圖形函數(shù) [打印本頁]

作者: 51黑dd    時(shí)間: 2016-4-6 19:58
標(biāo)題: ILI9163的51單片機(jī)驅(qū)動(dòng)程序 含有基本驅(qū)動(dòng)和基本圖形函數(shù)
驅(qū)動(dòng)文件說明:
1.V2版本本驅(qū)動(dòng)將包含ILI9163基本驅(qū)動(dòng)函數(shù)、基本圖形函數(shù),并將相應(yīng)函數(shù)進(jìn)行歸類。如果需要將本驅(qū)動(dòng)移植到其他平臺(tái),只需修改base文件中相應(yīng)函數(shù)即可。
1.8寸tft彩屏SGP18T驅(qū)動(dòng),ILI9163控制器;含有基本驅(qū)動(dòng)和基本圖形函數(shù)


51單片機(jī)所有驅(qū)動(dòng)文件下載:

部分代碼預(yù)覽:
  1. /**********************************************************
  2. 文件名稱:
  3. 功能說明:
  4. 編寫:阿呆游樂園
  5.   ADaiPlay.21ic.org
  6.   QQ:1325180192
  7. 時(shí)間:2011/8/
  8. 其他說明:版權(quán)所有,盜版請(qǐng)注明出處
  9. **********************************************************/

  10. #include<reg51.h>
  11. #include "MyType.h"
  12. #include "SGP18T_ILI9163B_base.h"
  13. #include "SGP18T_ILI9163B_figure.h"




  14. /*****************數(shù)組聲名**********************************/
  15. uint16 code palette[]={
  16.                                 0x0000,
  17.                                 0xf800,//red
  18.                                 0x07e0,//green
  19.                                 0x001f,//blue
  20.                                 0xf81f,//purple
  21.                                 0xffe0,//yellow
  22.                                 0x07ff,//cyan
  23.                                 0xffff, //white
  24.                                 0xfc08,//orange
  25.                                 };





  26. /**********************************************************
  27. 函數(shù)名稱:ILI9163B_display_full()
  28. 入口參數(shù):color為常用的需要顯示的顏色(已經(jīng)提前定義),color為
  29.                   NULL時(shí),則可將不常用顏色放入dat中加以顯示
  30. 出口參數(shù):無
  31. 時(shí)間:2011/8/8
  32. 功能說明:全屏顯示單色畫面
  33. 其他說明:無
  34. **********************************************************/
  35. void ILI9163B_display_full(uint8 color,uint16 dat)
  36. {
  37.           unsigned int i,j;
  38.        
  39.         ILI9163B_address_rst();

  40.         for(i=0;i<160;i++)
  41.         {
  42.              for(j=0;j<128;j++)
  43.         {
  44.                         if(color == NULL)
  45.                                ILI9163B_write_para16(dat);
  46.                         else
  47.                         {
  48.                                 ILI9163B_write_para16(palette[color]);
  49.                         }
  50.         }
  51.         }
  52. }



  53. /**********************************************************
  54. 函數(shù)名稱:ILI9163B_draw_part()
  55. 入口參數(shù):起始、終止橫坐標(biāo)(0-127),縱坐標(biāo)(0-159),顯示顏色uint16
  56. 出口參數(shù):無
  57. 時(shí)間:2011/8/8
  58. 功能說明:填充矩形區(qū)域
  59. 其他說明:0<=xs<xe<=127
  60.                   0<=ys<ye<=159
  61. **********************************************************/
  62. void ILI9163B_draw_part(uint8 xs,uint8 ys,uint8 xe,uint8 ye,uint16 color_dat)
  63. {
  64.         uint8 i,j;

  65.         ILI9163B_SetPos(xs,ys,xe,ye);       
  66.         for(j=0;j<(ye-ys+1);j++)
  67.     {
  68.             for(i=0;i<(xe-xs+1);i++)
  69.                 {
  70.                         ILI9163B_write_para16(color_dat);
  71.                 }
  72.         }   
  73. }

  74. /**********************************************************
  75. 函數(shù)名稱:ILI9163B_draw_rectangle()
  76. 入口參數(shù):起始、終止橫坐標(biāo)(0-127),縱坐標(biāo)(0-159),顯示顏色uint16
  77. 出口參數(shù):無
  78. 時(shí)間:2011/8/8
  79. 功能說明:畫矩形邊框
  80. 其他說明:0<=xs<xe<=127
  81.                   0<=ys<ye<=159
  82. **********************************************************/
  83. void ILI9163B_draw_rectangle(uint8 xs,uint8 ys,uint8 xe,uint8 ye,uint16 color_dat)
  84. {
  85.         ILI9163B_draw_line(xs,ys,xs,ye,color_dat);          //畫矩形左邊
  86.         ILI9163B_draw_line(xe,ys,xe,ye,color_dat);          //畫矩形右邊
  87.         ILI9163B_draw_line(xs,ys,xe,ys,color_dat);          //畫矩形上邊
  88.         ILI9163B_draw_line(xs,ye,xe,ye,color_dat);          //畫矩形下邊
  89. }


  90. /**********************************************************
  91. 函數(shù)名稱:ILI9163B_draw_circle()
  92. 入口參數(shù):圓心橫坐標(biāo)(0-127),縱坐標(biāo)(0-159),半徑(0-128),顯示顏色uint16
  93. 出口參數(shù):無
  94. 時(shí)間:2011/8/8
  95. 功能說明:畫圓形邊框(僅支持屏幕內(nèi)畫圓)
  96. 其他說明:0<=x<=127
  97.                   0<=y<=159
  98. **********************************************************/
  99. void ILI9163B_draw_circle(uint8 x,uint8 y,uint8 r,uint16 color_dat)
  100. {
  101.         unsigned char dx, dy = r;

  102.         if((x>=r) &&((128-x)>=r) && (y>=r) && ((160-y)>=r))                //確定所畫圓在屏幕范圍內(nèi),沒有超出最外邊,(暫不支持與屏幕邊相交)
  103.         {
  104.                 for(dx = 0; dx <= r; dx++)
  105.                 {
  106.                         while((r * r + 1 - dx * dx) < (dy * dy)) dy--;
  107.                         ILI9163B_draw_dot(x + dx, y - dy, color_dat);
  108.                         ILI9163B_draw_dot(x - dx, y - dy, color_dat);
  109.                         ILI9163B_draw_dot(x - dx, y + dy, color_dat);
  110.                         ILI9163B_draw_dot(x + dx, y + dy, color_dat);

  111.                         ILI9163B_draw_dot(x + dy, y - dx, color_dat);
  112.                         ILI9163B_draw_dot(x - dy, y - dx, color_dat);
  113.                         ILI9163B_draw_dot(x - dy, y + dx, color_dat);
  114.                         ILI9163B_draw_dot(x + dy, y + dx, color_dat);
  115.         }
  116.         }



  117. }


  118. /**********************************************************
  119. 函數(shù)名稱:ILI9163B_draw_line()
  120. 入口參數(shù):起始、終止橫坐標(biāo)(0-127),縱坐標(biāo)(0-159),顯示顏色uint16
  121. 出口參數(shù):無
  122. 時(shí)間:2011/8/8
  123. 功能說明:畫直線
  124. 其他說明:0<=xs<xe<=127
  125.                   0<=ys<ye<=159
  126. **********************************************************/
  127. void ILI9163B_draw_line(uint8 xs,uint8 ys,uint8 xe,uint8 ye,uint16 color_dat)
  128. {
  129.         uint8 i,ds;
  130.         int dx,dy,inc_x, inc_y;
  131.         int xerr = 0, yerr = 0;                                //初始化變量

  132.         if(xs==xe)                                                          //如果是畫垂直線則只需對(duì)豎直坐標(biāo)計(jì)數(shù)
  133.         {
  134.             ILI9163B_SetPos(xs,ys,xe,ye);
  135.                 for(i=0;i<(ye-ys+1);i++)
  136.                 {
  137.                         ILI9163B_write_para16(color_dat);
  138.                 }
  139.         }
  140.         else if(ys==ye)                                                //如果是水平線則只需要對(duì)水平坐標(biāo)計(jì)數(shù)
  141.     {
  142.                 ILI9163B_SetPos(xs,ys,xe,ye);
  143.                   for(i=0;i<(xe-xs+1);i++)
  144.                 {
  145.                         ILI9163B_write_para16(color_dat);
  146.                 }
  147.         }
  148.         else                                                                                        //如果是斜線,則重新計(jì)算,使用畫點(diǎn)函數(shù)畫出直線
  149.         {
  150.             dx = xe - xs;                                                                //計(jì)算坐標(biāo)增量
  151.             dy = ye - ys;

  152.                 if(dx > 0) inc_x = 1;                                                //設(shè)置單步方向
  153.                 else
  154.                 {
  155.                         inc_x = -1; dx = -dx;
  156.                 }
  157.                 if(dy > 0) inc_y = 1;                                                //設(shè)置單步方向
  158.                 else
  159.             {
  160.                         inc_y = -1; dy = -dy;
  161.                 }

  162.                 if(dx > dy) ds = dx;                                                //選取基本增量坐標(biāo)軸
  163.                 else                ds = dy;

  164.                 for(i = 0; i <= ds+1; i++)                                        //畫線輸出
  165.                 {
  166.                         ILI9163B_draw_dot(xs, ys,color_dat);        //畫點(diǎn)
  167.                         xerr += dx;
  168.                         yerr += dy;
  169.                         if(xerr > ds)
  170.                         {
  171.                                 xerr -= ds;
  172.                                 xs   += inc_x;
  173.                         }
  174.                         if(yerr > ds)
  175.                         {
  176.                                 yerr -= ds;
  177.                                 ys   += inc_y;
  178.                         }
  179.                 }
  180.         }  
  181. }

  182. /**********************************************************
  183. 函數(shù)名稱:ILI9163B_draw_dot()
  184. 入口參數(shù):起始橫坐標(biāo)(0-127),縱坐標(biāo)(0-159),顯示顏色uint16
  185. 出口參數(shù):無
  186. 時(shí)間:2011/8/8
  187. 功能說明:畫點(diǎn)
  188. 其他說明:0<=x<=127
  189.                   0<=y<=159
  190. **********************************************************/
  191. void ILI9163B_draw_dot(uint8 x,uint8 y,uint16 color_dat)
  192. {
  193.         ILI9163B_SetPos(x,y,x,y);
  194.         ILI9163B_write_para16(color_dat);
  195. }
復(fù)制代碼




GP18T_1.8ITL9163B.rar

48.74 KB, 下載次數(shù): 167, 下載積分: 黑幣 -5


作者: 尋找~~    時(shí)間: 2016-8-30 13:56
看看。。。。。。。
作者: WOFY    時(shí)間: 2016-10-7 10:09
看看
作者: 紫藤遐想    時(shí)間: 2017-6-26 16:01
看看,剛好我現(xiàn)在在做這個(gè)。
作者: Venson    時(shí)間: 2017-10-11 16:02
正好需要,參考參考!
作者: jensenxp    時(shí)間: 2017-10-31 22:24
參考參考, 看看
作者: amwguh86    時(shí)間: 2018-4-29 08:13
點(diǎn)下我這個(gè)屏
作者: wxy3002    時(shí)間: 2018-9-11 20:21
下載學(xué)學(xué)
作者: fafa378    時(shí)間: 2018-12-5 16:08
看看,謝謝
作者: ioioi    時(shí)間: 2019-1-10 21:23
感謝分享  正在找
作者: zgmzgm    時(shí)間: 2019-5-12 14:08
這屏的驅(qū)動(dòng)正需要,謝謝
作者: cqgdlq    時(shí)間: 2019-5-24 23:26
買了幾個(gè)屏,試下。謝謝。
作者: z13467599832    時(shí)間: 2019-10-21 13:34
來學(xué)習(xí)了
作者: lgf2974    時(shí)間: 2019-10-21 22:47
手里有幾片這屏幕,正需要這程序,贊一個(gè)!!
作者: zxy2266    時(shí)間: 2019-10-22 16:08
有9341的屏,和這個(gè)太小了
作者: always_nothing    時(shí)間: 2019-11-16 20:31
感謝分享,有一些贈(zèng)品屏幕
作者: Wetelesky    時(shí)間: 2019-12-20 19:29
謝謝樓主!
作者: 路過羊圈的狼    時(shí)間: 2022-5-7 16:14
手里正好有這個(gè)屏幕,SGP18T.不過分辨率不怎么好。




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1