You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//
// Created by iflyt on 2025/3/17.
//
#ifndef TIMER_KEY_MANAGER_H
#define TIMER_KEY_MANAGER_H
#include <cmsis_os2.h>
#include <stm32f4xx_hal.h>
// 按键和传感器引脚定义
#define SYSTEM_POWER_PIN GPIO_PIN_0
#define SYSTEM_POWER_PORT GPIOA
#define E_STOP_PIN GPIO_PIN_12
#define E_STOP_PORT GPIOF
#define TIMER_KEY_COUNT 2
/**
* 按键状态 */ enum class ButtonStateExtended { BUTTON_STATE_IDLE, BUTTON_STATE_PRESSED, BUTTON_STATE_LONG_PRESSED, BUTTON_STATE_LONG_RELEASED };
struct TimerKeyInfo { GPIO_TypeDef* port; uint16_t pin; uint32_t longPressTime; uint32_t pressStartTime; ButtonStateExtended state; };
class TimerKeyManager { public: TimerKeyManager(); ~TimerKeyManager();
void start();
void poll(); private: static TimerKeyInfo timer_keys_[TIMER_KEY_COUNT];
osTimerId_t timer_; };
#endif //TIMER_KEY_MANAGER_H
|