⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.c

📁 64*16的点阵显示
💻 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;          						//数据

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";

//========================================================================================
// 函数功能: 将DS1302的时间装配到显存
// 函数接口: void Time_ValueToASCII();
// 入口参数: extern unsigned char G_ucTime[]
// 出口参数: unsigned char G_ucDiszone[]
// 备    注:运算指令的优先级别 如:+优先于>> 
//========================================================================================
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
}
//========================================================================================
// 函数功能: 将数据串行输出
// 函数接口: void Matrix_Send1Row();
// 出口参数: 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
 }
//========================================================================================
// 函数功能: 输出一行显示
// 函数接口: void Matrix_Output1Row();
//========================================================================================
void Matrix_Output1Row()
{
    stb=0;
	stb=1;
}
//========================================================================================
// 函数功能: 点阵显示屏行使能
// 函数接口: 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
}
//========================================================================================
// 函数功能: 清屏
// 函数接口: Matrix_Dis1RowCom();
//========================================================================================
Matrix_Dis1RowCom()
{
	P0=0xff;             						//屏蔽点阵屏
	P2=0xff;
}
//========================================================================================
// 函数功能: 延时
// 函数接口: 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--);
}
//========================================================================================
// 函数功能: 点阵显示
// 函数接口: void Matrix_Dis();
// 入口参数: unsigned char tab[((G_ucDiszone[cCharIndex]-'0')<<4)+ucRow];
// 出口参数: 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 + -