#申请原创# @21小跑堂
在通常的情况下,我们所所用的显示器件多是数码管、液晶屏、OLED屏及TFT屏。但在公共场合要显示信息,就要有较大尺寸以便观察。 通常多使用半板来拼接成较大的广告牌,这里使用的是一款P4.75的红色点阵板,其显示分辨率为16*64像素点。 图1 点阵屏外观
该点阵屏采用的接口方式为HUB08,各引脚的名称如图2所示。 图2 HUB08接口
该点阵屏与开发板的连接关系为: A ----PE3 B ----PE4 C ----PE5 D ----PE2 R1 ----PA12 CLK----PA11 EN ----PE12 STB----PE11
所用引脚输出高低电平的语句定义为: #define LA_high Gpio_SetIO(GpioPortE, GpioPin3) #define LA_low Gpio_ClrIO(GpioPortE, GpioPin3) #define LB_high Gpio_SetIO(GpioPortE, GpioPin4) #define LB_low Gpio_ClrIO(GpioPortE, GpioPin4) #define LC_high Gpio_SetIO(GpioPortE, GpioPin5) #define LC_low Gpio_ClrIO(GpioPortE, GpioPin5) #define LD_high Gpio_SetIO(GpioPortE, GpioPin2) #define LD_low Gpio_ClrIO(GpioPortE, GpioPin2) #define LR1_high Gpio_SetIO(GpioPortA, GpioPin12) #define LR1_low Gpio_ClrIO(GpioPortA, GpioPin12) #define CLK_high Gpio_SetIO(GpioPortA, GpioPin11) #define CLK_low Gpio_ClrIO(GpioPortA, GpioPin11) #define LEN_high Gpio_SetIO(GpioPortE, GpioPin12) #define LEN_low Gpio_ClrIO(GpioPortE, GpioPin12) #define LSTB_high Gpio_SetIO(GpioPortE, GpioPin11) #define LSTB_low Gpio_ClrIO(GpioPortE, GpioPin11)
所用引脚的初始化函数为: void dzb_GPIO_Init(void)
{
stc_gpio_cfg_t stcGpioCfg;
Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
stcGpioCfg.enDir = GpioDirOut;
stcGpioCfg.enPu = GpioPuDisable;
stcGpioCfg.enPd = GpioPdEnable;
Gpio_Init(GpioPortA, GpioPin11, &stcGpioCfg);
Gpio_Init(GpioPortA, GpioPin12, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin2, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin3, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin4, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin5, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin11, &stcGpioCfg);
Gpio_Init(GpioPortE, GpioPin12, &stcGpioCfg);
}
点阵板发送数据的函数为: void OutByte(uint16_t dat)
{
uint8_t i=0 ;
for(i=0;i<16;i++)
{
CLK_low;
if(dat&0x0001)
{
LR1_high;
}
else
{
LR1_low;
}
dat=dat>>1;
CLK_high;
}
}
发送多列数据的函数为: void DisCol(uint16_t lenght)
{
uint16_t dat;
uint8_t m=0;
while(lenght--)
{
dat=(S[sj[m+1]*16+ScanRow]<<8)+S[sj[m]*16+ScanRow];
OutByte(dat);
m=m+2;
}
}
输出行地址的函数为: void SeleRow(uint8_t Nd)
{
uint8_t N;
N=Nd;
N=N%16;
if(N&0x01) LA_high;
else LA_low;
if (N&0x02) LB_high;
else LB_low;
if (N&0x04) LC_high;
else LC_low;
if (N&0x08) LD_high;
else LD_low;
}
实现显示输出的函数为: void Display(void)
{
DisCol(4);
LEN_high;
LSTB_high;
LSTB_low;
SeleRow(ScanRow);
LEN_low;
ScanRow++;
if(ScanRow>15) ScanRow=0;
}
为实现数字符号的显示,以字模提取软件所构建的字库存储结构为: u8 S[]={ 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"0",0*/ 0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,/*"1",1*/ 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,/*"2",2*/ ... 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,/*"9",9*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,/*":",10*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",11*/ };
实现显示输出效果的函数为: int32_t main(void)
{
dzb_GPIO_Init();
ScanRow=0;
while (1)
{
Display();
delay1ms(1);
}
}
经程序的编译与下载,其显示效果如图3所示。 图3显示效果
在以上驱动程序的基础上,将测试的固定数值改为读取字库中的字模即可实现字符或汉字的显示。 可通过工具软件PCtoLCD2002来提取字模,并将字模存放到数组中,其格式为: uint8_t tab[]={ 0x00,0x00,0xF8,0x23,0x00,0x10,0x00,0x10,0x00,0x00,0xFC,0x07,0x20,0xF1,0x20,0x11, 0x20,0x11,0x20,0x11,0x24,0x11,0x24,0x12,0x24,0x12,0x1C,0x14,0x00,0x28,0xFE,0x47,/*"远",0*/ 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0xF8,0x03,0x00,0x02, 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0xFE,0xFF,0x00,0x00,/*"上",1*/ 0x00,0x02,0x00,0x01,0xFE,0x7F,0x42,0x44,0xF4,0x9F,0x40,0x04,0xF8,0x3F,0x40,0x04, 0xFE,0xFF,0x20,0x08,0x10,0x13,0x88,0x20,0x46,0xC0,0x00,0x06,0x80,0x01,0x40,0x00,/*"寒",2*/ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21, 0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0xF8,0x3F,0x08,0x00,0x00,0x00,/*"山",3*/ ... }; 实现满屏静态显示的函数为: void DisCol(int16_t lenght)
{
int16_t dat,n;
int8_t m=0;
while(lenght--)
{
dat=( tab [m*32+ScanRow*2+1]<<8)+ tab [m*32+ScanRow*2];
OutBytep(dat);
m=m+1;
}
}
其显示的效果如图4所示,说明显示效果正确。 图4 静态显示效果 若要实现向上滚屏显示,则其显示函数为: void DisColp(uint16_t lenght)
{
uint16_t dat,n;
uint8_t m=0;
while(lenght--)
{
n=(ScanRow+hang)%16;
dat=( tab [m*32+n*2+1]<<8)+ tab [m*32+n*2];
OutBytep(dat);
m=m+1;
}
}
图5 滚动显示效果
视频演示:
|