⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ili932x.c

📁 MINI STM32 驱动TFT屏的显示,JPG文件的播放
💻 C
📖 第 1 页 / 共 4 页
字号:
#else
    if (y<39)
    {
      y++;
    }
    else if (x<14)
    {
      y=0;
      x++;
    }
    else
    {
      x=0;
      y=0;
    }
#endif
    
  }
  while(*s!=0);
  
  Set_Cs;
  
}
/****************************************
写入32X16的ASCII字符串
*****************************************/
void Lcd_Write32X16String(u8 x,u8 y,u8 x_offset,u8 y_offset,u16 CharColor,u16 CharBackColor,char *s)
{

  u8 databuff;
  Set_Rs;
  
  do
  {
    databuff=*s++;  
    Lcd_Write32X16ASCII(x,y,x_offset,y_offset,CharColor,CharBackColor,databuff);
    
#if (ID_AM==000)|(ID_AM==010)|(ID_AM==100)|(ID_AM==110)  
    if (x<14)
    {
      x++;
    } 
    else if (y<9)
    {
      x=0;
      y++;
    }   
    else
    {
      x=0;
      y=0;
    }   
#else
    if (y<6)
    {
      y++;
    }
    else if (x<19)
    {
      y=0;
      x++;
    }
    else
    {
      x=0;
      y=0;
    }   
#endif
      
  }
  while (*s!=0);
    
  Set_Cs;
  
}
void Lcd_Write32X16StringClarity(u8 x,u8 y,u8 x_offset,u8 y_offset,u16 CharColor,char *s)
{

  u8 databuff;
  Set_Rs;
  
  do
  {
    databuff=*s++;  
    Lcd_Write32X16ASCIIClarity(x,y,x_offset,y_offset,CharColor,databuff);

#if (ID_AM==000)|(ID_AM==010)|(ID_AM==100)|(ID_AM==110)  
    if (x<14)
    {
      x++;
    } 
    else if (y<9)
    {
      x=0;
      y++;
    }   
    else
    {
      x=0;
      y=0;
    }     
#else
    if (y<6)
    {
      y++;
    }
    else if (x<19)
    {
      y=0;
      x++;
    }
    else
    {
      x=0;
      y=0;
    }
#endif
    
  }
  while(*s!=0);
  
  Set_Cs;
  
}
/****************************************************************
函数名:Lcd写1个中文函数
入口参数:x,横向坐标,由左到右分别是0~15
          y,纵向坐标,由上到下分别为0~19
          CharColaor,字符的颜色 
          CharBackColor,字符背景颜色 
         ASCIICode,相应中文的编码
也就是说,320240分辨率的显示屏,横向能显示15中文字符,竖向能显示20行
返回值:无

注意!!!!!如果单独使用此函数则应该加上Lcd_Rs_H()和Set_Cs;为了优化系统省去了
这个指令,假设此函数执行的上一条语句是写命令,(RS_L情况)则写入将出错
,因为ILI9320认为当RS_L时写入的是命令
*****************************************************************/
void Lcd_WriteChinese(u8 x,u8 y,u16 x_offset,u16 y_offset,u16 CharColor,u16 CharBackColor,u16 ChineseCode)
{

  u8 ByteCounter,BitCounter;
  u8 *ChinesePointer;
  u8 ChineseBuffer[32];
        
  Lcd_SetBox(x*16,y*16,16,16,x_offset,y_offset);         
  Lcd_WR_Start();
  GetChineseCode(ChineseBuffer,ChineseCode,Chinese_Offset);
  ChinesePointer=ChineseBuffer;
        
  for(ByteCounter=0; ByteCounter<32; ByteCounter++)
  { 
    for(BitCounter=0;BitCounter<8;BitCounter++)
    {
      if((*ChinesePointer & (0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }     
    }
    ChinesePointer++;
  }
  //Set_Cs;
  
}
void Lcd_WriteChineseClarity(u8 x,u8 y,u8 x_offset,u8 y_offset,u16 CharColor,u16 ChineseCode)
{

  GPIO_InitTypeDef GPIO_InitStructure;
  u16 Temp;
  u8 ByteCounter,BitCounter;
  u8 *ChinesePointer;
  u8 ChineseBuffer[32];
  
  Lcd_SetBox(x*16,y*16,16,16,x_offset,y_offset);         
  Lcd_WR_Start();
  GetChineseCode(ChineseBuffer,ChineseCode,Chinese_Offset);
  ChinesePointer=ChineseBuffer;
  
  for(ByteCounter=0; ByteCounter<32; ByteCounter++)
  { 
    for(BitCounter=0; BitCounter<8; BitCounter++)
    {
      if((*ChinesePointer & (0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr;
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }     
    }
  ChinesePointer++;
  }
  //Set_Cs;
  
}
/****************************************************************
函数名:Lcd写1个32X32中文函数
入口参数:x,横向坐标,由左到右分别是0~7
          y,纵向坐标,由上到下分别为0~9
          CharColaor,字符的颜色 
          CharBackColor,字符背景颜色 
         ASCIICode,相应中文的编码
也就是说,320240分辨率的显示屏,横向能显示7中文字符,竖向能显示10行
返回值:无

注意!!!!!如果单独使用此函数则应该加上Lcd_Rs_H()和Set_Cs;为了优化系统省去了
这个指令,假设此函数执行的上一条语句是写命令,(RS_L情况)则写入将出错
,因为ILI9320认为当RS_L时写入的是命令
*****************************************************************/
void Lcd_Write32X32Chinese(u8 x,u8 y,u8 x_offset,u8 y_offset,u16 CharColor,u16 CharBackColor,u16 ChineseCode)
{
        
  u8 ByteCounter,BitCounter;
  u8 *ChinesePointer;
  u8 ChineseBuffer[32];
  
  Lcd_SetBox(x*32,y*32,32,32,x_offset,y_offset);         
  Lcd_WR_Start();
  GetChineseCode(ChineseBuffer,ChineseCode,Chinese_Offset);
  ChinesePointer=ChineseBuffer;
  
  for(ByteCounter=0; ByteCounter<16; ByteCounter++)
  { 
    for(BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*ChinesePointer)&(0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }
    for (BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*(ChinesePointer+1)) & (0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }          
    for (BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*ChinesePointer) & (0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }        
    for (BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*(ChinesePointer+1)) & (0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharBackColor);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }
    ChinesePointer+=2;
  }
  //Set_Cs;
 }
void Lcd_Write32X32ChineseClarity(u8 x,u8 y,u8 x_offset,u8 y_offset,u16 CharColor,u16 ChineseCode)
{
        
  GPIO_InitTypeDef GPIO_InitStructure;
  u8 ByteCounter,BitCounter;
  u8 *ChinesePointer;
  u8 ChineseBuffer[32];
  u16 Temp;

  Lcd_SetBox(x*32,y*32,32,32,x_offset,y_offset);         
  Lcd_WR_Start();
  GetChineseCode(ChineseBuffer,ChineseCode,Chinese_Offset);
  ChinesePointer=ChineseBuffer;       
  
  for(ByteCounter=0; ByteCounter<16; ByteCounter++)
  { 
    for(BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*ChinesePointer)&(0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr;
                     
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }
          
    for(BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*(ChinesePointer+1))&(0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr;
                     
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 
      }
    }

          
          
    for(BitCounter=0; BitCounter<8; BitCounter++)
    {
      if (((*ChinesePointer)&(0x80 >> BitCounter)) == 0x00)
      {
        //Set_Rs;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr;
                     
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        Clr_nRd;
        Set_nRd;
               
        Temp=GPIO_ReadInputData(GPIOE);
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
               
        DataToWrite(Temp);
        Clr_nWr;
        Set_nWr; 
      }
      else
      {
        //Set_Rs;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr;
        DataToWrite(CharColor);
        Clr_nWr;
        Set_nWr; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -