前面介绍过程序数码管的显示驱动,它所使用的芯片是MAX7219。其实该芯片不仅是用在串行数码管模块,它还可以用在点阵模块上。
图1是点阵模块,它的用法与串行数码管模块十分相近,只是在初始化和显示处理方面有所区别。
图1点阵模块
点阵模块的初始化函数为:
void Init_MAX7219_D(void)
{
Write_Max7219(0x0b, 0x07);
Write_Max7219(0x0c, 0x01);
Write_Max7219(0x0f, 0x00);
}
由于点阵模块在显示时,需要字模的支持,故需为其配置相应的字库,其结构如下:
unsignedchar disp[38][8]={
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x30,0x50,0x10,0x10,0x10,0x10,0x10},//1
{0x7E,0x2,0x2,0x7E,0x40,0x40,0x40,0x7E},//2
{0x3E,0x2,0x2,0x3E,0x2,0x2,0x3E,0x0},//3
{0x8,0x18,0x28,0x48,0xFE,0x8,0x8,0x8},//4
{0x3C,0x20,0x20,0x3C,0x4,0x4,0x3C,0x0},//5
{0x3C,0x20,0x20,0x3C,0x24,0x24,0x3C,0x0},//6
{0x3E,0x22,0x4,0x8,0x8,0x8,0x8,0x8},//7
{0x0,0x3E,0x22,0x22,0x3E,0x22,0x22,0x3E},//8
{0x3E,0x22,0x22,0x3E,0x2,0x2,0x2,0x3E},//9
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
...
{0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41},//X
{0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8},//Y
{0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F},//Z
{0x8,0x7F,0x49,0x49,0x7F,0x8,0x8,0x8},//zhong
{0xFE,0xBA,0x92,0xBA,0x92,0x9A,0xBA,0xFE},//guo
};
实现显示测试的程序为:
Init_MAX7219_D();
while(1)
{
for(j=0;j<38;j++)
{
for(i=1;i<9;i++)
{
Write_Max7219(i,disp[j][i-1]);
for(k=1;k<65;k++)
{
delay_n(65);
}
}
for(k=1;k<650;k++)
{
delay_n(65);
}
}
}
经程序的编译和下载,其显示效果如图2所示。
图2 显示效果
演示视频: