智能车制作

标题: 如何用C语言在12864液晶上显示图画? [打印本页]

作者: 401    时间: 2009-10-19 20:08
标题: 如何用C语言在12864液晶上显示图画?
如何用C语言在12864液晶上显示图画?请高手帮一下忙,谢谢!
本文来自: 电子工程师之家http://www.eehome.cn
作者: whut_wj    时间: 2009-10-19 22:07
你有没有LCD驱动的经验?1602 12864的资料很多了,你先搜一搜。
发个HCS12的12864驱动程序。
作者: 401    时间: 2009-10-20 10:33
我上个初学者,谢谢!
作者: dzxz001    时间: 2009-11-7 17:25

作者: Michael_Fei    时间: 2009-11-8 11:18
dg128的应用,程序层次很好,顶
作者: zhongxueliang    时间: 2009-11-14 10:34
好东西,表现顶一下
作者: uulove    时间: 2009-12-21 22:43
OK!
作者: cxccam    时间: 2010-3-17 11:05
很好啊。
作者: cxwtc123    时间: 2010-3-27 10:34
参考一下, 谢谢!
作者: rockzeng    时间: 2010-4-13 21:39
也来学习一下
作者: adolflinux    时间: 2010-5-24 20:18
其实这种东西我们也确实的需要!
作者: gxkj001    时间: 2010-9-19 00:45
我这边有一款彩色的开发资料 可以分享下
作者: 逆风飞翔    时间: 2010-10-18 00:03
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^0;
sbit rw=P3^1;
sbit e=P3^2;
uchar  busy;
void delay(uchar z)
{
  uchar x,y;
  for(x=z; x>0;x--)
    for(y=110;y>0;y--);
}
void delay100(uint n)
{
        uchar i;
        while(n--)
        for(i=0;i<40;i++);
}
void  check_busy(void)
{
  rs = 0;
  rw = 1;  //读命令
do  {
   
    e = 1;
    busy = P0;    //busy=P0这条语句一定要在  "e=1 "的后面   谨记  
    delay(5);
        e = 0;
        }while(busy&0x80);
}

void write_com(uchar com)
{  
  check_busy();
  rs=0;
  rw=0;

  e=1;
   P0=com;
  delay(5);
  e=0;
  delay(5);
}

