o Proper brightness clipping and documentation added.

This commit is contained in:
Henner Zeller 2015-08-15 11:55:07 +02:00
parent 55ff2662ba
commit cf252fbf4a
3 changed files with 8 additions and 2 deletions

View file

@ -85,6 +85,8 @@ public:
void set_luminance_correct(bool on);
bool luminance_correct() const;
// Set brightness in percent. 1%..100%.
// This will only affect newly set pixels.
void SetBrightness(uint8_t brightness);
uint8_t brightness();

View file

@ -43,7 +43,11 @@ public:
void set_luminance_correct(bool on) { do_luminance_correct_ = on; }
bool luminance_correct() const { return do_luminance_correct_; }
void SetBrightness(uint8_t brightness) { brightness_ = brightness; }
// Set brightness in percent; range=1..100
// This will only affect newly set pixels.
void SetBrightness(uint8_t b) {
brightness_ = (b <= 100 ? (b != 0 ? b : 1) : 100);
}
uint8_t brightness() { return brightness_; }
void DumpToMatrix(GPIO *io);

View file

@ -162,7 +162,7 @@ inline uint16_t Framebuffer::MapColor(uint8_t c) {
if (do_luminance_correct_) {
static uint16_t *luminance_lookup = CreateLuminanceCIE1931LookupTable();
return COLOR_OUT_BITS(luminance_lookup[c * 100 + brightness_ - 1]);
return COLOR_OUT_BITS(luminance_lookup[c * 100 + (brightness_ - 1)]);
} else {
// simple scale down the color value
c = c * brightness_ / 100;