ESPHome 2026.5.1
Loading...
Searching...
No Matches
max7219digit.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/time.h"
5
8
9#include <vector>
10
11namespace esphome::max7219digit {
12
17
22
23class MAX7219Component;
24
26
28 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
29 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
30 public:
31 void set_writer(max7219_writer_t &&writer) { this->writer_local_ = writer; };
32
33 void setup() override;
34
35 void loop() override;
36
37 void dump_config() override;
38
39 void update() override;
40
41 float get_setup_priority() const override;
42
43 void display();
44
45 void invert_on_off(bool on_off);
46 void invert_on_off();
47
48 void turn_on_off(bool on_off);
49
50 void draw_absolute_pixel_internal(int x, int y, Color color) override;
51 int get_height_internal() override;
52 int get_width_internal() override;
53
54 void set_intensity(uint8_t intensity) { this->intensity_ = intensity; };
55 void set_num_chips(uint8_t num_chips) { this->num_chips_ = num_chips; };
56 void set_num_chip_lines(uint8_t num_chip_lines) { this->num_chip_lines_ = num_chip_lines; };
57 void set_chip_lines_style(ChipLinesStyle chip_lines_style) { this->chip_lines_style_ = chip_lines_style; };
58 void set_chip_orientation(uint8_t rotate) { this->orientation_ = rotate; };
59 void set_scroll_speed(uint16_t speed) { this->scroll_speed_ = speed; };
60 void set_scroll_dwell(uint16_t dwell) { this->scroll_dwell_ = dwell; };
61 void set_scroll_delay(uint16_t delay) { this->scroll_delay_ = delay; };
62 void set_scroll(bool on_off) { this->scroll_ = on_off; };
64 void set_reverse(bool on_off) { this->reverse_ = on_off; };
65 void set_flip_x(bool flip_x) { this->flip_x_ = flip_x; };
66
67 void send_char(uint8_t chip, uint8_t data);
68 void send64pixels(uint8_t chip, const uint8_t pixels[8]);
69
70 void scroll_left();
71 void scroll(bool on_off, ScrollMode mode, uint16_t speed, uint16_t delay, uint16_t dwell);
72 void scroll(bool on_off, ScrollMode mode);
73 void scroll(bool on_off);
74 void intensity(uint8_t intensity);
75
77 uint8_t printdigitf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
79 uint8_t printdigitf(const char *format, ...) __attribute__((format(printf, 2, 3)));
80
82 uint8_t printdigit(uint8_t pos, const char *str);
84 uint8_t printdigit(const char *str);
85
87 uint8_t strftimedigit(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime, 3, 0)));
88
90 uint8_t strftimedigit(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
91
93
94 protected:
95 void send_byte_(uint8_t a_register, uint8_t data);
96 void send_to_all_(uint8_t a_register, uint8_t data);
97 uint8_t orientation_180_();
98
99 uint8_t intensity_;
100 uint8_t num_chips_;
106 bool update_{false};
110 uint16_t old_buffer_size_ = 0;
112 bool invert_ = false;
114 uint8_t bckgrnd_ = 0x0;
115 std::vector<std::vector<uint8_t>> max_displaybuffer_;
117 uint16_t stepsleft_;
120};
121
122} // namespace esphome::max7219digit
BedjetMode mode
BedJet operating mode.
void void void void void void strftime(int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format, ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format format and print the result with the anchor point at [x,...
Definition display.cpp:709
void printf(int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format,...) __attribute__((format(printf
Evaluate the printf-format format and print the result with the anchor point at [x,...
Definition display.cpp:624
uint8_t uint8_t display::DisplayType get_display_type() override
void send_to_all_(uint8_t a_register, uint8_t data)
void set_num_chips(uint8_t num_chips)
void draw_absolute_pixel_internal(int x, int y, Color color) override
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.
void send64pixels(uint8_t chip, const uint8_t pixels[8])
void scroll(bool on_off, ScrollMode mode, uint16_t speed, uint16_t delay, uint16_t dwell)
void send_byte_(uint8_t a_register, uint8_t data)
void set_writer(max7219_writer_t &&writer)
void set_num_chip_lines(uint8_t num_chip_lines)
float get_setup_priority() const override
void set_intensity(uint8_t intensity)
void send_char(uint8_t chip, uint8_t data)
void set_chip_orientation(uint8_t rotate)
uint8_t num_chips_
Intensity of the display from 0 to 15 (most)
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.
void set_chip_lines_style(ChipLinesStyle chip_lines_style)
std::vector< std::vector< uint8_t > > max_displaybuffer_
The SPIDevice is what components using the SPI will create.
Definition spi.h:429
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:32
const char int const __FlashStringHelper * format
Definition log.h:74
size_t size_t pos
Definition helpers.h:1038
void HOT delay(uint32_t ms)
Definition hal.cpp:85
static void uint32_t
A more user-friendly version of struct tm from time.h.
Definition time.h:23
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6