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

📄 lcm.c

📁 以C8051F040为平台,对东芝LCD驱动器T6963,进行底层及中间层驱动操作,完成写汉字,ASCII码,刷图,画点,画线,画圆操作
💻 C
📖 第 1 页 / 共 3 页
字号:
* 名称:LCD_ReadData()
* 功能:读取数据子程序。
* 入口参数:无
* 出口参数:返回值即为读出的数据
* 说明:函数会设置LCM数据总线为输入方式
***********************************************************************/
unsigned char LCD_ReadData(void)
{
   return(LCD_DATA);
}

/***********************************************************************
* 名称:LCD_ClearAll()
* 功能:LCD填充。以图形方式进行填充,起始地址为0x0000。
* 入口参数:ucDATA		要填充的数据
* 出口参数:无
***********************************************************************/
void LCD_ClearAll(void)
{  
   uint16 idata i;
	uint8  idata j;

   LCD_CS();                 /* ExSRAM Page 16.                  */

   LCD_WriteCommand(0xB0);   /* SET PAGE   ADDRESS               */
   LCD_WriteCommand(0x10);   /* SET COLUMN ADDRESS MSB(00000000) */
   LCD_WriteCommand(0x00);   /* SET COLUMN ADDRESS LSB(00000000) */
   LCD_WriteCommand(0x89);   /* SET RAM    ADDRESS CONTROL       */

   for(i=0; i<3840; i++)
     LCD_WriteData(0x00);

   for(i=0; i<240; i++)
	{
      for(j=0; j<16; j++)
		{
         LCD_WriteCommand(0xB0 + j   );     /* ROW / 8   */
         LCD_WriteCommand(0x10 + i>>4);     /* COL'S MSB */ 
         LCD_WriteCommand(   i % 16  );     /* COL'S LSB */
         LCD_WriteData(0x00);
//         DmS(20);
      }
   }

   ExInSRAM_Select(0);       //  
}

/***********************************************************************
* 名称:LCD_Initialize()
* 功能:LCM初始化,将LCM初始化为纯图形模式,显示起始地址为0x0000
* 入口参数:无
* 出口参数:无
* 说明:
***********************************************************************/
void LCD_Initialize(void)
{  
   LCD_Reset();
	DmS(100);

  /****************************
   *** 240128-052W 
	****************************/
   LCD_CS();                 /* ExSRAM Page 16.                  */

   LCD_WriteCommand(0xE2);   /* System reset*/
   DmS(1);
   LCD_WriteCommand(0xEB);   /* Set lcd bias ratio: 111010_10 */
   LCD_WriteCommand(0x25);   /* Set mux rate and temperature compensation*/
   LCD_WriteCommand(0x81);
   LCD_WriteCommand(0xA5);   /* Set gain and potentiometer 1_01_00101 */
   LCD_WriteCommand(0x2F);   /* Set power control 00101_1_11 */
// LCD_WriteCommand(0x30);   /* Set Advance Product Configuration 0011000_0 */
// LCD_WriteCommand(0x16);   /* */
   LCD_WriteCommand(0xAF);   /* Display Enable:    1010111_1 */
// LCD_WriteCommand(0xAE);   /* Sleep Mode:        1010111_0 */
// LCD_WriteCommand(0xE3);   /* NOP:               11100011  */
// LCD_WriteCommand(0xEE);   /* Reset Cursor Mode: 1110111_0 */
// LCD_WriteCommand(0xEF);   /* Set Cursor Mode:   1110111_1 */
   DmS(10);
                    
   LCD_WriteCommand(0x40);   /* Set start line:      01_000000     */
   LCD_WriteCommand(0xA4);   /* Set all pixel on:    1010010_DC[1] */
   LCD_WriteCommand(0xA6);   /* Set inverse display: 1010011_DC[0] */
   LCD_WriteCommand(0x89);   /* Set ram address control: 10001_001 */
   LCD_WriteCommand(0xC8);   /* Set lcd mapping control: 1100_1_0__0 */

  /****************************
   *** 240128-051 
	****************************/
//   LCD_WriteCommand(0xE2); /*system reset*/
//   DmS(10);
//   LCD_WriteCommand(0xEA); /*set lcd bias ratio*/
//   LCD_WriteCommand(0x25); /*set mux rate and temperature compensation*/
//   LCD_WriteCommand(0x81);
//   LCD_WriteCommand(0xBF); /*set gain and potentiometer(double-byte command)*/
//   LCD_WriteCommand(0x2F); /*set power control*/
//   LCD_WriteCommand(0xAF); /*set display enable*/
//   DmS(10);
//   LCD_WriteCommand(0x40); /*set start line*/
//   LCD_WriteCommand(0xA4); /*set all-pixel-on*/
//   LCD_WriteCommand(0xA6); /*set inverse display*/
//   LCD_WriteCommand(0x89); /*set ram address control*/
//   LCD_WriteCommand(0xC8); /*set lcd mapping control*/

   ExInSRAM_Select(0);       //  
}

/****************************************************************************
* 名称:LCD_UpdateByte()
* 功能:在指定位置上更新8个点。
* 入口参数:x 指定点所在列的位置
*           y 指定点所在行的位置
* 出口参数:
* 说明:
****************************************************************************/
void LCD_UpdateByte(uint8 x, uint8 y, uint8 ucDATA)
{   
   if( x >= (GUI_LCM_XMAX - 8) )        /* 参数过滤 */
     return;
   if( y >= (GUI_LCM_YMAX - 8) )        /* 参数过滤 */
     return;

   LCD_CS();                          /* ExSRAM Page 16 */

   LCD_WriteCommand(0xB0 + y>>3);     /* ROW / 8   */
   LCD_WriteCommand(0x10 + x>>4);     /* COL'S MSB */ 
   LCD_WriteCommand(   x % 16 );      /* COL'S LSB */

   LCD_WriteData(ucDATA);
 //  LCD_WriteData(0xff);
   DmS(20);

   ExInSRAM_Select(0);                /* Switch back to InSRAM */ 
}

