久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 7113|回復(fù): 10
打印 上一主題 下一主題
收起左側(cè)

STM32 I/O 口驅(qū)動(dòng)程序 ILI9325 TFT

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
STM32F103 使用 IO 口驅(qū)動(dòng) 320240 TFT(ILI9325) 液晶屏頭文件+函數(shù)文件。分享給大家,希望對(duì)大家有用。

完整源碼下載:
ILI9325.rar (7.13 KB, 下載次數(shù): 128)


主程序:

  1. #include "mILI9325.h"
  2. #include "mFONT.h"

  3. extern  mDis_Color  ILI9325;
  4. GPIO_InitTypeDef GPIO_InitStructure;

  5. //Red Gray scale灰階(65K)
  6. const unsigned char RedGrayScale[]={
  7.   0x00,0x00, 0x08,0x00, 0x10,0x00, 0x18,0x00, 0x20,0x00, 0x28,0x00, 0x30,0x00, 0x38,0x00,
  8.   0x40,0x00, 0x48,0x00, 0x50,0x00, 0x58,0x00, 0x60,0x00, 0x68,0x00, 0x70,0x00, 0x78,0x00,
  9.   0x80,0x00, 0x88,0x00, 0x90,0x00, 0x98,0x00, 0xA0,0x00, 0xA8,0x00, 0xB0,0x00, 0xB8,0x00,
  10.   0xC0,0x00, 0xC8,0x00, 0xD0,0x00, 0xD8,0x00, 0xE0,0x00, 0xE8,0x00, 0xF0,0x00, 0xF8,0x00,
  11. };
  12. //Green Gray scale灰階(65K)
  13. const unsigned char  GreenGrayScale[]={
  14.   0x00,0x00, 0x00,0x60, 0x00,0xA0, 0x00,0xE0, 0x01,0x00, 0x01,0x60, 0x01,0xA0, 0x01,0xE0,
  15.   0x02,0x00, 0x02,0x60, 0x02,0xA0, 0x02,0xE0, 0x03,0x00, 0x03,0x60, 0x03,0xA0, 0x03,0xE0,
  16.   0x04,0x00, 0x04,0x60, 0x04,0xA0, 0x04,0xE0, 0x05,0x00, 0x05,0x60, 0x05,0xA0, 0x05,0xE0,
  17.   0x06,0x00, 0x06,0x60, 0x06,0xA0, 0x06,0xE0, 0x07,0x00, 0x07,0x60, 0x07,0xA0, 0x07,0xE0,
  18. };

  19. //Blue Gray scale灰階(65K)
  20. const unsigned char  BlueGrayScale[]={
  21.   0x00,0x00, 0x00,0x01, 0x00,0x02, 0x00,0x03, 0x00,0x04, 0x00,0x05, 0x00,0x06, 0x00,0x07,
  22.   0x00,0x08, 0x00,0x09, 0x00,0x0A, 0x00,0x0B, 0x00,0x0C, 0x00,0x0D, 0x00,0x0E, 0x00,0x0F,
  23.   0x00,0x10, 0x00,0x11, 0x00,0x12, 0x00,0x13, 0x00,0x14, 0x00,0x15, 0x00,0x16, 0x00,0x17,
  24.   0x00,0x18, 0x00,0x19, 0x00,0x1A, 0x00,0x1B, 0x00,0x1C, 0x00,0x1D, 0x00,0x1E, 0x00,0x1F,
  25. };

  26. //White Gray scale灰階(65K)
  27. const unsigned char  WhiteGrayScale[]={
  28.   0x00,0x00, 0x08,0x61, 0x10,0xA2, 0x18,0xE3, 0x21,0x04, 0x29,0x65, 0x31,0xA6, 0x39,0xE7,
  29.   0x42,0x08, 0x4A,0x69, 0x52,0xAA, 0x5A,0xEB, 0x63,0x0C, 0x6B,0x6D, 0x73,0xAE, 0x7B,0xEF,
  30.   0x84,0x10, 0x8C,0x71, 0x94,0xB2, 0x9C,0xF3, 0xA5,0x14, 0xAD,0x75, 0xB5,0xB6, 0xBD,0xF7,
  31.   0xC6,0x18, 0xCE,0x79, 0xD6,0xBA, 0xDE,0xFB, 0xE7,0x1C, 0xEF,0x7D, 0xF7,0xBE, 0xFF,0xFF,
  32. };

  33. /*******************************************************************************
  34. * Function Name  : Delay_mS
  35. * Description    : 延時(shí)功能函數(shù)
  36. * Input          : nCount 延時(shí)值( mS )
  37. * Output         : None
  38. * Return         : None
  39. *******************************************************************************/
  40. void  Delay_mS (uint16_t nCount){
  41.   unsigned int  i;
  42.   do{
  43.     for(i=0; i<5000; i++);
  44.   }
  45.   while(nCount--);
  46. }

  47. /*******************************************************************************
  48. * Function Name  : Delay_uS
  49. * Description    : 延時(shí)功能函數(shù)
  50. * Input          : nCount 延時(shí)值( uS )
  51. * Output         : None
  52. * Return         : None
  53. *******************************************************************************/
  54. void  Delay_uS (uint16_t nCount){
  55.   unsigned int  i;
  56.   do{
  57.     for(i=0; i<5; i++);
  58.   }while(nCount--);
  59. }

  60. /*******************************************************************************
  61. * Function Name  : ILI9325_CtrlLinesConfig
  62. * Description    : Configures LCD control lines in Output Push-Pull mode.
  63. * Input          : None
  64. * Output         : None
  65. * Return         : None
  66. *******************************************************************************/
  67. void ILI9325_Reset(void){
  68.   //對(duì)TFT進(jìn)行復(fù)位一次
  69.   ILI9325_RESET_HIGH();
  70.   Delay_mS(50);
  71.   ILI9325_RESET_LOW();                              
  72.   Delay_mS(100);
  73.   ILI9325_RESET_HIGH();                    
  74.   Delay_mS(50);
  75. }

  76. /*******************************************************************************
  77. * Function Name  : ILI9325_CtrlLinesConfig 控制線配置
  78. * Description    : Configures LCD control lines in Output Push-Pull mode.
  79. * Input          : None
  80. * Output         : None
  81. * Return         : None
  82. *******************************************************************************/
  83. void ILI9325_CtrlLinesConfig(void) {
  84.   GPIO_InitTypeDef GPIO_InitStructure;
  85.   
  86.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOB, ENABLE);
  87.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOD, ENABLE);
  88.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOE, ENABLE);
  89.   
  90.   /* Configure PD.7--PD.11 as Output push-pull */
  91.   GPIO_InitStructure.GPIO_Pin = GPIO_LCD_CS | GPIO_LCD_RS | GPIO_LCD_WR | GPIO_LCD_RD |
  92.                                 GPIO_LCD_PW ;
  93.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  94.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  95.   GPIO_Init(GPIOB, &GPIO_InitStructure);

  96.   GPIO_InitStructure.GPIO_Pin = GPIO_LCD_RESET;
  97.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  98.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  99.   GPIO_Init(GPIOE, &GPIO_InitStructure);
  100.   
  101.   /* Configure PE.00 -- PE.15 as Output push-pull */
  102.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  103.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  104.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  105.   GPIO_Init(GPIOD, &GPIO_InitStructure);
  106. }

  107. /*******************************************************************************
  108. * Function Name  : ILI9325_WriteIndex
  109. * Description    : 尋址寄存器
  110. * Input          : Index
  111. * Output         : None
  112. * Return         : None
  113. *******************************************************************************/
  114. void ILI9325_WriteIndex(uint8_t Index) {
  115.   //寫索引寄存器
  116.   ILI9325_RS_LOW();
  117.   ILI9325_CS_LOW();
  118.   ILI9325_RD_HIGH();
  119.   GPIO_Write(GPIOD,Index);
  120.   ILI9325_WR_LOW();
  121.   ILI9325_WR_HIGH();
  122.   ILI9325_CS_HIGH();
  123. }

  124. /*******************************************************************************
  125. * Function Name  : ILI9325_WriteData
  126. * Description    :
  127. * Input          : Data
  128. * Output         : None
  129. * Return         : None
  130. *******************************************************************************/
  131. void ILI9325_WriteData(uint16_t Data) {
  132.   ILI9325_RS_HIGH();
  133.   ILI9325_CS_LOW();
  134.   ILI9325_RD_HIGH();
  135.   GPIO_Write(GPIOD,Data);
  136.   ILI9325_WR_LOW();
  137.   ILI9325_WR_HIGH();
  138.   ILI9325_CS_HIGH();
  139. }



  140. /*******************************************************************************
  141. * Function Name  : ILI9325_ReadData
  142. * Description    :
  143. * Input          : None
  144. * Output         : None
  145. * Return         : None
  146. *******************************************************************************/
  147. uint16_t ILI9325_ReadData(void) {
  148.   unsigned short Data=0;
  149.   
  150.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  151.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  152.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  153.   GPIO_Init(GPIOD, &GPIO_InitStructure);
  154.   
  155.   ILI9325_CS_LOW();
  156.   ILI9325_RS_HIGH();
  157.   ILI9325_WR_HIGH();
  158.   //丟掉第一次讀出的不確定數(shù)
  159.   ILI9325_RD_LOW();
  160.   Data = GPIO_ReadInputData(GPIOD);
  161.   ILI9325_RD_HIGH();
  162.   
  163.   ILI9325_RD_LOW();
  164.   Data = GPIO_ReadInputData(GPIOD);
  165.   ILI9325_RD_HIGH();
  166.   
  167.   ILI9325_CS_HIGH();
  168.   
  169.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  170.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  171.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  172.   GPIO_Init(GPIOD, &GPIO_InitStructure);
  173.   
  174.   return Data;
  175. }

  176. /*******************************************************************************
  177. * Function Name  : ILI9325_WriteReg
  178. * Description    : Writes to the selected LCD register.
  179. * Input          : - LCD_Reg: address of the selected register.
  180. *                  - LCD_RegValue: value to write to the selected register.
  181. * Output         : None
  182. * Return         : None
  183. *******************************************************************************/
  184. /*void ILI9325_WriteReg(unsigned char LCD_Reg, unsigned short LCD_RegValue) {
  185.   //寫索引寄存器
  186.   ILI9325_WriteIndex(unsigned char LCD_Reg);
  187.   //向所尋寄存器中寫入值
  188.   ILI9325_WriteData(unsigned short LCD_RegValue);
  189. }*/

  190. void ILI9325_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue) {
  191.   //寫索引寄存器
  192.   ILI9325_RS_LOW();
  193.   ILI9325_CS_LOW();
  194.   ILI9325_RD_HIGH();
  195.   GPIO_Write(GPIOD,LCD_Reg);
  196.   ILI9325_WR_LOW();
  197.   ILI9325_WR_HIGH();
  198.   ILI9325_CS_HIGH();
  199.   //向所尋寄存器中寫入值
  200.   ILI9325_RS_HIGH();
  201.   ILI9325_CS_LOW();
  202.   ILI9325_RD_HIGH();
  203.   GPIO_Write(GPIOD,LCD_RegValue);
  204.   ILI9325_WR_LOW();
  205.   ILI9325_WR_HIGH();
  206.   ILI9325_CS_HIGH();
  207. }

  208. /*******************************************************************************
  209. * Function Name  : ILI9325_BackLight(
  210. * Description    : LCD 背景燈狀態(tài)設(shè)置.
  211. * Input          : - State: 背景燈狀態(tài) ON 或者 OFF
  212. * Output         : None
  213. * Return         : None
  214. *******************************************************************************/
  215. void ILI9325_BackLight(uint8_t State) {
  216.   if(State == ON)
  217.     ILI9325_PW_HIGH();
  218.   else
  219.     ILI9325_PW_LOW();
  220. }

  221. /*******************************************************************************
  222. * Function Name  : ILI9325_WriteGRAM
  223. * Description    : Writes to the LCD RAM.
  224. * Input          : - RGB_Code: the pixel color in RGB mode (5-6-5).
  225. * Output         : None
  226. * Return         : None
  227. *******************************************************************************/
  228. void ILI9325_WriteGRAM(uint16_t RGB_Code) {
  229. ILI9325_WriteReg(R22,RGB_Code);
  230. }

  231. /*******************************************************************************
  232. * Function Name  : ILI9325_Init
  233. * Description    : Initializes LCD.
  234. * Input          : None
  235. * Output         : None
  236. * Return         : None
  237. *******************************************************************************/
  238. void ILI9325_Init(void) {
  239.   //Driver IC:ILI9325
  240.   
  241.   ILI9325_CtrlLinesConfig();  //TFT的系統(tǒng)接口配置(本TFT模塊采用的是i80 16-bit System Bus)
  242.   ILI9325_Reset();            //復(fù)位一次
  243.   
  244.   //ILI9325_WriteReg(0x00E3, 0x3008);
  245.   //ILI9325_WriteReg(0x00E7, 0x0012);
  246.   //ILI9325_WriteReg(0x00EF, 0x1231);
  247.   ILI9325_WriteReg(0x00E5, 0x78F0);
  248.   
  249.   /*其中的SM位配合R96中的GS位,來(lái)決定圖像刷新方向。本配置為從上到下
  250.   SM GS=00從下到上  SM GS=01從上到下  SM GS=10 從右到左  SM GS=11 從左到右*/
  251.   ILI9325_WriteReg(R1,  0x0100);//R1:驅(qū)動(dòng)輸出控制
  252.   
  253.   ILI9325_WriteReg(R2,  0x0700);//line inversion
  254.   /*GRAM水平方向更新*/
  255.   ILI9325_WriteReg(R3,  0x1018);//R3:數(shù)據(jù)進(jìn)入模式設(shè)置 1030

  256.   /*保持原圖像大小*/
  257.   ILI9325_WriteReg(R4,  0x0000);//R4:可將原圖像縮小到1/2或1/4來(lái)顯示
  258.   
  259. /*****************Display Control*******************/
  260.   ILI9325_WriteReg(R8,  0x0202);//0207
  261.   ILI9325_WriteReg(R9,  0x0000);
  262.   ILI9325_WriteReg(R0A, 0x0000);
  263.   ILI9325_WriteReg(R0C, 0x0000);
  264.   ILI9325_WriteReg(R0D, 0x0000);
  265.   ILI9325_WriteReg(R0F, 0x0000);
  266.   
  267. /***************Power Control*********************/  
  268.   ILI9325_WriteReg(R10, 0x0000);
  269.   ILI9325_WriteReg(R11, 0x0007);//0004
  270.   ILI9325_WriteReg(R12, 0x0000);
  271.   ILI9325_WriteReg(R13, 0x0000);
  272.   ILI9325_WriteReg(R7,  0x0000);
  273.   Delay_mS(200);
  274.   ILI9325_WriteReg(R10, 0x1690);
  275.   ILI9325_WriteReg(R11, 0x0227);//0224
  276.   Delay_mS(50);
  277.   ILI9325_WriteReg(R12, 0x009d);//001b
  278.   Delay_mS(50);
  279.   ILI9325_WriteReg(R13, 0x1900);//1100
  280.   ILI9325_WriteReg(R29, 0x0025);//0008
  281.   ILI9325_WriteReg(R2B, 0x000d);
  282.   Delay_mS(50);
  283.   
  284.   //默認(rèn)顯示坐標(biāo)(0,0)
  285.   ILI9325_WriteReg(R20, 0x0000);
  286.   ILI9325_WriteReg(R21, 0x0000);
  287.   
  288. /**************Gamma Control***********/  
  289.   ILI9325_WriteReg(R30, 0x0007);
  290.   ILI9325_WriteReg(R31, 0x0303);
  291.   ILI9325_WriteReg(R32, 0x0003);
  292.   ILI9325_WriteReg(R35, 0x0206);
  293.   ILI9325_WriteReg(R36, 0x0008);
  294.   ILI9325_WriteReg(R37, 0x0406);
  295.   ILI9325_WriteReg(R38, 0x0304);
  296.   ILI9325_WriteReg(R39, 0x0007);
  297.   ILI9325_WriteReg(R3C, 0x0602);
  298.   ILI9325_WriteReg(R3D, 0x0008);

  299. /********Sets display window,默認(rèn)為整個(gè)屏幕********/
  300.   ILI9325_WriteReg(R50, 0x0000);
  301.   ILI9325_WriteReg(R51, 0x00ee);
  302.   ILI9325_WriteReg(R52, 0x0000);
  303.   ILI9325_WriteReg(R53, 0x013f);

  304. /*******Gate Scan Control*************************/  
  305.   ILI9325_WriteReg(R60, 0xa700);
  306.   ILI9325_WriteReg(R61, 0x0001);
  307.   ILI9325_WriteReg(R6A, 0x0000);
  308. /********Partial Image Display Position Control***/
  309.   ILI9325_WriteReg(R80, 0x0000);
  310.   ILI9325_WriteReg(R81, 0x0000);
  311.   ILI9325_WriteReg(R82, 0x0000);
  312.   ILI9325_WriteReg(R83, 0x0000);
  313.   ILI9325_WriteReg(R84, 0x0000);
  314.   ILI9325_WriteReg(R85, 0x0000);
  315. /*******Panel Interface Control******************/
  316.   ILI9325_WriteReg(R90, 0x0010);
  317.   ILI9325_WriteReg(R92, 0x0600);
  318.   
  319.   ILI9325_WriteReg(R7,  0x0133);
  320.   ILI9325_WriteReg(R0,  0x0022);
  321.   
  322.   ILI9325.TextColor = 0x0000;
  323.   ILI9325.BackColor = 0x667F;
  324.   ILI9325_FillSCR(ILI9325.BackColor);
  325.   
  326.   ILI9325_BackLight(ON);
  327. }

  328. /*******************************************************************************
  329. * Function Name  : ILI9325_SetDisplayWindow
  330. * Description    : 設(shè)置顯示窗口
  331. * Input          : - startx:  specifies the X buttom left position.
  332. *                  - starty:  specifies the Y buttom left position.
  333. *                  - endx:    display window width.
  334. *                  - endy:    display window height.
  335. * Output         : None
  336. * Return         : None
  337. *******************************************************************************/
  338. void ILI9325_SetDisplayWindow(uint16_t startx, uint16_t starty, uint16_t endx, uint16_t endy) {
  339.         // 順轉(zhuǎn)90度
  340.   ILI9325_WriteReg(R50, starty);
  341.   ILI9325_WriteReg(R51, endy);
  342.   ILI9325_WriteReg(R52, 319-endx);
  343.   ILI9325_WriteReg(R53, 319-startx);
  344.   
  345.   ILI9325_WriteReg(R20, endy);
  346.   ILI9325_WriteReg(R21, 319-endx);
  347.   
  348.   /*// 逆轉(zhuǎn)90度
  349.   ILI9325_WriteReg(R50, 239-endy);
  350.   ILI9325_WriteReg(R51, 239-starty);
  351.   ILI9325_WriteReg(R52, startx);
  352.   ILI9325_WriteReg(R53, endx);
  353.   
  354.   ILI9325_WriteReg(R20, 239-starty);
  355.   ILI9325_WriteReg(R21, startx);
  356.   */
  357. }

  358. /*******************************************************************************
  359. * Function Name  : ILI9325_EnterSleep
  360. * Description    : LCD 進(jìn)入休眠模式
  361. * Input          : None
  362. * Output         : None
  363. * Return         : None
  364. *******************************************************************************/
  365. void ILI9325_EnterSleep(void) {
  366.   ILI9325_WriteReg(R7, 0x0131);
  367.   Delay_mS(10);
  368.   ILI9325_WriteReg(R7, 0x0130);
  369.   Delay_mS(10);
  370.   ILI9325_WriteReg(R7, 0x0000);
  371.        
  372.         ILI9325_WriteReg(R10, 0x0080);
  373.   ILI9325_WriteReg(R11, 0x0000);
  374.   ILI9325_WriteReg(R12, 0x0000);
  375.   ILI9325_WriteReg(R13, 0x0000);
  376.   Delay_mS(10);
  377.   ILI9325_WriteReg(R10, 0x0082);
  378. }

  379. /*******************************************************************************
  380. * Function Name  : ILI9325_ExitSleep
  381. * Description    : LCD 退出休眠模式
  382. * Input          : None
  383. * Output         : None
  384. * Return         : None
  385. *******************************************************************************/
  386. void ILI9325_ExitSleep(void) {
  387.   ILI9325_WriteReg(R10, 0x0080);
  388.   ILI9325_WriteReg(R11, 0x0000);
  389.   ILI9325_WriteReg(R12, 0x0000);
  390.   ILI9325_WriteReg(R13, 0x0000);
  391.   Delay_mS(10);
  392.   ILI9325_WriteReg(R10, 0x1490);
  393.   ILI9325_WriteReg(R11, 0x0224);
  394.   Delay_mS(10);
  395.   ILI9325_WriteReg(R12, 0x001A);
  396.   Delay_mS(10);
  397.   ILI9325_WriteReg(R13, 0x1100);
  398.   ILI9325_WriteReg(R29, 0x0011);
  399.   Delay_mS(10);
  400.   ILI9325_WriteReg(R7, 0x0133);
  401. }

  402. /*******************************************************************************
  403. * Function Name  : ILI9325_SetPixel
  404. * Description    : 在指定的 x,y 坐標(biāo)描點(diǎn)
  405. * Input          : -x: 指定描點(diǎn)坐標(biāo) x 值
  406. *                  -y: 指定描點(diǎn)坐標(biāo) y 值
  407. *                  -color: 描點(diǎn)顏色值
  408. * Output         : None
  409. * Return         : None
  410. *******************************************************************************/
  411. void ILI9325_SetPixel(uint16_t x, uint16_t y, uint16_t color) {
  412.         ILI9325_SetDisplayWindow(x,y,x,y);
  413.         ILI9325_WriteGRAM(color);
  414. }

  415. /*******************************************************************************
  416. * Function Name  : ILI9325_RectangleFill
  417. * Description    : 顯示窗口內(nèi)以指定顏色局部填充
  418. * Input          : -x: 指定起點(diǎn)坐標(biāo) x 值
  419. *                  -y: 指定起點(diǎn)坐標(biāo) y 值
  420. *                  -width: 指定填充寬度
  421. *                  -hight: 指定填充高度
  422. *                  -color: 指定填充顏色
  423. * Output         : None
  424. * Return         : None
  425. *******************************************************************************/
  426. void  ILI9325_RectangleFill(uint16_t x, uint16_t y, uint16_t width, uint16_t hight, uint16_t color) {       
  427.         uint16_t i,j;

  428.         ILI9325_SetDisplayWindow(x, y, x+width-1, y+hight-1);

  429.         for(i=0; i<width; i++) {   
  430.                 for(j=0; j<hight; j++) {
  431.                         ILI9325_WriteGRAM(color);
  432.                 }
  433.         }
  434. }

  435. /*******************************************************************************
  436. * Function Name  : ILI9325_FillSCR
  437. * Description    : 顯示窗口全部以指定顏色填充
  438. * Input          : -color: 指定填充顏色
  439. * Output         : None
  440. * Return         : None
  441. *******************************************************************************/
  442. void  ILI9325_FillSCR(uint16_t color) {       
  443.         uint16_t i,j;

  444.         ILI9325_SetDisplayWindow(0, 0, 319, 239);

  445.         for(i=0; i<320; i++) {   
  446.                 for(j=0; j<240; j++) {
  447.                         ILI9325_WriteGRAM(color);
  448.                 }
  449.         }
  450. }

  451. /*******************************************************************************
  452. * Function Name  : ILI9325_DrawBMP
  453. * Description    : 圖片顯示
  454. * Input          : -x: 指定起點(diǎn)坐標(biāo) x 值
  455. *                  -y: 指定起點(diǎn)坐標(biāo) y 值
  456. *                  -width: 指定圖片寬度
  457. *                  -hight: 指定圖片高度
  458. *                  -*pBmp: 圖片數(shù)據(jù)指針
  459. * Output         : None
  460. * Return         : None
  461. *******************************************************************************/
  462. void ILI9325_DrawBMP(uint16_t x,uint16_t y,uint16_t width,uint16_t hight,const uint8_t *pBmp) {
  463.         uint16_t i,j;
  464.         uint16_t Data;

  465.         ILI9325_SetDisplayWindow(x, y, x+width-1, y+hight-1);

  466.         for(i=0; i<width; i++) {   
  467.                 for(j=0; j<hight; j++) {
  468.                         Data = (*pBmp++)<<8;
  469.                         Data = Data | (*pBmp++);
  470.       
  471.       ILI9325_WriteGRAM(Data);
  472.                 }
  473.         }
  474. }



  475. /*******************************************************************************
  476. * Function Name  : ILI9325_SetCursor
  477. * Description    : Sets the cursor position.
  478. * Input          : - Xpos: specifies the X position.
  479. *                  - Ypos: specifies the Y position.
  480. * Output         : None
  481. * Return         : None
  482. *******************************************************************************/
  483. void ILI9325_SetCursor(uint16_t x, uint16_t y) {
  484.   ILI9325_SetDisplayWindow(x, y, x, y);
  485.   //ILI9325_WriteReg(R20, x);
  486.   //ILI9325_WriteReg(R21, y);
  487. }

  488. /*******************************************************************************
  489. * Function Name  : ILI9325_BGR2RGB
  490. * Description    :
  491. * Input          :
  492. * Output         :
  493. * Return         :
  494. *******************************************************************************/
  495. uint16_t ILI9325_BGR2RGB(uint16_t BGR_Code) {
  496.   uint16_t  r, g, b;

  497.   r = BGR_Code & 0x1f;
  498.   g = (BGR_Code>>5)  & 0x3f;
  499.   b = (BGR_Code>>11) & 0x1f;
  500.   
  501.   return( (r<<11) + (g<<5) + (b<<0) );
  502. }

  503. /*******************************************************************************
  504. * Function Name  : ILI9325_ReadRegister
  505. * Description    : Get the data of the appointed register.
  506. * Input          :
  507. * Output         :
  508. * Return         :
  509. *******************************************************************************/
  510. uint16_t ILI9325_ReadRegister(uint16_t LCD_Reg) {
  511.   //寫索引寄存器
  512.   ILI9325_WriteIndex(LCD_Reg);
  513.   return(ILI9325_ReadData());
  514. }

  515. /*******************************************************************************
  516. * Function Name  : CheckController
  517. * Description    : 讀取 LCD 標(biāo)示字符串
  518. * Input          :
  519. * Output         :
  520. * Return         : int 類型標(biāo)示字符串代碼
  521. *******************************************************************************/
  522. uint16_t CheckController(void) {
  523.   return(ILI9325_ReadRegister(R0));
  524. }

  525. /*******************************************************************************
  526. * Function Name  : ILI9325_GetPointRGB 獲得指定像素點(diǎn)的顏色數(shù)據(jù)
  527. * Description    : Get the color data of the appointed pixel.
  528. * Input          :
  529. * Output         :
  530. * Return         :
  531. *******************************************************************************/
  532. uint16_t ILI9325_GetPointRGB(uint16_t x,uint16_t y) {
  533.   //ILI9325_SetDisplayWindow(x, y, x, y);
  534.   ILI9325_SetCursor(x,y);
  535.   return(ILI9325_BGR2RGB(ILI9325_ReadRegister(R22)));
  536. }

  537. /*******************************************************************************
  538. * Function Name  : ILI9325_ClearLine
  539. * Description    : Clears the selected line.
  540. * Input          : - Line: the Line to be cleared.
  541. *                    This parameter can be one of the following values:
  542. *                  - Linex: where x can be 0..19
  543. * Output         : None
  544. * Return         : None
  545. *******************************************************************************/
  546. void ILI9325_ClearLine(uint8_t Line) {
  547.   //ILI9325_DisplayStringLine(Line, "                    ");
  548. }

  549. /*******************************************************************************
  550. * Function Name  : ILI9325_SetTextColor
  551. * Description    : Sets the Text color.
  552. * Input          : - Color: specifies the Text color code RGB(5-6-5).
  553. * Output         : - TextColor: Text color global variable used by LCD_DrawChar
  554. *                  and LCD_DrawPicture functions.
  555. * Return         : None
  556. *******************************************************************************/
  557. void ILI9325_SetTextColor(uint16_t Color) {
  558.   ILI9325.TextColor = Color;
  559. }

  560. /*******************************************************************************
  561. * Function Name  : ILI9325_SetBackColor
  562. * Description    : Sets the Background color.
  563. * Input          : - Color: specifies the Background color code RGB(5-6-5).
  564. * Output         : - BackColor: Background color global variable used by
  565. *                  LCD_DrawChar and LCD_DrawPicture functions.
  566. * Return         : None
  567. *******************************************************************************/
  568. void ILI9325_SetBackColor(uint16_t Color) {
  569.   ILI9325.BackColor = Color;
  570. }

  571. /******************************************************************
  572. - 功能描述:將一個(gè)32位的變量dat轉(zhuǎn)為字符串,比如把1234轉(zhuǎn)為"1234"
  573. - 參數(shù)說明:dat:帶轉(zhuǎn)的long型的變量
  574.              str:指向字符數(shù)組的指針,轉(zhuǎn)換后的字節(jié)串放在其中           
  575. - 返回說明:無(wú)
  576. ******************************************************************/
  577. void u32tostr(uint32_t dat,uint8_t *str) {
  578.   int8_t temp[20];
  579.   uint8_t i=0,j=0;
  580.   i=0;
  581.   while(dat){
  582.     temp[i]=dat%10+0x30;
  583.     i++;
  584.     dat/=10;
  585.   }
  586.   j=i;
  587.   for(i=0;i<j;i++) {
  588.     str[i]=temp[j-i-1];
  589.   }
  590.   if(!i) {str[i++]='0';}
  591.   str[i]=0;
  592. }

  593. /******************************************************************
  594. - 功能描述:將一個(gè)字符串轉(zhuǎn)為32位的變量,比如"1234"轉(zhuǎn)為1234
  595. - 參數(shù)說明:str:指向待轉(zhuǎn)換的字符串           
  596. - 返回說明:轉(zhuǎn)換后的數(shù)值
  597. ******************************************************************/

  598. unsigned long strtou32(unsigned char *str) {
  599.   uint32_t  temp=0;
  600.   uint32_t  fact=1;
  601.   uint8_t   len=StrLength(str);
  602.   uint8_t   i;
  603.   for(i=len;i>0;i--) {
  604.     temp+=((str[i-1]-0x30)*fact);
  605.     fact*=10;
  606.   }
  607.   return temp;
  608. }

  609. /*******************************************************************************
  610. * Function Name  : StrLength
  611. * Description    : Returns length of string.
  612. * Input          : - Str: Character Pointer.
  613. * Output         : None
  614. * Return         : String length.
  615. *******************************************************************************/
  616. static uint32_t StrLength(uint8_t *Str) {
  617.   uint32_t Index = 0;

  618.   /* Increment the Index unless the end of string */
  619.   for(Index = 0; *Str != '\0'; Str++, Index++);

  620.   return Index;
  621. }

  622. /*******************************************************************************
  623. * Function Name  : ILI9325_DrawChar
  624. * Description    : Draws a character on LCD.
  625. * Input          : - Xpos: the Line where to display the character shape.
  626. *                    This parameter can be one of the following values:
  627. *                       - Linex: where x can be 0..19
  628. *                  - Ypos: start column address.
  629. *                  - c: pointer to the character data.
  630. * Output         : None
  631. * Return         : None
  632. *******************************************************************************/
  633. void ILI9325_DrawChar_8x16(uint16_t x, uint16_t y, uint8_t *c) {
  634.   uint16_t  i=0,j=0,str=0;
  635.   uint16_t  OffSet=0;
  636.   
  637.   OffSet = (*c - 32)*16;//尋找ASCII_Table[]中相應(yīng)字符的點(diǎn)陣數(shù)據(jù)
  638.           /*pAscii傳過來(lái)的是該字符的ASCII碼數(shù)字表示(參看ASCII表,有嚴(yán)格
  639.           順序表示),減32是因?yàn)榈?~31號(hào)是控制字符,第32號(hào)為“空格”字符
  640.           除以16是因?yàn)樵贏SCII_Table[]中的每個(gè)字符點(diǎn)陣為16個(gè)字節(jié)表示*/
  641.   ILI9325_SetDisplayWindow(x, y, x+7, y+15);
  642.   
  643.   for(i=0;i<16;i++) {
  644.     str = *(ascii_8x16 + OffSet + i);
  645.     for(j=0;j<8;j++) {
  646.       if(str & (0x80>>j)) {
  647.         ILI9325_WriteGRAM(ILI9325.TextColor);
  648.       }
  649.       else {
  650.         ILI9325_WriteGRAM(ILI9325.BackColor);
  651.       }
  652.     }
  653.   }
  654. }

  655. /*******************************************************************************
  656. * Function Name  : ILI9325_DisplayChar
  657. * Description    : Displays one character .
  658. * Input          : - Line: the Line where to display the character shape .
  659. *                    This parameter can be one of the following values:
  660. *                       - Linex: where x can be 0..19
  661. *                  - Column: start column address.
  662. *                  - Ascii: character ascii code
  663. * Output         : None
  664. * Return         : None
  665. *******************************************************************************/
  666. void ILI9325_DisplayChar_8x16(uint16_t x, uint16_t y, uint8_t *Ascii) {
  667.   while(*Ascii != 0){
  668.     ILI9325_DrawChar_8x16(x,y,Ascii);
  669.     x += 8;
  670.     Ascii += 1;
  671.   }
  672. }

  673. /*******************************************************************************
  674. * Function Name  : ILI9325_DisplayChar
  675. * Description    : Displays one character .
  676. * Input          : - Line: the Line where to display the character shape .
  677. *                    This parameter can be one of the following values:
  678. *                       - Linex: where x can be 0..19
  679. *                  - Column: start column address.
  680. *                  - Ascii: character ascii code
  681. * Output         : None
  682. * Return         : None
  683. *******************************************************************************/
  684. void ILI9325_DrawChar_16x16(uint16_t x,uint16_t y,uint16_t Num){
  685.   uint8_t   i=0,j=0;
  686.   uint16_t  OffSet=0;
  687.   uint16_t  str=0;
  688.   
  689.   OffSet = Num*32;//尋找ASCII_Table[]中相應(yīng)字符的點(diǎn)陣數(shù)據(jù)
  690.           /*pAscii傳過來(lái)的是該字符的ASCII碼數(shù)字表示(參看ASCII表,有嚴(yán)格
  691.           順序表示),減32是因?yàn)榈?~31號(hào)是控制字符,第32號(hào)為“空格”字符
  692.           除以16是因?yàn)樵贏SCII_Table[]中的每個(gè)字符點(diǎn)陣為16個(gè)字節(jié)表示*/
  693.   ILI9325_SetDisplayWindow(x,y,x+15,y+15);
  694.   
  695.   for(i = 0; i < 16; i++){
  696.     str = ((uint16_t)(*(china_16x16 + OffSet + i*2)<<8)+*(china_16x16 + OffSet + i*2+1));
  697.    
  698.     for(j=0;j<16;j++) {
  699.       if(str & (0x8000>>j)) {
  700.         ILI9325_WriteGRAM(ILI9325.TextColor);
  701.       }
  702.       else {
  703.         ILI9325_WriteGRAM(ILI9325.BackColor);
  704.       }
  705.     }
  706.   }
  707. }

  708. /*******************************************************************************
  709. * Function Name  : ILI9325_DrawChar
  710. * Description    : Draws a character on LCD.
  711. * Input          : - Xpos: the Line where to display the character shape.
  712. *                    This parameter can be one of the following values:
  713. *                       - Linex: where x can be 0..19
  714. *                  - Ypos: start column address.
  715. *                  - c: pointer to the character data.
  716. * Output         : None
  717. * Return         : None
  718. *******************************************************************************/
  719. void ILI9325_DrawChar_16x24(uint16_t x, uint16_t y, uint8_t *c) {
  720.   uint8_t   i=0,j=0;
  721.   uint16_t  str=0;
  722.   uint16_t  OffSet=0;
  723.   
  724.   OffSet = (*c - 32)*48;//尋找ASCII_Table[]中相應(yīng)字符的點(diǎn)陣數(shù)據(jù)
  725.           /*pAscii傳過來(lái)的是該字符的ASCII碼數(shù)字表示(參看ASCII表,有嚴(yán)格
  726.           順序表示),減32是因?yàn)榈?~31號(hào)是控制字符,第32號(hào)為“空格”字符
  727.           除以16是因?yàn)樵贏SCII_Table[]中的每個(gè)字符點(diǎn)陣為16個(gè)字節(jié)表示*/
  728.   ILI9325_SetDisplayWindow(x, y, x+15, y+23);
  729.   
  730.   for(i=0;i<24;i++) {
  731.     str = ((uint16_t)(*(ascii_16x24 + OffSet + i*2)<<8))+(*(ascii_16x24 + OffSet + i*2+1));
  732.    
  733.     for(j=0;j<16;j++) {
  734.       if(str & (0x8000>>j)) {
  735.         ILI9325_WriteGRAM(ILI9325.TextColor);
  736.       }
  737.       else {
  738.         ILI9325_WriteGRAM(ILI9325.BackColor);
  739.       }
  740.     }
  741.   }
  742. }

  743. /*******************************************************************************
  744. * Function Name  : ILI9325_DisplayChar
  745. * Description    : Displays one character .
  746. * Input          : - Line: the Line where to display the character shape .
  747. *                    This parameter can be one of the following values:
  748. *                       - Linex: where x can be 0..19
  749. *                  - Column: start column address.
  750. *                  - Ascii: character ascii code
  751. * Output         : None
  752. * Return         : None
  753. *******************************************************************************/
  754. void ILI9325_DisplayChar_16x24(uint16_t x, uint16_t y, uint8_t *Ascii) {
  755.   while(*Ascii != 0){
  756.     ILI9325_DrawChar_16x24(x,y,Ascii);
  757.     x += 16;
  758.     Ascii += 1;
  759.   }
  760. }

  761. /*******************************************************************************
  762. * Function Name  : ILI9325_DisplayChar
  763. * Description    : Displays one character .
  764. * Input          : - Line: the Line where to display the character shape .
  765. *                    This parameter can be one of the following values:
  766. *                       - Linex: where x can be 0..19
  767. *                  - Column: start column address.
  768. *                  - Ascii: character ascii code
  769. * Output         : None
  770. * Return         : None
  771. *******************************************************************************/
  772. void ILI9325_DrawChar_24x24(uint16_t x,uint16_t y,uint16_t Num){
  773.   uint8_t   i=0,j=0;
  774.   uint16_t  OffSet=0;
  775.   uint32_t  str=0;
  776.   
  777.   OffSet = Num*72;//尋找ASCII_Table[]中相應(yīng)字符的點(diǎn)陣數(shù)據(jù)
  778.           /*pAscii傳過來(lái)的是該字符的ASCII碼數(shù)字表示(參看ASCII表,有嚴(yán)格
  779.           順序表示),減32是因?yàn)榈?~31號(hào)是控制字符,第32號(hào)為“空格”字符
  780.           除以16是因?yàn)樵贏SCII_Table[]中的每個(gè)字符點(diǎn)陣為16個(gè)字節(jié)表示*/
  781.   ILI9325_SetDisplayWindow(x,y,x+23,y+23);
  782.   
  783.   for(i = 0; i < 24; i++){
  784.     str = ((uint32_t)(*(china_24x24 + OffSet + i*3)<<16))+((uint16_t)(*(china_24x24 + OffSet + i*3+1)<<8))+(*(china_24x24 + OffSet + i*3+2));
  785.    
  786.     for(j=0;j<24;j++) {
  787.       if(str & (0x00800000>>j)) {
  788.         ILI9325_WriteGRAM(ILI9325.TextColor);
  789.       }
  790.       else {
  791.         ILI9325_WriteGRAM(ILI9325.BackColor);
  792.       }
  793.     }
  794.   }
  795. }

  796. /*******************************************************************************
  797. * Function Name  : ILI9325_DisplayChar
  798. * Description    : Displays one character .
  799. * Input          : - Line: the Line where to display the character shape .
  800. *                    This parameter can be one of the following values:
  801. *                       - Linex: where x can be 0..19
  802. *                  - Column: start column address.
  803. *                  - Ascii: character ascii code
  804. * Output         : None
  805. * Return         : None
  806. ******************************************************************************
  807. void ILI9325_DisplayChar_24x24(uint16_t x, uint16_t y, uint8_t *Ascii) {
  808.   while(*Ascii != 0){
  809.     ILI9325_DrawChar_24x24(x,y,Ascii);
  810.     x += 24;
  811.     Ascii += 1;
  812.   }
  813. }
  814. */
  815. /*******************************************************************************
  816. * Function Name  : ILI9325_DisplayChar
  817. * Description    : Displays one character .
  818. * Input          : - Line: the Line where to display the character shape .
  819. *                    This parameter can be one of the following values:
  820. *                       - Linex: where x can be 0..19
  821. *                  - Column: start column address.
  822. *                  - Ascii: character ascii code
  823. * Output         : None
  824. * Return         : None
  825. *******************************************************************************/
  826. void ILI9325_DrawChar_24x48(uint16_t x,uint16_t y,uint8_t *c){
  827.   unsigned char i=0,j=0;
  828.   unsigned long str=0;
  829.   unsigned short  OffSet=0;
  830.   
  831.   OffSet = (*c - 32)*144;//尋找ASCII_Table[]中相應(yīng)字符的點(diǎn)陣數(shù)據(jù)
  832.           /*pAscii傳過來(lái)的是該字符的ASCII碼數(shù)字表示(參看ASCII表,有嚴(yán)格
  833.           順序表示),減32是因?yàn)榈?~31號(hào)是控制字符,第32號(hào)為“空格”字符
  834.           除以16是因?yàn)樵贏SCII_Table[]中的每個(gè)字符點(diǎn)陣為16個(gè)字節(jié)表示*/
  835.   ILI9325_SetDisplayWindow(x,y,x+23,y+47);
  836.   
  837.   for(i = 0; i < 48; i++){
  838.     str = ((uint32_t)(*(ascii_24x48 + OffSet + i*3)<<16))+((uint16_t)(*(ascii_24x48 + OffSet + i*3+1)<<8))+(*(ascii_24x48 + OffSet + i*3+2));
  839.    
  840.     for(j=0;j<24;j++) {
  841.       if(str & (0x00800000>>j)) {
  842.         ILI9325_WriteGRAM(ILI9325.TextColor);
  843.       }
  844.       else {
  845.         ILI9325_WriteGRAM(ILI9325.BackColor);
  846.       }
  847.     }
  848.   }
  849. }

  850. /*******************************************************************************
  851. * Function Name  : ILI9325_DisplayChar
  852. * Description    : Displays one character .
  853. * Input          : - Line: the Line where to display the character shape .
  854. *                    This parameter can be one of the following values:
  855. *                       - Linex: where x can be 0..19
  856. *                  - Column: start column address.
  857. *                  - Ascii: character ascii code
  858. * Output         : None
  859. * Return         : None
  860. *******************************************************************************/
  861. void ILI9325_DisplayChar_24x48(uint16_t x, uint16_t y, uint8_t *Ascii) {
  862.   while(*Ascii != 0){
  863.     ILI9325_DrawChar_24x48(x,y,Ascii);
  864.     x += 24;
  865.     Ascii += 1;
  866.   }
  867. }

  868. /*******************************************************************************
  869. * Function Name  : ILI9325_Bre_Line
  870. * Description    : Bresenham 畫線程序
  871. * Input          : - x1: 指定的畫線起點(diǎn) x 坐標(biāo)
  872. *                  - y1: 指定的畫線起點(diǎn) y 坐標(biāo)
  873. *                  - x2: 指定的畫線終點(diǎn) x 坐標(biāo)
  874. *                  - y2: 指定的畫線終點(diǎn) y 坐標(biāo)
  875. *                  - color: 畫線顏色
  876. *                  - type:  類型
  877. * Output         : None
  878. * Return         : None
  879. *******************************************************************************/
  880. void ILI9325_Bre_Line(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color,uint16_t type) {
  881.   int16_t dx,dy,e,count = 0;
  882.   dx=x2-x1;
  883.   dy=y2-y1;
  884.   
  885.   if(dx>=0) {
  886.     if(dy >= 0) {             // dy>=0
  887.       if(dx>=dy) {            // 1/8 octant
  888.         e=dy-dx/2;
  889.         while(x1<=x2) {
  890.           count++;
  891.           if(type != 0){
  892.             if(count%2)
  893.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  894.             else
  895.               ILI9325_SetPixel(x1,y1,color);
  896.           }
  897.           else
  898.             ILI9325_SetPixel(x1,y1,color);
  899.          
  900.           if(e>0){
  901.             y1+=1;
  902.             e-=dx;
  903.           }
  904.           x1+=1;
  905.           e+=dy;
  906.         }
  907.       }
  908.       else {                // 2/8 octant
  909.         e=dx-dy/2;
  910.         while(y1<=y2) {
  911.           count++;
  912.           if(type != 0){
  913.             if(count%2)
  914.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  915.             else
  916.               ILI9325_SetPixel(x1,y1,color);
  917.           }
  918.           else
  919.             ILI9325_SetPixel(x1,y1,color);
  920.          
  921.           if(e>0){
  922.             x1+=1;
  923.             e-=dy;
  924.           }
  925.           y1+=1;
  926.           e+=dx;
  927.         }
  928.       }
  929.     }
  930.     else {                // dy<0
  931.       dy=-dy;             // dy=abs(dy)
  932.       if(dx>=dy) {        // 8/8 octant
  933.         e=dy-dx/2;
  934.         while(x1<=x2) {
  935.           count++;
  936.           if(type != 0){
  937.             if(count%2)
  938.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  939.             else
  940.               ILI9325_SetPixel(x1,y1,color);
  941.           }
  942.           else
  943.             ILI9325_SetPixel(x1,y1,color);
  944.          
  945.           if(e>0){
  946.             y1-=1;
  947.             e-=dx;
  948.           }
  949.           x1+=1;
  950.           e+=dy;
  951.         }
  952.       }
  953.       else {              // 7/8 octant
  954.         e=dx-dy/2;
  955.         while(y1>=y2) {
  956.           count++;
  957.           if(type != 0){
  958.             if(count%2)
  959.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  960.             else
  961.               ILI9325_SetPixel(x1,y1,color);
  962.           }
  963.           else
  964.             ILI9325_SetPixel(x1,y1,color);
  965.          
  966.           if(e>0){
  967.             x1+=1;
  968.             e-=dy;
  969.           }
  970.           y1-=1;
  971.           e+=dx;
  972.         }
  973.       }
  974.     }
  975.   }
  976.   else {                //dx<0
  977.     dx=-dx;             //dx=abs(dx)
  978.     if(dy >= 0) {       // dy>=0
  979.       if(dx>=dy) {      // 4/8 octant
  980.         e=dy-dx/2;
  981.         while(x1>=x2) {
  982.           count++;
  983.           if(type != 0){
  984.             if(count%2)
  985.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  986.             else
  987.               ILI9325_SetPixel(x1,y1,color);
  988.           }
  989.           else
  990.             ILI9325_SetPixel(x1,y1,color);
  991.          
  992.           if(e>0){
  993.             y1+=1;
  994.             e-=dx;
  995.           }
  996.           x1-=1;
  997.           e+=dy;
  998.         }
  999.       }
  1000.       else {            // 3/8 octant
  1001.         e=dx-dy/2;
  1002.         while(y1<=y2) {
  1003.           count++;
  1004.           if(type != 0){
  1005.             if(count%2)
  1006.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  1007.             else
  1008.               ILI9325_SetPixel(x1,y1,color);
  1009.           }
  1010.           else
  1011.             ILI9325_SetPixel(x1,y1,color);
  1012.          
  1013.           if(e>0){
  1014.             x1-=1;
  1015.             e-=dy;
  1016.           }
  1017.           y1+=1;
  1018.           e+=dx;
  1019.         }
  1020.       }
  1021.     }
  1022.     else {            // dy<0
  1023.       dy=-dy;         // dy=abs(dy)
  1024.       if(dx>=dy) {    // 5/8 octant
  1025.         e=dy-dx/2;
  1026.         while(x1>=x2) {
  1027.           count++;
  1028.           if(type != 0){
  1029.             if(count%2)
  1030.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  1031.             else
  1032.               ILI9325_SetPixel(x1,y1,color);
  1033.           }
  1034.           else
  1035.             ILI9325_SetPixel(x1,y1,color);
  1036.          
  1037.           if(e>0){
  1038.             y1-=1;
  1039.             e-=dx;
  1040.           }
  1041.           x1-=1;
  1042.           e+=dy;
  1043.         }
  1044.       }
  1045.       else {          // 6/8 octant
  1046.         e=dx-dy/2;
  1047.         while(y1>=y2) {
  1048.           count++;
  1049.           if(type != 0){
  1050.             if(count%2)
  1051.               ILI9325_SetPixel(x1,y1,ILI9325.BackColor);
  1052.             else
  1053.               ILI9325_SetPixel(x1,y1,color);
  1054.           }
  1055.           else
  1056.             ILI9325_SetPixel(x1,y1,color);
  1057.          
  1058.           if(e>0){
  1059.             x1-=1;
  1060.             e-=dy;
  1061.           }
  1062.           y1-=1;
  1063.           e+=dx;
  1064.         }
  1065.       }
  1066.     }
  1067.   }
  1068. }
復(fù)制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏4 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:140714 發(fā)表于 2017-6-18 00:38 | 只看該作者
感謝分享,這個(gè)是我目前看到最全的函數(shù)

評(píng)分

參與人數(shù) 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

板凳
ID:255044 發(fā)表于 2017-11-29 09:57 | 只看該作者
感謝樓主的無(wú)私分享
回復(fù)

使用道具 舉報(bào)

地板
ID:68875 發(fā)表于 2018-2-12 22:40 | 只看該作者
感謝樓主
回復(fù)

使用道具 舉報(bào)

5#
ID:68875 發(fā)表于 2018-3-10 15:33 | 只看該作者
感謝樓主的無(wú)私分享
回復(fù)

使用道具 舉報(bào)

6#
ID:364764 發(fā)表于 2018-7-4 13:31 | 只看該作者
非常感謝,正需要呢,謝謝。
回復(fù)

使用道具 舉報(bào)

7#
ID:364764 發(fā)表于 2018-7-6 17:01 | 只看該作者
你好我下載了你的文檔,,你的代碼少了一個(gè)字庫(kù)頭文件沒法用呀,能否發(fā)一下。謝謝。。415746969@qq.com
回復(fù)

使用道具 舉報(bào)

8#
ID:268693 發(fā)表于 2018-8-26 21:18 | 只看該作者
感謝,感謝樓主的分享!
回復(fù)

