marmil

RGB value test

Nov 30th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. You can test and see if a pixel is black (off) like this:
  2.  
  3. if ( leds[i] ) {
  4.   // it has a R,G, and/or B value and is not black
  5. } else {
  6.   // it is black (off)
  7. }
  8.  
  9.  
  10. You can also do something like this:
  11.  
  12. // fade leds above RGB brightness 32
  13. for (uint8_t i = 0; i < NUM_LEDS; i++) {
  14.   if ( leds[i].r > 32 ) { leds[i].r--; }
  15.   if ( leds[i].g > 32 ) { leds[i].g--; }
  16.   if ( leds[i].b > 32 ) { leds[i].b--; }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment