multi_led.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _MULTI_LED_H_
  2. #define _MULTI_LED_H_
  3. //#include "stdint.h"
  4. #include "TypeDef.h"
  5. #include <string.h>
  6. #include <stdbool.h>
  7. //According to your need to modify the constants.
  8. #define LED_SCAN 100
  9. typedef void (*LedCallback)(bool);
  10. enum LED_NUM_DEF
  11. {
  12. LED_WORK,
  13. LED_TX,
  14. LED_GZ,
  15. LED_MAX
  16. };
  17. enum LED_STATE_DEF
  18. {
  19. LED_STATE0_OFF, //关
  20. LED_STATE1_ON, //开
  21. LED_STATE2_FLASH, //闪烁
  22. LED_STATE3_CONUT, //延时关闭
  23. LED_STATE4_NOT, //取反
  24. LED_STATE5_FLASH_DELAY, //闪烁,延时关闭
  25. LED_STATE_MAX
  26. };
  27. typedef struct
  28. {
  29. u8 ID; //LED号
  30. bool OnOff; //状态
  31. u8 Type; //类型:0.关 1.开 2.闪烁 3.定时开关
  32. u16 FlashTime; //闪烁时间
  33. u16 CloseTime; //关闭时间/闪烁占空比
  34. u16 Count; //计时
  35. bool Res; //最后结果
  36. } pLed;
  37. typedef struct Led {
  38. pLed Play;
  39. LedCallback led_set_gpio;
  40. struct Led* next;
  41. }Led;
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. void led_init_Head(void);
  46. void led_init(struct Led* handle, LedCallback led_set_gpio);
  47. void led_set_state(struct Led* handle, u8 ID, u8 OnOff, u8 Type, u16 FlashTime, u16 CloseTime, bool Res );
  48. int led_start(struct Led* handle);
  49. void led_stop(struct Led* handle);
  50. void led_ticks(void);
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif