Skip to content

Commit

Permalink
Performing type cast before shift prevents type overflow. (#15)
Browse files Browse the repository at this point in the history
This fixes #14.
  • Loading branch information
aentinger committed Jan 8, 2024
1 parent 94b627b commit 653bdca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Arduino_APA102.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Arduino_APA102 {


uint32_t Color(uint8_t newRed, uint8_t newGreen, uint8_t newBlue) {
return (uint32_t)(newRed << 16 | newGreen << 8 | newBlue);
return (uint32_t)(((uint32_t)newRed) << 16 | ((uint32_t)newGreen) << 8 | newBlue);
}

uint16_t getLeds(){
Expand All @@ -67,4 +67,4 @@ class Arduino_APA102 {

};

#endif
#endif

0 comments on commit 653bdca

Please sign in to comment.