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

📄 lcd-t6963.c

📁 T6963的lpc21xx接口程序,且包括一些画直线,局部清屏等函数
💻 C
📖 第 1 页 / 共 2 页
字号:
  lcd_parameter[0] = addr;       //地址低位
  lcd_parameter[1] = addr >> 8;  //地址高位
  write_command_lcd(0x24, 2, lcd_parameter);  //指定显示的地址
  for( j = 0; j < x1 - x0; j++)   //清空32K显示RAM
    { lcd_parameter[0] = 0x00;     
      write_command_lcd(0xc0, 1, lcd_parameter);      
    } 
   addr += LCD_XMAX ; 
    } 
}


/****************************************************************************
* 名称:disp_many(uint8 x,uint8 y,uint16 *str,uint8 flag)
* 功能:显示一组字符串,以0作为字符串结束标志
* 入口参数:x --第一个字符在 LCD屏的X方向显示位置,以字节为单位
*           y -- 整个字符串在LCD屏的Y方向显示位置,以字符行为单位(0~8行),
*           str  -- 显示字符串的编码数组,字符和汉字的处理方式一样,汉字的编码占用2个字节的单元。
                    以0作为字符串结束标志
*           flag=1反显,flag=0不反显  (为整串反显或不反显)
            
* 出口参数:无 
* 其它:   
*          
****************************************************************************/
void disp_many(uint8 x,uint8 y,uint16 *str,uint8 flag)
{   uint16 c,xi;

    for(xi = 0; xi < LCD_XMAX ; xi++)  //不能超过一行最多显示的字符数
     { c = *str++;
       if(c == 0) break;
       disp_one(x, y, c, flag); x++;
     } 
     
}

/****************************************************************************
* 名称:lcd_line_fullrow(uint8 y)
* 功能:在LCD上画一条整行横线,从字节0到字节29
* 入口参数:y -- 横线所在的行号(0~128),以点为单位.
* 出口参数:无 
*        
****************************************************************************/
void lcd_line_wholerow(uint8 y)
{uint8 xa;
 uint16 xt;
   xt = y * LCD_XMAX ;
   xt = xt + LCD_GRAPHICS_ADDR;
      lcd_parameter[0] = xt;
      lcd_parameter[1] = xt >> 8 ;
      write_command_lcd(0x24,2,lcd_parameter);
  for(xa = 0; xa < LCD_XMAX ; xa++)
    {
      lcd_parameter[0] = 0xff;
      write_command_lcd(0xc0,1,lcd_parameter);
    }
}

/****************************************************************************
* 名称:lcd_linerow_8(uint8 xsta,uint8 xend)  //行
* 功能:在LCD上画一短横线(线段坐标是同一个字节中并)
* 入口参数:y -- 横线所在的行号(0~128),以点为单位.
*           xsta -- 横线的起点坐标(0~239),以点为单位.
*           xend -- 横线的终点坐标(0~239),以点为单位.
* 出口参数:无 
****************************************************************************/
void lcd_linerow_8(uint8 xsta,uint8 xend)  //行
{uint8 xi,xa,xb,xt;
   
   xa = 0;
   xi = xsta - (xsta / 8) * 8;
      xi = 8 - xi;
       for(xt = 0;xt < xi; xt ++)
        { xa = xa << 1;
          xa++;
        }
     
   xi = xend - (xend / 8) * 8;
     { xb = 0xc0;
       for(xt = 0;xt <= xi; xt ++)
        { xb = xb >> 1;
          xb = xb | 0x80;
        }
      lcd_parameter[0] = xa & xb;
      write_command_lcd(0xc0,1,lcd_parameter);
     }
}

/****************************************************************************
* 名称:lcd_line_row(uint8 y,uint8 xsta,uint8 xend)  //行
* 功能:在LCD上画一条任意长度的横线
* 入口参数:y -- 横线所在的行号(0~128),以点为单位.
*           xsta -- 横线的起点坐标(0~239),以点为单位.
*           xend -- 横线的终点坐标(0~239),以点为单位.
* 出口参数:无 
* 其它:   橫线是从第xsta+1的点位置(以0开始计数)开始显示()
****************************************************************************/
void lcd_line_row(uint8 y,uint8 xsta,uint8 xend)  //行
{uint8 xi,xa;
 uint8 xbstar,xbend;  //线段起点和终点的字节位置
 uint16 xt;

   if(xsta > xend) { xi = xsta; xsta = xend; xend = xi; }
   xt = y * LCD_XMAX ;
   xt = xt + (xsta / 8) + LCD_GRAPHICS_ADDR;
   lcd_parameter[0] = xt;
   lcd_parameter[1] = xt >> 8;
  write_command_lcd(0x24,2,lcd_parameter);
  //1.线段在同一字节中  
   xbstar = xsta / 8; xbend = xend / 8;
   if(xbstar == xbend ) { lcd_linerow_8(xsta,xend); return; }  
   
  //2.线段在多个字节中,则分为三部分处理:首字节,中间n-2个字节,尾字节.
  //2.1 首字节    
   xi = xsta % 8;
   xi = 7 - xi;
   xa = 1;
   for(xt = 0; xt < xi;xt ++)
     { xa = xa << 1;  xa++;  }
   lcd_parameter[0] = xa;
   write_command_lcd(0xc0,1,lcd_parameter);
   xbstar++;

  //2.2 中间处理 len - 2个字节
//  if(xbstar < xbend) 
    for( ; xbstar < xbend; xbstar++)  //画线条中间全部満一个字节(8点)的线
      {
        lcd_parameter[0] = 0xff;
        write_command_lcd(0xc0,1,lcd_parameter);
      }
   
 //线条后端单独用一个字节来处理
      xi = (xend % 8) + 1;
      xa = 0x00;
      for(xt = 0;xt < xi; xt ++)  //把需要的几个位置1
        { xa = xa >> 1;
          xa = xa | 0x80;
        }
      lcd_parameter[0] = xa;
      write_command_lcd(0xc0,1,lcd_parameter);
}

