mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Add Invert method for SSD1306 (#5292)
This commit is contained in:
parent
f814b6d47c
commit
11ed2d5f18
2 changed files with 8 additions and 1 deletions
|
@ -132,7 +132,7 @@ void SSD1306::setup() {
|
|||
this->command(SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME);
|
||||
|
||||
// Inverse display mode (0xA6, 0xA7)
|
||||
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
|
||||
this->set_invert(this->invert_);
|
||||
|
||||
// Disable scrolling mode (0x2E)
|
||||
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
||||
|
@ -190,6 +190,12 @@ void SSD1306::update() {
|
|||
this->do_update_();
|
||||
this->display();
|
||||
}
|
||||
|
||||
void SSD1306::set_invert(bool invert) {
|
||||
this->invert_ = invert;
|
||||
// Inverse display mode (0xA6, 0xA7)
|
||||
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
|
||||
}
|
||||
void SSD1306::set_contrast(float contrast) {
|
||||
// validation
|
||||
this->contrast_ = clamp(contrast, 0.0F, 1.0F);
|
||||
|
|
|
@ -43,6 +43,7 @@ class SSD1306 : public PollingComponent, public display::DisplayBuffer {
|
|||
void init_offset_x(uint8_t offset_x) { this->offset_x_ = offset_x; }
|
||||
void init_offset_y(uint8_t offset_y) { this->offset_y_ = offset_y; }
|
||||
void init_invert(bool invert) { this->invert_ = invert; }
|
||||
void set_invert(bool invert);
|
||||
bool is_on();
|
||||
void turn_on();
|
||||
void turn_off();
|
||||
|
|
Loading…
Reference in a new issue