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

📄 display.h

📁 由单片机搞的软时钟
💻 H
字号:
/**************************************************************************
  
                   		THE 75EG_MPX6_CA LIB
  
             		COPYRIGHT (c)   2008 BY CHENSS.
                       		--  ALL RIGHTS RESERVED  --
  
   File Name:       DISPLAY.H
   Author:          NET.XICP.CHENSS
   Created:         2008/1/25
   Modified:		NO
   Revision: 		1.0
  
***************************************************************************/

#ifndef _DISPLAY_H_
#define _DISPLAY_H_

#include<reg52.h>
#include"buffer.h"
#include"timer0.h"
//#include"timer2.h"

//void delay(uint x);
//void initD(uint);

void initDisplay(void)
{
	
	//initD(400);
	EA=1;
	ET1=1;
	TMOD&=0x0f;
	TMOD|=0x10;
	TH1=DTH1;
	TL1=DTL1;
	PT1=0;
	P2=0x01;
	TR1=1;
	temp=time;
}


void display(void) interrupt 3 using 2
{
//	uchar bitValue;
	
	uchar atBit,nowPoint,bitValue,showDP;
//	P2=0xff;
	TR1=0;
	TH1=DTH1;
	TL1=DTL1;
	
	
	if(temp==week)
	{
		uchar weekPoint;
		if(isFlickerSet)
		{
			weekPoint=10;
		}else
		{
			weekPoint=week[2];
		}
		P2=0x20;
		P0=coNumberList[weekPoint];
	}
	else
	{
		nowPoint=P2;
		nowPoint&=0x3f;
		for(atBit=0;nowPoint>0;atBit++)
		{
			nowPoint>>=1;
		}
		switch(atBit)
		{
		
			case 6:
				if(isFlickerSet&flickerIndex==0)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[0];
					bitValue/=10;
				}
				P2=0x01;
				P0=coNumberList[bitValue];
				break;
			case 1:
				if(isFlickerSet&flickerIndex==0)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[0];
					bitValue%=10;
				}
				
				showDP=coNumberList[bitValue];
				if(isFlicker)
				{
					showDP^=0x80;
				}
				P2=0x02;
				P0=showDP;
				break;
			case 2:
				if(isFlickerSet&flickerIndex==1)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[1];
					bitValue/=10;
				}
				
				P2=0x04;
				P0=coNumberList[bitValue];
				break;
			case 3:
				if(isFlickerSet&flickerIndex==1)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[1];
					bitValue%=10;
				}
				
				showDP=coNumberList[bitValue];
				if(isFlicker)
				{
					showDP^=0x80;
				}
				P2=0x08;
				P0=showDP;
				break;
			case 4:
				if(isFlickerSet&flickerIndex==2)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[2];
					bitValue/=10;
				}
				
				P2=0x10;
				P0=coNumberList[bitValue];
				break;
			case 5:
				if(isFlickerSet&flickerIndex==2)
				{
					bitValue=10;
				}else
				{
					bitValue=temp[2];
					bitValue%=10;
				}
				
				P2=0x20;
				P0=coNumberList[bitValue];
				break;

		}
	}
	TR1=1;
}
/*

void delay(uint dx)
{
	while(dx>1)
	{
		dx--;
	}
}


void initD(uint m)
{
	uchar turn,j;
	TR1=0;
	for(turn=20;turn>0;turn--)
	{
		
		P2=0x01;
		for(j=0;j<6;j++)
		{
			P0=0x00;
			delay(m);
			P2<<=1;
		}
	}

}*/
//******************************************************************************
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -