ESPHome 2025.5.0
Loading...
Searching...
No Matches
max7219.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/time.h"
5
7
8namespace esphome {
9namespace max7219 {
10
11class MAX7219Component;
12
13using max7219_writer_t = std::function<void(MAX7219Component &)>;
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 void set_writer(max7219_writer_t &&writer);
20
21 void setup() override;
22
23 void dump_config() override;
24
25 void update() override;
26
27 float get_setup_priority() const override;
28
29 void display();
30
31 void set_intensity(uint8_t intensity);
32 void set_num_chips(uint8_t num_chips);
33 void set_reverse(bool reverse) { this->reverse_ = reverse; };
34
36 uint8_t printf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
38 uint8_t printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
39
41 uint8_t print(uint8_t pos, const char *str);
43 uint8_t print(const char *str);
44
46 uint8_t strftime(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime, 3, 0)));
47
49 uint8_t strftime(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
50
51 protected:
52 void send_byte_(uint8_t a_register, uint8_t data);
53 void send_to_all_(uint8_t a_register, uint8_t data);
54
55 uint8_t intensity_{15}; // Intensity of the display from 0 to 15 (most)
56 bool intensity_changed_{}; // True if we need to re-send the intensity
57 uint8_t num_chips_{1};
58 uint8_t *buffer_;
59 bool reverse_{false};
61};
62
63} // namespace max7219
64} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
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:203
optional< max7219_writer_t > writer_
Definition max7219.h:60
void set_intensity(uint8_t intensity)
Definition max7219.cpp:224
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:233
void send_to_all_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:160
void set_writer(max7219_writer_t &&writer)
Definition max7219.cpp:223
float get_setup_priority() const override
Definition max7219.cpp:117
void send_byte_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:156
void set_num_chips(uint8_t num_chips)
Definition max7219.cpp:231
void set_reverse(bool reverse)
Definition max7219.h:33
The SPIDevice is what components using the SPI will create.
Definition spi.h:421
struct @67::@68 __attribute__
std::function< void(MAX7219Component &)> max7219_writer_t
Definition max7219.h:13
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
A more user-friendly version of struct tm from time.h.
Definition time.h:15
std::string print()