void write_dat(uchar dat)
{  
  check_busy();
  rs=1;
  rw=0;
  
  e=1;
  P0=dat;
  delay(5);
  e=0;
  delay(5);
}
uchar code pic[]={
/*--  宽度x高度=128x64  --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x1F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x07,0xFC,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x1F,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0xF0,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x01,0xC0,0x00,0x00,0x07,0x00,0x0E,0x1C,0x00,0x00,0x07,0x00,0x00,0x00,0x01,
0x80,0x03,0x80,0x00,0x00,0x03,0x90,0x0E,0x1C,0x00,0x10,0x3F,0x80,0x00,0x00,0x01,
0x80,0x07,0x40,0x00,0x00,0x01,0xC0,0x0C,0x1C,0x00,0x3F,0xFF,0x80,0x00,0x60,0x01,
0x80,0x0E,0x00,0x00,0x00,0x00,0xE0,0x0C,0x1C,0x60,0x3E,0x40,0x07,0xFF,0xE0,0xF1,
0x80,0x1C,0x00,0x00,0x00,0x00,0x70,0x0D,0xFF,0xE0,0x38,0x70,0x03,0xFF,0xE3,0xF1,
0x80,0x3A,0x00,0x00,0x00,0x00,0x38,0x3F,0x9C,0xE0,0x38,0x70,0x03,0x80,0x63,0xF1,
0x80,0x30,0x00,0x00,0x00,0x00,0x18,0x3F,0x9C,0xE0,0x30,0x60,0x03,0x80,0x03,0xF1,
0x80,0x70,0x00,0x00,0x00,0x00,0x1C,0x3F,0x9C,0xE0,0x30,0x60,0xC3,0x9E,0x03,0x71,
0x80,0xE0,0x00,0x00,0x00,0x00,0x0C,0x7D,0x9C,0xE0,0x70,0x61,0xE3,0xFF,0xC0,0x71,
0x80,0xC0,0x00,0x00,0x00,0x00,0x0E,0x7C,0x1C,0xF8,0x7F,0xFF,0xE7,0xFF,0xE0,0x71,
0x80,0xC0,0x0F,0x00,0x00,0xC0,0x06,0x6F,0xFF,0xF8,0x30,0x60,0x03,0xE1,0xE0,0x71,
0x81,0x80,0x1F,0x80,0x01,0xE0,0x07,0x0F,0xFF,0xF8,0x0E,0x6C,0x01,0xC0,0xF0,0x71,
0x81,0x80,0x1F,0x80,0x03,0xF0,0x03,0x0C,0x1E,0x00,0x0F,0x6F,0x00,0x00,0x70,0x71,
0x83,0x80,0x1F,0x80,0x03,0xF0,0x03,0x0C,0x3F,0x00,0x1E,0x67,0x81,0x00,0x70,0x71,
0x83,0x80,0x1F,0x80,0x03,0xF0,0x03,0x8C,0x3B,0x00,0x3C,0x63,0xC3,0x80,0xE0,0x71,
0x83,0x00,0x1F,0x80,0x03,0xF0,0x01,0x8C,0x73,0x80,0x78,0x61,0xC7,0xC1,0xE0,0x71,
0x83,0x00,0x1F,0x80,0x03,0xF0,0x01,0x8C,0xF1,0xC0,0xE0,0x61,0xC7,0xFF,0xC0,0x71,
0x83,0x00,0x1F,0x80,0x03,0xF0,0x01,0x8C,0xE1,0xF1,0xC3,0xE0,0xC0,0xFF,0x80,0xF1,
0x87,0x00,0x0F,0x00,0x01,0xE0,0x01,0x8F,0xC0,0xF9,0x83,0xE0,0x00,0x3E,0x00,0x01,
0x87,0x00,0x06,0x00,0x00,0xD0,0x01,0xCF,0x80,0x70,0x00,0xE0,0x00,0x00,0x00,0x01,
0x87,0x00,0x00,0x00,0x00,0x00,0x01,0xC8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x87,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x87,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x87,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x87,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF1,
0x83,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF1,
0x83,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF1,
0x83,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF1,
0x83,0x00,0x00,0x00,0x00,0x20,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x83,0x80,0x18,0x00,0x00,0x60,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x81,0x80,0x1C,0x00,0x00,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x81,0x80,0x1E,0x00,0x01,0xE0,0x07,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x07,0xF8,0x01,
0x81,0xC0,0x1F,0x00,0x03,0xE0,0x06,0x07,0xFF,0x07,0xFE,0x07,0xFE,0x0F,0xFE,0x01,
0x80,0xC0,0x0F,0x80,0x07,0xE0,0x0E,0x1F,0x8F,0x0F,0x9F,0x0F,0x9F,0x1F,0x1E,0x01,
0x80,0xE0,0x0F,0xC0,0x07,0xE0,0x0E,0x1E,0x07,0x1E,0x07,0x9E,0x07,0x9C,0x0F,0x01,
0x80,0x60,0x07,0xE0,0x0F,0xC0,0x1C,0x0E,0x03,0x1C,0x03,0x9C,0x03,0x9C,0x07,0x01,
0x80,0x70,0x03,0xF0,0x3F,0x80,0x18,0x00,0x07,0x1C,0x03,0x9C,0x03,0x9C,0x07,0x81,
0x80,0x38,0x01,0xFC,0xFF,0x00,0x38,0x00,0x0F,0x38,0x03,0xB8,0x03,0x9C,0x0F,0x81,
0x80,0x18,0x00,0xFF,0xFE,0x00,0x70,0x00,0x3E,0x38,0x01,0xB8,0x01,0x9F,0x1F,0x81,
0x80,0x0C,0x00,0x3F,0xF8,0x00,0xE0,0x00,0xFC,0x38,0x01,0xB8,0x01,0x8F,0xFF,0x81,
0x80,0x0E,0x00,0x07,0x80,0x01,0xC0,0x03,0xF0,0x3C,0x03,0xBC,0x03,0x87,0xFB,0x01,
0x80,0x07,0x00,0x00,0x00,0x03,0xC0,0x07,0xC0,0x1C,0x03,0x9C,0x03,0x80,0x07,0x01,
0x80,0x03,0xC0,0x00,0x00,0x07,0x00,0x07,0x80,0x1E,0x07,0x9E,0x07,0x98,0x0F,0x01,
0x80,0x01,0xE0,0x00,0x00,0x1E,0x00,0x0F,0x00,0x8F,0x0F,0x0F,0x0F,0x1E,0x1E,0x01,
0x80,0x00,0x78,0x00,0x00,0x7C,0x00,0x0F,0xFF,0x8F,0xFE,0x0F,0xFE,0x3F,0xFE,0x01,
0x80,0x00,0x3E,0x00,0x01,0xF8,0x00,0x1F,0xFF,0x83,0xFC,0x03,0xFC,0x0F,0xF8,0x01,
0x80,0x00,0x0F,0xE0,0x1F,0xE0,0x00,0x18,0x01,0x80,0xF0,0x00,0xF0,0x01,0xE0,0x01,
0x80,0x00,0x03,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
void lcdcls(void)
{
        write_com(0x01);
        write_com(0x34);
        write_com(0x30);
}

void init(void)
{
            write_com(0x30) ;              //基本指令集
            delay(10) ;
            write_com(0x06) ;              //光标右移
            delay(10) ;
            write_com(0x0c);              //开显示     游标位置不显示    0x0e 则显示
            delay(10) ;
            write_com(0x01) ;             //清屏
}
void lcd_dis(void)
{   

  uchar i,j,k;//先设垂直地址再设水平地址(连续写入两个字节的资料来完成垂直与水平的坐标地址)
   uint x=0;
   uchar LCD_X=0x80;
for(k=0;k<2;k++)
{
    for(i=0;i<32;i++)                          //写垂直(Y轴)数据                                                           
                {
                 write_com(0x80+i);
             write_com(LCD_X);
         
                        for(j=0;j<16;j++)                       //写水平(X轴)数据
                        {
                                write_dat(pic[x]);  
                                x++;
                        }          
                }
        LCD_X=0x88;
  }
}               

void main(void)
{   
    init();
          delay100(10);
while(1)
{
        write_com(0x36);                     //设置显示图形方式
                lcd_dis();                               //图形方式下显示(我的电脑和我的文档)
                delay100(5000);
                lcdcls();                               //清除当前显示

                delay100(100);

}   

}

你可以参考一下我的程序           还不懂的话  可以联系我  Q262439672
作者: xbsf-写轮眼    时间: 2011-3-22 20:23
看看了
作者: 为梦    时间: 2012-2-20 20:51
学习~~~
作者: 钉子柠檬    时间: 2012-4-27 22:59
图画我做过!挺好玩的!不过你要有那个取模的软件!还有就是你的区和行数据要弄好!否则会是很乱的!
作者: woaisuqiuyan    时间: 2012-6-13 21:34
感谢12#和13#的朋友,学习了。
作者: 西伯利亚野狼    时间: 2012-11-25 17:28





欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2