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.

34 lines
649 B

Introduced a HUB component + front panel IRQ handling A HUB component was introduced. This HUB component has all the knowledge about the Yeelight Bedside Lamp 2 hardware. It known what pins are used, that PWM frequencies to use, what pins to switch in binary mode, etc. etc. No configuration is required for this HUB component. It's automatically loaded when the light component is loaded. The light component will use the HUB component to access the pins that are required for driving the LED circuitry. Note that this simplifies the configuration by A LOT. There's no need anymore to configure the pinouts in the YAML file. This is a logical route to take, since we're talking about a factory-produced PCB with a soldered on ESP32 chip, which uses the same GPIO's and settings on all produced devices (I presume). It would be quite redundant to force every user into configuring these pinouts themselves. ** Beware to update your device yaml configuration ** There are a few pinouts left to move into the HUB. I will do that in the next commit. Your device yaml configuration can be simplified along with these changes. Some of the keys in the existing light configuration block will no longer work and will have to be removed (red, green, blue, white). ** Further development ** The HUB will be extended make it the central component that also handles the I2C communication. This way, there is a central place to regulate the traffic to and from the front panel. We will be able to build upon this by implementing extra, fully separated components that handle for example the front panel light level, the power button, the color button and the slider. ** Interrupt handler for the I2C IRQ trigger pin ** One requirement for the I2C communication has already been implemented: an interrupt handler for the GPIO that is used by the front panel to signal the ESP that a new touch or release event is avilable to be read. It doens't do anything functionally right now, but if you watch the log file, you will see that touch events are detected and that they trigger some log messages.
3 years ago
  1. #pragma once
  2. #include <array>
  3. #include <stdexcept>
  4. #include "../common.h"
  5. #include "gpio_outputs.h"
  6. namespace esphome {
  7. namespace yeelight {
  8. namespace bs2 {
  9. /**
  10. * This class can handle the GPIO outputs in case the light of turned off.
  11. */
  12. class ColorOff : public GPIOOutputs {
  13. protected:
  14. bool set_light_color_values(light::LightColorValues v) {
  15. if (v.get_state() != 0.0f && v.get_brightness() != 0.0f) {
  16. return false;
  17. }
  18. red = 1.0f;
  19. green = 1.0f;
  20. blue = 1.0f;
  21. white = 0.0f;
  22. return true;
  23. }
  24. };
  25. } // namespace yeelight_bs2
  26. } // namespace yeelight
  27. } // namespace bs2