led.h 932 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Squeezelite for esp32
  3. *
  4. * (c) Sebastien 2019
  5. * Philippe G. 2019, philippe_44@outlook.com
  6. *
  7. * This software is released under the MIT License.
  8. * https://opensource.org/licenses/MIT
  9. *
  10. */
  11. #ifndef LED_H
  12. #define LED_H
  13. #include "driver/gpio.h"
  14. enum { LED_GREEN = 0, LED_RED };
  15. typedef enum { LED_GPIO = -1, LED_WS2812 } led_type_t;
  16. #define led_on(idx) led_blink_core(idx, 1, 0, false)
  17. #define led_off(idx) led_blink_core(idx, 0, 0, false)
  18. #define led_blink(idx, on, off) led_blink_core(idx, on, off, false)
  19. #define led_blink_pushed(idx, on, off) led_blink_core(idx, on, off, true)
  20. // if type is LED_GPIO then color set the GPIO logic value for "on"
  21. bool led_config(int idx, gpio_num_t gpio, int color, int bright, led_type_t type);
  22. bool led_brightness(int idx, int percent);
  23. bool led_blink_core(int idx, int ontime, int offtime, bool push);
  24. bool led_unpush(int idx);
  25. int led_allocate(void);
  26. #endif