ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
hub75_component.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
5#include <utility>
6
10#include "esphome/core/hal.h"
11#include "esphome/core/log.h"
12#include "hub75.h" // hub75 library
13
14namespace esphome::hub75 {
15
18
20 public:
21 // Constructor accepting config
22 explicit HUB75Display(const Hub75Config &config);
23
24 // Core Component methods
25 void setup() override;
26 void dump_config() override;
27 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
28
29 // Display/PollingComponent methods
30 void update() override;
32 void fill(Color color) override;
33 void draw_pixel_at(int x, int y, Color color) override;
34 void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
35 display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
36
37 // Brightness control (runtime mutable)
38 void set_brightness(uint8_t brightness);
39
40 protected:
41 // Display internal methods
42 int get_width_internal() override { return config_.panel_width * config_.layout_cols; }
43 int get_height_internal() override { return config_.panel_height * config_.layout_rows; }
44
45 // Member variables
46 Hub75Driver *driver_{nullptr};
47 Hub75Config config_; // Immutable configuration
48
49 // Runtime state (mutable)
50 uint8_t brightness_{128};
51 bool enabled_{false};
52};
53
54template<typename... Ts> class SetBrightnessAction : public Action<Ts...>, public Parented<HUB75Display> {
55 public:
56 TEMPLATABLE_VALUE(uint8_t, brightness)
57
58 void play(const Ts &...x) override { this->parent_->set_brightness(this->brightness_.value(x...)); }
59};
60
61} // namespace esphome::hub75
62
63#endif
uint8_t h
Definition bl0906.h:2
virtual void play(const Ts &...x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1037
void update() override
Definition hub75.cpp:76
void draw_pixel_at(int x, int y, Color color) override
Definition hub75.cpp:105
HUB75Display(const Hub75Config &config)
Definition hub75.cpp:14
void set_brightness(uint8_t brightness)
Definition hub75.cpp:182
void setup() override
Definition hub75.cpp:24
void dump_config() override
Definition hub75.cpp:37
void fill(Color color) override
Definition hub75.cpp:89
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
Definition hub75.cpp:118
display::DisplayType get_display_type() override
float get_setup_priority() const override
TEMPLATABLE_VALUE(uint8_t, brightness) void play(const Ts &...x) override
const float PROCESSOR
For components that use data from sensors like displays.
Definition component.cpp:82
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6