ESPHome 2026.2.1
Loading...
Searching...
No Matches
addressable_light_display.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <vector>
9
10namespace esphome {
11namespace 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).
28 if (this->last_effect_index_.has_value()) {
30 }
31
32 } else if (!enabled_ && enabled) { // disabled -> enabled
33 // - Save the current effect index.
35 // - Disable any current effect.
37 }
38 }
39 enabled_ = enabled;
40 }
41 bool get_enabled() { return enabled_; }
42
43 void set_pixel_mapper(std::function<int(int, int)> &&pixel_mapper_f) { this->pixel_mapper_f_ = pixel_mapper_f; }
44 void setup() override;
45 void display();
46
48
49 protected:
50 int get_width_internal() override;
51 int get_height_internal() override;
52 void draw_absolute_pixel_internal(int x, int y, Color color) override;
53 void update() override;
54
57 bool enabled_{true};
58 int32_t width_;
59 int32_t height_;
60 std::vector<Color> addressable_light_buffer_;
62 optional<std::function<int(int, int)>> pixel_mapper_f_;
63};
64} // namespace addressable_light
65} // namespace esphome
optional< std::function< int(int, int)> > pixel_mapper_f_
void draw_absolute_pixel_internal(int x, int y, Color color) override
void set_pixel_mapper(std::function< int(int, int)> &&pixel_mapper_f)
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:91
uint32_t get_current_effect_index() const
Get the currently active effect index (0 = no effect, 1+ = effect index).
bool has_value() const
Definition optional.h:92
bool state
Definition fan.h:2
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6