📄 max7221.c
字号:
#include <REG52.H>
#include <Max7221.h>
unsigned char DisplayBuffer[8]={9,1,5,3,0,4,6,7};//显示缓冲区
unsigned char code table2[]=
{0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6, 0xbe, 0xe0, 0xfe, 0xe6, 0x02};
unsigned char code table3[]=
{~0xfc, ~0x60, ~0xda, ~0xf2, ~0x66, ~0xb6, ~0xbe, ~0xe0, ~0xfe, ~0xe6, ~0x02};
unsigned char code tablea[]=
{0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01};//段选编码
unsigned char code tableb[]=
{0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02};//段选编码
unsigned char code tablec[]=
{0x04, 0x04,0x04,0x04,0x04,0x04,0x04,0x04};//段选编码
unsigned char code tabled[]=
{0x08, 0x08,0x08,0x08,0x08,0x08,0x08,0x08};//段选编码
unsigned char code tablee[]=
{0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10};//段选编码
unsigned char code tablef[]=
{0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20};//段选编码
unsigned char code tableg[]=
{0x40, 0x40,0x40,0x40,0x40,0x40,0x40,0x40};//段选编码
unsigned char code tableh[]=
{0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80};//段选编码
void delay(void)
{ unsigned int a,b;
a=5000;b=10;
while(b--)
while(a--);
}
/*此函数未调试成功*/
unsigned char change(unsigned char *tab)
{
unsigned char tabl[8];
unsigned char i;
for(i=0;i<8;i--)
{
tabl[i] =(tab[i]>>7)&0x01 * (1<<7)
+(tab[i]>>6)&0x01 * (1<<6)
+(tab[i]>>5)&0x01 * (1<<5)
+(tab[i]>>4)&0x01 * (1<<4)
+(tab[i]>>3)&0x01 * (1<<3)
+(tab[i]>>2)&0x01 * (1<<2)
+(tab[i]>>1)&0x01 * (1<<1)
+(tab[i]>>0)&0x01 * 1;
}
for(i=0;i<8;i++) tabl[i]&=0xff;
return *tabl;
}
unsigned char code table[]=
{0x3f,0x06,0x5b,0x4f
,0x66,0x6d,0x7d,0x07,
0x7f,0x6f};//段选编码
/*从最高位到最低位依次是:hafc debg*/
unsigned char code table4[]=//这个译码数组0、123467已经改好了! by张强
{0x7e, 0x12, 0x4f,0x5b
,0x33, 0x6d, 0x7d, 0x52,
0x7f,0x6f};//段选编码
main()
{ unsigned char tablo[8];
InitialMax7221();
*tablo=change(&table);
//while(1)
{
Max7221Display(&tablo[0]);
//delay();
// Max7221Display2(&tablea[0]);
//delay();
// Max7221Display2(&tableb[0]);
//delay();
//Max7221Display2(&tablec[0]);
//delay();
// Max7221Display2(&tabled[0]);
//delay();
// Max7221Display2(&tablee[0]);
// delay();
//Max7221Display2(&tablef[0]);
// delay();
//Max7221Display2(&tableg[0]);
// Max7221Display2(&tableh[0]);
//delay();
}
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -