setBrightness safe handling + return

This commit is contained in:
Patrick Haßel 2025-01-27 14:47:37 +01:00
parent d498cd12b4
commit 2b80b1d671
2 changed files with 7 additions and 7 deletions

View File

@ -19,8 +19,7 @@ public:
void setup() override {
config.read();
display.setup();
display.setBrightness(6);
display.setup(10);
display.clear();
display.printf(1, 1, LEFT, Blue, "Test");
display.drawLine(0, 7, 32, 0, 1, Red);

View File

@ -58,9 +58,9 @@ public:
// basic ----------------------------------------------------------------------------------------
void setup() {
void setup(const int brightness) {
leds.begin();
leds.setBrightness(10);
setBrightness(brightness);
clear();
}
@ -78,11 +78,13 @@ public:
}
}
void setBrightness(const uint8_t brightness) {
uint8_t setBrightness(int brightness) {
brightness = max(0, min(brightness, 255));
if (leds.getBrightness() != brightness) {
leds.setBrightness(brightness);
dirty = true;
}
return brightness;
}
uint8_t getBrightness() const {
@ -176,8 +178,7 @@ public:
} else if (align == CENTER) {
x = x - w / 2;
}
} else {
}
} else {}
}
void measure(const char *message, int& w, int& h) {