- /*
- 08接口简单说明
- A 、B 、 C、 D:两片74HC138的输入信号
- EN: 74HC138的输出使能,低电平有效
- R1: 是74HC595的数据线,串行数据输入
- R2: 用不上
- G1: 用不上
- G2: 用不上
- LT:74HC595时钟
- SK:74HC595的存储控制线
- */
- //单片机:STC89C52
- //晶振:22.1184M,下载选择双倍时钟,否则会有闪烁!
- //显示屏:HUB08接口16X64单红点阵
- //显示方式:左移
- #include
- #include"zimo.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define SPEED 5 //定义速度与数字成反比 数字小,速度快
- #define NUMBER 11 //定义要移动显示总16X16汉字个数,计算方法:NUMBER=汉字显示个数+4个空格
- uchar word=0,col=0,col1=0,disrow=0,move=0;//wor为要显字变量,col为位移变量,col1为字节偏移量,disrow为行变量
- uchar BUFF__UP[17]; //缓冲字节数取值=[2*板点阵宽度/8]+1比较保险,即两倍板的点阵字节数.
- uchar BUFF__UP0[12]; //上半屏显示缓冲
- sbit R1=P0^4;//红色数据1
- sbit R2=P3^3;//红色数据2
- sbit G1=P3^4;//绿色数据1
- sbit G2=P3^5;//绿色数据
- sbit CLK=P0^7; //595时钟端口
- sbit STB=P0^6; //595锁存端口
- sbit OE =P0^5;//74HC138使能:低有效
- //根据列指针由双字节合并为单字节的子程序模块
- //和点阵的取模方式有关:低位在前,高位在后,但是实际显示,高位在前,低位在后!
- uchar Combine_2byte(uchar h1,uchar h2)
- {
- uchar T_date,tempcol;
- tempcol=col1;
- T_date=(h1>>tempcol)|(h2<<(8-tempcol));
- return T_date;
- }
- //分别装屏点阵数据
- void Load_one_line(void) //多加4个16X16汉字的缓冲
- {
- BUFF__UP[0]=Table[word][disrow*2+0];//装载点阵数据
- BUFF__UP[1]=Table[word][disrow*2+1];
- BUFF__UP[2]=Table[word+1][disrow*2+0];
- BUFF__UP[3]=Table[word+1][disrow*2+1];
- BUFF__UP[4]=Table[word+2][disrow*2+0];
- BUFF__UP[5]=Table[word+2][disrow*2+1];
- BUFF__UP[6]=Table[word+3][disrow*2+0];
- BUFF__UP[7]=Table[word+3][disrow*2+1];
- BUFF__UP[8]=Table[word+4][disrow*2+0];
- BUFF__UP[9]=Table[word+4][disrow*2+1];
- BUFF__UP[10]=Table[word+5][disrow*2+0];
- BUFF__UP[11]=Table[word+5][disrow*2+1];
- BUFF__UP[12]=Table[word+6][disrow*2+0];
- BUFF__UP[13]=Table[word+6][disrow*2+1];
- BUFF__UP[14]=Table[word+7][disrow*2+0];
- BUFF__UP[15]=Table[word+7][disrow*2+1];
- }
- //发送屏一线点阵数据
- void Send_one_line(void)
- {
- char s;
- uchar temp,i,inc;
- if(col<8) inc=0;
- if(8<=col&&col<16) inc=1;
- for(s=0+inc;s<=8+inc;s++)
- {
- temp=Combine_2byte(BUFF__UP[s],BUFF__UP[s+1]);
- for(i=0;i<8;i++)
- {
- R1=~(temp>>i)&0x01;//取出最低位
- R2=0xff; //不显示
- G1=0xff;
- G2=0xff;
- CLK=0;
- CLK=1; //移位时钟
- }
- }
- }
- //左移函数
- void LEFT_MOVE()
- {
- uchar i;
- for(col=0;col<16;col++)//循环16次,点亮并移动一个汉字,步进是一位
- {
- col1=col%8;//一个字节移动位数
- for(i=0;i
- {
- for(disrow=0;disrow<16;disrow++)//扫描16行
- {
- Load_one_line();//装载一行点阵数据
- Send_one_line();//发送一行点阵数据
- OE=1;
- STB=1; // 输出锁存
- STB=0;
- P0=disrow; // 行扫描
- OE=0;
- }
- }
- }
- word=word+1;// 一个汉字移动后,指向下一个汉字
- if(word>=NUMBER)
- {
- word=0;//移动完NUMBER个汉字后重新开始
- }
- }
- //主函数入口
- void main(void)
- {
- R1=0;//数据初始化
- R2=0;
- G1=0;
- G2=0;
- while(1)
- {
- LEFT_MOVE(); //左移
- }
- }
- zimo.h
- unsigned char code Table[][32]=
- {
- 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,
- 0x08,0x00,0xC8,0x7F,0x48,0x00,0x7F,0x00,0x48,0x3F,0x68,0x00,0xD8,0x7F,0x48,0x03,
- 0x4C,0x25,0x4B,0x65,0x48,0x19,0x48,0x11,0x28,0x11,0x28,0x65,0x1A,0x23,0x04,0x01,
- 0xFC,0x1F,0x00,0x0C,0x60,0x03,0x80,0x00,0xFC,0x1F,0x84,0x10,0x84,0x10,0xFC,0x1F,
- 0x84,0x10,0x84,0x10,0xFC,0x1F,0x84,0x10,0x84,0x10,0x84,0x10,0x84,0x14,0x04,0x08,
- 0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x84,0x10,0x84,0x10,0xFC,0x1F,
- 0x84,0x10,0x84,0x10,0x84,0x10,0xFC,0x1F,0x84,0x10,0x80,0x40,0x80,0x40,
- 0x00,0x7F,0x00,0x00,
- 0x00,0x00,0xFC,0x0F,0x00,0x04,0x00,0x02,0x00,0x01,0x80,0x00,0x80,0x00,
- 0x80,0x20,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
- 0xA0,0x00,0x40,0x00,
- 0x00,0x01,0x00,0x01,0x3F,0x01,0xA0,0x7F,0xA1,0x20,0x52,0x12,0x14,0x02,
- 0x08,0x02,0x18,0x02,0x18,0x06,0x24,0x05,0x24,0x09,0x82,0x18,0x61,0x70,
- 0x1C,0x20,0x00,0x00,
- 0x02,0x00,0x84,0x01,0x6C,0x3E,0x24,0x22,0x20,0x22,0x20,0x22,0x27,0x22,
- 0x24,0x22,0xA4,0x22,0x64,0x2A,0x24,0x12,0x04,0x02,0x04,0x02,0x0A,0x00,
- 0xF1,0x7F,0x00,0x00,
- 0x90,0x00,0x90,0x01,0x88,0x20,0xC8,0x7F,0x44,0x20,0x2C,0x12,0x16,0x02,
- 0x45,0x0A,0xC4,0x12,0x44,0x12,0x24,0x22,0x24,0x62,0x14,0x22,0x84,0x02,
- 0x04,0x01,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,
- };
复制代码 |