You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. #pragma once
  2. namespace esphome {
  3. namespace yeelight {
  4. namespace bs2 {
  5. /**
  6. * This abstract class is used for implementing classes that translate
  7. * LightColorValues into the required GPIO PWM duty cycle levels to represent
  8. * the requested color on the physical device.
  9. */
  10. class GPIOOutputs {
  11. public:
  12. float red = 0.0f;
  13. float green = 0.0f;
  14. float blue = 0.0f;
  15. float white = 0.0f;
  16. /**
  17. * Sets the red, green, blue, white fields to the PWM duty cycles
  18. * that are required to represent the requested light color for
  19. * the provided LightColorValues input.
  20. *
  21. * Returns true when the input can be handled, false otherwise.
  22. */
  23. virtual bool set_light_color_values(light::LightColorValues v) = 0;
  24. /**
  25. * Copies the current output values to another GPIOOutputs object.
  26. */
  27. void copy_to(GPIOOutputs *other) {
  28. other->red = red;
  29. other->green = green;
  30. other->blue = blue;
  31. other->white = white;
  32. }
  33. void log(const char *prefix) {
  34. ESP_LOGD(TAG, "%s: RGB=[%f,%f,%f], white=%f",
  35. prefix, red, green, blue, white);
  36. }
  37. };
  38. } // namespace bs2
  39. } // namespace yeelight
  40. } // namespace esphome