[ssd1351] fix: wait for the component to be at least in setup phase b… (#5454)

This commit is contained in:
De Cock Xavier 2023-09-30 00:08:56 +02:00 committed by GitHub
parent 2c94c3d96f
commit d3913be7e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,6 +112,9 @@ void SSD1351::set_brightness(float brightness) {
} else { } else {
this->brightness_ = brightness; this->brightness_ = brightness;
} }
if (!this->is_ready()) {
return; // Component is not yet setup skip the command
}
// now write the new brightness level to the display // now write the new brightness level to the display
this->command(SSD1351_CONTRASTMASTER); this->command(SSD1351_CONTRASTMASTER);
this->data(int(SSD1351_MAX_CONTRAST * (this->brightness_))); this->data(int(SSD1351_MAX_CONTRAST * (this->brightness_)));