ws2812.h 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //WS2812灯带控制器
  2. #ifndef __WS2812_H__
  3. #define __WS2812_H__
  4. #include <stdint.h>
  5. #include "main.h"
  6. #define WS2812_NUM 5 //灯珠数量(分边)
  7. #define WS2812_IO PA3 //引脚
  8. #define BREATH_NUM 50 //呼吸灯变化次数
  9. struct str_ws2812
  10. {
  11. uint32_t light_color[2];
  12. uint32_t light_color_use[2];
  13. uint8_t light_mode[2];
  14. uint16_t light_speed[2];
  15. uint8_t breath_count[2];
  16. uint8_t breath_dir[2];
  17. };
  18. enum light_mode_type
  19. {
  20. MODE_NORMAL, //常亮
  21. MODE_BLINK, //闪烁
  22. MODE_BREATH, //呼吸
  23. };
  24. enum light_color_type
  25. {
  26. COLOR_BLUE = 0x000088, //蓝
  27. COLOR_GREEN = 0x008800, //绿
  28. COLOR_RED = 0x880000, //红
  29. COLOR_YELLOW = 0x888800, //黄
  30. };
  31. void light_ctrl(void);
  32. void light_refresh(uint32_t rgb_left, uint32_t rgb_right);
  33. void light_set(uint8_t mode_select, uint16_t speed_ms, uint32_t rgb_color, uint8_t channel);
  34. #endif