#define Down_OK 64
unsigned char S1_OK, Page , Page_tmp;
unsigned int i;
unsigned int i2;
extern unsigned char BL_PWM, BL_OUT,BL_tmp1,BL_tmp2;
extern unsigned char KEY_Too;
extern unsigned char Display_OFF_Logo_Bit, Disp_GO_bit;
extern unsigned char Power_off_bit;
unsigned char KEY_OFF_SYSTEM_bit;
void Scan_KEY(void)
{
if(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6) == 0) //读 S1 == 0
{
++i;
if(i >= Down_OK)
{
i = 0;
if(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6) == 0) //读S1 == 0
{
if(S1_OK == 0)
{
S1_OK = 1;
BL_tmp1 = 0;
BL_tmp2 = 0; //延时进入PWM暗屏模式时间
if(KEY_Too == 0) // = 0
{
KEY_Too = 1; //标志
BL_OUT = 0; //全亮
}
if( GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_7) == 0 ) //开机
{
POW_ON__1; //PB7 开机锁输出1
POW_5V__1; //PB5 开机5V输出1 //LCD_BL__1; //PA8 LCD_BL背光1
}
++Page_tmp;
if(Page_tmp >= 3) //一共0~3,4个页面
{
Page_tmp = 0;
}
}
else
{
if(Power_off_bit == 1) //3秒关机
{
Power_off_bit = 0;
KEY_OFF_SYSTEM_bit = 1; //关机
}
}
}
}
}
else
{
Page = Page_tmp; //释放 按钮
S1_OK = 0; //归零
i2 = 0;
i = 0;
}
} |