/*****************************************************
16*128 LED点阵屏 C 程序
******************************************************
声明:
本程序供大家学习之用,用勿用于商业用途。尊重版权。
编写:邓椿薪
时间:2006年1月20日 晚
邮箱:love2151@xinhuanet.com
*******************************************************
//595连级输出数据,138行驱动。P0_1为移动速度高速/*点阵显示汉字程串口输出字符数据,
//P2口输出行扫描信号,P2_7输出595锁存信号。*/
#include
#define uchar unsigned char
#define uint unsigned int
uchar yid,h; //YID为移动计数器,H为行段计数器。
uint zimuo; //字模计数器
uchar code hanzi[]; //汉字字模
uchar BUFF[18]; //缓存
void in_data(void); //调整数据
void rxd_data(void); //发送数据
void sbuf_out(); //16段扫描
unsigned code sw[16]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; /*16行段码*/
//{0x60,0x62,0x64,0x66,0x68,0x6a,0x6c,0x6e,
//0x70,0x72,0x74,0x76,0x78,0x7a,0x7c,0x7e}; /*16行段码*/
/********************************************/
void main(void)
{
uchar i,d=10;
yid=0;
zimuo=0;
while(1)
{
while(yid<16) //数据移位。
{
for(i=0;i sbuf_out(); } yid++; //移动一步 } yid=0; zimuo=zimuo+32; //后移一个字, if(zimuo>=3386) //总数减7个字。 zimuo=0; } } /********************************/ void sbuf_out() { for(h=0;h<16;h++) //16行扫描 { in_data(); //调整数据 rxd_data(); //串口发送数据 P1=0x7f; //关闭显示。 P1_7=1; //锁存为高,595锁存信号 P1=sw[h]; //送段码 } } /******************************************************/ void in_data(void) { char s; for(s=8;s>=0;s--) //h为向后先择字节计数器,zimuoo为向后先字计数器 { BUFF[2*s+1]=hanzi[zimuo+32*s+2*h]; //把第一个字模的第一个字节放入BUFF0中,第二个字模和第一个字节放入BUFF2中 BUFF[2*s]=hanzi[zimuo+1+32*s+2*h]; // 把第一个字模的第二个字节放入BUFF1中,第二个字模的第二个字节放入BUFF3中 } } /*******************************************************/ void rxd_data(void) //串行发送数据 { char s; uchar inc,tempyid,temp; if(yid<8) inc=0; else inc=1; for(s=0+inc;s<16+inc;s++) //发送8字节数据 { if(yid<8) tempyid=yid; else tempyid=yid-8; temp=(BUFF[s]>>tempyid)|(BUFF[s+1]<//temp=255-temp; SBUF=temp;//把BUFF中的字节从大到小移位相或后发送输出。 while(!TI);TI=0; //等待发送中断 } } /*******************************************************/ uchar code hanzi[]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //============================================================================= /*-- 调入了一幅图像:这是您新建的图像 --*/ /*-- 宽度x高度=16x16 --*/ 0x00,0x00,0x38,0x3C,0x7E,0x7E,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x7F,0xFE,0x3F,0xFC,0x1F,0xF8,0x0F,0xF0,0x07,0xE0,0x03,0xC0,0x00,0x00, /*-- 文字: 欢 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x01,0x00,0x01,0x00,0x01,0x3F,0x7F,0xA0,0x20,0xA1,0x12,0x52,0x02,0x14,0x02,0x08, 0x02,0x18,0x06,0x18,0x05,0x24,0x09,0x24,0x18,0x82,0x70,0x61,0x20,0x1C,0x00,0x00, /*-- 文字: 迎 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x02,0x01,0x84,0x3E,0x6C,0x22,0x24,0x22,0x20,0x22,0x20,0x22,0x27,0x22,0x24, 0x22,0xA4,0x2A,0x64,0x12,0x24,0x02,0x04,0x02,0x04,0x00,0x0A,0x7F,0xF1,0x00,0x00, /*-- 文字: 来 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x80,0x00,0x80,0x3F,0xFC,0x00,0x80,0x0C,0x90,0x04,0xA0,0x02,0xC0,0x7F,0xFE, 0x01,0x80,0x02,0xC0,0x04,0xA0,0x18,0x90,0x70,0x8C,0x20,0x83,0x00,0x80,0x00,0x80, /*-- 文字: 到 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x20,0x00,0x21,0xFE,0x20,0x10,0x24,0x48,0x24,0x84,0x25,0xFE,0x24,0xA4,0x24,0x20, 0x24,0x20,0x25,0xFE,0x24,0x20,0x24,0x20,0x21,0xA0,0x20,0x70,0x28,0x0E,0x10,0x04, /*-- 文字: 单 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x04,0x10,0x0C,0x60,0x02,0x20,0x1F,0xFC,0x10,0x84,0x1F,0xFC,0x10,0x84,0x10,0x84, 0x1F,0xFC,0x10,0x84,0x00,0x80,0x7F,0xFF,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80, /*-- 文字: 片 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x02,0x00,0x02,0x08,0x02,0x08,0x22,0x08,0x7F,0xF8,0x00,0x08,0x00,0x08,0x00,0x08, 0x0F,0xF8,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x04,0x08,0x04,0x08,0x02,0x08,0x01, /*-- 文字: 机 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x08,0x1F,0x08,0x11,0x08,0x11,0x7F,0x11,0x08,0x11,0x08,0x11,0x1C,0x11,0x2C, 0x11,0x2A,0x11,0x0A,0x10,0x89,0x50,0x88,0x50,0x48,0x50,0x48,0x60,0x28,0x00,0x08, /*-- 文字: 爱 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x1F,0x00,0x09,0xFC,0x08,0x48,0x04,0x90,0x7F,0xFC,0x40,0x44,0x00,0x42,0x3F,0xFC, 0x00,0x20,0x0F,0xE0,0x04,0x30,0x02,0xD0,0x03,0x08,0x0C,0xC6,0x70,0x31,0x20,0x0C, /*-- 文字: 好 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x08,0x3F,0x88,0x10,0x08,0x08,0x08,0x04,0x3F,0x04,0x24,0x04,0x24,0x7F,0xE4, 0x04,0x22,0x04,0x26,0x04,0x18,0x04,0x10,0x04,0x28,0x04,0x64,0x05,0x22,0x02,0x01, /*-- 文字: 者 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x80,0x10,0x80,0x37,0xFC,0x08,0x80,0x04,0x80,0x7F,0xFE,0x01,0x00,0x00,0xC0, 0x1F,0xE0,0x10,0x38,0x10,0x27,0x1F,0xE0,0x10,0x20,0x10,0x20,0x1F,0xE0,0x10,0x20, /*-- 文字: D --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x22,0x00,0x42,0x00,0x42,0x00,0x42, 0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x22,0x00,0x1F,0x00,0x00,0x00,0x00, /*-- 文字: I --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08, 0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x00,0x00,0x00, /*-- 文字: Y --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x14, 0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x1C,0x00,0x00,0x00,0x00, /*-- 文字: 网 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x3F,0xFE,0x20,0x02,0x20,0x82,0x28,0x8A,0x39,0x52,0x2A,0x22,0x24,0x22, 0x24,0x52,0x2A,0x52,0x29,0x8A,0x20,0x86,0x20,0x02,0x38,0x02,0x10,0x02,0x00,0x00, /*-- 文字: 站 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x04,0x00,0x04,0x04,0x04,0x08,0x04,0x08,0x7C,0x7F,0x04,0x20,0x04,0x22,0x04,0x24, 0x3F,0x94,0x20,0x94,0x20,0x88,0x20,0xBC,0x20,0x83,0x3F,0x80,0x20,0x80,0x00,0x00, /*-- 文字: 论 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x02,0x02,0x02,0x04,0x05,0x0C,0x09,0x04,0x10,0x80,0x60,0x40,0x20,0xA7,0x08,0x84, 0x1C,0x84,0x03,0x84,0x00,0x84,0x00,0xA4,0x20,0x94,0x20,0x8C,0x3F,0x04,0x00,0x00, /*-- 文字: 坛 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x3F,0x88,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x3F,0x7F,0xC8,0x02,0x08, 0x06,0x08,0x01,0x08,0x11,0x38,0x20,0x8C,0x7E,0x43,0x63,0xE0,0x20,0x40,0x00,0x00, /*-- 文字: , --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x08,0x00,0x04,0x00,0x00, /*-- 文字: 这 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x01,0x00,0x06,0x02,0x02,0x0C,0x3F,0xE8,0x08,0x00,0x08,0x40,0x04,0x8F,0x05,0x08, 0x02,0x08,0x02,0x08,0x05,0x08,0x08,0x88,0x10,0x48,0x00,0x14,0x7F,0xE2,0x00,0x01, /*-- 文字: 里 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x1F,0xFC,0x10,0x84,0x10,0x84,0x10,0x84,0x1F,0xFC,0x10,0x84,0x10,0x84,0x1F,0xFC, 0x00,0x80,0x00,0x80,0x1F,0xFC,0x00,0x80,0x00,0x80,0x00,0x80,0x7F,0xFF,0x00,0x00, /*-- 文字: 有 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x80,0x00,0x80,0x7F,0xFE,0x00,0x40,0x00,0x20,0x0F,0xF0,0x08,0x18,0x08,0x14, 0x0F,0xF2,0x08,0x11,0x08,0x10,0x0F,0xF0,0x08,0x10,0x09,0x10,0x0E,0x10,0x04,0x10, /*-- 文字: 众 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/ 0x00,0x80,0x00,0x80,0x00,0x80,0x01,0x40,0x02,0x20,0x0C,0x10,0x70,0x0C,0x24,0x13, 0x04,0x10,0x04,0x10,0x04,0x10,0x0A,0x28,0x12,0x44,0x31,0x42,0x10,0x81,0x00,0x00, /*-- 文字: 多 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
相关文章