ESPHome 2026.1.5
Loading...
Searching...
No Matches
max7219.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/time.h"
5
8
9namespace esphome::max7219 {
10
11class MAX7219Component;
12
14
16 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
17 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
18 public:
19 explicit MAX7219Component(uint8_t num_chips);
20
21 void set_writer(max7219_writer_t &&writer);
22
23 void setup() override;
24
25 void dump_config() override;
26
27 void update() override;
28
29 float get_setup_priority() const override;
30
31 void display();
32
33 void set_intensity(uint8_t intensity);
34 void set_reverse(bool reverse) { this->reverse_ = reverse; };
35
37 uint8_t printf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
39 uint8_t printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
40
42 uint8_t print(uint8_t pos, const char *str);
44 uint8_t print(const char *str);
45
47 uint8_t strftime(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime, 3, 0)));
48
50 uint8_t strftime(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
51
52 protected:
53 void send_byte_(uint8_t a_register, uint8_t data);
54 void send_to_all_(uint8_t a_register, uint8_t data);
55
56 uint8_t intensity_{15}; // Intensity of the display from 0 to 15 (most)
57 bool intensity_changed_{}; // True if we need to re-send the intensity
58 uint8_t num_chips_{1};
59 uint8_t *buffer_{nullptr};
60 bool reverse_{false};
62};
63
64} // namespace esphome::max7219
This class simplifies creating components that periodically check a state.
Definition component.h:525
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
Definition max7219.cpp:205
void set_intensity(uint8_t intensity)
Definition max7219.cpp:226
uint8_t strftime(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format and print the result at the given position.
Definition max7219.cpp:234
MAX7219Component(uint8_t num_chips)
Definition max7219.cpp:118
void send_to_all_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:162
void set_writer(max7219_writer_t &&writer)
Definition max7219.cpp:225
float get_setup_priority() const override
Definition max7219.cpp:116
void send_byte_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:158
void set_reverse(bool reverse)
Definition max7219.h:34
The SPIDevice is what components using the SPI will create.
Definition spi.h:427
struct @65::@66 __attribute__
A more user-friendly version of struct tm from time.h.
Definition time.h:16
std::string print()