# 按键模块代码 **Repository Path**: a-flying-panda/key-module-code ## Basic Information - **Project Name**: 按键模块代码 - **Description**: 太帅咯太帅咯太帅咯太帅咯太帅咯太帅咯太帅咯 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-04 - **Last Updated**: 2025-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 按键模块代码 ### **LINUX移植步骤** 1. *创建按键对象* ```c struct key_t key1 = *key_create("/dev/key"); ``` 2. `放到MS级别的定时器中断。 ```c key_handle(key1); ``` 3. *获取按键状态* ```c int status = key_GetState(key1); ``` 4. *按键复位(注意处理完按键事件后一定要复位,除了长按)* ```c key_Reset(key1); ``` --- ### **MCU移植步骤** #### 静态创建按键 1. *创建按键对象* ```c struct key_t key1_static; ``` 2. *初始化按键对象* ```C key_create_static(&key1_static,GPIOA, LCD_RES_Pin); ``` 3. `放到MS级别的定时器中断。 ```C key_handle(&key1_static); ``` 5. *获取按键状态* ```C int status = key_GetState(&key1_static); ``` 6. *按键复位(注意处理完按键事件后一定要复位,除了长按)* ```C int key_Reset(&key1_static) ``` #### 动态创建按键 1. *创建按键对象* ```C struct key_t key1 = key_create(GPIOA, LCD_RES_Pin); ``` 2. `放到MS级别的定时器中断。 ```C key_handle(key1); ``` 3. *获取按键状态* ```C int status = key_GetState(key1); ``` 4. *按键复位(注意处理完按键事件后一定要复位,除了长按)* ```C key_Reset(key1); ``` --- ### **LINUX QT移植步骤** 1. *创建按键对象* ```c++ class key key1; ``` 2. 放到MS级别的定时器中断。 ```c++ key1.handle(); ``` 3. *获取按键状态* ```c++ int status = key1.GetState(); ``` 4. *按键复位(注意处理完按键事件后一定要复位,除了长按)* ```c++ key1.Reset(); ``` ---