Add get_contrast() and get_brightness() to SSD1306 class to get protected variables (#6435)

This commit is contained in:
Ben Kristinsson 2024-03-27 02:13:41 +01:00 committed by GitHub
parent 0948a3c306
commit 58de8a4ee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -236,6 +236,7 @@ void SSD1306::set_invert(bool invert) {
// Inverse display mode (0xA6, 0xA7) // Inverse display mode (0xA6, 0xA7)
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_); this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
} }
float SSD1306::get_contrast() { return this->contrast_; };
void SSD1306::set_contrast(float contrast) { void SSD1306::set_contrast(float contrast) {
// validation // validation
this->contrast_ = clamp(contrast, 0.0F, 1.0F); 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(SSD1306_COMMAND_SET_CONTRAST);
this->command(int(SSD1306_MAX_CONTRAST * (this->contrast_))); this->command(int(SSD1306_MAX_CONTRAST * (this->contrast_)));
} }
float SSD1306::get_brightness() { return this->brightness_; };
void SSD1306::set_brightness(float brightness) { void SSD1306::set_brightness(float brightness) {
// validation // validation
if (!this->is_ssd1305_()) if (!this->is_ssd1305_())

View file

@ -36,7 +36,9 @@ class SSD1306 : public display::DisplayBuffer {
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; } 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 set_external_vcc(bool external_vcc) { this->external_vcc_ = external_vcc; }
void init_contrast(float contrast) { this->contrast_ = contrast; } void init_contrast(float contrast) { this->contrast_ = contrast; }
float get_contrast();
void set_contrast(float contrast); void set_contrast(float contrast);
float get_brightness();
void init_brightness(float brightness) { this->brightness_ = brightness; } void init_brightness(float brightness) { this->brightness_ = brightness; }
void set_brightness(float brightness); void set_brightness(float brightness);
void init_flip_x(bool flip_x) { this->flip_x_ = flip_x; } void init_flip_x(bool flip_x) { this->flip_x_ = flip_x; }