第一次提交
This commit is contained in:
62
app/app_light.h
Normal file
62
app/app_light.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef APP_LIGHT_H
|
||||
#define APP_LIGHT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// 定义灯光状态枚举
|
||||
typedef enum
|
||||
{
|
||||
LIGHT_OFF,
|
||||
LIGHT_ON,
|
||||
LIGHT_BLINK
|
||||
} LightState;
|
||||
|
||||
// 定义灯光类型枚举
|
||||
typedef enum
|
||||
{
|
||||
LIGHT_HEAD,
|
||||
LIGHT_TAIL,
|
||||
LIGHT_LEFT_TURN,
|
||||
LIGHT_RIGHT_TURN,
|
||||
LIGHT_BRAKE,
|
||||
LIGHT_ALARM,
|
||||
LIGHT_COUNT
|
||||
} LightType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LightState states[LIGHT_COUNT];
|
||||
uint8_t brightness[LIGHT_COUNT];
|
||||
uint16_t blink_interval[LIGHT_COUNT]; // 闪烁间隔(毫秒)
|
||||
uint8_t blink_state[LIGHT_COUNT]; // 闪烁状态
|
||||
Timer timer;// 设置定时器,定时调用灯光处理函数
|
||||
uint8_t old_light_state; // 旧的灯光状态
|
||||
uint8_t light_state; // 当前的灯光状态
|
||||
Timer timer_function; // 函数定时器
|
||||
uint8_t light_switch; // 当前的灯光开关状态
|
||||
uint8_t double_click_flag;//双击标志
|
||||
} LightSystem;
|
||||
|
||||
// 在头文件中声明外部变量
|
||||
extern LightSystem light_data;
|
||||
|
||||
// 使用内联函数
|
||||
static inline uint8_t setLightOn(void) { return 1; }
|
||||
static inline uint8_t setLightOff(void) { return 0; }
|
||||
|
||||
void lightAppInit(void);
|
||||
void setLightState(LightType light, LightState state);
|
||||
void setLightBrightness(LightType light, uint8_t brightness);
|
||||
void setBlinkInterval(uint16_t interval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_LIGHT_H
|
||||
Reference in New Issue
Block a user