?? led-8zi.c
字號:
/*****************************************************
16*128 LED點陣屏 C 程序
******************************************************
聲明:
本程序中DS1302讀寫部分是直接引用網上網友提供的共享程序,
本程序供大家學習之用,用勿用于商業用途。尊重版權。
編寫:鄧椿薪
時間:2006年1月20日 晚
郵箱:love2151@xinhuanet.com
*******************************************************
//595連級輸出數據,138行驅動。P0_1為移動速度高速/*點陣顯示漢字程串口輸出字符數據,
//P2口輸出行掃描信號,P0_0輸出595鎖存信號。*/
#include <AT89x51.H>
#define uchar unsigned char
#define uint unsigned int
uchar yid,h; //YID為移動計數器,H為行段計數器。
uint zimuo; //字模計數器
uchar code hanzi[]; //漢字字模
uchar BUFF[18]; //緩存
void in_data(void); //調整數據
void rxd_data(void); //發送數據
void sbuf_out(); //16段掃描
unsigned char code sw[16]={0xe0,0xe2,0xe4,0xe6,0xe8,
0xea,0xec,0xee,0xf0,0xf2,0xf4,0xf6,0xf8,0xfa,0xfc,0xfe}; /*16行段碼*/
/********************************************/
void main(void)
{
uchar i,d=5;
yid=0;
zimuo=0;
while(1)
{
while(yid<16) //數據移位。
{
for(i=0;i<d;i++) //移動速度
{
sbuf_out();
if(P0_1==0)
{ //移動速度調整
if(++d==12)
d=2;
while(P0_1==0)
{ sbuf_out();}
}
}
yid++; //移動一步
}
yid=0;
zimuo=zimuo+32; //后移一個字,
if(zimuo>=3386) //總數減7個字。
zimuo=0;
}
}
/********************************/
void sbuf_out()
{
for(h=0;h<16;h++) //16行掃描
{
in_data(); //調整數據
rxd_data(); //串口發送數據
P2=sw[h]; //送段碼
P0_0=1; //鎖存為高,595鎖存信號
P0_0=0;
}
}
/******************************************************/
void in_data(void)
{
char s;
for(s=8;s>=0;s--) //h為向后先擇字節計數器,zimuoo為向后先字計數器
{
BUFF[2*s+1]=hanzi[zimuo+32*s+2*h]; //把第一個字模的第一個字節放入BUFF0中,第二個字模和第一個字節放入BUFF2中
BUFF[2*s]=hanzi[zimuo+1+32*s+2*h]; // 把第一個字模的第二個字節放入BUFF1中,第二個字模的第二個字節放入BUFF3中
}
}
/*******************************************************/
void rxd_data(void) //串行發送數據
{
char s;
uchar inc,tempyid,temp;
if(yid<8)
inc=0;
else
inc=1;
for(s=0+inc;s<16+inc;s++) //發送8字節數據
{
if(yid<8)
tempyid=yid;
else
tempyid=yid-8;
temp=(BUFF[s]>>tempyid)|(BUFF[s+1]<<(8-tempyid)); //h1左移tempyid位后和h2右移8-tempyid相或,取出移位后的數據。
temp=255-temp;
SBUF=temp;//把BUFF中的字節從大到小移位相或后發送輸出。
while(!TI);TI=0; //等待發送中斷
}
}
/*******************************************************/
uchar code hanzi[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//=============================================================================
/*-- 調入了一幅圖像:這是您新建的圖像 --*/
/*-- 寬度x高度=16x16 --*/
0x00,0x00,0x38,0x3C,0x7E,0x7E,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0x7F,0xFE,0x3F,0xFC,0x1F,0xF8,0x0F,0xF0,0x07,0xE0,0x03,0xC0,0x00,0x00,
/*-- 文字: 8 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x24,
0x00,0x18,0x00,0x24,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x3C,0x00,0x00,0x00,0x00,
//============================================================================
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -