| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //WS2812灯带控制器
- #ifndef __WS2812_H__
- #define __WS2812_H__
- #include <stdint.h>
- #include "main.h"
- #define WS2812_NUM 5 //灯珠数量(分边)
- #define WS2812_IO PA3 //引脚
- #define BREATH_NUM 50 //呼吸灯变化次数
- typedef enum
- {
- BEEP_MUTE = 0x00,/*静默*/
- BEEP_ERR_HW = 0x01,/*设备故障*/
- BEEP_ERR_HM = 0x02,/*操作故障*/
- BEEP_SCANOK = 0x03,/*扫码成功*/
- BEEP_WORKEND = 0x04/*完成*/
- } BEEPTYPE;
- struct str_ws2812
- {
- uint32_t light_color[2];
- uint32_t light_color_use[2];
- uint8_t light_mode[2];
- uint16_t light_speed[2];
- uint8_t breath_count[2];
- uint8_t breath_dir[2];
- };
- enum light_mode_type
- {
- MODE_NORMAL, //常亮
- MODE_BLINK, //闪烁
- MODE_BREATH, //呼吸
- };
- enum light_color_type
- {
- COLOR_BLUE = 0x000088, //蓝
- COLOR_GREEN = 0x008800, //绿
- COLOR_RED = 0x880000, //红
- COLOR_YELLOW = 0x888800, //黄
- };
- void light_ctrl(void);
- void light_refresh(uint32_t rgb_left, uint32_t rgb_right);
- void light_set(uint8_t mode_select, uint16_t speed_ms, uint32_t rgb_color, uint8_t channel);
- void beep_set(BEEPTYPE beep);
- #endif
|