From 4f2e2fa297070e4d7f55a37175359f4d8f74c0f0 Mon Sep 17 00:00:00 2001 From: buxtronix Date: Sat, 2 May 2020 09:05:09 +1000 Subject: [PATCH] Some max7219 updates. (#1021) * Some max7219 updates. Disable test mode on startup and allow dynamic brightness * fix formatting --- esphome/components/max7219/max7219.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/max7219/max7219.cpp b/esphome/components/max7219/max7219.cpp index 6616da1a58..99eca6c14f 100644 --- a/esphome/components/max7219/max7219.cpp +++ b/esphome/components/max7219/max7219.cpp @@ -12,6 +12,7 @@ static const uint8_t MAX7219_REGISTER_DECODE_MODE = 0x09; static const uint8_t MAX7219_REGISTER_INTENSITY = 0x0A; static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B; static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C; +static const uint8_t MAX7219_REGISTER_TEST = 0x0F; static const uint8_t MAX7219_UNKNOWN_CHAR = 0b11111111; const uint8_t MAX7219_ASCII_TO_RAW[95] PROGMEM = { @@ -127,6 +128,7 @@ void MAX7219Component::setup() { this->send_to_all_(MAX7219_REGISTER_INTENSITY, this->intensity_); this->display(); // power up + this->send_to_all_(MAX7219_REGISTER_TEST, 0); this->send_to_all_(MAX7219_REGISTER_SHUTDOWN, 1); } void MAX7219Component::dump_config() { @@ -210,7 +212,10 @@ uint8_t MAX7219Component::printf(const char *format, ...) { return 0; } void MAX7219Component::set_writer(max7219_writer_t &&writer) { this->writer_ = writer; } -void MAX7219Component::set_intensity(uint8_t intensity) { this->intensity_ = intensity; } +void MAX7219Component::set_intensity(uint8_t intensity) { + this->intensity_ = intensity; + this->send_to_all_(MAX7219_REGISTER_INTENSITY, this->intensity_); +} void MAX7219Component::set_num_chips(uint8_t num_chips) { this->num_chips_ = num_chips; } #ifdef USE_TIME