求大神帮忙,自己编写LED点阵位移程序显示出来的汉字是乱码
时间:10-02
整理:3721RD
点击:
#include"reg51.h"
#include"intrins.h"
#define NOP() _nop_()
typedef unsigned char u8;
typedef unsigned int u16;
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit MOSIO = P3^4;
sbit R_CLK = P3^5;
sbit S_CLK = P3^6;
ulong column;
ulong row;
ulong dt;
uchar code tab0[]= {0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80,
0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00};
uchar code tab1[] =
/*-- 文字: 张 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
{
0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,
0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,
};
uchar code tab2[] =
{
/*-- 文字: 瑞 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x84,0x84,0xFC,0x84,0x84,0x40,0x5E,0x50,0x50,0x50,0xDF,0x50,0x50,0x50,0x5E,0x00,
0x10,0x30,0x1F,0x08,0x08,0x00,0xFE,0x02,0x02,0x7F,0x02,0x7E,0x02,0x82,0xFE,0x00,
};
uchar code tab3[] =
{
/*-- 文字: 曦 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFC,0x84,0x84,0xFC,0x00,0x22,0xAA,0xAB,0xAA,0xBE,0x2A,0xAB,0x2A,0xA2,0x00,0x00,
0x3F,0x10,0x10,0x3F,0x00,0x0A,0x56,0x9F,0x72,0x06,0x0A,0x4F,0x32,0x5A,0xE3,0x00,
};
uchar code tab4[]=
{
/*-- 文字: 生 --*/
/*-- 宋体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,
};
uchar code tab5[]=
{
/*-- 文字: 日 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,0x00,0x00,
};
uchar code tab6[]=
{
/*-- 文字: 快 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xE0,0x00,0xFF,0x10,0x20,0x08,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0x00,0x00,
0x01,0x00,0x00,0xFF,0x00,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x81,0x00,
};
uchar code tab7[]=
{
/*-- 文字: 乐 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00,
0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00,
};
void HC595SendData( uchar BT3,uchar BT2,uchar BT1,uchar BT0);
void main(void)
{
int k,i,ms;
i=80;
while(1)
{
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab1[2*k+1],~tab1[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab2[2*k+1],~tab2[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab3[2*k+1],~tab3[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab4[2*k+1],~tab4[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab5[2*k+1],~tab5[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab6[2*k+1],~tab6[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab7[2*k+1],~tab7[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
}
}
void HC595SendData(uchar BT3,uchar BT2,uchar BT1,uchar BT0)
{
uchar i;
for(i=0;i<8;i++)
{
MOSIO =BT3>>7;
BT3<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT2>>7;
BT2<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT1>>7;
BT1<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT0>>7;
BT0<<=1;
S_CLK =0;
S_CLK =1;
}
R_CLK = 0;
R_CLK = 1;
R_CLK = 0;
}
#include"intrins.h"
#define NOP() _nop_()
typedef unsigned char u8;
typedef unsigned int u16;
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit MOSIO = P3^4;
sbit R_CLK = P3^5;
sbit S_CLK = P3^6;
ulong column;
ulong row;
ulong dt;
uchar code tab0[]= {0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80,
0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00};
uchar code tab1[] =
/*-- 文字: 张 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
{
0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,
0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,
};
uchar code tab2[] =
{
/*-- 文字: 瑞 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x84,0x84,0xFC,0x84,0x84,0x40,0x5E,0x50,0x50,0x50,0xDF,0x50,0x50,0x50,0x5E,0x00,
0x10,0x30,0x1F,0x08,0x08,0x00,0xFE,0x02,0x02,0x7F,0x02,0x7E,0x02,0x82,0xFE,0x00,
};
uchar code tab3[] =
{
/*-- 文字: 曦 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFC,0x84,0x84,0xFC,0x00,0x22,0xAA,0xAB,0xAA,0xBE,0x2A,0xAB,0x2A,0xA2,0x00,0x00,
0x3F,0x10,0x10,0x3F,0x00,0x0A,0x56,0x9F,0x72,0x06,0x0A,0x4F,0x32,0x5A,0xE3,0x00,
};
uchar code tab4[]=
{
/*-- 文字: 生 --*/
/*-- 宋体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,
};
uchar code tab5[]=
{
/*-- 文字: 日 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,0x00,0x00,
};
uchar code tab6[]=
{
/*-- 文字: 快 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xE0,0x00,0xFF,0x10,0x20,0x08,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0x00,0x00,
0x01,0x00,0x00,0xFF,0x00,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x81,0x00,
};
uchar code tab7[]=
{
/*-- 文字: 乐 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00,
0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00,
};
void HC595SendData( uchar BT3,uchar BT2,uchar BT1,uchar BT0);
void main(void)
{
int k,i,ms;
i=80;
while(1)
{
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab1[2*k+1],~tab1[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab2[2*k+1],~tab2[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab3[2*k+1],~tab3[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab4[2*k+1],~tab4[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab5[2*k+1],~tab5[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab6[2*k+1],~tab6[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
for(ms=i;ms>0;ms--)
{
for(k=0;k<16;k++)
{
HC595SendData(~tab7[2*k+1],~tab7[2*k],tab0[2*k],tab0[2*k+1]);
}
}
HC595SendData(0xff,0xff,0,0);
}
}
void HC595SendData(uchar BT3,uchar BT2,uchar BT1,uchar BT0)
{
uchar i;
for(i=0;i<8;i++)
{
MOSIO =BT3>>7;
BT3<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT2>>7;
BT2<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT1>>7;
BT1<<=1;
S_CLK =0;
S_CLK =1;
}
for(i=0;i<8;i++)
{
MOSIO =BT0>>7;
BT0<<=1;
S_CLK =0;
S_CLK =1;
}
R_CLK = 0;
R_CLK = 1;
R_CLK = 0;
}
字库问题,或者,字库提取的问题
那该怎么办
自己想办法,还能怎么办
我是想说怎么能显示出字来,我要是有办法还用问吗
乱码一般都是段位引起的,仔细检查一下段位,看看是哪里接错线了。
这是我程序图跟接线图,应该没问题,您方便的话能不能加一下我的qq1115354533
你是在原来的程序上修改的?就是自己改 了库吗?
我自己改的程序,弄好了,我现在不明白的是为啥10进制能显示,16进制不能显示
老哥 你这个是怎么解决的?
我遇到的相同的问题
谢谢,小编提供的场地。
MICROCHIP 原装正品,另有可替换单片机(无需修改PCB资料,程序可共用PIC的) 有用到的兄弟多多支持! 电话13430885511(微信同号),QQ2355910801