Skip to content

Commit

Permalink
clamp Brightness at 1.0F to prevent Brightness overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzuger committed Mar 22, 2020
1 parent 86ae007 commit 3d7a876
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tlc5947/tlc5947.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ static bool pattern_do_tick(tlc5947_tlc5947_obj_t* self, pattern_base_t* pattern
case pBRIGHTNESS:{ // change overall brightness
tprintf("pBRIGHTNESS\n\r");
hsv c = rgbtohsv(rgb12torgb(pattern->color));
c.v += p->brighness.brightness;
float new = c.v + p->brighness.brightness;
c.v = new <= 1.0F ? new : 1.0F;
pattern->color = rgbtorgb12(hsvtorgb(c));
self->data.changed = true;
pattern->current++;
Expand Down

0 comments on commit 3d7a876

Please sign in to comment.