9 static const char *
const TAG =
"max7219";
11 static const uint8_t MAX7219_REGISTER_NOOP = 0x00;
12 static const uint8_t MAX7219_REGISTER_DECODE_MODE = 0x09;
13 static const uint8_t MAX7219_REGISTER_INTENSITY = 0x0A;
14 static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B;
15 static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C;
16 static const uint8_t MAX7219_REGISTER_TEST = 0x0F;
17 static const uint8_t MAX7219_UNKNOWN_CHAR = 0b11111111;
19 const 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,
"Setting up MAX7219...");
122 for (uint8_t i = 0; i < this->
num_chips_ * 8; i++)
136 ESP_LOGCONFIG(TAG,
"MAX7219:");
137 ESP_LOGCONFIG(TAG,
" Number of Chips: %u", this->
num_chips_);
138 ESP_LOGCONFIG(TAG,
" Intensity: %u", this->
intensity_);
139 LOG_PIN(
" CS Pin: ", this->
cs_);
140 LOG_UPDATE_INTERVAL(
this);
144 for (uint8_t i = 0; i < 8; i++) {
146 for (uint8_t j = 0; j < this->
num_chips_; j++) {
162 for (uint8_t i = 0; i < this->
num_chips_; i++)
171 for (uint8_t i = 0; i < this->
num_chips_ * 8; i++)
178 uint8_t pos = start_pos;
179 for (; *str !=
'\0'; str++) {
180 uint8_t data = MAX7219_UNKNOWN_CHAR;
181 if (*str >=
' ' && *str <=
'~')
184 if (data == MAX7219_UNKNOWN_CHAR) {
185 ESP_LOGW(TAG,
"Encountered character '%c' with no MAX7219 representation while translating string!", *str);
188 if (pos != start_pos)
190 this->
buffer_[pos] |= 0b10000000;
193 ESP_LOGE(TAG,
"MAX7219 String is too long for the display!");
200 return pos - start_pos;
205 va_start(arg, format);
207 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
210 return this->
print(pos, buffer);
215 va_start(arg, format);
217 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
220 return this->
print(buffer);
235 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
237 return this->
print(pos, buffer);
void send_to_all_(uint8_t a_register, uint8_t data)
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...
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
void spi_setup() override
A more user-friendly version of struct tm from time.h.
void set_intensity(uint8_t intensity)
void send_byte_(uint8_t a_register, uint8_t data)
void write_byte(uint8_t data)
const float PROCESSOR
For components that use data from sensors like displays.
optional< max7219_writer_t > writer_
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
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.
uint8_t progmem_read_byte(const uint8_t *addr)
std::function< void(MAX7219Component &)> max7219_writer_t
float get_setup_priority() const override
void set_writer(max7219_writer_t &&writer)
Implementation of SPI Controller mode.
const uint8_t MAX7219_ASCII_TO_RAW [95] PROGMEM
void set_num_chips(uint8_t num_chips)
void dump_config() override