单片机对19264液晶屏的驱动

畅学单片机 2021-06-19 16:45

首先说下19264屏

1926屏是由3个64*64 组成 64行 192列 其中192列 是64+64+64 =192

它们分别有CS1 CS2 CS3 控制 让那个屏显示 所以 每个屏最多只能显示64行64列 切结8行 等于1页。

每页只能最多写8行 64列,8*64 =512位 512/8 =64字节最多写64字节 。以上就是19264液晶屏的基本原理,虽然各个厂商硬件有所差异但原理基本相同。


C++Code

#include “main.h”


#define __LCD_C__


const uchar code jie[]={


0x08,0x08,0x08,0xFF,0x88,0x68,0x24,0x2C,0xB4,0x25,0x26,0x34,0x2C,0x24,0x20,0x00,


0x02,0x42,0x81,0x7F,0x02,0x82,0x8A,0x4E,0x53,0x32,0x12,0x2E,0x42,0xC2,0x02,0x00 //“接”,0


};


const uchar code di[]={


0x10,0x10,0x10,0xFE,0x10,0x50,0x40,0xFE,0x20,0x20,0xFF,0x10,0x10,0xF8,0x10,0x00,


0x20,0x20,0x10,0x1F,0x08,0x08,0x00,0x3F,0x40,0x40,0x4F,0x42,0x44,0x43,0x70,0x00//“地”,1


};


const uchar code zu[]={


0x00,0xFF,0x11,0x29,0xC7,0x01,0xFE,0x22,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,0x00,


0x00,0xFF,0x02,0x04,0x43,0x40,0x7F,0x42,0x42,0x42,0x42,0x42,0x7F,0x40,0x40,0x00//“阻”,3


};


const uchar code ce[]={


0x08,0x31,0x86,0x60,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0x00,0xFF,0x00,


0x04,0xFC,0x03,0x00,0x80,0x47,0x30,0x0F,0x10,0x67,0x00,0x07,0x40,0x80,0x7F,0x00//“测”,0


};


const uchar code shi[]={


0x40,0x42,0xDC,0x08,0x00,0x90,0x90,0x90,0x90,0x90,0xFF,0x10,0x12,0x1C,0x10,0x00,


0x00,0x00,0x7F,0x20,0x10,0x20,0x20,0x1F,0x10,0x10,0x01,0x06,0x18,0x20,0x78,0x00//“试”,1


};


const uchar code dian[]={


0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,


0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00,//“电”,2


};


const uchar code liu[]={


0x10,0x60,0x01,0x86,0x60,0x04,0x44,0x64,0x55,0x4E,0x44,0x64,0xC4,0x04,0x04,0x00,


0x04,0x04,0xFC,0x03,0x40,0x30,0x0F,0x00,0x00,0x7F,0x00,0x3F,0x40,0x40,0x70,0x00//“流”,3


};


const uchar code si[]={


0x00, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0x10, 0x90, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10, 0x10, 0x00,


0x00, 0x07, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x03, 0x40, 0x80, 0x7F, 0x00, 0x00, 0x00, 0x00//“时”,0


};


const uchar code jian[]={


0x00, 0xF8, 0x01, 0x06, 0x00, 0xF0, 0x92, 0x92, 0x92, 0x92, 0xF2, 0x02, 0x02, 0xFE, 0x00, 0x00,


0x00, 0xFF, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x07, 0x40, 0x80, 0x7F, 0x00, 0x00//“间”,1


};


const uchar code bao[]={


0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xFF,0xC1,0x41,0x41,0x49,0x51,0xCF,0x00,0x00,


0x01,0x41,0x80,0x7F,0x00,0x00,0x00,0xFF,0x40,0x23,0x14,0x1C,0x33,0x60,0x20,0x00


};


const uchar code jing[]={


0x20,0x1A,0xFA,0xAF,0xAA,0xEF,0x0A,0xFA,0x10,0x8F,0x54,0x24,0x5C,0x84,0x04,0x00,


0x02,0x02,0x02,0xEA,0xAA,0xAA,0xAB,0xAA,0xAB,0xAA,0xAA,0xEA,0x02,0x02,0x03,0x00


};


const uchar code bu[]={


0x08,0x08,0x89,0xCE,0x2A,0x98,0x48,0x00,0x00,0x00,0xFF,0x20,0x40,0x80,0x00,0x00,


0x02,0x01,0x00,0xFF,0x01,0x02,0x04,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x03,0x00


};


