ESPHome 2025.5.0
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).
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_;
60 optional<std::function<int(int, int)>> pixel_mapper_f_;
61};
62} // namespace addressable_light
63} // 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:63
std::string get_effect_name()
Return the name of the current effect, or if no effect is active "None".
bool state
Definition fan.h:0
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