![]() However, working with raw RGB values in your code can be awkward in some cases. By mixing different amounts of red, green, and blue, thousands or millions of resultant colors can be displayed. Setting HSV Colors Introduction to HSVĬRGB color objects use separate red, green, and blue channels internally to represent each composite color, as this is exactly the same way that multicolor LEDs do it: they have one red LED, one green LED, and one blue LED in each 'pixel'. Performance-minded programmers using AVR/ATmega MCUs to move large number of colors in this way may wish to use the alternative "memmove8" library function, as it is measurably faster than the standard libc "memmove". Memmove( &leds, &leds, 10 * sizeof( CRGB) ) The two pieces of code below perform the exact same function. In addition, CRGB colors can be set a number of other ways which are often more convenient and compact. ![]() Setting RGB ColorsĬRGB colors can be set by assigning values to the individual red, green, and blue channels. Often using the class methods described here is faster and smaller than hand-written C/C++ code to achieve the same thing. In addition to simply providing data storage for the RGB colors of each LED pixel, the CRGB class also provides several useful methods color-manipulation, some of which are implemented in assembly language for speed and compactness. The CRGB object "is trivially copyable", meaning that it can be copied from one place in memory to another and still function normally. This is a bit unusual for a C++ class, but in a microcontroller environment this can be critical to maintain performance. All of the methods on the CRGB class expect this, and will continue to operate normally. That is to say, there is no "CRGB::setRed( myRedValue )" method instead you just directly store 'myRedValue' into the ".red" data member on the object. You are welcome, and invited, to directly access the underlying memory of this object if that suits your needs. ![]() or, using the shorter synonyms "r", "g", and "b". The three color channel values can be referred to as "red", "green", and "blue".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |