ESPHome  2022.6.2
addressable_light_display.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/color.h"
7 
8 namespace esphome {
9 namespace addressable_light {
10 
12  public:
13  light::AddressableLight *get_light() const { return this->light_; }
14 
15  void set_width(int32_t width) { width_ = width; }
16  void set_height(int32_t height) { height_ = height; }
19  light_ = static_cast<light::AddressableLight *>(state->get_output());
20  }
21  void set_enabled(bool enabled) {
22  if (light_state_) {
23  if (enabled_ && !enabled) { // enabled -> disabled
24  // - Tell the parent light to refresh, effectively wiping the display. Also
25  // restores the previous effect (if any).
27 
28  } else if (!enabled_ && enabled) { // disabled -> enabled
29  // - Save the current effect.
31  // - Disable any current effect.
33  }
34  }
35  enabled_ = enabled;
36  }
37  bool get_enabled() { return enabled_; }
38 
39  void set_pixel_mapper(std::function<int(int, int)> &&pixel_mapper_f) { this->pixel_mapper_f_ = pixel_mapper_f; }
40  void setup() override;
41  void display();
42 
44 
45  protected:
46  int get_width_internal() override;
47  int get_height_internal() override;
48  void draw_absolute_pixel_internal(int x, int y, Color color) override;
49  void update() override;
50 
53  bool enabled_{true};
54  int32_t width_;
55  int32_t height_;
56  std::vector<Color> addressable_light_buffer_;
59 };
60 } // namespace addressable_light
61 } // namespace esphome
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:32
optional< std::function< int(int, int)> > pixel_mapper_f_
void set_pixel_mapper(std::function< int(int, int)> &&pixel_mapper_f)
std::string get_effect_name()
Return the name of the current effect, or if no effect is active "None".
LightOutput * get_output() const
Get the light output associated with this object.
This class simplifies creating components that periodically check a state.
Definition: component.h:266
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
Definition: light_call.cpp:656
Definition: a4988.cpp:4
void draw_absolute_pixel_internal(int x, int y, Color color) override
bool state
Definition: fan.h:34