개발모듈/펌웨어 모듈
- Key Control 5
메가아재
2019. 12. 11. 15:08
반응형
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | // 키설정 #define KEY_PRESS_NO 0x73 #define KEY_PRESS_AUTO 0x72 #define KEY_PRESS_MANU 0x71 #define KEY_PRESS_Y_H 0x63 #define KEY_PRESS_M_M 0x53 #define KEY_PRESS_D_S 0x33 #define KEY_PRESS_AUTO_MANU 0x70 #define TIME_LONG_KEY 1000 #define TIME_SHORT_KEY 30 // 키입력 처리함수 void Key_Input(void) { static unsigned char Key_Flag; static unsigned char Repeat; // 키입력을 읽는다. Key_In_Data = PIND & 0x73; if(Key_In_Data == Key_In_Data_Old) { Key_Count++; if(Key_Count >= TIME_LONG_KEY && Key_Flag == 0) { Key_Flag = 1; Key_Count = TIME_LONG_KEY; switch(Key_In_Data) { case KEY_PRESS_AUTO_MANU : // 아무것도 안눌렸을때 // Led_Status ^= LED_Y_H; // Led_Status ^= LED_M_M; // Led_Status ^= LED_D_S; break; case KEY_PRESS_Y_H : case KEY_PRESS_M_M : case KEY_PRESS_D_S : if(Led_Status & LED_MANU) { Repeat = 1; Key_Count = 0; } break; default : /* printf("Repeat -> %d\r\n", Repeat); printf("Key_Count -> %d\r\n", Key_Count); printf("Key_Flag -> %d\r\n", Key_Flag); */ break; } } else if(Key_Count == TIME_SHORT_KEY) { if(Repeat == 1) Key_Count = 0; // 키처리 switch(Key_In_Data) { case KEY_PRESS_NO : // 아무것도 안눌렸을때 // printf("KEY_PRESS_NO\r\n"); break; case KEY_PRESS_AUTO : Led_Status |= LED_AUTO; Led_Status &= ~LED_MANU; // printf("KEY_PRESS_AUTO\r\n"); break; case KEY_PRESS_MANU : Led_Status &= ~LED_AUTO; Led_Status |= LED_MANU; // printf("KEY_PRESS_MANU\r\n"); break; case KEY_PRESS_Y_H : Key_Manu_Inc(MANU_YEAR); // printf("KEY_PRESS_Y_H\r\n"); break; case KEY_PRESS_M_M : Key_Manu_Inc(MANU_MON); // printf("KEY_PRESS_M_M\r\n"); break; case KEY_PRESS_D_S : Key_Manu_Inc(MANU_DAY); // printf("KEY_PRESS_D_S\r\n"); break; } } } else { Key_Count = 0; Key_Flag = 0; Repeat = 0; } Key_In_Data_Old = Key_In_Data; } | cs |
반응형