File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -494,11 +494,14 @@ namespace pimoroni {
494
494
void CosmicUnicorn::set_brightness (float value) {
495
495
value = value < 0 .0f ? 0 .0f : value;
496
496
value = value > 1 .0f ? 1 .0f : value;
497
+ // Max brightness is - in fact - 256 since it's applied with:
498
+ // result = (channel * brightness) >> 8
499
+ // eg: (255 * 256) >> 8 == 255
497
500
this ->brightness = floor (value * 256 .0f );
498
501
}
499
502
500
503
float CosmicUnicorn::get_brightness () {
501
- return this ->brightness / 255 .0f ;
504
+ return this ->brightness / 256 .0f ;
502
505
}
503
506
504
507
void CosmicUnicorn::adjust_brightness (float delta) {
Original file line number Diff line number Diff line change @@ -488,11 +488,14 @@ namespace pimoroni {
488
488
void GalacticUnicorn::set_brightness (float value) {
489
489
value = value < 0 .0f ? 0 .0f : value;
490
490
value = value > 1 .0f ? 1 .0f : value;
491
+ // Max brightness is - in fact - 256 since it's applied with:
492
+ // result = (channel * brightness) >> 8
493
+ // eg: (255 * 256) >> 8 == 255
491
494
this ->brightness = floor (value * 256 .0f );
492
495
}
493
496
494
497
float GalacticUnicorn::get_brightness () {
495
- return this ->brightness / 255 .0f ;
498
+ return this ->brightness / 256 .0f ;
496
499
}
497
500
498
501
void GalacticUnicorn::adjust_brightness (float delta) {
Original file line number Diff line number Diff line change @@ -485,11 +485,14 @@ namespace pimoroni {
485
485
void StellarUnicorn::set_brightness (float value) {
486
486
value = value < 0 .0f ? 0 .0f : value;
487
487
value = value > 1 .0f ? 1 .0f : value;
488
+ // Max brightness is - in fact - 256 since it's applied with:
489
+ // result = (channel * brightness) >> 8
490
+ // eg: (255 * 256) >> 8 == 255
488
491
this ->brightness = floor (value * 256 .0f );
489
492
}
490
493
491
494
float StellarUnicorn::get_brightness () {
492
- return this ->brightness / 255 .0f ;
495
+ return this ->brightness / 256 .0f ;
493
496
}
494
497
495
498
void StellarUnicorn::adjust_brightness (float delta) {
You can’t perform that action at this time.
0 commit comments