//整体快速测试程序
/***************头文件******************/
#include "regx52.h"
#include "the4X4key.h"
#include "led.h"
#include "lcd1602.h"
#include "_7dled.h"
#include "buzzer.h"
#include "lcd12864.h"

bit flash_time_ok=0;
bit ledrun_time_ok=0;

/***************主函数******************/
void main()
{
	IE=0x82;				//TIMER0
	TMOD=0x01;				//方式1
	TH0=(65536-5000)/256;	//定时5MS
	TL0=(65536-5000)%256;	//定时5MS
	TR0=1;
	while(1)
	{
   		if(keytime_10ms_ok)
   		{
		     matrixkey_csan();
			 keytime_10ms_ok=0;
   		}
		if(programflag==1)					   //led全闪
    	{ 
	  		if(flash_time_ok)
	   		{
	 			ledflash();
				flash_time_ok=0;
	   		}
    	}
		else if(programflag==2)				   //上下流水灯
	 	{
	   		if(ledrun_time_ok)
	    	{
				ledrunstar();
				ledrun_time_ok=0;
	 		}
	 	}
	  	else if(programflag==3)			   //数码管
	   {
		 	if(flash_time_ok)
		  	{
			  	jianzhiprocess();
			   	flash_time_ok=0;
		  	}
		 display();
	   
	   }
	   else if(programflag==4)			   //蜂鸣器
	   {
		 	if(distime_5ms_ok)
		  	{
		   		buzzerstart();
		   		distime_5ms_ok=0;
		  	}	
		}
		else if(programflag==5)			  //lcd1602
		{
		  	if(flash_time_ok)
		  	{
		  		lcdtest();
		  		flash_time_ok=0;
		  	}	 
		 }
		 else if(programflag==6)			  //lcd12864
		 {
		 
		  if(flash_time_ok)
		   {
		    lcd12864test();
		  	flash_time_ok=0;
			}	 		 
		 }

 }
}

//********************************时间中断  给标志位
void timer0() interrupt 1
{
	static uchar timer=0;
	static uchar timer1=0;
	static uchar timer2=0;
	TH0=(65536-5000)/256;
	TL0=(65536-5000)%256;
	timer++;
	timer1++;
	timer2++;
	distime_5ms_ok=1;
	if(timer==2)
	{
	  keytime_10ms_ok=1;
	  timer=0;
	}	
	if(timer1==20)
	{
	  ledrun_time_ok=1;
	  timer1=0; 
	}	
	if(timer2==100)
	{
	  flash_time_ok=1;
	  timer2=0;
	}
}