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,
"Running setup");
32 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
33 std::vector<uint8_t> vec(1);
55 " Number of Chips: %u\n"
56 " Number of Chips Lines: %u\n"
57 " Chips Lines Style : %u\n"
65 LOG_PIN(
" CS Pin: ", this->
cs_);
66 LOG_UPDATE_INTERVAL(
this);
71 const uint32_t millis_since_last_scroll = now - this->
last_scroll_;
75 ESP_LOGV(TAG,
"Buffer size changed %d to %d", this->
old_buffer_size_, first_line_size);
82 ESP_LOGVV(TAG,
"Return if there is no need to scroll or scroll is off.");
88 ESP_LOGVV(TAG,
"At first step. Waiting for scroll delay");
96 ESP_LOGVV(TAG,
"Dwell time at end of string in case of stop at end. Step %d, since last scroll %d, dwell %d.",
97 this->
stepsleft_, millis_since_last_scroll, this->scroll_dwell_);
100 ESP_LOGV(TAG,
"Dwell time passed. Continue scrolling.");
105 ESP_LOGVV(TAG,
"Call to scroll left action");
106 this->last_scroll_ = now;
119 for (uint8_t chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
120 for (uint8_t j = 0; j < 8; j++) {
162 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
186 for (uint8_t i = 0; i < this->
num_chips_; i++)
192 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
232 for (
int chip_line = 0; chip_line < this->
num_chip_lines_; chip_line++) {
233 auto scroll = [&](std::vector<uint8_t> &
line, uint16_t steps) {
234 std::rotate(
line.begin(), std::next(
line.begin(), steps),
line.end());
251 for (uint8_t i = 0; i < 8; i++)
258 for (uint8_t col = 0; col < 8; col++) {
260 for (uint8_t i = 0; i < chip; i++) {
262 MAX7219_REGISTER_NOOP);
266 for (uint8_t i = 0; i < 8; i++) {
269 b |= ((pixels[i] >> col) & 1) << i;
271 b |= ((pixels[i] >> col) & 1) << (7 - i);
277 for (uint8_t i = 0; i < 8; i++) {
279 b |= ((pixels[i] >> (7 - col)) & 1) << (7 - i);
281 b |= ((pixels[i] >> (7 - col)) & 1) << i;
285 for (uint8_t i = 0; i < 8; i++) {
286 b |= ((pixels[7 - col] >> i) & 1) << (7 - i);
295 for (
int i = 0; i < this->
num_chips_ - chip - 1; i++)
296 this->
send_byte_(MAX7219_REGISTER_NOOP, MAX7219_REGISTER_NOOP);
304 uint8_t chip = start_pos;
315 va_start(arg, format);
317 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
325 va_start(arg, format);
327 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
336 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.