led_strip_interface.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include "esp_err.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. typedef struct led_strip_t led_strip_t; /*!< Type of LED strip */
  13. /**
  14. * @brief LED strip interface definition
  15. */
  16. struct led_strip_t {
  17. /**
  18. * @brief Set RGB for a specific pixel
  19. *
  20. * @param strip: LED strip
  21. * @param index: index of pixel to set
  22. * @param red: red part of color
  23. * @param green: green part of color
  24. * @param blue: blue part of color
  25. *
  26. * @return
  27. * - ESP_OK: Set RGB for a specific pixel successfully
  28. * - ESP_ERR_INVALID_ARG: Set RGB for a specific pixel failed because of invalid parameters
  29. * - ESP_FAIL: Set RGB for a specific pixel failed because other error occurred
  30. */
  31. esp_err_t (*set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue);
  32. /**
  33. * @brief Refresh memory colors to LEDs
  34. *
  35. * @param strip: LED strip
  36. * @param timeout_ms: timeout value for refreshing task
  37. *
  38. * @return
  39. * - ESP_OK: Refresh successfully
  40. * - ESP_FAIL: Refresh failed because some other error occurred
  41. *
  42. * @note:
  43. * After updating the LED colors in the memory, a following invocation of this API is needed to flush colors to strip.
  44. */
  45. esp_err_t (*refresh)(led_strip_t *strip);
  46. /**
  47. * @brief Clear LED strip (turn off all LEDs)
  48. *
  49. * @param strip: LED strip
  50. * @param timeout_ms: timeout value for clearing task
  51. *
  52. * @return
  53. * - ESP_OK: Clear LEDs successfully
  54. * - ESP_FAIL: Clear LEDs failed because some other error occurred
  55. */
  56. esp_err_t (*clear)(led_strip_t *strip);
  57. /**
  58. * @brief Free LED strip resources
  59. *
  60. * @param strip: LED strip
  61. *
  62. * @return
  63. * - ESP_OK: Free resources successfully
  64. * - ESP_FAIL: Free resources failed because error occurred
  65. */
  66. esp_err_t (*del)(led_strip_t *strip);
  67. };
  68. #ifdef __cplusplus
  69. }
  70. #endif