/****************************************************************************
* 名称:LCD_UpdatePoint()
* 功能:在指定位置上画点,刷新某一点。
* 入口参数:x            指定点所在列的位置
*           y            指定点所在行的位置
*           bCOLOR  0/1  显示/不显示   
* 出口参数:
* 说明:
****************************************************************************/
void LCD_UpdatePoint(uint8 x, uint8 y, bit bCOLOR)
{  
   LCD_CS();                         /* ExSRAM Page 16 */

   LCD_WriteCommand(0xB0 + y>>3);    
   LCD_WriteCommand(0x10 + x>>4);
   LCD_WriteCommand(   x % 16);

   if(bCOLOR)
     LCD_WriteData(0x01<<y % 8);
   else
     LCD_WriteData(0x00);

   ExInSRAM_Select(0);       //  
}


/****************************************************************************
* 名称:LCD_DispAsciiCh16x8()
* 功能:显示ASCII 16×8字符。
* 入口参数:x	指定显示位置,x坐标
*           y	指定显示位置,y坐标
*           ch	要显示的ASCII字符对应的数组的地址。
* 出口参数:返回值为1时表示操作成功,为0时表示操作失败。
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
bit LCD_DispAsciiCh16x8(uint8 xx, uint8 yy, uint8 ucASCII)
{  
   uint8  x, y;
   uint8  i;
   uint16 AddrOffSet;

   x = xx;
	y = yy;
   if( x >= (GUI_LCM_XMAX-8) )              /* 参数过滤 */
     return(0);
   if( y >= (GUI_LCM_YMAX-8) )              /* 参数过滤 */
     return(0);

   AddrOffSet = ( ucASCII - 32) * 16;       //     
   for(i=0; i<16; i++)						     // 显示共16行
   {  
      LCD_UpdateByte(x, y, FONT16x8ASII[AddrOffSet + i]);
      y++;									        // 指向下一行
   }   
   return(1);
}


/****************************************************************************
* 名称:LCD_DispAsciiStr16x8()
* 功能:输出显示字符串,16*8字体
* 入口参数:x	   指定显示位置,x坐标
*           y	   指定显示位置,y坐标
*           str	要显示的ASCII码字符串
* 出口参数:无
* 说明:
****************************************************************************/
void LCD_DispAsciiStr16x8(uint8 x, uint8 y, uint8 *str, bit bReve)
{  
   uint8  *OffSet;
   uint8  i;
   uint16 AddOffSet;

   OffSet    = strstr(Index_FONT16x8ASII, str);
   AddOffSet = (OffSet-Index_FONT16x8ASII) << 4;

   if( !bReve )
   {
      for(i=0;i<8;i++)
        LCD_UpdateByte(x+i, y,   FONT16x8ASII[AddOffSet++]);
      for(i=0;i<8;i++)
        LCD_UpdateByte(x+i, y+8, FONT16x8ASII[AddOffSet++]);
   }
   else
   {
      for(i=0;i<8;i++)
        LCD_UpdateByte(x+i, y,   ~FONT16x8ASII[AddOffSet++]);
      for(i=0;i<8;i++)
        LCD_UpdateByte(x+i, y+8, ~FONT16x8ASII[AddOffSet++]);
   }
}


/****************************************************************************
* 名称:LCD_DispChChar16x16()
* 功能:显示汉字(16*16字体)。
* 入口参数:x	指定显示位置,x坐标
*           y	指定显示位置,y坐标
*           ch	要显示的汉字对应的数组的首地址。
* 出口参数:返回值为1时表示操作成功,为0时表示操作失败。
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
bit LCD_DispChChar16x16(uint8 xx, uint8 yy, char *ucCHAR, uint8 FontNo)
{  
   uint8  xdata x, y;
   uint8  xdata i, j, k;
   char   xdata *OffSetCH; 
   uint16 xdata AddrOffSet;
      
   x = xx;
	y = yy;
   if( x >= (GUI_LCM_XMAX-8) )                  /* 参数过滤 */
     return(0);
   if( y >= (GUI_LCM_YMAX-8) )                  /* 参数过滤 */
     return(0);

   OffSetCH   = strstr(Index_FONT16x16ChCH, ucCHAR);
   if( OffSetCH == 0 )
     return (0);
   AddrOffSet = ( OffSetCH - Index_FONT16x16ChCH ) << 4;    // = / 2 * 32;
                                             
   k = 0;
   for(i=0; i<16; i++)						         // 显示共16行
   {  
      for(j=0; j<2; j++)				   	      // 每行共16点
      {  
		   if( FontNo == 0 )                      // 宋体
           LCD_UpdateByte(x, y, FONT16x16ChCH1[AddrOffSet + k]);
		   if( FontNo == 1 )                      // 宋体加粗
           LCD_UpdateByte(x, y, FONT16x16ChCH2[AddrOffSet + k]);

		   x = x + 8;
			k++;
      }      
      y++;									            // 指向下一行
      x = x - 16;							            // 恢复x值
   }   
   return(1);
}


⌨️ 快捷键说明

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