ESPHome 2025.12.0-dev
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 {
10namespace max7219 {
11
12class MAX7219Component;
13
15
17 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
18 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
19 public:
20 void set_writer(max7219_writer_t &&writer);
21
22 void setup() override;
23
24 void dump_config() override;
25
26 void update() override;
27
28 float get_setup_priority() const override;
29
30 void display();
31
32 void set_intensity(uint8_t intensity);
33 void set_num_chips(uint8_t num_chips);
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_;
60 bool reverse_{false};
62};
63
64} // namespace max7219
65} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:437
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:204
void set_intensity(uint8_t intensity)
Definition max7219.cpp:225
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
void send_to_all_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:161
void set_writer(max7219_writer_t &&writer)
Definition max7219.cpp:224
float get_setup_priority() const override
Definition max7219.cpp:117
void send_byte_(uint8_t a_register, uint8_t data)
Definition max7219.cpp:157
void set_num_chips(uint8_t num_chips)
Definition max7219.cpp:232
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__
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()