/****************************************************************************
* 名称:lcd_line_col(uint8 x, uint8 xd) 
* 功能:在LCD指定的两点间画一条竖线
* 入口参数:x  -- 竖线在LCD的X方向显示位置,以字节为单位(0~39)
*           xd -- 竖线的线型.(0~3f)
*           xsta -- 竖线的起点坐标(0~127),以点为单位.
*           xend -- 竖线的终点坐标(0~127),以点为单位.
* 出口参数:无 
* 其它:  
*        
****************************************************************************/
void lcd_line_col(uint8 x, uint8 xd,uint8 xsta,uint8 xend)  //列
{
 uint8 xi;
 uint16 xt;
   if(xsta > xend) {xi = xend; xend = xsta;}  //若起点大于始点,则交换起点与终点的值.
   else {xi = xsta; }
   xt = xi * LCD_XMAX ;
   xt = xt+ x + LCD_GRAPHICS_ADDR;

  for(; xi <= xend; xi++)
    {  //lcd_addr
      lcd_parameter[0] = xt;
      lcd_parameter[1] = xt >> 8;//
      write_command_lcd(0x24,2,lcd_parameter);
       //char_addr
     lcd_parameter[0] = xd;
     write_command_lcd(0xc0,1,lcd_parameter);
	  xt += LCD_XMAX ;
    }  
}
/****************************************************************************
* 名称:lcd_line_coldot(uint8 x,uint8 xsta,uint8 xend)  //列
* 功能:在LCD指定的两点间画一条竖线
* 入口参数:x  -- 竖线在LCD的X方向显示位置,以点为单位(0~239)
*          // xd -- 竖线的线型.(0~3f)
*           xsta -- 竖线的起点坐标(0~127),以点为单位.
*           xend -- 竖线的终点坐标(0~127),以点为单位.
* 出口参数:无 
* 其它:  
*        
****************************************************************************/
void lcd_line_coldot(uint8 x,uint8 xsta,uint8 xend)  //列
{
 uint8 xi,xd;
 uint16 xt;
   if(xsta > xend) {xi = xend; xend = xsta;xsta = xi;}  //若起点大于始点,则交换起点与终点的值.
//   else {xi = xsta; }
   xt = xi * LCD_XMAX ;
   xt = xt + (x / 8) + LCD_GRAPHICS_ADDR;//0x0800;
   xd = x % LCD_YMAX ;
   xd = 0x01 << (7 - xd);
  for(xi = 0; xi <= (xend - xsta); xi++)
    {  //lcd_addr
      lcd_parameter[0] = xt;
      lcd_parameter[1] = xt >> 8;//
      write_command_lcd(0x24,2,lcd_parameter);
       //char_addr
     lcd_parameter[0] = xd;
     write_command_lcd(0xc0,1,lcd_parameter);
	  xt += LCD_XMAX ;
    }  
}
/****************************************************************************
* 名称:lcd_rectangle(uint8 x1,uint8 y1,uint8 x2,uint8 y2)
* 功能:在LCD指定的两坐标点(对角坐标)之间画一矩形
* 入口参数:x1,y1 -- 起点坐标,以点为单位(0~239,0~127)
*           x2,y2 -- 终点坐标,以点为单位(0~239,0~127)
* 出口参数:无 
* 其它:  
*        
****************************************************************************/
void lcd_rectangle(uint8 x1,uint8 py1,uint8 x2,uint8 y2)     
{ uint8 xa,xb;
  //先画竖线,后画横线
  if(( x1 / 8 ) == (x2 / 8)) //两条竖线在同一个字节中
   { //使用字节的线型法画竖线
     xa =  x1 % 8;
     xa = 0x01 << (7 - xa);
     xb =  x2 % 8;
     xb = 0x01 << (7 - xb);
     xa = xa | xb;
     lcd_line_col(x1 / 8, xa, py1,y2);
   }
  else 
   { 
     lcd_line_coldot(x1,py1,y2);
     lcd_line_coldot(x2,py1,y2);
   }
   lcd_line_row(py1,x1,x2);  //行   
   lcd_line_row(y2,x1,x2);  //行   
}

⌨️ 快捷键说明

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