12864显示自定义图像乱码问题
时间:10-02
整理:3721RD
点击:
用这个图取字模
但显示出来会出现2道粗线
就算把CGRAM全部送0 然后显示 那2道粗线还是存在
求教大神这是什么问题 怎么解决?
代码如下:
- void delayms(uint z)
- {
- uint i,j;
- for(i=z;i>0;i--)
- for(j=110;j>0;j--);
- }
- void delayus(uchar z)
- {
- uchar i;
- for(i=z;i>0;i--)
- {
- _nop_();_nop_();
- _nop_();_nop_();
- _nop_();_nop_();
- }
- }
- void check_busy()
- {
- rs=0;
- rw=1;
- en=1;
- while(P0&0x80);
- en=0;
- }
- void LCD12864_write_com(uchar com)
- {
- check_busy();
- rs=0;
- rw=0;
- P0=com;
- en=1;
- delayms(1);
- en=0;
- }
- void LCD12864_write_dat(uchar dat)
- {
- check_busy();
- rs=1;
- rw=0;
- P0=dat;
- en=1;
- delayms(1);
- en=0;
- }
- void LCD12864_init()
- {
- delayms(40);
- psb=1;
- delayus(20);
- res=0;
- delayus(20);
- res=1;
- delayus(20);
- LCD12864_write_com(0x30);
- delayus(20);
- LCD12864_write_com(0x30);
- delayus(8);
- LCD12864_write_com(0x0c);
- delayus(20);
- LCD12864_write_com(0x01);
- delayms(10);
- LCD12864_write_com(0x06);
- delayus(20);
- }
- void clean_screen()
- {
- LCD12864_write_com(0x01);
- delayms(10);
- }
- void clean_cgram()
- {
- uchar i,j;
- LCD12864_write_com(0x34);
- for(i=0;i<32;i++)
- {
- LCD12864_write_com(0x80+i);
- LCD12864_write_com(0x80);
- for(j=0;j<16;j++)
- {
- LCD12864_write_dat(0x00);
- }
- }
-
- for(i=0;i<32;i++)
- {
- LCD12864_write_com(0x88+i);
- LCD12864_write_com(0x88);
- for(j=0;j<16;j++)
- {
- LCD12864_write_dat(0x00);
- }
- }
- //LCD12864_write_com(0x36);
- LCD12864_write_com(0x30);
- }
- void display_pic(uchar *img)
- {
- uchar i,j;
- LCD12864_write_com(0x34);
- clean_screen();
- for(i=0;i<32;i++)
- {
- LCD12864_write_com(0x80+i);
- LCD12864_write_com(0x80);
- for(j=0;j<16;j++)
- {
- LCD12864_write_dat(*img);
- img++;
- }
- }
-
- for(i=0;i<32;i++)
- {
- LCD12864_write_com(0x88+i);
- LCD12864_write_com(0x88);
- for(j=0;j<16;j++)
- {
- LCD12864_write_dat(*img);
- img++;
- }
- }
- LCD12864_write_com(0x36);
- LCD12864_write_com(0x30);
- }
- void main()
- {
- dx=1;
- P0=0;
- dx=0;
- wx=1;
- P0=0xff;
- wx=0;
-
- LCD12864_init();
- clean_screen();
- clean_cgram();
- display_pic(pic1);
-
- while(1);
-
- }
是不是显示所有图片都这样啊
对啊。就算全部送0 那2粗线还是会在