Introduce clamp as a template function (#1953)

This commit is contained in:
Stefan Agner
2021-07-14 07:08:18 +02:00
committed by GitHub
parent 08b67e7aea
commit 5cb0c11feb
13 changed files with 17 additions and 14 deletions
@@ -130,7 +130,7 @@ void SSD1306::update() {
}
void SSD1306::set_brightness(float brightness) {
// validation
this->brightness_ = clamp(brightness, 0, 1);
this->brightness_ = clamp(brightness, 0.0F, 1.0F);
// now write the new brightness level to the display
this->command(SSD1306_COMMAND_SET_CONTRAST);
this->command(int(SSD1306_MAX_CONTRAST * (this->brightness_)));