使用道具 舉報(bào)

9#
ID:422626 發(fā)表于 2018-11-16 18:21 | 只看該作者
少了個(gè)頭文件啊 #include "mFONT.h"
回復(fù)

使用道具 舉報(bào)

10#
ID:50694 發(fā)表于 2019-11-19 13:42 | 只看該作者
白下了,少文件啊
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 中文字幕视频一区二区 | 一区二区精品视频 | 久久久久久久久91 | 日韩精品欧美精品 | 成人在线观看免费 | av一级久久 | 中文字幕免费中文 | 毛片.com| 午夜精品一区二区三区在线播放 | 亚洲国产aⅴ成人精品无吗 综合国产在线 | 男人的天堂中文字幕 | 毛片网站在线观看 | 久久乐国产精品 | 中文字幕亚洲精品 | 亚洲精品白浆高清久久久久久 | 国产精品夜夜春夜夜爽久久电影 | 农村妇女毛片精品久久久 | 黄在线免费观看 | 91在线视频一区 | 韩日免费视频 | 亚洲激情自拍偷拍 | 久久高清精品 | 久久99深爱久久99精品 | 国产精品欧美精品日韩精品 | 北条麻妃av一区二区三区 | 天天精品在线 | 亚洲精品在线播放 | 亚洲国产自产 | 久久久人成影片免费观看 | 久久99视频 | 天天射中文 | 成人免费影院 | 网络毛片| 观看av| av中文网 | 高清一区二区三区 | 欧美成人精品一区二区男人看 | 日韩一区在线观看视频 | 中文字幕在线不卡 | 国产精品久久久久久久三级 | 亚洲欧美高清 |