LED_BREATH_ATY.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file LED_BREATH_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2026 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief functions of LED for C platform
  20. *
  21. * @version
  22. * - 1_01_250814 > ATY
  23. * -# Preliminary version, first Release
  24. ********************************************************************************
  25. */
  26. #ifndef __LED_BREATH_ATY_H
  27. #define __LED_BREATH_ATY_H
  28. #include "INCLUDE_ATY.h"
  29. /******************************* For user *************************************/
  30. #define BREATH_LED_MAX 100 // LED最大亮度
  31. #define BREATH_LED_MIN 50 // LED最小亮度
  32. #define BREATH_LED_MID (BREATH_LED_MIN + ((BREATH_LED_MAX - BREATH_LED_MIN) / 2)) // LED中等亮度
  33. #define BREATH_LED_SPEED_MID 30 // LED中等速度
  34. /******************************************************************************/
  35. typedef enum {
  36. BREATH_MODE_SMOOTH, // 平滑呼吸
  37. BREATH_MODE_STEP, // 阶梯呼吸
  38. BREATH_MODE_FAST, // 快速呼吸
  39. BREATH_MODE_SLOW, // 慢速呼吸
  40. BREATH_MODE_PAUSE_TOP, // 顶部停顿
  41. BREATH_MODE_PAUSE_BOTTOM, // 底部停顿
  42. BREATH_MODE_PULSE // 突然亮起
  43. } LedBreathMode_t;
  44. struct LED_BREATH_ATY_Dev
  45. {
  46. LedBreathMode_t breathMode;
  47. uint32_t breathTimer;
  48. int8_t breathDir;
  49. uint8_t breathVal;
  50. uint8_t breathPauseCnt;
  51. uint8_t breathStep;
  52. uint8_t breathMax;
  53. uint8_t breathMin;
  54. uint8_t breathUpdate;
  55. void (*pwmSet)(uint8_t breathVal);
  56. uint8_t lock;
  57. uint8_t debugEnable;
  58. void (*LOG)(const char*, ...);
  59. };
  60. void LedBreath(struct LED_BREATH_ATY_Dev* dev);
  61. void SetLedBreathMode(struct LED_BREATH_ATY_Dev* dev, LedBreathMode_t mode);
  62. #endif /* __LED_BREATH_ATY_H */
  63. /******************************** End Of File *********************************/