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; Color *buffer = nullptr;
uint8_t brightness = 10;
public: public:
Display(uint8_t width, uint8_t height) : Display(uint8_t width, uint8_t height) :
@ -60,7 +62,6 @@ public:
void setup() { void setup() {
leds.begin(); leds.begin();
leds.setBrightness(8);
clear(); clear();
flush(); flush();
} }
@ -73,12 +74,12 @@ public:
} }
} }
void setBrightness(uint8_t brightness) { void setBrightness(uint8_t value) {
leds.setBrightness(brightness); brightness = value;
} }
uint8_t getBrightness() { uint8_t getBrightness() const {
return leds.getBrightness(); return brightness;
} }
void clear() { void clear() {
@ -124,7 +125,11 @@ public:
if (buffer == nullptr) { if (buffer == nullptr) {
return; 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: private:

View File

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