FIX: double-buffer needs to take 'brightness' into account

This commit is contained in:
Patrick Haßel 2023-01-03 14:47:46 +01:00
parent 4c8068d2cf
commit a039947e13
2 changed files with 12 additions and 7 deletions

View File

@ -35,6 +35,8 @@ private:
Color *buffer = nullptr;
uint8_t brightness = 10;
public:
Display(uint8_t width, uint8_t height) :
@ -60,7 +62,6 @@ public:
void setup() {
leds.begin();
leds.setBrightness(8);
clear();
flush();
}
@ -73,12 +74,12 @@ public:
}
}
void setBrightness(uint8_t brightness) {
leds.setBrightness(brightness);
void setBrightness(uint8_t value) {
brightness = value;
}
uint8_t getBrightness() {
return leds.getBrightness();
uint8_t getBrightness() const {
return brightness;
}
void clear() {
@ -124,7 +125,11 @@ public:
if (buffer == nullptr) {
return;
}
buffer[index] = color;
buffer[index] = {
(uint8_t) (color.r * brightness >> 8),
(uint8_t) (color.g * brightness >> 8),
(uint8_t) (color.b * brightness >> 8)
};
}
private:

View File

@ -86,7 +86,7 @@ void web_brighter() {
}
void web_darker() {
setBrightness(max(1, display.getBrightness() - 10));
setBrightness(display.getBrightness() - 10);
redirect();
}