11namespace max7219digit {
13static const char *
const TAG =
"max7219DIGIT";
15static const uint8_t MAX7219_REGISTER_NOOP = 0x00;
16static const uint8_t MAX7219_REGISTER_DECODE_MODE = 0x09;
17static const uint8_t MAX7219_REGISTER_INTENSITY = 0x0A;
18static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B;
19static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C;
20static const uint8_t MAX7219_REGISTER_DISPLAY_TEST = 0x0F;
29 ESP_LOGCONFIG(TAG,
"Setting up MAX7219_DIGITS...");
32 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
33 std::vector<uint8_t> vec(1);
53 ESP_LOGCONFIG(TAG,
"MAX7219DIGIT:");
54 ESP_LOGCONFIG(TAG,
" Number of Chips: %u", this->
num_chips_);
55 ESP_LOGCONFIG(TAG,
" Number of Chips Lines: %u", this->
num_chip_lines_);
57 ESP_LOGCONFIG(TAG,
" Intensity: %u", this->
intensity_);
58 ESP_LOGCONFIG(TAG,
" Scroll Mode: %u", this->
scroll_mode_);
62 LOG_PIN(
" CS Pin: ", this->
cs_);
63 LOG_UPDATE_INTERVAL(
this);
68 const uint32_t millis_since_last_scroll = now - this->
last_scroll_;
72 ESP_LOGV(TAG,
"Buffer size changed %d to %d", this->
old_buffer_size_, first_line_size);
79 ESP_LOGVV(TAG,
"Return if there is no need to scroll or scroll is off.");
85 ESP_LOGVV(TAG,
"At first step. Waiting for scroll delay");
93 ESP_LOGVV(TAG,
"Dwell time at end of string in case of stop at end. Step %d, since last scroll %d, dwell %d.",
94 this->
stepsleft_, millis_since_last_scroll, this->scroll_dwell_);
97 ESP_LOGV(TAG,
"Dwell time passed. Continue scrolling.");
102 ESP_LOGVV(TAG,
"Call to scroll left action");
103 this->last_scroll_ = now;
116 for (uint8_t chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
117 for (uint8_t j = 0; j < 8; j++) {
159 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
183 for (uint8_t i = 0; i < this->
num_chips_; i++)
189 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
229 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
230 auto scroll = [&](std::vector<uint8_t> &
line, uint16_t steps) {
231 std::rotate(
line.begin(), std::next(
line.begin(), steps),
line.end());
248 for (uint8_t i = 0; i < 8; i++)
255 for (uint8_t col = 0; col < 8; col++) {
257 for (uint8_t i = 0; i < chip; i++) {
259 MAX7219_REGISTER_NOOP);
263 for (uint8_t i = 0; i < 8; i++) {
266 b |= ((pixels[i] >> col) & 1) << i;
268 b |= ((pixels[i] >> col) & 1) << (7 - i);
274 for (uint8_t i = 0; i < 8; i++) {
276 b |= ((pixels[i] >> (7 - col)) & 1) << (7 - i);
278 b |= ((pixels[i] >> (7 - col)) & 1) << i;
282 for (uint8_t i = 0; i < 8; i++) {
283 b |= ((pixels[7 - col] >> i) & 1) << (7 - i);
292 for (
int i = 0; i < this->
num_chips_ - chip - 1; i++)
293 this->
send_byte_(MAX7219_REGISTER_NOOP, MAX7219_REGISTER_NOOP);
301 uint8_t chip = start_pos;
312 va_start(arg, format);
314 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
322 va_start(arg, format);
324 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
333 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
BedjetMode mode
BedJet operating mode.
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void line(int x1, int y1, int x2, int y2, Color color=COLOR_ON)
Draw a straight line from the point [x1,y1] to [x2,y2] with the given color.
void send_to_all_(uint8_t a_register, uint8_t data)
void draw_absolute_pixel_internal(int x, int y, Color color) override
void set_scroll_dwell(uint16_t dwell)
uint8_t uint8_t uint8_t printdigit(uint8_t pos, const char *str)
Print str at the given position.
uint8_t printdigitf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
int get_height_internal() override
void send64pixels(uint8_t chip, const uint8_t pixels[8])
uint8_t orientation_180_()
void scroll(bool on_off, ScrollMode mode, uint16_t speed, uint16_t delay, uint16_t dwell)
void set_scroll_delay(uint16_t delay)
void send_byte_(uint8_t a_register, uint8_t data)
void intensity(uint8_t intensity)
void set_scroll_speed(uint16_t speed)
float get_setup_priority() const override
void set_scroll_mode(ScrollMode mode)
void send_char(uint8_t chip, uint8_t data)
void set_scroll(bool on_off)
optional< max7219_writer_t > writer_local_
ChipLinesStyle chip_lines_style_
void turn_on_off(bool on_off)
uint8_t num_chips_
Intensity of the display from 0 to 15 (most)
uint16_t old_buffer_size_
void dump_config() override
uint8_t strftimedigit(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format and print the result at the given position.
std::vector< std::vector< uint8_t > > max_displaybuffer_
int get_width_internal() override
void spi_setup() override
void write_byte(uint8_t data)
constexpr uint8_t MAX7219_NO_DISPLAY_TEST
constexpr uint8_t MAX7219_NO_SHUTDOWN
constexpr uint8_t MAX7219_DISPLAY_TEST
constexpr uint8_t MAX7219_SHUTDOWN
const float PROCESSOR
For components that use data from sensors like displays.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)
Application App
Global storage of Application pointer - only one Application can exist.
uint8_t progmem_read_byte(const uint8_t *addr)
bool is_on() ESPHOME_ALWAYS_INLINE
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.