const uchar codecang[]={


0x40,0x20,0xF8,0x27,0x02,0x30,0x92,0x9C,0x90,0x9F,0x90,0x98,0x96,0x34,0x10,0x00,


0x00,0x00,0x7F,0x00,0x00,0x22,0x72,0x2A,0x2E,0x22,0x22,0x2A,0x72,0x22,0x02,0x00


};


const uchar code zero[]={


0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, //“0”,


0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //“1”,


0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, //“2”,


0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, //“3”,


0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, //“4”,


0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, //“5”,


0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, //“6”,


0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, //“7”,


0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, //“8”,


0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, //“9”,


0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00 //“。”


};


const uchar code m[]={


0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00


};


const uchar code R[]={


0x00,0x00,0xC0,0x20,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x20,0xC0,0x00,0x00,0x00,


0x00,0x38,0x23,0x24,0x28,0x30,0x00,0x00,0x00,0x30,0x28,0x24,0x23,0x38,0x00,0x00


};


const uchar code A[]={


0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00


};


const uchar code S[]={


0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00


};


void delay_ms(uint dly) //@6MHz


{


unsigned char i, j;


while(dly!=0){


//_nop_();


//_nop_();


dly--;


i = 6;


j = 210;


do


{


while (--j);


} while (--i);


}


}


void send_bt(uint bty){


uchar i;


for (i=0;i《8;i++){


clk164 =0;


if (bty & 0x80)


dat164 = 1;


else


dat164 = 0;


clk164 = 1;


bty = bty 《《 1;


}


}


void lcd_write_command(uchar cmd){


//while(busy()); //返回1 死循环 测试忙


lcd_di =0;


lcd_rw =0;


send_bt(cmd);


lcd_e =1;


//delay(1);


_nop_();


lcd_e =0;


}


void lcd_write_data(uchar dat){


//while(busy()); //返回1 死循环 测试忙


lcd_di =1;


lcd_rw =0;


send_bt(dat);


lcd_e =1;


//delay(1);//防止 写数据 与写指令频率太快


_nop_();


lcd_e =0;


}


void set_line(uchar line){


lcd_di =0;


lcd_rw =0;


line = 0xc0 | line;


lcd_write_command(line);


}


void set_page(uchar page){


lcd_di = 0;


lcd_rw = 0;


page = 0xb8 | page;


lcd_write_command(page);


}


void set_column(uchar col){


lcd_di = 0;


lcd_rw = 0;


col = col & 0x3f;


col = 0x40 | col;


lcd_write_command(col);


}


void select_screen(uchar swich){


//swich = 0x07 & swich;


switch(swich)


{


case 0:


{lcd_cs1=lcd_cs2=lcd_cs3 =0;


break;}


case 1:


{lcd_cs1=lcd_cs2 =0;


lcd_cs3 = 1;


break;}


case 2:


{lcd_cs1=lcd_cs3 = 0;


lcd_cs2 =1;


break;}


case 3:


{lcd_cs1=0;


lcd_cs2=lcd_cs3 = 1;


break;}


case 4:


{lcd_cs1=1;


lcd_cs2=lcd_cs3=1;


break;}


case 5:


{lcd_cs1=lcd_cs3=1;


lcd_cs2 =0;


break;}


case 6:


{lcd_cs1=lcd_cs2=1;


lcd_cs3=0;


break;}


case 7:


{lcd_cs1=lcd_cs2=lcd_cs3=1;


break;}


default:


break;


}


}


void set_on_off(uchar swich){


lcd_di = 0;


lcd_rw = 0;


swich = 0x3e | swich;


lcd_write_command(swich);


}


void lcd_scr_clr(void){


uchar i,j;


lcd_cs1 =lcd_cs2 = lcd_cs3 =0;


set_line(0);


set_on_off(1);


set_column(0);


for (i=0;i《8;i++){


set_page(i);


for (j=0;j《64;j++){


lcd_write_data(0x00);


}


}


}


void lcd_init(void){


//while(busy()); //返回1 死循环 防止更改PO口继电器


clr164=1;


lcd_rst=1;


lcd_scr_clr();


set_line(0);//这里是设置起始行


}

为了方便大家更好的学习,您还可以关注畅学电子和EDA的公众号,每天推送相关知识,希望能对你的学习有所帮助!



畅学单片机 以单片机为核心,带你全面了解和单片机相关的知识技巧,经验心得。关注我们,一起来学习吧!
评论 (0)
热门推荐
X
广告
我要评论
0
0
点击右上角,分享到朋友圈 我知道啦
请使用浏览器分享功能 我知道啦