multi_led.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. {
  39. pLed Play;
  40. LedCallback led_set_gpio;
  41. struct Led* next;
  42. } Led;
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. void led_init_Head ( void );
  47. void led_init ( struct Led* handle, LedCallback led_set_gpio );
  48. void led_set_state ( struct Led* handle, u8 ID, u8 OnOff, u8 Type, u16 FlashTime, u16 CloseTime, bool Res );
  49. int led_start ( struct Led* handle );
  50. void led_stop ( struct Led* handle );
  51. void led_ticks ( void );
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif