ESPHome 2026.5.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
11
13 public:
14 light::AddressableLight *get_light() const { return this->light_; }
15
16 void set_width(int32_t width) { width_ = width; }
17 void set_height(int32_t height) { height_ = height; }
20 light_ = static_cast<light::AddressableLight *>(state->get_output());
21 }
22 void set_enabled(bool enabled) {
23 if (light_state_) {
24 if (enabled_ && !enabled) { // enabled -> disabled
25 // - Tell the parent light to refresh, effectively wiping the display. Also
26 // restores the previous effect (if any).
27 if (this->last_effect_index_.has_value()) {
29 }
30
31 } else if (!enabled_ && enabled) { // disabled -> enabled
32 // - Save the current effect index.
34 // - Disable any current effect.
36 }
37 }
38 enabled_ = enabled;
39 }
40 bool get_enabled() { return enabled_; }
41
42 void set_pixel_mapper(std::function<int(int, int)> &&pixel_mapper_f) { this->pixel_mapper_f_ = pixel_mapper_f; }
43 void setup() override;
44 void display();
45
47
48 protected:
49 int get_width_internal() override;
50 int get_height_internal() override;
51 void draw_absolute_pixel_internal(int x, int y, Color color) override;
52 void update() override;
53
56 bool enabled_{true};
57 int32_t width_;
58 int32_t height_;
59 std::vector<Color> addressable_light_buffer_;
60 optional<uint32_t> last_effect_index_;
61 optional<std::function<int(int, int)>> pixel_mapper_f_;
62};
63} // namespace esphome::addressable_light
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:93
uint32_t get_current_effect_index() const
Get the currently active effect index (0 = no effect, 1+ = effect index).
bool state
Definition fan.h:2
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6