| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
A quick overview of the FastLED library and the various pieces/components of it
In addition, there is API level documentation at http://fastled.io/docs
The core of the library is providing support to a number of LED chipsets that are out there.
(See the [chipset reference] wiki page for a more complete list with more information on each chip)
SPI based chipsets are usually 4 wires - data, clock, power, and ground. The advantage to these led chipsets is they can be cheap, the SPI data protocol does well over distance, and with some chipsets, you can get really high data transfer rates.
Three wire led pixels are becoming quite popular. Having only data, ground, and power lines, they're a bit more compact than the SPI based chipsets (even further, the WS2812B's combine the led controller chip and the led in a single package!).
Of course, progress always marches forward, and there's a variety of new led chipsets on the horizon for the library to support. Here's a taste of what's coming:
The older version of this library, FastSPI_LED, supported a number of chipsets that required work on the host MCU to manage PWM. For a combination of reasons, including these chipsets going away, as well as a desire to get away from having the library rely on timer based code, those chipsets are no longer supported:
One of the goals of this version of the library is to lay the groundwork for making it more easily portable to a wide variety of platforms. At the moment, the library has only been tested and is known to work with AVR and ARM based MCUs that are nominally arduino-compatable. Namely, if the code is built/pushed using some variation of the Arduino application with stock compilers, the library should work. Future versions of the library will support a wider range of platforms and compilers.
Some upcoming platforms:
How easy is the library to use? Here's a quick example providing some blinking code:
#include "FastLED.h"
CRGB leds[1];
void setup() { FastLED.addLeds<NEOPIXEL, 6>(leds, 1); }
void loop() {
leds[0] = CRGB::White; FastLED.show(); delay(30);
leds[0] = CRGB::Black; FastLED.show(); delay(30);
}Unsatisfied with the state of a lot of the HSV and color wheel libraries, we put a lot of work into providing an HSV to RGB conversion library that is fast and adjusted for human color perception. Why use the HSV color space? It's a bit easier to navigate and provide transitions between colors than using RGB. When defining colors with RGB you're mixing the Red, Green, and Blue color values. When using HSV, instead, you're defining the hue of the color (that is, where it is on the color wheel), how saturated it is, and how bright it is. For example, here's some simple code that will cycle through the colors of a rainbow:
#include "FastLED.h"
CRGB leds[60];
void setup() { FastLED.addLeds<NEOPIXEL, 6>(leds, 60); }
void loop() {
static uint8_t hue = 0;
FastLED.showColor(CHSV(hue++, 255, 255));
delay(10);
}When doing LED programming, a lot of times you want to do math on the rgb or hsv values to help provide your transitions in brightness and color. However, the AVR/arduino platform isn't exactly known for the fastest math out there. To help out with this, the library provides a number of math functions tuned for 8-bit operations, including scaling functions, fast sin/cos functions, fast random number generators, and interpolation and memory management functions.
Finally, to do a lot of the magic in writing to LEDs, the library has some generalized classes to provide high speed, flexible access to pins and SPI hardware. While write only at the moment, this code can help you access pins and devices quicker than the stock arduino libraries do, even moreso once read support is added to the pin and spi libraries.
| Back | FazBrowse Home | New Git URL |