forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

jinlicong
2024-06-07 fa6053f85287163f6e2d5dba690bec05cbc95f4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "key.h"
#include "gpio.h"
#include "lcd.h"
#include "main.h"
#include "system_run_fun.h"
 
/*******************************************************************************
 * Function Name: Key_GPIO_Init
 * Parameters: none
 * Return: none
 * Description: 
 ******************************************************************************/
void Key_GPIO_Init(void)
{
    InputtIO(KEY1_PORT,KEY1_PIN,IN_NORMAL);  
    InputtIO(KEY2_PORT,KEY2_PIN,IN_NORMAL);
    InputtIO(KEY3_PORT,KEY3_PIN,IN_NORMAL);
//    InputtIO(KEY4_PORT,KEY4_PIN,IN_PULLUP);
}
 
void Key_GPIO_Close(void)
{
    CloseIO(KEY2_PORT,KEY2_PIN);
    CloseIO(KEY3_PORT,KEY3_PIN);
//    InputtIO(KEY4_PORT,KEY4_PIN,IN_PULLUP);
}
 
 
 
void keyPro(void)
{
    static uint8_t P_Key1Cnt=0,R_Key2Cnt=0,L_Key3Cnt=0;
    
    P_Key1Cnt = (KEY1_IO_READ==Bit_RESET)? P_Key1Cnt+1:0;
    R_Key2Cnt = (KEY2_IO_READ==Bit_RESET)? R_Key2Cnt+1:0;
    L_Key3Cnt = (KEY3_IO_READ==Bit_RESET)? L_Key3Cnt+1:0;
 
    
    //Èç¹ûûÓм¤»î£¬Ôò°´¼ü2ºÍ3²»ÉúЧ
    if(__SYS_DELAY_SEC_TIME_GET_(sys_active_time) ==0){
        R_Key2Cnt = L_Key3Cnt = 0;
    }
    
    if(R_Key2Cnt== 5)
    {
        //ÀýÈçÓÒ¼ü³¤°´5Ãë½øÈë²éѯģʽ
        R_Key2Cnt = 0;
        if(sys_display_para_g.sys_and_display_mode == NORMAL_MODE){
            sys_display_para_g.sys_and_display_mode = DISPLAY_PARA;
        }else if(sys_display_para_g.sys_and_display_mode == DISPLAY_PARA){
            sys_display_para_g.sys_and_display_mode = NORMAL_MODE;
        }else{
            sys_display_para_g.sys_and_display_mode = NORMAL_MODE;
        }
    }
    
    
    
    /**ÓÉÓÚĿǰKey2ºÍkey3ÓõÄPE14ºÍPE15Òý½ÅûÓÐÖжϣ¬ÔÝʱֻÄÜÂÖѯ²éѯ*/
    if(P_Key1Cnt ==0 && R_Key2Cnt >0 && L_Key3Cnt ==0) //µ¥»÷key2 ÓÒ¼ü
    {
        lcd_wake_up_flag_g = SET;
        if(__SYS_DELAY_SEC_TIME_GET_(sys_active_time) >0){ //¼¤»îºóÈÎÒâ°´¼üÖØÖü¤»îʱ¼ä
            __SYS_DELAY_SEC_TIME_SET_(sys_active_time,SYS_WAKE_UP_TIME);
        }
    }
    
    if(P_Key1Cnt ==0 && R_Key2Cnt ==0 && L_Key3Cnt >0) //µ¥»÷key3 ×ó¼ü
    {
        lcd_wake_up_flag_g = SET;
        if(__SYS_DELAY_SEC_TIME_GET_(sys_active_time) >0){ //¼¤»îºóÈÎÒâ°´¼üÖØÖü¤»îʱ¼ä
                __SYS_DELAY_SEC_TIME_SET_(sys_active_time,SYS_WAKE_UP_TIME);
        }
    }else if(P_Key1Cnt ==0 && R_Key2Cnt >0 && L_Key3Cnt >0) //µ¥»÷key2 + key3
    {
        lcd_wake_up_flag_g = SET;
        if(__SYS_DELAY_SEC_TIME_GET_(sys_active_time) >0){ //¼¤»îºóÈÎÒâ°´¼üÖØÖü¤»îʱ¼ä
                __SYS_DELAY_SEC_TIME_SET_(sys_active_time,SYS_WAKE_UP_TIME);
        }
        
        //²É¼¯Á÷Á¿¼ÆÊý¾Ý²¢´¥·¢Éϱ¨
        start_rs485_g = RS485_START_REASON_KEY;
        start_wrc_g = WRC_MEANS_KEY;
        
    }
    
    
    
}