代码
#include<reg51.h>
#include <intrins.h>
unsigned char code FONT16x16[3][32]={
{ 0x12, 0x48, 0x12, 0x48, 0x13, 0xC8, 0x12, 0x48, 0x10, 0x08, 0x10, 0x08, 0x10, 0x28, 0x10, 0x10,0x08, 0x00, 0x08, 0x04, 0x0F, 0xFE, 0x10, 0x08, 0x10, 0x48, 0x33, 0xE8, 0x52, 0x48, 0x92, 0x48},//何
{ 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05, 0x00, 0x02, 0x00,0x02, 0x00, 0x01, 0x00, 0x7F, 0xFE, 0x40, 0x02, 0x80, 0x04, 0x00, 0x00, 0xFF, 0xFE, 0x01, 0x00},//宁
{ 0x14, 0x08, 0x25, 0x10, 0xE4, 0xA0, 0x24, 0x40, 0x28, 0xA0, 0x29, 0x10, 0x32, 0x0E, 0x24, 0x04,0x00, 0x40, 0x40, 0x40, 0x30, 0x40, 0x17, 0xFC, 0x04, 0x44, 0x84, 0x48, 0x44, 0x40, 0x0F, 0xF8,
}};//波
sbit SDI=P2^1;
sbit SRCLK=P2^0;
sbit RCLK=P2^2;
#define LineCtrl P1
void delay(unsigned int us)
{
while(us--);
}
void SendByte(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
SRCLK=0;
if(dat&0x80)
SDI=1;
else
SDI=0;
SRCLK=1;
dat=dat<<1;
}
}
void Display(unsigned char *dat1,unsigned char *dat2,unsigned char *dat3)
{
unsigned char i;
for(i=0;i<16;i++)
{
SendByte(dat3[2*i+1]); SendByte(dat3[2*i]);
SendByte(dat2[2*i+1]); SendByte(dat2[2*i]);
SendByte(dat1[2*i+1]); SendByte(dat1[2*i]);
RCLK=0;
_nop_();
_nop_();
_nop_();
_nop_();
LineCtrl=i;
RCLK=1;
delay(100);
}
}
void main(void)
{ while(1)
Display(FONT16x16[0],FONT16x16[1],FONT16x16[2]);
}