打板实测效果如下
单片机源程序如下:
- #include"stc12c5axx.h"
- #include "intrins.h"
- #define uchar unsigned char
- #define uint unsigned int
- sbit e=P4^3;
- sbit rw=P0^3;
- sbit rs=P0^4;
- sbit cs1=P0^7;
- sbit cs2=P0^6;
- ///***********大汉字数组,取模方式32X32*****************/
- //uchar code tab[][128]={
- //
- ///*-- 调入了一幅图像:这是您新建的图像 --*/
- ///*-- 宽度x高度=16x16 --*/
- //0x02,0x00,0x01,0x00,0x21,0x00,0x63,0x02,0x06,0x00,0x05,0x04,0xB5,0x00,0x01,0x0A,
- //0x13,0x08,0x81,0x09,0xA3,0x0A,0x91,0x09,0xAB,0x0A,0x41,0x08,0x11,0x00,0x00,0x09
- //
- //
- //};
- /***********标准汉字数组,取模方式16X16*****************/
- uchar code tab_biao[][32]={
- /*-- 文字: 代 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x80,0x60,0xF8,0x07,0x20,0x20,0x20,0x7F,0xA0,0x10,0x11,0x16,0x10,0x10,0x00,
- 0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,0x40,0xF8,0x00,
- /*-- 文字: 码 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x04,0x84,0xE4,0x5C,0x44,0xC4,0x00,0x02,0xF2,0x82,0x82,0x82,0xFE,0x80,0x80,0x00,
- 0x02,0x01,0x7F,0x10,0x10,0x3F,0x00,0x08,0x08,0x08,0x08,0x48,0x88,0x40,0x3F,0x00,
- /*-- 文字: 书 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0xF9,0x02,0x04,0x00,0x00,0x00,
- 0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x21,0x41,0x21,0x1F,0x00,0x00,
- /*-- 文字: 写 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x06,0x82,0x7A,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x0A,0x06,0x00,
- 0x08,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x49,0x81,0x41,0x3F,0x00,0x00,0x00,
- /*-- 文字: 人 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x00,
- /*-- 文字: 生 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x80,0x40,0x30,0x1E,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
- 0x40,0x40,0x42,0x42,0x42,0x42,0x42,0x7F,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,
- /*-- 文字: 技 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
- 0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,
- /*-- 文字: 术 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x10,0x10,0x10,0x10,0xD0,0x30,0xFF,0x30,0xD0,0x12,0x1C,0x10,0x10,0x00,0x00,
- 0x10,0x08,0x04,0x02,0x01,0x00,0x00,0xFF,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x00,
- /*-- 文字: 成 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0x08,0x08,0xFF,0x08,0x09,0x0A,0xC8,0x08,0x00,
- 0x80,0x60,0x1F,0x00,0x10,0x20,0x1F,0x80,0x40,0x21,0x16,0x18,0x26,0x41,0xF8,0x00,
- /*-- 文字: 就 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x04,0xE4,0x25,0x26,0x24,0xE4,0x04,0x20,0x20,0xFF,0x20,0xE2,0x2C,0x20,0x20,0x00,
- 0x10,0x4B,0x82,0x7E,0x02,0x0B,0x90,0x60,0x1C,0x03,0x00,0x3F,0x40,0x40,0x70,0x00,
- /*-- 文字: 梦 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x44,0x24,0x14,0x7F,0x94,0x24,0x00,0x24,0x14,0x7F,0x14,0x24,0x44,0x40,0x00,
- 0x00,0x80,0x88,0x84,0x42,0x45,0x29,0x11,0x11,0x09,0x05,0x03,0x00,0x00,0x00,0x00,
- /*-- 文字: 想 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x08,0x88,0x68,0xFF,0x48,0x88,0x00,0xFE,0x52,0x52,0x52,0xFE,0x00,0x00,0x00,
- 0x40,0x31,0x00,0x00,0x3B,0x40,0x40,0x44,0x5B,0x42,0x42,0x72,0x03,0x08,0x30,0x00,
- /*-- 文字: 技 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
- 0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,
- /*-- 文字: 术 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x10,0x10,0x10,0x10,0xD0,0x30,0xFF,0x30,0xD0,0x12,0x1C,0x10,0x10,0x00,0x00,
- 0x10,0x08,0x04,0x02,0x01,0x00,0x00,0xFF,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x00,
- /*-- 文字: 照 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0xFE,0x42,0x42,0x42,0xFE,0x00,0x42,0xA2,0x9E,0x82,0xA2,0xC2,0xBE,0x00,0x00,
- 0x80,0x6F,0x08,0x08,0x28,0xCF,0x00,0x00,0x2F,0xC8,0x08,0x08,0x28,0xCF,0x00,0x00,
- /*-- 文字: 亮 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x04,0x04,0x74,0x54,0x54,0x55,0x56,0x54,0x54,0x54,0x74,0x04,0x04,0x00,0x00,
- 0x84,0x83,0x41,0x21,0x1D,0x05,0x05,0x05,0x05,0x05,0x7D,0x81,0x81,0x85,0xE3,0x00,
- /*-- 文字: 前 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x08,0xE8,0x29,0x2E,0x28,0xE8,0x08,0x08,0xC8,0x0C,0x0B,0xE8,0x08,0x08,0x00,
- 0x00,0x00,0xFF,0x09,0x49,0x89,0x7F,0x00,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,
- /*-- 文字: 程 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,
- 0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,
- /*-- 文字: 学 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
- 0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
- /*-- 文字: 习 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x02,0x02,0x02,0x12,0x22,0xC2,0x02,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
- 0x00,0x08,0x18,0x08,0x04,0x04,0x04,0x02,0x02,0x41,0x81,0x40,0x3F,0x00,0x00,0x00,
- /*-- 文字: 成 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0x08,0x08,0xFF,0x08,0x09,0x0A,0xC8,0x08,0x00,
- 0x80,0x60,0x1F,0x00,0x10,0x20,0x1F,0x80,0x40,0x21,0x16,0x18,0x26,0x41,0xF8,0x00,
- /*-- 文字: 就 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x04,0xE4,0x25,0x26,0x24,0xE4,0x04,0x20,0x20,0xFF,0x20,0xE2,0x2C,0x20,0x20,0x00,
- 0x10,0x4B,0x82,0x7E,0x02,0x0B,0x90,0x60,0x1C,0x03,0x00,0x3F,0x40,0x40,0x70,0x00,
- /*-- 文字: 未 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x80,0x80,0x88,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x88,0x80,0x80,0x00,
- 0x20,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x01,0x02,0x04,0x08,0x10,0x20,0x20,0x00,
- /*-- 文字: 来 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x08,0x08,0x28,0xC8,0x08,0x08,0xFF,0x08,0x08,0x88,0x68,0x08,0x08,0x00,0x00,
- 0x21,0x21,0x11,0x11,0x09,0x05,0x03,0xFF,0x03,0x05,0x09,0x11,0x11,0x21,0x21,0x00,
- };
- void Delay50us() //@11.0592MHz
- {
- unsigned char i, j;
- _nop_();
- _nop_();
- _nop_();
- i = 1;
- j = 133;
- do
- {
- while (--j);
- } while (--i);
- }
- void lcd12864_write_com(uchar com) //写指令
- {
- rs=0;
- rw=0;
- e=0;
- Delay50us();
- P1=com;
- Delay50us();
- e=1;
- Delay50us();
- e=0;
- }
- void lcd12864_write_date(uchar date)//写数据
- {
- rs=1;
- rw=0;
- e=0;
- Delay50us();
- P1=date;
- Delay50us();
- e=1;
- Delay50us();
- e=0;
- }
- void lcd12864_init() //初始化
- {
- lcd12864_write_com(0x3f);//打开屏幕 ,关闭是3e
- Delay50us();
- lcd12864_write_com(0xc0); //行的初始化地址
- Delay50us();
- lcd12864_write_com(0xb8);//页的初始化地址
- Delay50us();
- lcd12864_write_com(0x40);//列的初始化地址
- Delay50us();
-
- }
- void clear_lcd12864() //清屏
- {
- uchar i,j;
- cs1=1;cs2=1; //打开左右两屏,实物 注意:LCD12864实物是CS1=1;CS2=1为打开,
- for(i=0;i<8;i++) //共8页
- {
- lcd12864_write_com(0xb8+i);//页的初始化地址
- lcd12864_write_com(0x40);//列的初始化地址
- for(j=0;j<64;j++) //共64列
- {
- lcd12864_write_date(0x00);
- }
- }
- }
- //12864显示程序:
- /***********大汉字显示函数************************/
- //void hanzi(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- //{
- // uchar i,j;
- // for(i=0;i<4;i++) //4页
- // {
- // lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- // lcd12864_write_com(0x40+lie);//列的初始化地址
- // for(j=0;j<32;j++) //这里要显示大汉字,取模为32X32
- // {
- // lcd12864_write_date(shuzhu[i*32+j]);
- // }
- // }
- //}
- /***********标准汉字显示函数************************/
- void hanzi2(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- {
- uchar i,j;
- for(i=0;i<2;i++) //2页
- {
- lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- lcd12864_write_com(0x40+lie);//列的初始化地址
- for(j=0;j<16;j++) //这里要显示标准汉字,取模为16X16
- {
- lcd12864_write_date(shuzhu[i*16+j]);
- }
- }
- }
- ///***********小数字显示函数************************/
- // void shuzi2(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- //{
- // uchar i,j;
- // for(i=0;i<2;i++) //2页
- // {
- // lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- // lcd12864_write_com(0x40+lie);//列的初始化地址
- // for(j=0;j<8;j++) //数字取半模,这里要改为8
- // {
- // lcd12864_write_date(shuzhu[i*8+j]);
- // }
- // }
- //}
- void lcd12864_dis() //汉字显示函数
- {
- /*******显示第一行***********/
- // cs1=0;cs2=1;//打开左半屏 ,实物
- //
- // shuzi2(0,0,tab_banlie[10]);// Q
- // shuzi2(0,8,tab_banlie[10]);// Q
- // hanzi2(0,16,tab_biao[4]); //":"
- // shuzi2(0,32,tab_banlie[1]);// 1
- // shuzi2(0,40,tab_banlie[2]);// 2
- // shuzi2(0,48,tab_banlie[3]);// 3
- // shuzi2(0,56,tab_banlie[4]);// 4
- //
- // cs1=0;cs2=1;//打开右半屏 ,实物
- //
- // shuzi2(0,0,tab_banlie[5]);// 5
- // shuzi2(0,8,tab_banlie[6]);// 6
- // shuzi2(0,16,tab_banlie[7]);// 7
- // shuzi2(0,24,tab_banlie[8]);// 8
- // shuzi2(0,32,tab_banlie[9]);// 9
-
- /*******显示第一行(标准汉字)***********/
-
- cs1=1;cs2=0;//打开左半屏 ,实物
-
- hanzi2(0,0,tab_biao[0]); //代
- hanzi2(0,16,tab_biao[1]); //码
- hanzi2(0,32,tab_biao[2]); //书
- hanzi2(0,48,tab_biao[3]); //写
-
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi2(0,0,tab_biao[4]); //人
- hanzi2(0,16,tab_biao[5]); //生
- //
- /*******显示第二行(标准汉字)***********/
- cs1=1;cs2=0;//打开左半屏 ,实物
-
- hanzi2(2,0,tab_biao[6]); //好
- hanzi2(2,16,tab_biao[7]); //好
- hanzi2(2,32,tab_biao[8]); //学
- hanzi2(2,48,tab_biao[9]); //习
- //
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi2(2,0,tab_biao[10]); //好
- hanzi2(2,16,tab_biao[11]); //好
- // hanzi2(4,32,tab_biao[14]); //学
- // hanzi2(4,48,tab_biao[15]); //习
- /*******显示第三行(标准汉字)***********/
- cs1=1;cs2=0;//打开左半屏 ,实物
-
- hanzi2(4,0,tab_biao[12]); //好
- hanzi2(4,16,tab_biao[13]); //好
- hanzi2(4,32,tab_biao[14]); //学
- hanzi2(4,48,tab_biao[15]); //习
-
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi2(4,0,tab_biao[16]); //好
- hanzi2(4,16,tab_biao[17]); //好
- // hanzi2(8,32,tab_biao[6]); //学
- // hanzi2(8,48,tab_biao[7]); //习
- ///*******显示第四行(标准汉字)***********/
- //
- cs1=1;cs2=0;//打开左半屏 ,实物
-
- hanzi2(6,0,tab_biao[18]); //好
- hanzi2(6,16,tab_biao[19]); //好
- hanzi2(6,32,tab_biao[20]); //学
- hanzi2(6,48,tab_biao[21]); //习
-
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi2(6,0,tab_biao[22]); //好
- hanzi2(6,16,tab_biao[23]); //好
- // hanzi2(2,32,tab_biao[6]); //学
- // hanzi2(2,48,tab_biao[7]); //习
- //
-
- /*******显示第三行(大汉字)***********/
-
- // cs1=1;cs2=0;//打开左半屏 ,实物
- // hanzi(4,0,tab[4]); //天
- // hanzi(4,32,tab[5]); //天
- //
- // cs1=0;cs2=1;//打开右半屏 ,实物
- // hanzi(4,0,tab[6]); //向
- // hanzi(4,32,tab[7]); //上
- }
- void main()
- {
- lcd12864_init();
- clear_lcd12864();
-
- while(1)
- {
- lcd12864_dis();
- }
- }
复制代码
全部资料51hei下载地址:
18b20.zip
(53.16 KB, 下载次数: 84)
|