村网通总站 姬家寨村 455496.nync.com 欢迎您!
//*《姬家寨村特殊符号》*/
//硬件设计:姬学瑞;软件编程:姬学瑞;
//版权所有;侵权必究!
//姬家寨村电子科技研究所监制。
/*头文件*/
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define NOP() _nop_()
/*端口定义*/
#define ABCD_port P1 //HC138 ABCD端口定义
//sbit D_port = P1^7;
//sbit C_port = P1^6;
//sbit B_port = P1^5;
//sbit A_port = P1^4;
sbit EN_port = P1^3;//定义译码器控制端口
sbit S_IN_port = P1^2;//锁存器串行数据输入端
sbit RCK_port = P1^1;
sbit SRCK_port = P1^0;
uchar code ziku_table[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*显示8行空白*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xEF,0xFF,0xB7,0xFF,0xDB,0xFF,0xED,0xFF,0xF6,0x7F,0xFB,0xBF,0xFD,0xDF,0xFE,
0xBF,0xFD,0x7F,0xFB,0xFF,0xF6,0xFF,0xED,0xFF,0xDB,0xFF,0xB7,0xFF,0xEF,0xFF,0xDF,/*"《",0*/
0xF7,0xFF,0x77,0x80,0x77,0xF7,0x77,0xF7,0x40,0xF7,0x5B,0xC1,0x5B,0xDD,0x5B,0xDD,
0x6D,0xDD,0x6B,0xDD,0x77,0xC1,0x77,0xF7,0x6B,0xF7,0x5D,0xF7,0x5E,0x80,0xFF,0xFF,/*"姬",1*/
0xBF,0xFF,0x7F,0xFF,0x03,0x80,0xFD,0xDF,0x05,0xE8,0x7F,0xFF,0xBF,0xFF,0x0F,0xFB,
0xB1,0xF2,0xDF,0xFC,0x67,0xFC,0x99,0xF2,0xE7,0x8E,0xF9,0xDE,0x5F,0xFF,0xBF,0xFF,/*"家",2*/
0x7F,0xFF,0xFF,0xFE,0x01,0x80,0xDD,0xCD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07,0xF0,0x0F,0xF8,0x1F,0xFC,0x3F,0xFE,0x7F,0xFF,0xFF,0xFF,/*"◆",15*/
0xFF,0xFF,0x01,0xC0,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,
0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0xFD,0xDF,0x01,0xC0,0xFF,0xFF,0xFF,0xFF,/*"□",16*/
0xFF,0xFF,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,
0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0xFF,0xFF,0xFF,0xFF,/*"■",17*/
0xFF,0xFF,0x1F,0xFC,0xE7,0xF3,0x1B,0xEC,0xEB,0xEB,0xF5,0xD7,0xF5,0xD7,0xF5,0xD7,
0xF5,0xD7,0xF5,0xD7,0xEB,0xEB,0x1B,0xEC,0xE7,0xF3,0x1F,0xFC,0xFF,0xFF,0xFF,0xFF,/*"◎",18*/
0xFF,0xFF,0xFF,0xFF,0x1F,0xFE,0xE7,0xF9,0xFB,0xF7,0xFB,0xF7,0xFD,0xEF,0x3D,0xEF,
0x3D,0xEF,0xFD,0xEF,0xFB,0xF7,0xFB,0xF7,0xE7,0xF9,0x1F,0xFE,0xFF,0xFF,0xFF,0xFF,/*"⊙",19*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*显示8行空白*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
uchar data disp_buff[32]; //32 个显示数据缓存
//数据格式为 第1级第1行高八位,低八位,第1级第2行高八位。。。。。。
uchar data disp_han; //目前显示到第几行
void T0_Set() /*定义中断方式,中断时间*/
{
TMOD = 0x01; //定时0,工作在方式1
TH0 = (65536-1000)/256;
TL0 = (65536-1000)/256;
TR0 = 1; //启动计数
EA = 1; //开总中断
ET0 = 1; //开定时器0中断
return;
}
void delay_1ms(uchar x)
{
uchar j;
while(x--){
for(j=0;j<125;j++)
{;}
}
}
void main()
{
uchar i;
uint data_temp[2];
uint temp,temp1;
uchar hanzi;
uchar han;
uchar shift=1;
for(i=0;i<32;i++) disp_buff[i]=0xff;
T0_Set();
while(1){
for(hanzi=0;hanzi<15;hanzi++){ //最多显示多少个字
for(shift=0;shift<16;shift++){ //一个字移位16位
for(han=0;han<16;han++){ //一个字有16行数据
//取字库里面数据
data_temp[0]=ziku_table[(hanzi*32)+(han*2)+1]*0x100 + ziku_table[(hanzi*32)+(han*2)];
data_temp[1]=ziku_table[((hanzi+1)*32)+(han*2)+1]*0x100 + ziku_table[((hanzi+1)*32)+(han*2)];
//右往左移动
temp = data_temp[0];
temp1 = data_temp[1];
for(i=shift;i>0;i--){
temp = (temp>>1) ;
if((temp1&0x0001)!=0) temp = temp + 0x8000; //将TMEP1的最低位移位到TMEP的最高位
temp1 = (temp1>>1);
}
disp_buff[han*2+1]=temp/0x100;
disp_buff[han*2+0]=temp%0x100;
//------------------------------
}
delay_1ms(20); //移位速度
}
}
}
}
void SLED_Disp() interrupt 1 using 3
{
uchar i;
uchar data_buff;
uchar temp;
uchar han;
TH0 = (65536-1000)/256;
TL0 = (65536-1000)/256;
RCK_port = 0; //HC595锁定输出,避免数据传输过程中,屏数据变化从而显示闪烁
SRCK_port = 0;
han=disp_han;
//74HC595输出数据
temp = disp_han*2+1;
data_buff = disp_buff[temp];
for(i=0;i<8;i++){
if((data_buff&0x80)!=0) S_IN_port = 1;
else S_IN_port = 0;
SRCK_port = 1;
SRCK_port = 0;
data_buff <<= 1;
}
temp = disp_han*2;
data_buff = disp_buff[temp];
for(i=0;i<8;i++){
if((data_buff&0x80)!=0) S_IN_port = 1;
else S_IN_port = 0;
SRCK_port = 1;
SRCK_port = 0;
data_buff <<= 1;
}
//74HC138输出控制
EN_port = 1; //关屏显示,原理为使HC138输出全为1,从而三极管截止,点阵不显示
ABCD_port = (ABCD_port & 0x0f)|(han<<4); //HC138译码输出
RCK_port = 1; //允许HC595数据输出到Q1-Q8端口
EN_port = 0; //HC138输出有效,打开显示
RCK_port = 0; //锁定HC595数据输出
disp_han++; //显示下一行数据
if(disp_han>=16) disp_han=0;
}