mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
[TM1637] Let turn off the display (#6656)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
74fd52e05f
commit
6fe328ef2b
2 changed files with 3 additions and 1 deletions
|
@ -225,7 +225,7 @@ void TM1637Display::display() {
|
||||||
|
|
||||||
// Write display CTRL CMND + brightness
|
// Write display CTRL CMND + brightness
|
||||||
this->start_();
|
this->start_();
|
||||||
this->send_byte_(TM1637_CMD_CTRL + ((this->intensity_ & 0x7) | 0x08));
|
this->send_byte_(TM1637_CMD_CTRL + ((this->intensity_ & 0x7) | (this->on_ ? 0x08 : 0x00)));
|
||||||
this->stop_();
|
this->stop_();
|
||||||
}
|
}
|
||||||
bool TM1637Display::send_byte_(uint8_t b) {
|
bool TM1637Display::send_byte_(uint8_t b) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ class TM1637Display : public PollingComponent {
|
||||||
void set_intensity(uint8_t intensity) { this->intensity_ = intensity; }
|
void set_intensity(uint8_t intensity) { this->intensity_ = intensity; }
|
||||||
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
||||||
void set_length(uint8_t length) { this->length_ = length; }
|
void set_length(uint8_t length) { this->length_ = length; }
|
||||||
|
void set_on(bool on) { this->on_ = on; }
|
||||||
|
|
||||||
void display();
|
void display();
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ class TM1637Display : public PollingComponent {
|
||||||
uint8_t intensity_;
|
uint8_t intensity_;
|
||||||
uint8_t length_;
|
uint8_t length_;
|
||||||
bool inverted_;
|
bool inverted_;
|
||||||
|
bool on_{true};
|
||||||
optional<tm1637_writer_t> writer_{};
|
optional<tm1637_writer_t> writer_{};
|
||||||
uint8_t buffer_[6] = {0};
|
uint8_t buffer_[6] = {0};
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
|
|
Loading…
Reference in a new issue