mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Add get_contrast() and get_brightness() to SSD1306 class to get protected variables (#6435)
This commit is contained in:
parent
0948a3c306
commit
58de8a4ee6
2 changed files with 4 additions and 0 deletions
|
@ -236,6 +236,7 @@ void SSD1306::set_invert(bool invert) {
|
|||
// Inverse display mode (0xA6, 0xA7)
|
||||
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
|
||||
}
|
||||
float SSD1306::get_contrast() { return this->contrast_; };
|
||||
void SSD1306::set_contrast(float contrast) {
|
||||
// validation
|
||||
this->contrast_ = clamp(contrast, 0.0F, 1.0F);
|
||||
|
@ -243,6 +244,7 @@ void SSD1306::set_contrast(float contrast) {
|
|||
this->command(SSD1306_COMMAND_SET_CONTRAST);
|
||||
this->command(int(SSD1306_MAX_CONTRAST * (this->contrast_)));
|
||||
}
|
||||
float SSD1306::get_brightness() { return this->brightness_; };
|
||||
void SSD1306::set_brightness(float brightness) {
|
||||
// validation
|
||||
if (!this->is_ssd1305_())
|
||||
|
|
|
@ -36,7 +36,9 @@ class SSD1306 : public display::DisplayBuffer {
|
|||
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
|
||||
void set_external_vcc(bool external_vcc) { this->external_vcc_ = external_vcc; }
|
||||
void init_contrast(float contrast) { this->contrast_ = contrast; }
|
||||
float get_contrast();
|
||||
void set_contrast(float contrast);
|
||||
float get_brightness();
|
||||
void init_brightness(float brightness) { this->brightness_ = brightness; }
|
||||
void set_brightness(float brightness);
|
||||
void init_flip_x(bool flip_x) { this->flip_x_ = flip_x; }
|
||||
|
|
Loading…
Reference in a new issue