mirror of
https://github.com/Hopiu/rpi-rgb-led-matrix.git
synced 2026-03-16 22:10:27 +00:00
o Proper brightness clipping and documentation added.
This commit is contained in:
parent
55ff2662ba
commit
cf252fbf4a
3 changed files with 8 additions and 2 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue