9static const char *
const TAG =
"max7219";
11static const uint8_t MAX7219_REGISTER_NOOP = 0x00;
12static const uint8_t MAX7219_REGISTER_DECODE_MODE = 0x09;
13static const uint8_t MAX7219_REGISTER_INTENSITY = 0x0A;
14static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B;
15static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C;
16static const uint8_t MAX7219_REGISTER_TEST = 0x0F;
17static const uint8_t MAX7219_UNKNOWN_CHAR = 0b11111111;
19const uint8_t MAX7219_ASCII_TO_RAW[95]
PROGMEM = {
101 MAX7219_UNKNOWN_CHAR,
107 MAX7219_UNKNOWN_CHAR,
108 MAX7219_UNKNOWN_CHAR,
110 MAX7219_UNKNOWN_CHAR,
119 ESP_LOGCONFIG(TAG,
"Running setup");
122 for (uint8_t i = 0; i < this->
num_chips_ * 8; i++)
138 " Number of Chips: %u\n"
141 LOG_PIN(
" CS Pin: ", this->
cs_);
142 LOG_UPDATE_INTERVAL(
this);
146 for (uint8_t i = 0; i < 8; i++) {
148 for (uint8_t j = 0; j < this->
num_chips_; j++) {
164 for (uint8_t i = 0; i < this->
num_chips_; i++)
173 for (uint8_t i = 0; i < this->
num_chips_ * 8; i++)
180 uint8_t pos = start_pos;
181 for (; *str !=
'\0'; str++) {
182 uint8_t data = MAX7219_UNKNOWN_CHAR;
183 if (*str >=
' ' && *str <=
'~')
186 if (data == MAX7219_UNKNOWN_CHAR) {
187 ESP_LOGW(TAG,
"Encountered character '%c' with no MAX7219 representation while translating string!", *str);
190 if (pos != start_pos)
192 this->
buffer_[pos] |= 0b10000000;
195 ESP_LOGE(TAG,
"MAX7219 String is too long for the display!");
202 return pos - start_pos;
207 va_start(arg, format);
209 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
212 return this->
print(pos, buffer);
217 va_start(arg, format);
219 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
222 return this->
print(buffer);
237 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
239 return this->
print(pos, buffer);
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
optional< max7219_writer_t > writer_
void set_intensity(uint8_t intensity)
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.
void send_to_all_(uint8_t a_register, uint8_t data)
void dump_config() override
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
void set_writer(max7219_writer_t &&writer)
float get_setup_priority() const override
void send_byte_(uint8_t a_register, uint8_t data)
void set_num_chips(uint8_t num_chips)
void spi_setup() override
void write_byte(uint8_t data)
const uint8_t MAX7219_ASCII_TO_RAW[95] PROGMEM
std::function< void(MAX7219Component &)> max7219_writer_t
const float PROCESSOR
For components that use data from sensors like displays.
Providing packet encoding functions for exchanging data with a remote host.
uint8_t progmem_read_byte(const uint8_t *addr)
A more user-friendly version of struct tm from time.h.
size_t strftime(char *buffer, size_t buffer_len, const char *format)
Convert this ESPTime struct to a null-terminated c string buffer as specified by the format argument.