ESPHome  2024.4.1
addressable_light_display.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/color.h"
7 
8 #include <vector>
9 
10 namespace esphome {
11 namespace addressable_light {
12 
14  public:
15  light::AddressableLight *get_light() const { return this->light_; }
16 
17  void set_width(int32_t width) { width_ = width; }
18  void set_height(int32_t height) { height_ = height; }
21  light_ = static_cast<light::AddressableLight *>(state->get_output());
22  }
23  void set_enabled(bool enabled) {
24  if (light_state_) {
25  if (enabled_ && !enabled) { // enabled -> disabled
26  // - Tell the parent light to refresh, effectively wiping the display. Also
27  // restores the previous effect (if any).
29 
30  } else if (!enabled_ && enabled) { // disabled -> enabled
31  // - Save the current effect.
33  // - Disable any current effect.
35  }
36  }
37  enabled_ = enabled;
38  }
39  bool get_enabled() { return enabled_; }
40 
41  void set_pixel_mapper(std::function<int(int, int)> &&pixel_mapper_f) { this->pixel_mapper_f_ = pixel_mapper_f; }
42  void setup() override;
43  void display();
44 
46 
47  protected:
48  int get_width_internal() override;
49  int get_height_internal() override;
50  void draw_absolute_pixel_internal(int x, int y, Color color) override;
51  void update() override;
52 
55  bool enabled_{true};
56  int32_t width_;
57  int32_t height_;
58  std::vector<Color> addressable_light_buffer_;
61 };
62 } // namespace addressable_light
63 } // namespace esphome
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:34
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".
uint16_t x
Definition: tt21100.cpp:17
LightOutput * get_output() const
Get the light output associated with this object.
uint16_t y
Definition: tt21100.cpp:18
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
Definition: light_call.cpp:657
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void draw_absolute_pixel_internal(int x, int y, Color color) override
bool state
Definition: fan.h:34