?? matrix.c
字號:
//========================================================================================
// 程序功能: 將DS1302的時間裝配到顯存
// 將顯存中的內容顯示到點陣
// 程序接口: void Time_ValueToASCII();
// void Matrix_Dis();
// 編寫時間: 2009-03-02
//========================================================================================
#include<Module.h>
#include<AsciiTab.h>
extern bit G_b500mS;
extern unsigned char G_ucTime[];
#define P4 0x0e8
sbit scl=P3^7; //脈沖
sbit stb=P4^0; //顯示 74hc595
sbit sda=P4^1; //數(shù)據(jù)
unsigned char code up[]={0xf7,0xfb,0xfd,0xfe,0x7f,0xbf,0xdf,0xef};
unsigned char code down[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char G_ucDiszone[]="10:10:10";
//========================================================================================
// 函數(shù)功能: 將DS1302的時間裝配到顯存
// 函數(shù)接口: void Time_ValueToASCII();
// 入口參數(shù): extern unsigned char G_ucTime[]
// 出口參數(shù): unsigned char G_ucDiszone[]
// 備 注:運算指令的優(yōu)先級別 如:+優(yōu)先于>>
//========================================================================================
void Time_ValueToASCII()
{
static uc ucPreSecond=10;
G_ucDiszone[0]=((G_ucTime[2]&0xf0) >> 4)+'0';//時
G_ucDiszone[1]=(G_ucTime[2]&0x0f)+'0';
G_ucDiszone[2]=':';
G_ucDiszone[3]=((G_ucTime[1]&0xf0) >> 4)+'0';//分
G_ucDiszone[4]=(G_ucTime[1]&0x0f)+'0';
//if(G_ucDiszone[7]%2==0) G_ucDiszone[5]=10+'0';
//else G_ucDiszone[5]=17+'0';
G_ucDiszone[6]=((G_ucTime[0]&0xf0) >> 4)+'0';//秒
G_ucDiszone[7]=(G_ucTime[0]&0x0f)+'0';
if((G_ucTime[0]!=ucPreSecond)&&(TR0==0) ) //':’以500的時間閃爍
{
TR0=1;
G_b500mS=0;
}//if
if( G_b500mS==0 )
{
G_ucDiszone[5]=':';
}//if
else
{
TR0=0;
G_ucDiszone[5]=' ';
ucPreSecond=G_ucTime[0];
}//else
}
//========================================================================================
// 函數(shù)功能: 將數(shù)據(jù)串行輸出
// 函數(shù)接口: void Matrix_Send1Row();
// 出口參數(shù): unsigned char sda
//========================================================================================
void Matrix_Send1Row(uc temp)
{
uc i;
scl=0;
for(i=0;i<8;i++)
{
scl=0;
temp=temp<<1;
sda=CY;
scl=1;
}//for
}
//========================================================================================
// 函數(shù)功能: 輸出一行顯示
// 函數(shù)接口: void Matrix_Output1Row();
//========================================================================================
void Matrix_Output1Row()
{
stb=0;
stb=1;
}
//========================================================================================
// 函數(shù)功能: 點陣顯示屏行使能
// 函數(shù)接口: void Matrix_En1RowCom(uc ucRow);
//========================================================================================
void Matrix_En1RowCom(uc ucRow)
{
if( ucRow<8 ) //行掃描
{
P2=0xff;
P0=up[ucRow];
}//if
else
{
P0=0xff;
P2=down[ucRow-8];
}//else
}
//========================================================================================
// 函數(shù)功能: 清屏
// 函數(shù)接口: Matrix_Dis1RowCom();
//========================================================================================
Matrix_Dis1RowCom()
{
P0=0xff; //屏蔽點陣屏
P2=0xff;
}
//========================================================================================
// 函數(shù)功能: 延時
// 函數(shù)接口: void Matrix_DisDelay(uc z);
//========================================================================================
void Matrix_DisDelay(uc z) //延時子程序
{
uc x,y;
for(x=z;x>0;x--)
for(y=5;y>0;y--);
}
//========================================================================================
// 函數(shù)功能: 點陣顯示
// 函數(shù)接口: void Matrix_Dis();
// 入口參數(shù): unsigned char tab[((G_ucDiszone[cCharIndex]-'0')<<4)+ucRow];
// 出口參數(shù): unsigned char Matrix_Send1Row(tab[((G_ucDiszone[cCharIndex]-'0')<<4)+ucRow]);
//========================================================================================
void Matrix_Dis()
{
uc ucRow;
char cCharIndex;
for(ucRow=0;ucRow<16;ucRow++)
{
for(cCharIndex=7;cCharIndex>=0;cCharIndex--)
{
if( G_ucDiszone[cCharIndex]==' ')
Matrix_Send1Row(tab[16*16+ucRow]);
else
Matrix_Send1Row(tab[((G_ucDiszone[cCharIndex]-'0')<<4)+ucRow]);
}//for
Matrix_Output1Row();
Matrix_En1RowCom(ucRow);
Matrix_DisDelay(10);
Matrix_Dis1RowCom();
}//for
//while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -