Atm_led_WS2812.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Atm_led_mcp.cpp
  3. *
  4. * Created on: 09.12.2017
  5. * Author: ian
  6. */
  7. #ifdef FASTLED_INTERNAL
  8. #include <Atm_led_WS2812.h>
  9. #include <Atm_led.hpp>
  10. Atm_led_WS2812::Atm_led_WS2812(CRGB& _leds ):
  11. Atm_led(),
  12. leds(_leds) {
  13. // nothing to see here
  14. }
  15. void Atm_led_WS2812::initLED() {
  16. leds = CRGB::White;
  17. FastLED.show() ;
  18. //Serial.printf("WS2812 init %x\n", pin);
  19. }
  20. void Atm_led_WS2812::switchOn() {
  21. color.val = pwm_max ;
  22. leds = color ;
  23. FastLED.show() ;
  24. }
  25. void Atm_led_WS2812::switchOff() {
  26. color.val = pwm_min ;
  27. leds = color ;
  28. FastLED.show() ;
  29. }
  30. void Atm_led_WS2812::setBrightness(int value) {
  31. color.val = value ;
  32. leds = color ;
  33. // leds[pin].r = r;
  34. // leds[pin].g = g;
  35. // leds[pin].b = b;
  36. FastLED.show() ;
  37. }
  38. Atm_led_WS2812& Atm_led_WS2812::setMinMax(int min, int max) {
  39. this->pwm_min = min ;
  40. this->pwm_max = max ;
  41. return *this;
  42. }
  43. Atm_led_WS2812& Atm_led_WS2812::setHueSat(int hue, int sat) {
  44. this->color.hue = hue ;
  45. this->color.sat = sat ;
  46. leds=color ;
  47. FastLED.show();
  48. return *this;
  49. }
  50. #endif