#include <stc15.h>    	            //包含支持STC15W4K32S4单片机的头文件
#include <intrins.h>
#include <gpio.h>					 //I/O初始化文件
#define uchar unsigned char
#define uint  unsigned int
#include <display.h>
sbit k1=P3^2;
sbit k2=P3^3;
uint counter=0;
void Delay10ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 117;
	j = 184;
	do
	{
		while (--j);
	} while (--i);
}
void main(void)			
{						
	gpio();
	while(1)
	{
		if(k1==0)		               //检测加1功能键
	 	{
			Delay10ms();	             //延时去抖
		 	if(k1==0)
		 	{
				counter++;
				while(k1==0);       	//等待键释放			
			}
		 }
		if(k2==0)			        //检测减1功能键
		{
			Delay10ms();	        //延时去抖
		 	if(k2==0)
		 	{
				if(counter!=0)	
				{
					counter--;			
					while(k2==0);	
				}
			}
		 	               //等待键释放			
		} 
		Dis_buf[0]= counter%10;                       //取个位数，送显示缓冲区
		Dis_buf[1]= counter/10%10;                    //取十位数，送显示缓冲区
		Dis_buf[2]= counter/100%10;                   //取百位数，送显示缓冲区
		Dis_buf[3]= counter/1000%10;                  //取千位数，送位显示缓冲区
		Dis_buf[4]=counter/10000%10;                 //取万位数，送显示缓冲区
		display();					
	}					
}
