Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AlexGyver/Arduino_Ambilight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <beragumbo@ya.ru>2017-09-03 00:37:36 +0300
committerAlex <beragumbo@ya.ru>2017-09-03 00:37:36 +0300
commite9e091ba628994af5f75c27f76becf5d26cba33e (patch)
tree398e7c857a0a8d7850af5310a826a3261886030c /Библиотеки/FastLED-master/examples
parent24c7f7bfe652daee35173de5585f8ae28e1d6040 (diff)
added
Diffstat (limited to 'Библиотеки/FastLED-master/examples')
-rw-r--r--Библиотеки/FastLED-master/examples/AnalogOutput/AnalogOutput.ino65
-rw-r--r--Библиотеки/FastLED-master/examples/Blink/Blink.ino54
-rw-r--r--Библиотеки/FastLED-master/examples/ColorPalette/ColorPalette.ino188
-rw-r--r--Библиотеки/FastLED-master/examples/ColorTemperature/ColorTemperature.ino85
-rw-r--r--Библиотеки/FastLED-master/examples/Cylon/Cylon.ino53
-rw-r--r--Библиотеки/FastLED-master/examples/DemoReel100/DemoReel100.ino126
-rw-r--r--Библиотеки/FastLED-master/examples/Fire2012/Fire2012.ino105
-rw-r--r--Библиотеки/FastLED-master/examples/Fire2012WithPalette/Fire2012WithPalette.ino164
-rw-r--r--Библиотеки/FastLED-master/examples/FirstLight/FirstLight.ino78
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino37
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/MirroringSample/MirroringSample.ino44
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/MultiArrays/MultiArrays.ino52
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino34
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino37
-rw-r--r--Библиотеки/FastLED-master/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino47
-rw-r--r--Библиотеки/FastLED-master/examples/Noise/Noise.ino112
-rw-r--r--Библиотеки/FastLED-master/examples/NoisePlayground/NoisePlayground.ino73
-rw-r--r--Библиотеки/FastLED-master/examples/NoisePlusPalette/NoisePlusPalette.ino273
-rw-r--r--Библиотеки/FastLED-master/examples/Pintest/Pintest.ino105
-rw-r--r--Библиотеки/FastLED-master/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino136
-rw-r--r--Библиотеки/FastLED-master/examples/RGBCalibrate/RGBCalibrate.ino70
-rw-r--r--Библиотеки/FastLED-master/examples/RGBSetDemo/RGBSetDemo.ino22
-rw-r--r--Библиотеки/FastLED-master/examples/SmartMatrix/SmartMatrix.ino121
-rw-r--r--Библиотеки/FastLED-master/examples/XYMatrix/XYMatrix.ino196
24 files changed, 2277 insertions, 0 deletions
diff --git a/Библиотеки/FastLED-master/examples/AnalogOutput/AnalogOutput.ino b/Библиотеки/FastLED-master/examples/AnalogOutput/AnalogOutput.ino
new file mode 100644
index 0000000..3373310
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/AnalogOutput/AnalogOutput.ino
@@ -0,0 +1,65 @@
+#include <FastLED.h>
+
+// Example showing how to use FastLED color functions
+// even when you're NOT using a "pixel-addressible" smart LED strip.
+//
+// This example is designed to control an "analog" RGB LED strip
+// (or a single RGB LED) being driven by Arduino PWM output pins.
+// So this code never calls FastLED.addLEDs() or FastLED.show().
+//
+// This example illustrates one way you can use just the portions
+// of FastLED that you need. In this case, this code uses just the
+// fast HSV color conversion code.
+//
+// In this example, the RGB values are output on three separate
+// 'analog' PWM pins, one for red, one for green, and one for blue.
+
+#define REDPIN 5
+#define GREENPIN 6
+#define BLUEPIN 3
+
+// showAnalogRGB: this is like FastLED.show(), but outputs on
+// analog PWM output pins instead of sending data to an intelligent,
+// pixel-addressable LED strip.
+//
+// This function takes the incoming RGB values and outputs the values
+// on three analog PWM output pins to the r, g, and b values respectively.
+void showAnalogRGB( const CRGB& rgb)
+{
+ analogWrite(REDPIN, rgb.r );
+ analogWrite(GREENPIN, rgb.g );
+ analogWrite(BLUEPIN, rgb.b );
+}
+
+
+
+// colorBars: flashes Red, then Green, then Blue, then Black.
+// Helpful for diagnosing if you've mis-wired which is which.
+void colorBars()
+{
+ showAnalogRGB( CRGB::Red ); delay(500);
+ showAnalogRGB( CRGB::Green ); delay(500);
+ showAnalogRGB( CRGB::Blue ); delay(500);
+ showAnalogRGB( CRGB::Black ); delay(500);
+}
+
+void loop()
+{
+ static uint8_t hue;
+ hue = hue + 1;
+ // Use FastLED automatic HSV->RGB conversion
+ showAnalogRGB( CHSV( hue, 255, 255) );
+
+ delay(20);
+}
+
+
+void setup() {
+ pinMode(REDPIN, OUTPUT);
+ pinMode(GREENPIN, OUTPUT);
+ pinMode(BLUEPIN, OUTPUT);
+
+ // Flash the "hello" color sequence: R, G, B, black.
+ colorBars();
+}
+
diff --git a/Библиотеки/FastLED-master/examples/Blink/Blink.ino b/Библиотеки/FastLED-master/examples/Blink/Blink.ino
new file mode 100644
index 0000000..95eb6cb
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Blink/Blink.ino
@@ -0,0 +1,54 @@
+#include "FastLED.h"
+
+// How many leds in your strip?
+#define NUM_LEDS 1
+
+// For led chips like Neopixels, which have a data line, ground, and power, you just
+// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
+// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
+#define DATA_PIN 3
+#define CLOCK_PIN 13
+
+// Define the array of leds
+CRGB leds[NUM_LEDS];
+
+void setup() {
+ // Uncomment/edit one of the following lines for your leds arrangement.
+ // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
+ FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+}
+
+void loop() {
+ // Turn the LED on, then pause
+ leds[0] = CRGB::Red;
+ FastLED.show();
+ delay(500);
+ // Now turn the LED off, then pause
+ leds[0] = CRGB::Black;
+ FastLED.show();
+ delay(500);
+}
diff --git a/Библиотеки/FastLED-master/examples/ColorPalette/ColorPalette.ino b/Библиотеки/FastLED-master/examples/ColorPalette/ColorPalette.ino
new file mode 100644
index 0000000..0fdfb59
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/ColorPalette/ColorPalette.ino
@@ -0,0 +1,188 @@
+#include <FastLED.h>
+
+#define LED_PIN 5
+#define NUM_LEDS 50
+#define BRIGHTNESS 64
+#define LED_TYPE WS2811
+#define COLOR_ORDER GRB
+CRGB leds[NUM_LEDS];
+
+#define UPDATES_PER_SECOND 100
+
+// This example shows several ways to set up and use 'palettes' of colors
+// with FastLED.
+//
+// These compact palettes provide an easy way to re-colorize your
+// animation on the fly, quickly, easily, and with low overhead.
+//
+// USING palettes is MUCH simpler in practice than in theory, so first just
+// run this sketch, and watch the pretty lights as you then read through
+// the code. Although this sketch has eight (or more) different color schemes,
+// the entire sketch compiles down to about 6.5K on AVR.
+//
+// FastLED provides a few pre-configured color palettes, and makes it
+// extremely easy to make up your own color schemes with palettes.
+//
+// Some notes on the more abstract 'theory and practice' of
+// FastLED compact palettes are at the bottom of this file.
+
+
+
+CRGBPalette16 currentPalette;
+TBlendType currentBlending;
+
+extern CRGBPalette16 myRedWhiteBluePalette;
+extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
+
+
+void setup() {
+ delay( 3000 ); // power-up safety delay
+ FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
+ FastLED.setBrightness( BRIGHTNESS );
+
+ currentPalette = RainbowColors_p;
+ currentBlending = LINEARBLEND;
+}
+
+
+void loop()
+{
+ ChangePalettePeriodically();
+
+ static uint8_t startIndex = 0;
+ startIndex = startIndex + 1; /* motion speed */
+
+ FillLEDsFromPaletteColors( startIndex);
+
+ FastLED.show();
+ FastLED.delay(1000 / UPDATES_PER_SECOND);
+}
+
+void FillLEDsFromPaletteColors( uint8_t colorIndex)
+{
+ uint8_t brightness = 255;
+
+ for( int i = 0; i < NUM_LEDS; i++) {
+ leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
+ colorIndex += 3;
+ }
+}
+
+
+// There are several different palettes of colors demonstrated here.
+//
+// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
+// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
+//
+// Additionally, you can manually define your own color palettes, or you can write
+// code that creates color palettes on the fly. All are shown here.
+
+void ChangePalettePeriodically()
+{
+ uint8_t secondHand = (millis() / 1000) % 60;
+ static uint8_t lastSecond = 99;
+
+ if( lastSecond != secondHand) {
+ lastSecond = secondHand;
+ if( secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; }
+ if( secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }
+ if( secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; }
+ if( secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; }
+ if( secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; }
+ if( secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }
+ if( secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; }
+ if( secondHand == 40) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; }
+ if( secondHand == 45) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; }
+ if( secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }
+ if( secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
+ }
+}
+
+// This function fills the palette with totally random colors.
+void SetupTotallyRandomPalette()
+{
+ for( int i = 0; i < 16; i++) {
+ currentPalette[i] = CHSV( random8(), 255, random8());
+ }
+}
+
+// This function sets up a palette of black and white stripes,
+// using code. Since the palette is effectively an array of
+// sixteen CRGB colors, the various fill_* functions can be used
+// to set them up.
+void SetupBlackAndWhiteStripedPalette()
+{
+ // 'black out' all 16 palette entries...
+ fill_solid( currentPalette, 16, CRGB::Black);
+ // and set every fourth one to white.
+ currentPalette[0] = CRGB::White;
+ currentPalette[4] = CRGB::White;
+ currentPalette[8] = CRGB::White;
+ currentPalette[12] = CRGB::White;
+
+}
+
+// This function sets up a palette of purple and green stripes.
+void SetupPurpleAndGreenPalette()
+{
+ CRGB purple = CHSV( HUE_PURPLE, 255, 255);
+ CRGB green = CHSV( HUE_GREEN, 255, 255);
+ CRGB black = CRGB::Black;
+
+ currentPalette = CRGBPalette16(
+ green, green, black, black,
+ purple, purple, black, black,
+ green, green, black, black,
+ purple, purple, black, black );
+}
+
+
+// This example shows how to set up a static color palette
+// which is stored in PROGMEM (flash), which is almost always more
+// plentiful than RAM. A static PROGMEM palette like this
+// takes up 64 bytes of flash.
+const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
+{
+ CRGB::Red,
+ CRGB::Gray, // 'white' is too bright compared to red and blue
+ CRGB::Blue,
+ CRGB::Black,
+
+ CRGB::Red,
+ CRGB::Gray,
+ CRGB::Blue,
+ CRGB::Black,
+
+ CRGB::Red,
+ CRGB::Red,
+ CRGB::Gray,
+ CRGB::Gray,
+ CRGB::Blue,
+ CRGB::Blue,
+ CRGB::Black,
+ CRGB::Black
+};
+
+
+
+// Additionl notes on FastLED compact palettes:
+//
+// Normally, in computer graphics, the palette (or "color lookup table")
+// has 256 entries, each containing a specific 24-bit RGB color. You can then
+// index into the color palette using a simple 8-bit (one byte) value.
+// A 256-entry color palette takes up 768 bytes of RAM, which on Arduino
+// is quite possibly "too many" bytes.
+//
+// FastLED does offer traditional 256-element palettes, for setups that
+// can afford the 768-byte cost in RAM.
+//
+// However, FastLED also offers a compact alternative. FastLED offers
+// palettes that store 16 distinct entries, but can be accessed AS IF
+// they actually have 256 entries; this is accomplished by interpolating
+// between the 16 explicit entries to create fifteen intermediate palette
+// entries between each pair.
+//
+// So for example, if you set the first two explicit entries of a compact
+// palette to Green (0,255,0) and Blue (0,0,255), and then retrieved
+// the first sixteen entries from the virtual palette (of 256), you'd get
+// Green, followed by a smooth gradient from green-to-blue, and then Blue.
diff --git a/Библиотеки/FastLED-master/examples/ColorTemperature/ColorTemperature.ino b/Библиотеки/FastLED-master/examples/ColorTemperature/ColorTemperature.ino
new file mode 100644
index 0000000..66093e0
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/ColorTemperature/ColorTemperature.ino
@@ -0,0 +1,85 @@
+#include <FastLED.h>
+
+#define LED_PIN 3
+
+// Information about the LED strip itself
+#define NUM_LEDS 60
+#define CHIPSET WS2811
+#define COLOR_ORDER GRB
+CRGB leds[NUM_LEDS];
+
+#define BRIGHTNESS 128
+
+
+// FastLED v2.1 provides two color-management controls:
+// (1) color correction settings for each LED strip, and
+// (2) master control of the overall output 'color temperature'
+//
+// THIS EXAMPLE demonstrates the second, "color temperature" control.
+// It shows a simple rainbow animation first with one temperature profile,
+// and a few seconds later, with a different temperature profile.
+//
+// The first pixel of the strip will show the color temperature.
+//
+// HELPFUL HINTS for "seeing" the effect in this demo:
+// * Don't look directly at the LED pixels. Shine the LEDs aganst
+// a white wall, table, or piece of paper, and look at the reflected light.
+//
+// * If you watch it for a bit, and then walk away, and then come back
+// to it, you'll probably be able to "see" whether it's currently using
+// the 'redder' or the 'bluer' temperature profile, even not counting
+// the lowest 'indicator' pixel.
+//
+//
+// FastLED provides these pre-conigured incandescent color profiles:
+// Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc,
+// HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky,
+// FastLED provides these pre-configured gaseous-light color profiles:
+// WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent,
+// FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent,
+// MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium,
+// FastLED also provides an "Uncorrected temperature" profile
+// UncorrectedTemperature;
+
+#define TEMPERATURE_1 Tungsten100W
+#define TEMPERATURE_2 OvercastSky
+
+// How many seconds to show each temperature before switching
+#define DISPLAYTIME 20
+// How many seconds to show black between switches
+#define BLACKTIME 3
+
+void loop()
+{
+ // draw a generic, no-name rainbow
+ static uint8_t starthue = 0;
+ fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20);
+
+ // Choose which 'color temperature' profile to enable.
+ uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2);
+ if( secs < DISPLAYTIME) {
+ FastLED.setTemperature( TEMPERATURE_1 ); // first temperature
+ leds[0] = TEMPERATURE_1; // show indicator pixel
+ } else {
+ FastLED.setTemperature( TEMPERATURE_2 ); // second temperature
+ leds[0] = TEMPERATURE_2; // show indicator pixel
+ }
+
+ // Black out the LEDs for a few secnds between color changes
+ // to let the eyes and brains adjust
+ if( (secs % DISPLAYTIME) < BLACKTIME) {
+ memset8( leds, 0, NUM_LEDS * sizeof(CRGB));
+ }
+
+ FastLED.show();
+ FastLED.delay(8);
+}
+
+void setup() {
+ delay( 3000 ); // power-up safety delay
+ // It's important to set the color correction for your LED strip here,
+ // so that colors can be more accurately rendered through the 'temperature' profiles
+ FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
+ FastLED.setBrightness( BRIGHTNESS );
+}
+
diff --git a/Библиотеки/FastLED-master/examples/Cylon/Cylon.ino b/Библиотеки/FastLED-master/examples/Cylon/Cylon.ino
new file mode 100644
index 0000000..be02207
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Cylon/Cylon.ino
@@ -0,0 +1,53 @@
+#include "FastLED.h"
+
+// How many leds in your strip?
+#define NUM_LEDS 64
+
+// For led chips like Neopixels, which have a data line, ground, and power, you just
+// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
+// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
+#define DATA_PIN 7
+#define CLOCK_PIN 13
+
+// Define the array of leds
+CRGB leds[NUM_LEDS];
+
+void setup() {
+ Serial.begin(57600);
+ Serial.println("resetting");
+ LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
+ LEDS.setBrightness(84);
+}
+
+void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
+
+void loop() {
+ static uint8_t hue = 0;
+ Serial.print("x");
+ // First slide the led in one direction
+ for(int i = 0; i < NUM_LEDS; i++) {
+ // Set the i'th led to red
+ leds[i] = CHSV(hue++, 255, 255);
+ // Show the leds
+ FastLED.show();
+ // now that we've shown the leds, reset the i'th led to black
+ // leds[i] = CRGB::Black;
+ fadeall();
+ // Wait a little bit before we loop around and do it again
+ delay(10);
+ }
+ Serial.print("x");
+
+ // Now go in the other direction.
+ for(int i = (NUM_LEDS)-1; i >= 0; i--) {
+ // Set the i'th led to red
+ leds[i] = CHSV(hue++, 255, 255);
+ // Show the leds
+ FastLED.show();
+ // now that we've shown the leds, reset the i'th led to black
+ // leds[i] = CRGB::Black;
+ fadeall();
+ // Wait a little bit before we loop around and do it again
+ delay(10);
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/DemoReel100/DemoReel100.ino b/Библиотеки/FastLED-master/examples/DemoReel100/DemoReel100.ino
new file mode 100644
index 0000000..03534a9
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/DemoReel100/DemoReel100.ino
@@ -0,0 +1,126 @@
+#include "FastLED.h"
+
+FASTLED_USING_NAMESPACE
+
+// FastLED "100-lines-of-code" demo reel, showing just a few
+// of the kinds of animation patterns you can quickly and easily
+// compose using FastLED.
+//
+// This example also shows one easy way to define multiple
+// animations patterns and have them automatically rotate.
+//
+// -Mark Kriegsman, December 2014
+
+#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
+#warning "Requires FastLED 3.1 or later; check github for latest code."
+#endif
+
+#define DATA_PIN 3
+//#define CLK_PIN 4
+#define LED_TYPE WS2811
+#define COLOR_ORDER GRB
+#define NUM_LEDS 64
+CRGB leds[NUM_LEDS];
+
+#define BRIGHTNESS 96
+#define FRAMES_PER_SECOND 120
+
+void setup() {
+ delay(3000); // 3 second delay for recovery
+
+ // tell FastLED about the LED strip configuration
+ FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+ //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+
+ // set master brightness control
+ FastLED.setBrightness(BRIGHTNESS);
+}
+
+
+// List of patterns to cycle through. Each is defined as a separate function below.
+typedef void (*SimplePatternList[])();
+SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };
+
+uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
+uint8_t gHue = 0; // rotating "base color" used by many of the patterns
+
+void loop()
+{
+ // Call the current pattern function once, updating the 'leds' array
+ gPatterns[gCurrentPatternNumber]();
+
+ // send the 'leds' array out to the actual LED strip
+ FastLED.show();
+ // insert a delay to keep the framerate modest
+ FastLED.delay(1000/FRAMES_PER_SECOND);
+
+ // do some periodic updates
+ EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
+ EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
+}
+
+#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
+
+void nextPattern()
+{
+ // add one to the current pattern number, and wrap around at the end
+ gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
+}
+
+void rainbow()
+{
+ // FastLED's built-in rainbow generator
+ fill_rainbow( leds, NUM_LEDS, gHue, 7);
+}
+
+void rainbowWithGlitter()
+{
+ // built-in FastLED rainbow, plus some random sparkly glitter
+ rainbow();
+ addGlitter(80);
+}
+
+void addGlitter( fract8 chanceOfGlitter)
+{
+ if( random8() < chanceOfGlitter) {
+ leds[ random16(NUM_LEDS) ] += CRGB::White;
+ }
+}
+
+void confetti()
+{
+ // random colored speckles that blink in and fade smoothly
+ fadeToBlackBy( leds, NUM_LEDS, 10);
+ int pos = random16(NUM_LEDS);
+ leds[pos] += CHSV( gHue + random8(64), 200, 255);
+}
+
+void sinelon()
+{
+ // a colored dot sweeping back and forth, with fading trails
+ fadeToBlackBy( leds, NUM_LEDS, 20);
+ int pos = beatsin16( 13, 0, NUM_LEDS-1 );
+ leds[pos] += CHSV( gHue, 255, 192);
+}
+
+void bpm()
+{
+ // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
+ uint8_t BeatsPerMinute = 62;
+ CRGBPalette16 palette = PartyColors_p;
+ uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
+ for( int i = 0; i < NUM_LEDS; i++) { //9948
+ leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
+ }
+}
+
+void juggle() {
+ // eight colored dots, weaving in and out of sync with each other
+ fadeToBlackBy( leds, NUM_LEDS, 20);
+ byte dothue = 0;
+ for( int i = 0; i < 8; i++) {
+ leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
+ dothue += 32;
+ }
+}
+
diff --git a/Библиотеки/FastLED-master/examples/Fire2012/Fire2012.ino b/Библиотеки/FastLED-master/examples/Fire2012/Fire2012.ino
new file mode 100644
index 0000000..dec5cd7
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Fire2012/Fire2012.ino
@@ -0,0 +1,105 @@
+#include <FastLED.h>
+
+#define LED_PIN 5
+#define COLOR_ORDER GRB
+#define CHIPSET WS2811
+#define NUM_LEDS 30
+
+#define BRIGHTNESS 200
+#define FRAMES_PER_SECOND 60
+
+bool gReverseDirection = false;
+
+CRGB leds[NUM_LEDS];
+
+void setup() {
+ delay(3000); // sanity delay
+ FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
+ FastLED.setBrightness( BRIGHTNESS );
+}
+
+void loop()
+{
+ // Add entropy to random number generator; we use a lot of it.
+ // random16_add_entropy( random());
+
+ Fire2012(); // run simulation frame
+
+ FastLED.show(); // display this frame
+ FastLED.delay(1000 / FRAMES_PER_SECOND);
+}
+
+
+// Fire2012 by Mark Kriegsman, July 2012
+// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
+////
+// This basic one-dimensional 'fire' simulation works roughly as follows:
+// There's a underlying array of 'heat' cells, that model the temperature
+// at each point along the line. Every cycle through the simulation,
+// four steps are performed:
+// 1) All cells cool down a little bit, losing heat to the air
+// 2) The heat from each cell drifts 'up' and diffuses a little
+// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
+// 4) The heat from each cell is rendered as a color into the leds array
+// The heat-to-color mapping uses a black-body radiation approximation.
+//
+// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
+//
+// This simulation scales it self a bit depending on NUM_LEDS; it should look
+// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
+//
+// I recommend running this simulation at anywhere from 30-100 frames per second,
+// meaning an interframe delay of about 10-35 milliseconds.
+//
+// Looks best on a high-density LED setup (60+ pixels/meter).
+//
+//
+// There are two main parameters you can play with to control the look and
+// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
+// in step 3 above).
+//
+// COOLING: How much does the air cool as it rises?
+// Less cooling = taller flames. More cooling = shorter flames.
+// Default 50, suggested range 20-100
+#define COOLING 55
+
+// SPARKING: What chance (out of 255) is there that a new spark will be lit?
+// Higher chance = more roaring fire. Lower chance = more flickery fire.
+// Default 120, suggested range 50-200.
+#define SPARKING 120
+
+
+void Fire2012()
+{
+// Array of temperature readings at each simulation cell
+ static byte heat[NUM_LEDS];
+
+ // Step 1. Cool down every cell a little
+ for( int i = 0; i < NUM_LEDS; i++) {
+ heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
+ }
+
+ // Step 2. Heat from each cell drifts 'up' and diffuses a little
+ for( int k= NUM_LEDS - 1; k >= 2; k--) {
+ heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
+ }
+
+ // Step 3. Randomly ignite new 'sparks' of heat near the bottom
+ if( random8() < SPARKING ) {
+ int y = random8(7);
+ heat[y] = qadd8( heat[y], random8(160,255) );
+ }
+
+ // Step 4. Map from heat cells to LED colors
+ for( int j = 0; j < NUM_LEDS; j++) {
+ CRGB color = HeatColor( heat[j]);
+ int pixelnumber;
+ if( gReverseDirection ) {
+ pixelnumber = (NUM_LEDS-1) - j;
+ } else {
+ pixelnumber = j;
+ }
+ leds[pixelnumber] = color;
+ }
+}
+
diff --git a/Библиотеки/FastLED-master/examples/Fire2012WithPalette/Fire2012WithPalette.ino b/Библиотеки/FastLED-master/examples/Fire2012WithPalette/Fire2012WithPalette.ino
new file mode 100644
index 0000000..e65a87f
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Fire2012WithPalette/Fire2012WithPalette.ino
@@ -0,0 +1,164 @@
+#include <FastLED.h>
+
+#define LED_PIN 5
+#define COLOR_ORDER GRB
+#define CHIPSET WS2811
+#define NUM_LEDS 30
+
+#define BRIGHTNESS 200
+#define FRAMES_PER_SECOND 60
+
+bool gReverseDirection = false;
+
+CRGB leds[NUM_LEDS];
+
+// Fire2012 with programmable Color Palette
+//
+// This code is the same fire simulation as the original "Fire2012",
+// but each heat cell's temperature is translated to color through a FastLED
+// programmable color palette, instead of through the "HeatColor(...)" function.
+//
+// Four different static color palettes are provided here, plus one dynamic one.
+//
+// The three static ones are:
+// 1. the FastLED built-in HeatColors_p -- this is the default, and it looks
+// pretty much exactly like the original Fire2012.
+//
+// To use any of the other palettes below, just "uncomment" the corresponding code.
+//
+// 2. a gradient from black to red to yellow to white, which is
+// visually similar to the HeatColors_p, and helps to illustrate
+// what the 'heat colors' palette is actually doing,
+// 3. a similar gradient, but in blue colors rather than red ones,
+// i.e. from black to blue to aqua to white, which results in
+// an "icy blue" fire effect,
+// 4. a simplified three-step gradient, from black to red to white, just to show
+// that these gradients need not have four components; two or
+// three are possible, too, even if they don't look quite as nice for fire.
+//
+// The dynamic palette shows how you can change the basic 'hue' of the
+// color palette every time through the loop, producing "rainbow fire".
+
+CRGBPalette16 gPal;
+
+void setup() {
+ delay(3000); // sanity delay
+ FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
+ FastLED.setBrightness( BRIGHTNESS );
+
+ // This first palette is the basic 'black body radiation' colors,
+ // which run from black to red to bright yellow to white.
+ gPal = HeatColors_p;
+
+ // These are other ways to set up the color palette for the 'fire'.
+ // First, a gradient from black to red to yellow to white -- similar to HeatColors_p
+ // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White);
+
+ // Second, this palette is like the heat colors, but blue/aqua instead of red/yellow
+ // gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White);
+
+ // Third, here's a simpler, three-step gradient, from black to red to white
+ // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::White);
+
+}
+
+void loop()
+{
+ // Add entropy to random number generator; we use a lot of it.
+ random16_add_entropy( random());
+
+ // Fourth, the most sophisticated: this one sets up a new palette every
+ // time through the loop, based on a hue that changes every time.
+ // The palette is a gradient from black, to a dark color based on the hue,
+ // to a light color based on the hue, to white.
+ //
+ // static uint8_t hue = 0;
+ // hue++;
+ // CRGB darkcolor = CHSV(hue,255,192); // pure hue, three-quarters brightness
+ // CRGB lightcolor = CHSV(hue,128,255); // half 'whitened', full brightness
+ // gPal = CRGBPalette16( CRGB::Black, darkcolor, lightcolor, CRGB::White);
+
+
+ Fire2012WithPalette(); // run simulation frame, using palette colors
+
+ FastLED.show(); // display this frame
+ FastLED.delay(1000 / FRAMES_PER_SECOND);
+}
+
+
+// Fire2012 by Mark Kriegsman, July 2012
+// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
+////
+// This basic one-dimensional 'fire' simulation works roughly as follows:
+// There's a underlying array of 'heat' cells, that model the temperature
+// at each point along the line. Every cycle through the simulation,
+// four steps are performed:
+// 1) All cells cool down a little bit, losing heat to the air
+// 2) The heat from each cell drifts 'up' and diffuses a little
+// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
+// 4) The heat from each cell is rendered as a color into the leds array
+// The heat-to-color mapping uses a black-body radiation approximation.
+//
+// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
+//
+// This simulation scales it self a bit depending on NUM_LEDS; it should look
+// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
+//
+// I recommend running this simulation at anywhere from 30-100 frames per second,
+// meaning an interframe delay of about 10-35 milliseconds.
+//
+// Looks best on a high-density LED setup (60+ pixels/meter).
+//
+//
+// There are two main parameters you can play with to control the look and
+// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
+// in step 3 above).
+//
+// COOLING: How much does the air cool as it rises?
+// Less cooling = taller flames. More cooling = shorter flames.
+// Default 55, suggested range 20-100
+#define COOLING 55
+
+// SPARKING: What chance (out of 255) is there that a new spark will be lit?
+// Higher chance = more roaring fire. Lower chance = more flickery fire.
+// Default 120, suggested range 50-200.
+#define SPARKING 120
+
+
+void Fire2012WithPalette()
+{
+// Array of temperature readings at each simulation cell
+ static byte heat[NUM_LEDS];
+
+ // Step 1. Cool down every cell a little
+ for( int i = 0; i < NUM_LEDS; i++) {
+ heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
+ }
+
+ // Step 2. Heat from each cell drifts 'up' and diffuses a little
+ for( int k= NUM_LEDS - 1; k >= 2; k--) {
+ heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
+ }
+
+ // Step 3. Randomly ignite new 'sparks' of heat near the bottom
+ if( random8() < SPARKING ) {
+ int y = random8(7);
+ heat[y] = qadd8( heat[y], random8(160,255) );
+ }
+
+ // Step 4. Map from heat cells to LED colors
+ for( int j = 0; j < NUM_LEDS; j++) {
+ // Scale the heat value from 0-255 down to 0-240
+ // for best results with color palettes.
+ byte colorindex = scale8( heat[j], 240);
+ CRGB color = ColorFromPalette( gPal, colorindex);
+ int pixelnumber;
+ if( gReverseDirection ) {
+ pixelnumber = (NUM_LEDS-1) - j;
+ } else {
+ pixelnumber = j;
+ }
+ leds[pixelnumber] = color;
+ }
+}
+
diff --git a/Библиотеки/FastLED-master/examples/FirstLight/FirstLight.ino b/Библиотеки/FastLED-master/examples/FirstLight/FirstLight.ino
new file mode 100644
index 0000000..ce89f64
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/FirstLight/FirstLight.ino
@@ -0,0 +1,78 @@
+// Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't)
+// #define FASTLED_FORCE_SOFTWARE_SPI
+// Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
+// #define FASTLED_FORCE_SOFTWARE_SPI
+// #define FASTLED_FORCE_SOFTWARE_PINS
+#include "FastLED.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////
+//
+// Move a white dot along the strip of leds. This program simply shows how to configure the leds,
+// and then how to turn a single pixel white and then off, moving down the line of pixels.
+//
+
+// How many leds are in the strip?
+#define NUM_LEDS 60
+
+// Data pin that led data will be written out over
+#define DATA_PIN 3
+
+// Clock pin only needed for SPI based chipsets when not using hardware SPI
+//#define CLOCK_PIN 8
+
+// This is an array of leds. One item for each led in your strip.
+CRGB leds[NUM_LEDS];
+
+// This function sets up the ledsand tells the controller about them
+void setup() {
+ // sanity check delay - allows reprogramming if accidently blowing power w/leds
+ delay(2000);
+
+ // Uncomment one of the following lines for your leds arrangement.
+ // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
+ FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA104, DATA_PIN>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+}
+
+// This function runs over and over, and is where you do the magic to light
+// your leds.
+void loop() {
+ // Move a single white led
+ for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
+ // Turn our current led on to white, then show the leds
+ leds[whiteLed] = CRGB::White;
+
+ // Show the leds (only one of which is set to white, from above)
+ FastLED.show();
+
+ // Wait a little bit
+ delay(100);
+
+ // Turn our current led back to black for the next loop around
+ leds[whiteLed] = CRGB::Black;
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino b/Библиотеки/FastLED-master/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino
new file mode 100644
index 0000000..b2b115e
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino
@@ -0,0 +1,37 @@
+// ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
+// using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three
+// different pins, each strip getting its own CRGB array to be played with, only this time they're going
+// to be all parts of an array of arrays.
+
+#include "FastLED.h"
+
+#define NUM_STRIPS 3
+#define NUM_LEDS_PER_STRIP 60
+CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
+
+// For mirroring strips, all the "special" stuff happens just in setup. We
+// just addLeds multiple times, once for each strip
+void setup() {
+ // tell FastLED there's 60 NEOPIXEL leds on pin 10
+ FastLED.addLeds<NEOPIXEL, 10>(leds[0], NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 11
+ FastLED.addLeds<NEOPIXEL, 11>(leds[1], NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 12
+ FastLED.addLeds<NEOPIXEL, 12>(leds[2], NUM_LEDS_PER_STRIP);
+
+}
+
+void loop() {
+ // This outer loop will go over each strip, one at a time
+ for(int x = 0; x < NUM_STRIPS; x++) {
+ // This inner loop will go over each led in the current strip, one at a time
+ for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
+ leds[x][i] = CRGB::Red;
+ FastLED.show();
+ leds[x][i] = CRGB::Black;
+ delay(100);
+ }
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/MirroringSample/MirroringSample.ino b/Библиотеки/FastLED-master/examples/Multiple/MirroringSample/MirroringSample.ino
new file mode 100644
index 0000000..39d748b
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/MirroringSample/MirroringSample.ino
@@ -0,0 +1,44 @@
+// MirroringSample - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
+// using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on four
+// different pins, and show the same thing on all four of them, a simple bouncing dot/cyclon type pattern
+
+#include "FastLED.h"
+
+#define NUM_LEDS_PER_STRIP 60
+CRGB leds[NUM_LEDS_PER_STRIP];
+
+// For mirroring strips, all the "special" stuff happens just in setup. We
+// just addLeds multiple times, once for each strip
+void setup() {
+ // tell FastLED there's 60 NEOPIXEL leds on pin 4
+ FastLED.addLeds<NEOPIXEL, 4>(leds, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 5
+ FastLED.addLeds<NEOPIXEL, 5>(leds, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 6
+ FastLED.addLeds<NEOPIXEL, 6>(leds, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 7
+ FastLED.addLeds<NEOPIXEL, 7>(leds, NUM_LEDS_PER_STRIP);
+}
+
+void loop() {
+ for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
+ // set our current dot to red
+ leds[i] = CRGB::Red;
+ FastLED.show();
+ // clear our current dot before we move on
+ leds[i] = CRGB::Black;
+ delay(100);
+ }
+
+ for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
+ // set our current dot to red
+ leds[i] = CRGB::Red;
+ FastLED.show();
+ // clear our current dot before we move on
+ leds[i] = CRGB::Black;
+ delay(100);
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/MultiArrays/MultiArrays.ino b/Библиотеки/FastLED-master/examples/Multiple/MultiArrays/MultiArrays.ino
new file mode 100644
index 0000000..a983d60
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/MultiArrays/MultiArrays.ino
@@ -0,0 +1,52 @@
+// MultiArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
+// using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three
+// different pins, each strip getting its own CRGB array to be played with
+
+#include "FastLED.h"
+
+#define NUM_LEDS_PER_STRIP 60
+CRGB redLeds[NUM_LEDS_PER_STRIP];
+CRGB greenLeds[NUM_LEDS_PER_STRIP];
+CRGB blueLeds[NUM_LEDS_PER_STRIP];
+
+// For mirroring strips, all the "special" stuff happens just in setup. We
+// just addLeds multiple times, once for each strip
+void setup() {
+ // tell FastLED there's 60 NEOPIXEL leds on pin 10
+ FastLED.addLeds<NEOPIXEL, 10>(redLeds, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 11
+ FastLED.addLeds<NEOPIXEL, 11>(greenLeds, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 12
+ FastLED.addLeds<NEOPIXEL, 12>(blueLeds, NUM_LEDS_PER_STRIP);
+
+}
+
+void loop() {
+ for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
+ // set our current dot to red, green, and blue
+ redLeds[i] = CRGB::Red;
+ greenLeds[i] = CRGB::Green;
+ blueLeds[i] = CRGB::Blue;
+ FastLED.show();
+ // clear our current dot before we move on
+ redLeds[i] = CRGB::Black;
+ greenLeds[i] = CRGB::Black;
+ blueLeds[i] = CRGB::Blue;
+ delay(100);
+ }
+
+ for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
+ // set our current dot to red, green, and blue
+ redLeds[i] = CRGB::Red;
+ greenLeds[i] = CRGB::Green;
+ blueLeds[i] = CRGB::Blue;
+ FastLED.show();
+ // clear our current dot before we move on
+ redLeds[i] = CRGB::Black;
+ greenLeds[i] = CRGB::Black;
+ blueLeds[i] = CRGB::Blue;
+ delay(100);
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino b/Библиотеки/FastLED-master/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino
new file mode 100644
index 0000000..35a6c6a
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino
@@ -0,0 +1,34 @@
+// MultipleStripsInOneArray - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
+// using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on three
+// different pins, each strip will be referring to a different part of the single led array
+
+#include "FastLED.h"
+
+#define NUM_STRIPS 3
+#define NUM_LEDS_PER_STRIP 60
+#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS
+
+CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
+
+// For mirroring strips, all the "special" stuff happens just in setup. We
+// just addLeds multiple times, once for each strip
+void setup() {
+ // tell FastLED there's 60 NEOPIXEL leds on pin 10, starting at index 0 in the led array
+ FastLED.addLeds<NEOPIXEL, 10>(leds, 0, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 11, starting at index 60 in the led array
+ FastLED.addLeds<NEOPIXEL, 11>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
+
+ // tell FastLED there's 60 NEOPIXEL leds on pin 12, starting at index 120 in the led array
+ FastLED.addLeds<NEOPIXEL, 12>(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
+
+}
+
+void loop() {
+ for(int i = 0; i < NUM_LEDS; i++) {
+ leds[i] = CRGB::Red;
+ FastLED.show();
+ leds[i] = CRGB::Black;
+ delay(100);
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino b/Библиотеки/FastLED-master/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino
new file mode 100644
index 0000000..6aad445
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino
@@ -0,0 +1,37 @@
+#define USE_OCTOWS2811
+#include<OctoWS2811.h>
+#include<FastLED.h>
+
+#define NUM_LEDS_PER_STRIP 64
+#define NUM_STRIPS 8
+
+CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
+
+// Pin layouts on the teensy 3:
+// OctoWS2811: 2,14,7,8,6,20,21,5
+
+void setup() {
+ LEDS.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
+ LEDS.setBrightness(32);
+}
+
+void loop() {
+ static uint8_t hue = 0;
+ for(int i = 0; i < NUM_STRIPS; i++) {
+ for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) {
+ leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255);
+ }
+ }
+
+ // Set the first n leds on each strip to show which strip it is
+ for(int i = 0; i < NUM_STRIPS; i++) {
+ for(int j = 0; j <= i; j++) {
+ leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red;
+ }
+ }
+
+ hue++;
+
+ LEDS.show();
+ LEDS.delay(10);
+}
diff --git a/Библиотеки/FastLED-master/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino b/Библиотеки/FastLED-master/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino
new file mode 100644
index 0000000..d646cde
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino
@@ -0,0 +1,47 @@
+#include<FastLED.h>
+
+#define NUM_LEDS_PER_STRIP 64
+// Note: this can be 12 if you're using a teensy 3 and don't mind soldering the pads on the back
+#define NUM_STRIPS 16
+
+CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
+
+// Pin layouts on the teensy 3/3.1:
+// WS2811_PORTD: 2,14,7,8,6,20,21,5
+// WS2811_PORTC: 15,22,23,9,10,13,11,12,28,27,29,30 (these last 4 are pads on the bottom of the teensy)
+// WS2811_PORTDC: 2,14,7,8,6,20,21,5,15,22,23,9,10,13,11,12 - 16 way parallel
+//
+// Pin layouts on the due
+// WS2811_PORTA: 69,68,61,60,59,100,58,31 (note: pin 100 only available on the digix)
+// WS2811_PORTB: 90,91,92,93,94,95,96,97 (note: only available on the digix)
+// WS2811_PORTD: 25,26,27,28,14,15,29,11
+//
+
+void setup() {
+ // LEDS.addLeds<WS2811_PORTA,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
+ // LEDS.addLeds<WS2811_PORTB,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
+ // LEDS.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
+ LEDS.addLeds<WS2811_PORTDC,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
+ LEDS.setBrightness(32);
+}
+
+void loop() {
+ static uint8_t hue = 0;
+ for(int i = 0; i < NUM_STRIPS; i++) {
+ for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) {
+ leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255);
+ }
+ }
+
+ // Set the first n leds on each strip to show which strip it is
+ for(int i = 0; i < NUM_STRIPS; i++) {
+ for(int j = 0; j <= i; j++) {
+ leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red;
+ }
+ }
+
+ hue++;
+
+ LEDS.show();
+ LEDS.delay(10);
+}
diff --git a/Библиотеки/FastLED-master/examples/Noise/Noise.ino b/Библиотеки/FastLED-master/examples/Noise/Noise.ino
new file mode 100644
index 0000000..c2a6475
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Noise/Noise.ino
@@ -0,0 +1,112 @@
+#include<FastLED.h>
+
+//
+// Mark's xy coordinate mapping code. See the XYMatrix for more information on it.
+//
+
+// Params for width and height
+const uint8_t kMatrixWidth = 16;
+const uint8_t kMatrixHeight = 16;
+#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
+#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
+// Param for different pixel layouts
+const bool kMatrixSerpentineLayout = true;
+
+
+uint16_t XY( uint8_t x, uint8_t y)
+{
+ uint16_t i;
+
+ if( kMatrixSerpentineLayout == false) {
+ i = (y * kMatrixWidth) + x;
+ }
+
+ if( kMatrixSerpentineLayout == true) {
+ if( y & 0x01) {
+ // Odd rows run backwards
+ uint8_t reverseX = (kMatrixWidth - 1) - x;
+ i = (y * kMatrixWidth) + reverseX;
+ } else {
+ // Even rows run forwards
+ i = (y * kMatrixWidth) + x;
+ }
+ }
+
+ return i;
+}
+
+// The leds
+CRGB leds[kMatrixWidth * kMatrixHeight];
+
+// The 32bit version of our coordinates
+static uint16_t x;
+static uint16_t y;
+static uint16_t z;
+
+// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
+// use the z-axis for "time". speed determines how fast time moves forward. Try
+// 1 for a very slow moving effect, or 60 for something that ends up looking like
+// water.
+// uint16_t speed = 1; // almost looks like a painting, moves very slowly
+uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100
+// uint16_t speed = 33;
+// uint16_t speed = 100; // wicked fast!
+
+// Scale determines how far apart the pixels in our noise matrix are. Try
+// changing these values around to see how it affects the motion of the display. The
+// higher the value of scale, the more "zoomed out" the noise iwll be. A value
+// of 1 will be so zoomed in, you'll mostly see solid colors.
+
+// uint16_t scale = 1; // mostly just solid colors
+// uint16_t scale = 4011; // very zoomed out and shimmery
+uint16_t scale = 311;
+
+// This is the array that we keep our computed noise values in
+uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
+
+void setup() {
+ // uncomment the following lines if you want to see FPS count information
+ // Serial.begin(38400);
+ // Serial.println("resetting!");
+ delay(3000);
+ LEDS.addLeds<WS2811,5,RGB>(leds,NUM_LEDS);
+ LEDS.setBrightness(96);
+
+ // Initialize our coordinates to some random values
+ x = random16();
+ y = random16();
+ z = random16();
+}
+
+// Fill the x/y array of 8-bit noise values using the inoise8 function.
+void fillnoise8() {
+ for(int i = 0; i < MAX_DIMENSION; i++) {
+ int ioffset = scale * i;
+ for(int j = 0; j < MAX_DIMENSION; j++) {
+ int joffset = scale * j;
+ noise[i][j] = inoise8(x + ioffset,y + joffset,z);
+ }
+ }
+ z += speed;
+}
+
+
+void loop() {
+ static uint8_t ihue=0;
+ fillnoise8();
+ for(int i = 0; i < kMatrixWidth; i++) {
+ for(int j = 0; j < kMatrixHeight; j++) {
+ // We use the value at the (i,j) coordinate in the noise
+ // array for our brightness, and the flipped value from (j,i)
+ // for our pixel's hue.
+ leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]);
+
+ // You can also explore other ways to constrain the hue used, like below
+ // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]);
+ }
+ }
+ ihue+=1;
+
+ LEDS.show();
+ // delay(10);
+}
diff --git a/Библиотеки/FastLED-master/examples/NoisePlayground/NoisePlayground.ino b/Библиотеки/FastLED-master/examples/NoisePlayground/NoisePlayground.ino
new file mode 100644
index 0000000..e2c7cb3
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/NoisePlayground/NoisePlayground.ino
@@ -0,0 +1,73 @@
+#include <FastLED.h>
+
+#define kMatrixWidth 16
+#define kMatrixHeight 16
+
+#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
+// Param for different pixel layouts
+#define kMatrixSerpentineLayout true
+
+// led array
+CRGB leds[kMatrixWidth * kMatrixHeight];
+
+// x,y, & time values
+uint32_t x,y,v_time,hue_time,hxy;
+
+// Play with the values of the variables below and see what kinds of effects they
+// have! More octaves will make things slower.
+
+// how many octaves to use for the brightness and hue functions
+uint8_t octaves=1;
+uint8_t hue_octaves=3;
+
+// the 'distance' between points on the x and y axis
+int xscale=57771;
+int yscale=57771;
+
+// the 'distance' between x/y points for the hue noise
+int hue_scale=1;
+
+// how fast we move through time & hue noise
+int time_speed=1111;
+int hue_speed=31;
+
+// adjust these values to move along the x or y axis between frames
+int x_speed=331;
+int y_speed=1111;
+
+void loop() {
+ // fill the led array 2/16-bit noise values
+ fill_2dnoise16(LEDS.leds(), kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout,
+ octaves,x,xscale,y,yscale,v_time,
+ hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false);
+
+ LEDS.show();
+
+ // adjust the intra-frame time values
+ x += x_speed;
+ y += y_speed;
+ v_time += time_speed;
+ hue_time += hue_speed;
+ // delay(50);
+}
+
+
+void setup() {
+ // initialize the x/y and time values
+ random16_set_seed(8934);
+ random16_add_entropy(analogRead(3));
+
+ Serial.begin(57600);
+ Serial.println("resetting!");
+
+ delay(3000);
+ LEDS.addLeds<WS2811,6,GRB>(leds,NUM_LEDS);
+ LEDS.setBrightness(96);
+
+ hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
+ x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
+ y = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
+ v_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
+ hue_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
+
+}
diff --git a/Библиотеки/FastLED-master/examples/NoisePlusPalette/NoisePlusPalette.ino b/Библиотеки/FastLED-master/examples/NoisePlusPalette/NoisePlusPalette.ino
new file mode 100644
index 0000000..4e06bdd
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/NoisePlusPalette/NoisePlusPalette.ino
@@ -0,0 +1,273 @@
+#include<FastLED.h>
+
+#define LED_PIN 3
+#define BRIGHTNESS 96
+#define LED_TYPE WS2811
+#define COLOR_ORDER GRB
+
+const uint8_t kMatrixWidth = 16;
+const uint8_t kMatrixHeight = 16;
+const bool kMatrixSerpentineLayout = true;
+
+
+// This example combines two features of FastLED to produce a remarkable range of
+// effects from a relatively small amount of code. This example combines FastLED's
+// color palette lookup functions with FastLED's Perlin/simplex noise generator, and
+// the combination is extremely powerful.
+//
+// You might want to look at the "ColorPalette" and "Noise" examples separately
+// if this example code seems daunting.
+//
+//
+// The basic setup here is that for each frame, we generate a new array of
+// 'noise' data, and then map it onto the LED matrix through a color palette.
+//
+// Periodically, the color palette is changed, and new noise-generation parameters
+// are chosen at the same time. In this example, specific noise-generation
+// values have been selected to match the given color palettes; some are faster,
+// or slower, or larger, or smaller than others, but there's no reason these
+// parameters can't be freely mixed-and-matched.
+//
+// In addition, this example includes some fast automatic 'data smoothing' at
+// lower noise speeds to help produce smoother animations in those cases.
+//
+// The FastLED built-in color palettes (Forest, Clouds, Lava, Ocean, Party) are
+// used, as well as some 'hand-defined' ones, and some proceedurally generated
+// palettes.
+
+
+#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
+#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
+
+// The leds
+CRGB leds[kMatrixWidth * kMatrixHeight];
+
+// The 16 bit version of our coordinates
+static uint16_t x;
+static uint16_t y;
+static uint16_t z;
+
+// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
+// use the z-axis for "time". speed determines how fast time moves forward. Try
+// 1 for a very slow moving effect, or 60 for something that ends up looking like
+// water.
+uint16_t speed = 20; // speed is set dynamically once we've started up
+
+// Scale determines how far apart the pixels in our noise matrix are. Try
+// changing these values around to see how it affects the motion of the display. The
+// higher the value of scale, the more "zoomed out" the noise iwll be. A value
+// of 1 will be so zoomed in, you'll mostly see solid colors.
+uint16_t scale = 30; // scale is set dynamically once we've started up
+
+// This is the array that we keep our computed noise values in
+uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
+
+CRGBPalette16 currentPalette( PartyColors_p );
+uint8_t colorLoop = 1;
+
+void setup() {
+ delay(3000);
+ LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS);
+ LEDS.setBrightness(BRIGHTNESS);
+
+ // Initialize our coordinates to some random values
+ x = random16();
+ y = random16();
+ z = random16();
+}
+
+
+
+// Fill the x/y array of 8-bit noise values using the inoise8 function.
+void fillnoise8() {
+ // If we're runing at a low "speed", some 8-bit artifacts become visible
+ // from frame-to-frame. In order to reduce this, we can do some fast data-smoothing.
+ // The amount of data smoothing we're doing depends on "speed".
+ uint8_t dataSmoothing = 0;
+ if( speed < 50) {
+ dataSmoothing = 200 - (speed * 4);
+ }
+
+ for(int i = 0; i < MAX_DIMENSION; i++) {
+ int ioffset = scale * i;
+ for(int j = 0; j < MAX_DIMENSION; j++) {
+ int joffset = scale * j;
+
+ uint8_t data = inoise8(x + ioffset,y + joffset,z);
+
+ // The range of the inoise8 function is roughly 16-238.
+ // These two operations expand those values out to roughly 0..255
+ // You can comment them out if you want the raw noise data.
+ data = qsub8(data,16);
+ data = qadd8(data,scale8(data,39));
+
+ if( dataSmoothing ) {
+ uint8_t olddata = noise[i][j];
+ uint8_t newdata = scale8( olddata, dataSmoothing) + scale8( data, 256 - dataSmoothing);
+ data = newdata;
+ }
+
+ noise[i][j] = data;
+ }
+ }
+
+ z += speed;
+
+ // apply slow drift to X and Y, just for visual variation.
+ x += speed / 8;
+ y -= speed / 16;
+}
+
+void mapNoiseToLEDsUsingPalette()
+{
+ static uint8_t ihue=0;
+
+ for(int i = 0; i < kMatrixWidth; i++) {
+ for(int j = 0; j < kMatrixHeight; j++) {
+ // We use the value at the (i,j) coordinate in the noise
+ // array for our brightness, and the flipped value from (j,i)
+ // for our pixel's index into the color palette.
+
+ uint8_t index = noise[j][i];
+ uint8_t bri = noise[i][j];
+
+ // if this palette is a 'loop', add a slowly-changing base value
+ if( colorLoop) {
+ index += ihue;
+ }
+
+ // brighten up, as the color palette itself often contains the
+ // light/dark dynamic range desired
+ if( bri > 127 ) {
+ bri = 255;
+ } else {
+ bri = dim8_raw( bri * 2);
+ }
+
+ CRGB color = ColorFromPalette( currentPalette, index, bri);
+ leds[XY(i,j)] = color;
+ }
+ }
+
+ ihue+=1;
+}
+
+void loop() {
+ // Periodically choose a new palette, speed, and scale
+ ChangePaletteAndSettingsPeriodically();
+
+ // generate noise data
+ fillnoise8();
+
+ // convert the noise data to colors in the LED array
+ // using the current palette
+ mapNoiseToLEDsUsingPalette();
+
+ LEDS.show();
+ // delay(10);
+}
+
+
+
+// There are several different palettes of colors demonstrated here.
+//
+// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
+// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
+//
+// Additionally, you can manually define your own color palettes, or you can write
+// code that creates color palettes on the fly.
+
+// 1 = 5 sec per palette
+// 2 = 10 sec per palette
+// etc
+#define HOLD_PALETTES_X_TIMES_AS_LONG 1
+
+void ChangePaletteAndSettingsPeriodically()
+{
+ uint8_t secondHand = ((millis() / 1000) / HOLD_PALETTES_X_TIMES_AS_LONG) % 60;
+ static uint8_t lastSecond = 99;
+
+ if( lastSecond != secondHand) {
+ lastSecond = secondHand;
+ if( secondHand == 0) { currentPalette = RainbowColors_p; speed = 20; scale = 30; colorLoop = 1; }
+ if( secondHand == 5) { SetupPurpleAndGreenPalette(); speed = 10; scale = 50; colorLoop = 1; }
+ if( secondHand == 10) { SetupBlackAndWhiteStripedPalette(); speed = 20; scale = 30; colorLoop = 1; }
+ if( secondHand == 15) { currentPalette = ForestColors_p; speed = 8; scale =120; colorLoop = 0; }
+ if( secondHand == 20) { currentPalette = CloudColors_p; speed = 4; scale = 30; colorLoop = 0; }
+ if( secondHand == 25) { currentPalette = LavaColors_p; speed = 8; scale = 50; colorLoop = 0; }
+ if( secondHand == 30) { currentPalette = OceanColors_p; speed = 20; scale = 90; colorLoop = 0; }
+ if( secondHand == 35) { currentPalette = PartyColors_p; speed = 20; scale = 30; colorLoop = 1; }
+ if( secondHand == 40) { SetupRandomPalette(); speed = 20; scale = 20; colorLoop = 1; }
+ if( secondHand == 45) { SetupRandomPalette(); speed = 50; scale = 50; colorLoop = 1; }
+ if( secondHand == 50) { SetupRandomPalette(); speed = 90; scale = 90; colorLoop = 1; }
+ if( secondHand == 55) { currentPalette = RainbowStripeColors_p; speed = 30; scale = 20; colorLoop = 1; }
+ }
+}
+
+// This function generates a random palette that's a gradient
+// between four different colors. The first is a dim hue, the second is
+// a bright hue, the third is a bright pastel, and the last is
+// another bright hue. This gives some visual bright/dark variation
+// which is more interesting than just a gradient of different hues.
+void SetupRandomPalette()
+{
+ currentPalette = CRGBPalette16(
+ CHSV( random8(), 255, 32),
+ CHSV( random8(), 255, 255),
+ CHSV( random8(), 128, 255),
+ CHSV( random8(), 255, 255));
+}
+
+// This function sets up a palette of black and white stripes,
+// using code. Since the palette is effectively an array of
+// sixteen CRGB colors, the various fill_* functions can be used
+// to set them up.
+void SetupBlackAndWhiteStripedPalette()
+{
+ // 'black out' all 16 palette entries...
+ fill_solid( currentPalette, 16, CRGB::Black);
+ // and set every fourth one to white.
+ currentPalette[0] = CRGB::White;
+ currentPalette[4] = CRGB::White;
+ currentPalette[8] = CRGB::White;
+ currentPalette[12] = CRGB::White;
+
+}
+
+// This function sets up a palette of purple and green stripes.
+void SetupPurpleAndGreenPalette()
+{
+ CRGB purple = CHSV( HUE_PURPLE, 255, 255);
+ CRGB green = CHSV( HUE_GREEN, 255, 255);
+ CRGB black = CRGB::Black;
+
+ currentPalette = CRGBPalette16(
+ green, green, black, black,
+ purple, purple, black, black,
+ green, green, black, black,
+ purple, purple, black, black );
+}
+
+
+//
+// Mark's xy coordinate mapping code. See the XYMatrix for more information on it.
+//
+uint16_t XY( uint8_t x, uint8_t y)
+{
+ uint16_t i;
+ if( kMatrixSerpentineLayout == false) {
+ i = (y * kMatrixWidth) + x;
+ }
+ if( kMatrixSerpentineLayout == true) {
+ if( y & 0x01) {
+ // Odd rows run backwards
+ uint8_t reverseX = (kMatrixWidth - 1) - x;
+ i = (y * kMatrixWidth) + reverseX;
+ } else {
+ // Even rows run forwards
+ i = (y * kMatrixWidth) + x;
+ }
+ }
+ return i;
+}
+
diff --git a/Библиотеки/FastLED-master/examples/Pintest/Pintest.ino b/Библиотеки/FastLED-master/examples/Pintest/Pintest.ino
new file mode 100644
index 0000000..727341e
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Pintest/Pintest.ino
@@ -0,0 +1,105 @@
+
+#include <FastSPI_LED2.h>
+
+const char *getPort(void *portPtr) {
+#ifdef PORTA
+ if(portPtr == (void*)&PORTA) { return "PORTA"; }
+#endif
+#ifdef PORTB
+ if(portPtr == (void*)&PORTB) { return "PORTB"; }
+#endif
+#ifdef PORTC
+ if(portPtr == (void*)&PORTC) { return "PORTC"; }
+#endif
+#ifdef PORTD
+ if(portPtr == (void*)&PORTD) { return "PORTD"; }
+#endif
+#ifdef PORTE
+ if(portPtr == (void*)&PORTE) { return "PORTE"; }
+#endif
+#ifdef PORTF
+ if(portPtr == (void*)&PORTF) { return "PORTF"; }
+#endif
+#ifdef PORTG
+ if(portPtr == (void*)&PORTG) { return "PORTG"; }
+#endif
+#ifdef PORTH
+ if(portPtr == (void*)&PORTH) { return "PORTH"; }
+#endif
+#ifdef PORTI
+ if(portPtr == (void*)&PORTI) { return "PORTI"; }
+#endif
+#ifdef PORTJ
+ if(portPtr == (void*)&PORTJ) { return "PORTJ"; }
+#endif
+#ifdef PORTK
+ if(portPtr == (void*)&PORTK) { return "PORTK"; }
+#endif
+#ifdef PORTL
+ if(portPtr == (void*)&PORTL) { return "PORTL"; }
+#endif
+#ifdef GPIO_A_PDOR
+ if(portPtr == (void*)&GPIO_A_PDOR) { return "GPIO_A_PDOR"; }
+#endif
+#ifdef GPIO_B_PDOR
+ if(portPtr == (void*)&GPIO_B_PDOR) { return "GPIO_B_PDOR"; }
+#endif
+#ifdef GPIO_C_PDOR
+ if(portPtr == (void*)&GPIO_C_PDOR) { return "GPIO_C_PDOR"; }
+#endif
+#ifdef GPIO_D_PDOR
+ if(portPtr == (void*)&GPIO_D_PDOR) { return "GPIO_D_PDOR"; }
+#endif
+#ifdef GPIO_E_PDOR
+ if(portPtr == (void*)&GPIO_E_PDOR) { return "GPIO_E_PDOR"; }
+#endif
+#ifdef REG_PIO_A_ODSR
+ if(portPtr == (void*)&REG_PIO_A_ODSR) { return "REG_PIO_A_ODSR"; }
+#endif
+#ifdef REG_PIO_B_ODSR
+ if(portPtr == (void*)&REG_PIO_B_ODSR) { return "REG_PIO_B_ODSR"; }
+#endif
+#ifdef REG_PIO_C_ODSR
+ if(portPtr == (void*)&REG_PIO_C_ODSR) { return "REG_PIO_C_ODSR"; }
+#endif
+#ifdef REG_PIO_D_ODSR
+ if(portPtr == (void*)&REG_PIO_D_ODSR) { return "REG_PIO_D_ODSR"; }
+#endif
+ return "unknown";
+}
+
+template<uint8_t PIN> void CheckPin()
+{
+ CheckPin<PIN - 1>();
+
+ RwReg *systemThinksPortIs = portOutputRegister(digitalPinToPort(PIN));
+ RwReg systemThinksMaskIs = digitalPinToBitMask(PIN);
+
+ Serial.print("Pin "); Serial.print(PIN); Serial.print(": Port ");
+
+ if(systemThinksPortIs == FastPin<PIN>::port()) {
+ Serial.print("valid & mask ");
+ } else {
+ Serial.print("invalid, is "); Serial.print(getPort((void*)FastPin<PIN>::port())); Serial.print(" should be ");
+ Serial.print(getPort((void*)systemThinksPortIs));
+ Serial.print(" & mask ");
+ }
+
+ if(systemThinksMaskIs == FastPin<PIN>::mask()) {
+ Serial.println("valid.");
+ } else {
+ Serial.print("invalid, is "); Serial.print(FastPin<PIN>::mask()); Serial.print(" should be "); Serial.println(systemThinksMaskIs);
+ }
+}
+
+template<> void CheckPin<-1> () {}
+
+void setup() {
+ Serial.begin(38400);
+ Serial.println("resetting!");
+}
+
+void loop() {
+ CheckPin<MAX_PIN>();
+ delay(10000);
+} \ No newline at end of file
diff --git a/Библиотеки/FastLED-master/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino b/Библиотеки/FastLED-master/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino
new file mode 100644
index 0000000..24f2394
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino
@@ -0,0 +1,136 @@
+// LED Audio Spectrum Analyzer Display
+//
+// Creates an impressive LED light show to music input
+// using Teensy 3.1 with the OctoWS2811 adaptor board
+// http://www.pjrc.com/store/teensy31.html
+// http://www.pjrc.com/store/octo28_adaptor.html
+//
+// Line Level Audio Input connects to analog pin A3
+// Recommended input circuit:
+// http://www.pjrc.com/teensy/gui/?info=AudioInputAnalog
+//
+// This example code is in the public domain.
+
+#define USE_OCTOWS2811
+#include <OctoWS2811.h>
+#include <FastLED.h>
+#include <Audio.h>
+#include <Wire.h>
+#include <SD.h>
+#include <SPI.h>
+
+// The display size and color to use
+const unsigned int matrix_width = 60;
+const unsigned int matrix_height = 32;
+const unsigned int myColor = 0x400020;
+
+// These parameters adjust the vertical thresholds
+const float maxLevel = 0.5; // 1.0 = max, lower is more "sensitive"
+const float dynamicRange = 40.0; // total range to display, in decibels
+const float linearBlend = 0.3; // useful range is 0 to 0.7
+
+CRGB leds[matrix_width * matrix_height];
+
+// Audio library objects
+AudioInputAnalog adc1(A3); //xy=99,55
+AudioAnalyzeFFT1024 fft; //xy=265,75
+AudioConnection patchCord1(adc1, fft);
+
+
+// This array holds the volume level (0 to 1.0) for each
+// vertical pixel to turn on. Computed in setup() using
+// the 3 parameters above.
+float thresholdVertical[matrix_height];
+
+// This array specifies how many of the FFT frequency bin
+// to use for each horizontal pixel. Because humans hear
+// in octaves and FFT bins are linear, the low frequencies
+// use a small number of bins, higher frequencies use more.
+int frequencyBinsHorizontal[matrix_width] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
+ 3, 3, 3, 3, 4, 4, 4, 4, 4, 5,
+ 5, 5, 6, 6, 6, 7, 7, 7, 8, 8,
+ 9, 9, 10, 10, 11, 12, 12, 13, 14, 15,
+ 15, 16, 17, 18, 19, 20, 22, 23, 24, 25
+};
+
+
+
+// Run setup once
+void setup() {
+ // the audio library needs to be given memory to start working
+ AudioMemory(12);
+
+ // compute the vertical thresholds before starting
+ computeVerticalLevels();
+
+ // turn on the display
+ FastLED.addLeds<OCTOWS2811>(leds,(matrix_width * matrix_height) / 8);
+}
+
+// A simple xy() function to turn display matrix coordinates
+// into the index numbers OctoWS2811 requires. If your LEDs
+// are arranged differently, edit this code...
+unsigned int xy(unsigned int x, unsigned int y) {
+ if ((y & 1) == 0) {
+ // even numbered rows (0, 2, 4...) are left to right
+ return y * matrix_width + x;
+ } else {
+ // odd numbered rows (1, 3, 5...) are right to left
+ return y * matrix_width + matrix_width - 1 - x;
+ }
+}
+
+// Run repetitively
+void loop() {
+ unsigned int x, y, freqBin;
+ float level;
+
+ if (fft.available()) {
+ // freqBin counts which FFT frequency data has been used,
+ // starting at low frequency
+ freqBin = 0;
+
+ for (x=0; x < matrix_width; x++) {
+ // get the volume for each horizontal pixel position
+ level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1);
+
+ // uncomment to see the spectrum in Arduino's Serial Monitor
+ // Serial.print(level);
+ // Serial.print(" ");
+
+ for (y=0; y < matrix_height; y++) {
+ // for each vertical pixel, check if above the threshold
+ // and turn the LED on or off
+ if (level >= thresholdVertical[y]) {
+ leds[xy(x,y)] = CRGB(myColor);
+ } else {
+ leds[xy(x,y)] = CRGB::Black;
+ }
+ }
+ // increment the frequency bin count, so we display
+ // low to higher frequency from left to right
+ freqBin = freqBin + frequencyBinsHorizontal[x];
+ }
+ // after all pixels set, show them all at the same instant
+ FastLED.show();
+ // Serial.println();
+ }
+}
+
+
+// Run once from setup, the compute the vertical levels
+void computeVerticalLevels() {
+ unsigned int y;
+ float n, logLevel, linearLevel;
+
+ for (y=0; y < matrix_height; y++) {
+ n = (float)y / (float)(matrix_height - 1);
+ logLevel = pow10f(n * -1.0 * (dynamicRange / 20.0));
+ linearLevel = 1.0 - n;
+ linearLevel = linearLevel * linearBlend;
+ logLevel = logLevel * (1.0 - linearBlend);
+ thresholdVertical[y] = (logLevel + linearLevel) * maxLevel;
+ }
+}
diff --git a/Библиотеки/FastLED-master/examples/RGBCalibrate/RGBCalibrate.ino b/Библиотеки/FastLED-master/examples/RGBCalibrate/RGBCalibrate.ino
new file mode 100644
index 0000000..9f1c236
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/RGBCalibrate/RGBCalibrate.ino
@@ -0,0 +1,70 @@
+#include "FastLED.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// RGB Calibration code
+//
+// Use this sketch to determine what the RGB ordering for your chipset should be. Steps for setting up to use:
+
+// * Uncomment the line in setup that corresponds to the LED chipset that you are using. (Note that they
+// all explicitly specify the RGB order as RGB)
+// * Define DATA_PIN to the pin that data is connected to.
+// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
+// * Compile/upload/run the sketch
+
+// You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green
+// leds, and 3 blue leds. If you see different colors, the count of each color tells you what the
+// position for that color in the rgb orering should be. So, for example, if you see 1 Blue, and 2
+// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).
+
+// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
+// and it should come out correctly, 1 red, 2 green, and 3 blue.
+//
+//////////////////////////////////////////////////
+
+#define NUM_LEDS 6
+
+// Data pin that led data will be written out over
+#define DATA_PIN 6
+// Clock pin only needed for SPI based chipsets when not using hardware SPI
+//#define CLOCK_PIN 8
+
+CRGB leds[NUM_LEDS];
+
+void setup() {
+ // sanity check delay - allows reprogramming if accidently blowing power w/leds
+ delay(2000);
+
+ // Uncomment one of the following lines for your leds arrangement.
+ // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
+ // FastLED.setBrightness(CRGB(255,255,255));
+ // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
+ FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS);
+
+ // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+ // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+}
+
+void loop() {
+ leds[0] = CRGB(255,0,0);
+ leds[1] = CRGB(0,255,0);
+ leds[2] = CRGB(0,255,0);
+ leds[3] = CRGB(0,0,255);
+ leds[4] = CRGB(0,0,255);
+ leds[5] = CRGB(0,0,255);
+ FastLED.show();
+ delay(1000);
+}
diff --git a/Библиотеки/FastLED-master/examples/RGBSetDemo/RGBSetDemo.ino b/Библиотеки/FastLED-master/examples/RGBSetDemo/RGBSetDemo.ino
new file mode 100644
index 0000000..3b9ef24
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/RGBSetDemo/RGBSetDemo.ino
@@ -0,0 +1,22 @@
+#include<FastLED.h>
+#define NUM_LEDS 40
+
+CRGBArray<NUM_LEDS> leds;
+
+void setup() { FastLED.addLeds<NEOPIXEL,6>(leds, NUM_LEDS); }
+
+void loop(){
+ static uint8_t hue;
+ for(int i = 0; i < NUM_LEDS/2; i++) {
+ // fade everything out
+ leds.fadeToBlackBy(40);
+
+ // let's set an led value
+ leds[i] = CHSV(hue++,255,255);
+
+ // now, let's first 20 leds to the top 20 leds,
+ leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
+ FastLED.delay(33);
+ }
+}
+
diff --git a/Библиотеки/FastLED-master/examples/SmartMatrix/SmartMatrix.ino b/Библиотеки/FastLED-master/examples/SmartMatrix/SmartMatrix.ino
new file mode 100644
index 0000000..997b6d2
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/SmartMatrix/SmartMatrix.ino
@@ -0,0 +1,121 @@
+#include<SmartMatrix.h>
+#include<FastLED.h>
+
+#define kMatrixWidth 32
+#define kMatrixHeight 32
+const bool kMatrixSerpentineLayout = false;
+
+#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
+
+CRGB leds[kMatrixWidth * kMatrixHeight];
+
+
+uint16_t XY( uint8_t x, uint8_t y)
+{
+ uint16_t i;
+
+ if( kMatrixSerpentineLayout == false) {
+ i = (y * kMatrixWidth) + x;
+ }
+
+ if( kMatrixSerpentineLayout == true) {
+ if( y & 0x01) {
+ // Odd rows run backwards
+ uint8_t reverseX = (kMatrixWidth - 1) - x;
+ i = (y * kMatrixWidth) + reverseX;
+ } else {
+ // Even rows run forwards
+ i = (y * kMatrixWidth) + x;
+ }
+ }
+
+ return i;
+}
+
+// The 32bit version of our coordinates
+static uint16_t x;
+static uint16_t y;
+static uint16_t z;
+
+// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
+// use the z-axis for "time". speed determines how fast time moves forward. Try
+// 1 for a very slow moving effect, or 60 for something that ends up looking like
+// water.
+// uint16_t speed = 1; // almost looks like a painting, moves very slowly
+uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100
+// uint16_t speed = 33;
+// uint16_t speed = 100; // wicked fast!
+
+// Scale determines how far apart the pixels in our noise matrix are. Try
+// changing these values around to see how it affects the motion of the display. The
+// higher the value of scale, the more "zoomed out" the noise iwll be. A value
+// of 1 will be so zoomed in, you'll mostly see solid colors.
+
+// uint16_t scale = 1; // mostly just solid colors
+// uint16_t scale = 4011; // very zoomed out and shimmery
+uint16_t scale = 31;
+
+// This is the array that we keep our computed noise values in
+uint8_t noise[kMatrixWidth][kMatrixHeight];
+
+void setup() {
+ // uncomment the following lines if you want to see FPS count information
+ // Serial.begin(38400);
+ // Serial.println("resetting!");
+ delay(3000);
+ LEDS.addLeds<SMART_MATRIX>(leds,NUM_LEDS);
+ LEDS.setBrightness(96);
+
+ // Initialize our coordinates to some random values
+ x = random16();
+ y = random16();
+ z = random16();
+
+ // Show off smart matrix scrolling text
+ pSmartMatrix->setScrollMode(wrapForward);
+ pSmartMatrix->setScrollColor({0xff, 0xff, 0xff});
+ pSmartMatrix->setScrollSpeed(15);
+ pSmartMatrix->setScrollFont(font6x10);
+ pSmartMatrix->scrollText("Smart Matrix & FastLED", -1);
+ pSmartMatrix->setScrollOffsetFromEdge(10);
+}
+
+// Fill the x/y array of 8-bit noise values using the inoise8 function.
+void fillnoise8() {
+ for(int i = 0; i < kMatrixWidth; i++) {
+ int ioffset = scale * i;
+ for(int j = 0; j < kMatrixHeight; j++) {
+ int joffset = scale * j;
+ noise[i][j] = inoise8(x + ioffset,y + joffset,z);
+ }
+ }
+ z += speed;
+}
+
+
+void loop() {
+ static uint8_t circlex = 0;
+ static uint8_t circley = 0;
+
+ static uint8_t ihue=0;
+ fillnoise8();
+ for(int i = 0; i < kMatrixWidth; i++) {
+ for(int j = 0; j < kMatrixHeight; j++) {
+ // We use the value at the (i,j) coordinate in the noise
+ // array for our brightness, and the flipped value from (j,i)
+ // for our pixel's hue.
+ leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]);
+
+ // You can also explore other ways to constrain the hue used, like below
+ // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]);
+ }
+ }
+ ihue+=1;
+
+ // N.B. this requires SmartMatrix modified w/triple buffering support
+ pSmartMatrix->fillCircle(circlex % 32,circley % 32,6,CRGB(CHSV(ihue+128,255,255)));
+ circlex += random16(2);
+ circley += random16(2);
+ LEDS.show();
+ // delay(10);
+}
diff --git a/Библиотеки/FastLED-master/examples/XYMatrix/XYMatrix.ino b/Библиотеки/FastLED-master/examples/XYMatrix/XYMatrix.ino
new file mode 100644
index 0000000..53c2141
--- /dev/null
+++ b/Библиотеки/FastLED-master/examples/XYMatrix/XYMatrix.ino
@@ -0,0 +1,196 @@
+#include <FastLED.h>
+
+#define LED_PIN 3
+
+#define COLOR_ORDER GRB
+#define CHIPSET WS2811
+
+#define BRIGHTNESS 64
+
+// Helper functions for an two-dimensional XY matrix of pixels.
+// Simple 2-D demo code is included as well.
+//
+// XY(x,y) takes x and y coordinates and returns an LED index number,
+// for use like this: leds[ XY(x,y) ] == CRGB::Red;
+// No error checking is performed on the ranges of x and y.
+//
+// XYsafe(x,y) takes x and y coordinates and returns an LED index number,
+// for use like this: leds[ XY(x,y) ] == CRGB::Red;
+// Error checking IS performed on the ranges of x and y, and an
+// index of "-1" is returned. Special instructions below
+// explain how to use this without having to do your own error
+// checking every time you use this function.
+// This is a slightly more advanced technique, and
+// it REQUIRES SPECIAL ADDITIONAL setup, described below.
+
+
+// Params for width and height
+const uint8_t kMatrixWidth = 16;
+const uint8_t kMatrixHeight = 16;
+
+// Param for different pixel layouts
+const bool kMatrixSerpentineLayout = true;
+// Set 'kMatrixSerpentineLayout' to false if your pixels are
+// laid out all running the same way, like this:
+//
+// 0 > 1 > 2 > 3 > 4
+// |
+// .----<----<----<----'
+// |
+// 5 > 6 > 7 > 8 > 9
+// |
+// .----<----<----<----'
+// |
+// 10 > 11 > 12 > 13 > 14
+// |
+// .----<----<----<----'
+// |
+// 15 > 16 > 17 > 18 > 19
+//
+// Set 'kMatrixSerpentineLayout' to true if your pixels are
+// laid out back-and-forth, like this:
+//
+// 0 > 1 > 2 > 3 > 4
+// |
+// |
+// 9 < 8 < 7 < 6 < 5
+// |
+// |
+// 10 > 11 > 12 > 13 > 14
+// |
+// |
+// 19 < 18 < 17 < 16 < 15
+//
+// Bonus vocabulary word: anything that goes one way
+// in one row, and then backwards in the next row, and so on
+// is call "boustrophedon", meaning "as the ox plows."
+
+
+// This function will return the right 'led index number' for
+// a given set of X and Y coordinates on your matrix.
+// IT DOES NOT CHECK THE COORDINATE BOUNDARIES.
+// That's up to you. Don't pass it bogus values.
+//
+// Use the "XY" function like this:
+//
+// for( uint8_t x = 0; x < kMatrixWidth; x++) {
+// for( uint8_t y = 0; y < kMatrixHeight; y++) {
+//
+// // Here's the x, y to 'led index' in action:
+// leds[ XY( x, y) ] = CHSV( random8(), 255, 255);
+//
+// }
+// }
+//
+//
+uint16_t XY( uint8_t x, uint8_t y)
+{
+ uint16_t i;
+
+ if( kMatrixSerpentineLayout == false) {
+ i = (y * kMatrixWidth) + x;
+ }
+
+ if( kMatrixSerpentineLayout == true) {
+ if( y & 0x01) {
+ // Odd rows run backwards
+ uint8_t reverseX = (kMatrixWidth - 1) - x;
+ i = (y * kMatrixWidth) + reverseX;
+ } else {
+ // Even rows run forwards
+ i = (y * kMatrixWidth) + x;
+ }
+ }
+
+ return i;
+}
+
+
+// Once you've gotten the basics working (AND NOT UNTIL THEN!)
+// here's a helpful technique that can be tricky to set up, but
+// then helps you avoid the needs for sprinkling array-bound-checking
+// throughout your code.
+//
+// It requires a careful attention to get it set up correctly, but
+// can potentially make your code smaller and faster.
+//
+// Suppose you have an 8 x 5 matrix of 40 LEDs. Normally, you'd
+// delcare your leds array like this:
+// CRGB leds[40];
+// But instead of that, declare an LED buffer with one extra pixel in
+// it, "leds_plus_safety_pixel". Then declare "leds" as a pointer to
+// that array, but starting with the 2nd element (id=1) of that array:
+// CRGB leds_with_safety_pixel[41];
+// CRGB* const leds( leds_plus_safety_pixel + 1);
+// Then you use the "leds" array as you normally would.
+// Now "leds[0..N]" are aliases for "leds_plus_safety_pixel[1..(N+1)]",
+// AND leds[-1] is now a legitimate and safe alias for leds_plus_safety_pixel[0].
+// leds_plus_safety_pixel[0] aka leds[-1] is now your "safety pixel".
+//
+// Now instead of using the XY function above, use the one below, "XYsafe".
+//
+// If the X and Y values are 'in bounds', this function will return an index
+// into the visible led array, same as "XY" does.
+// HOWEVER -- and this is the trick -- if the X or Y values
+// are out of bounds, this function will return an index of -1.
+// And since leds[-1] is actually just an alias for leds_plus_safety_pixel[0],
+// it's a totally safe and legal place to access. And since the 'safety pixel'
+// falls 'outside' the visible part of the LED array, anything you write
+// there is hidden from view automatically.
+// Thus, this line of code is totally safe, regardless of the actual size of
+// your matrix:
+// leds[ XYsafe( random8(), random8() ) ] = CHSV( random8(), 255, 255);
+//
+// The only catch here is that while this makes it safe to read from and
+// write to 'any pixel', there's really only ONE 'safety pixel'. No matter
+// what out-of-bounds coordinates you write to, you'll really be writing to
+// that one safety pixel. And if you try to READ from the safety pixel,
+// you'll read whatever was written there last, reglardless of what coordinates
+// were supplied.
+
+#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
+CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
+CRGB* const leds( leds_plus_safety_pixel + 1);
+
+uint16_t XYsafe( uint8_t x, uint8_t y)
+{
+ if( x >= kMatrixWidth) return -1;
+ if( y >= kMatrixHeight) return -1;
+ return XY(x,y);
+}
+
+
+// Demo that USES "XY" follows code below
+
+void loop()
+{
+ uint32_t ms = millis();
+ int32_t yHueDelta32 = ((int32_t)cos16( ms * (27/1) ) * (350 / kMatrixWidth));
+ int32_t xHueDelta32 = ((int32_t)cos16( ms * (39/1) ) * (310 / kMatrixHeight));
+ DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768);
+ if( ms < 5000 ) {
+ FastLED.setBrightness( scale8( BRIGHTNESS, (ms * 256) / 5000));
+ } else {
+ FastLED.setBrightness(BRIGHTNESS);
+ }
+ FastLED.show();
+}
+
+void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
+{
+ byte lineStartHue = startHue8;
+ for( byte y = 0; y < kMatrixHeight; y++) {
+ lineStartHue += yHueDelta8;
+ byte pixelHue = lineStartHue;
+ for( byte x = 0; x < kMatrixWidth; x++) {
+ pixelHue += xHueDelta8;
+ leds[ XY(x, y)] = CHSV( pixelHue, 255, 255);
+ }
+ }
+}
+
+
+void setup() {
+ FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
+ FastLED.setBrightness( BRIGHTNESS );
+}