![]() #define GREEN 10 // pin for green - never explicitly referenced don't futz with these, illicit sums later Note that there's some legacy code left in here which seems to do nothing This variant cycles through the HSV colour wheel, though at fixed saturations and values. If 'hue' were to run from 0-359, as with traditional HSV ranges, here's roughly what you'd have to do have a variable that cycles to a new hue each time through your main loop, stepping by an arbitrary amount each time, and wrapping around back to the start.Pretty much everyone tries the RGB colour cycler when they get their first Arduino. One of the big design decisions was to represent hue as a number from 0-255, rather than from 0-359 (or 0-95) here's a code example of how the FastLED hue range design (from 0-255) makes your animation code faster and more compact, just by keeping 'hue' down to a single full-range one-byte number. Why FastLED full-range one-byte hues are fasterĪnimations using FastLED HSV colors are often be much, much faster than traditional HSV code, because FastLED HSV code has been designed explicitly for microcontroller environments where every byte and every cycle counts. The Red, Green, and Blue components of each color, shown below the color mix.The mixed color itself, rendered in such a way that it 'looks about right' on a computer monitor, despite the fact that in practice the color will be generated by a set of independent LEDs.All things being equal, the human eye is most sensitive to green. The top grayscale bar is the Luminance (Y) of each color: Luminance is Radiance weighted by the sensitivity of the human eye to each component of the light, and represents the apparent brightness of each color, more or less.In the Rainbow color map, rendering yellow takes a little bit more power than other colors, but otherwise the power usage and radiance curves are absolutely flat. The FastLED color maps have extremely uniform radiance across the entire color map, and a correspondingly uniform power consumption across colors. ![]() The bottom grayscale bar is the Radiance of each color: the total amount of light emitted.These charts show several things about each part of the color map: Here is the "Spectrum" color map that FastLED provides if you call hsv2rgb_spectrum explicitly: Here is the "Rainbow" color map that FastLED uses for everything by default: (Wikipedia has further discussion about the nature of spectrum-vs-rainbow: ) Traditional 'spectrum' HSV color maps have much narrower bands of yellow, and the yellow can also appear muddy. ![]() The 'rainbow' color map provides more evenly-spaced color bands, including a band of 'yellow' which is the same width as other colors, and which has an appropriately high inherent brightness. However, by default FastLED uses a 'rainbow' color map instead of a spectrum. Traditional computer HSV color models use a 'spectrum' color map, and FastLED does offer an "hsv2rgb_spectrum" function. The performance implications are discussed further below, but suffice it to say that it's faster this way. Accordingly, to make your code smaller, faster, and more efficient, the FastLED library uses simple one-byte values (from 0-255) for hue, and for saturation, and for value. But neither "360" nor "100" is a particularly computer-native number, and there's no strong reason to use 'degrees' to represent hue, nor 'percentages' to represent saturation or value they're all pretty much arbitrary scales. Saturation and value are often represented as numbers (percentages) from 0-100. In 'traditional' computer HSV color models, hue is represented as a number (of degrees) from 0-360. Numeric range differences: everything here is 0-255 The FastLED Hue-Saturation-Value color model differs from 'traditional' computer HSV color models in two important respects: first is differences in the numeric range of values used to represent colors (everything here is a one-byte value from 0-255), and second is in the mapping of hue numbers to colors themselves (FastLED defaults to using a richer 'rainbow' color map, instead of the traditional 'spectrum' color mapping).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |