-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
278 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/// This animation has been taken from https://github.com/atuline/FastLED-Demos and | ||
/// modified to be used with FastLEDHub. | ||
/// It is licensed under the GNU General Public License v3.0. | ||
|
||
#pragma once | ||
|
||
#include <FastLEDHub.h> | ||
|
||
extern CRGB leds[]; | ||
|
||
class Confetti : public Animation | ||
{ | ||
public: | ||
using Animation::Animation; | ||
|
||
uint8_t fade = 8; | ||
uint8_t inc = 1; | ||
uint8_t saturation = 100; | ||
uint8_t brightness = 255; | ||
int hue = 50; | ||
int hueDiff = 256; | ||
|
||
void reset() | ||
{ | ||
} | ||
|
||
void loop() | ||
{ | ||
uint8_t secondHand = (millis() / 1000) % 15; | ||
static uint8_t lastSecond = 99; | ||
if (lastSecond != secondHand) | ||
{ | ||
lastSecond = secondHand; | ||
switch(secondHand) | ||
{ | ||
case 0: inc = 1; hue = 192; saturation = 255; fade = 2; hueDiff = 256; break; | ||
case 5: inc = 2; hue = 128; fade = 8; hueDiff = 64; break; | ||
case 10: inc = 1; hue = random16(255); fade = 1; hueDiff = 16; break; | ||
case 15: break; | ||
} | ||
} | ||
|
||
fadeToBlackBy(leds, FastLEDHub[0].size(), fade); | ||
int pos = random16(FastLEDHub[0].size()); | ||
leds[pos] += CHSV((hue + random16(hueDiff))/4 , saturation, brightness); | ||
hue = hue + inc; | ||
|
||
FastLEDHub.delay(5); | ||
FastLEDHub.show(); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <FastLEDHub.h> | ||
|
||
extern CRGB leds[]; | ||
|
||
class Gradient : public Animation | ||
{ | ||
public: | ||
using Animation::Animation; | ||
|
||
uint16_t NUM_LEDS; | ||
|
||
void reset() | ||
{ | ||
NUM_LEDS = FastLEDHub[0].size(); | ||
} | ||
|
||
void loop() | ||
{ | ||
for(uint16_t i = 0; i < NUM_LEDS; i++) | ||
{ | ||
leds[i] = blend(FastLEDHub.getColorPicker(0)->value, FastLEDHub.getColorPicker(1)->value, 255 * i / NUM_LEDS); | ||
} | ||
|
||
FastLEDHub.show(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <FastLEDHub.h> | ||
|
||
extern CRGB leds[]; | ||
|
||
class Rainbow : public Animation | ||
{ | ||
public: | ||
using Animation::Animation; | ||
|
||
void reset() | ||
{ | ||
} | ||
|
||
void loop() | ||
{ | ||
// Since we use beatsin88 to generate a sine wave we need to incorporate the speed slider without using delay(): | ||
uint16_t speed = FastLEDHub.getSlider("Speed")->value; | ||
uint16_t startHue = beatsin16(speed / 16 / 5, 0, 1535); | ||
uint16_t endHue = beatsin16(speed / 16 / 2, 0, 1535); | ||
|
||
if (startHue < endHue) | ||
{ | ||
for(int16_t i = 0; i < FastLEDHub[0].size(); i++) | ||
{ | ||
leds[i] = hsv2rgb_smooth(startHue + (endHue - startHue) * i / FastLEDHub[0].size(), FastLEDHub.getSlider("Saturation")->value, 255); | ||
} | ||
} | ||
else | ||
{ | ||
for(int16_t i = FastLEDHub[0].size() - 1; i >= 0; i--) | ||
{ | ||
leds[i] = hsv2rgb_smooth(startHue + (endHue - startHue) * i / FastLEDHub[0].size(), FastLEDHub.getSlider("Saturation")->value, 255); | ||
} | ||
} | ||
|
||
FastLEDHub.show(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <FastLEDHub.h> | ||
|
||
#include "Animations/Confetti.h" | ||
#include "Animations/Color.h" | ||
#include "Animations/Gradient.h" | ||
#include "Animations/Rainbow.h" | ||
#include "Animations/RGBWave.h" | ||
|
||
#define NUM_LEDS 100 | ||
#define LIGHTSTRIP_PIN 5 | ||
#define LED_TYPE WS2812B | ||
|
||
CRGB leds[NUM_LEDS]; | ||
|
||
void setup() | ||
{ | ||
FastLEDHub.initialize("Basic Example"); | ||
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS); | ||
|
||
FastLEDHub.registerAnimation(new Color("Color")); | ||
FastLEDHub.registerAnimation(new Gradient("Gradient")); | ||
FastLEDHub.registerAnimation(new Rainbow("Rainbow")); | ||
FastLEDHub.registerAnimation(new RGBWave("RGB Wave")); | ||
FastLEDHub.registerAnimation(new Confetti("Confetti")); | ||
|
||
FastLEDHub.registerSlider(new Slider("Saturation", 0, 255, 255, 1, "palette2")); | ||
|
||
FastLEDHub.registerColorPicker(new ColorPicker("Primary Color", CRGB(255, 0, 0))); | ||
FastLEDHub.registerColorPicker(new ColorPicker("Secondary Color", CRGB(0, 255, 0))); | ||
} | ||
|
||
void loop() | ||
{ | ||
FastLEDHub.handle(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <FastLEDHub.h> | ||
|
||
extern CRGB leds[]; | ||
|
||
class Gradient : public Animation | ||
{ | ||
public: | ||
using Animation::Animation; | ||
|
||
uint16_t NUM_LEDS; | ||
|
||
void reset() | ||
{ | ||
NUM_LEDS = FastLEDHub[0].size(); | ||
} | ||
|
||
void loop() | ||
{ | ||
for(uint16_t i = 0; i < NUM_LEDS; i++) | ||
{ | ||
leds[i] = blend(FastLEDHub.getColorPicker(0)->value, FastLEDHub.getColorPicker(1)->value, 255 * i / NUM_LEDS); | ||
} | ||
|
||
FastLEDHub.show(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <FastLEDHub.h> | ||
|
||
#include <Animations/Color.h> // This animation comes with FastLEDHub | ||
#include "Animations/Gradient.h" | ||
|
||
#define NUM_LEDS 100 | ||
#define LIGHTSTRIP_PIN 5 | ||
#define LED_TYPE WS2812B | ||
|
||
CRGB leds[NUM_LEDS]; | ||
|
||
void setup() | ||
{ | ||
FastLEDHub.initialize("Color Pickers Example"); | ||
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS); | ||
|
||
FastLEDHub.registerAnimation(new Color("Color")); | ||
FastLEDHub.registerAnimation(new Gradient("Gradient")); | ||
|
||
FastLEDHub.registerColorPicker(new ColorPicker("Primary Color", CRGB(255, 0, 0))); | ||
FastLEDHub.registerColorPicker(new ColorPicker("Secondary Color", CRGB(255, 0, 0))); | ||
} | ||
|
||
void loop() | ||
{ | ||
FastLEDHub.handle(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <FastLEDHub.h> | ||
|
||
extern CRGB leds[]; | ||
|
||
class Rainbow : public Animation | ||
{ | ||
public: | ||
using Animation::Animation; | ||
|
||
void reset() | ||
{ | ||
} | ||
|
||
void loop() | ||
{ | ||
// Since we use beatsin88 to generate a sine wave we need to incorporate the speed slider without using delay(): | ||
uint16_t speed = FastLEDHub.getSlider("Speed")->value; | ||
uint16_t startHue = beatsin16(speed / 16 / 5, 0, 1535); | ||
uint16_t endHue = beatsin16(speed / 16 / 2, 0, 1535); | ||
|
||
if (startHue < endHue) | ||
{ | ||
for(int16_t i = 0; i < FastLEDHub[0].size(); i++) | ||
{ | ||
leds[i] = hsv2rgb_smooth(startHue + (endHue - startHue) * i / FastLEDHub[0].size(), FastLEDHub.getSlider("Saturation")->value, 255); | ||
} | ||
} | ||
else | ||
{ | ||
for(int16_t i = FastLEDHub[0].size() - 1; i >= 0; i--) | ||
{ | ||
leds[i] = hsv2rgb_smooth(startHue + (endHue - startHue) * i / FastLEDHub[0].size(), FastLEDHub.getSlider("Saturation")->value, 255); | ||
} | ||
} | ||
|
||
FastLEDHub.show(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <FastLEDHub.h> | ||
|
||
#include "Animations/Rainbow.h" | ||
|
||
#define NUM_LEDS 100 | ||
#define LIGHTSTRIP_PIN 5 | ||
#define LED_TYPE WS2812B | ||
|
||
CRGB leds[NUM_LEDS]; | ||
|
||
void setup() | ||
{ | ||
FastLEDHub.initialize("Sliders Example"); | ||
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS); | ||
|
||
FastLEDHub.registerAnimation(new Rainbow("Rainbow")); | ||
|
||
FastLEDHub.registerSlider(new Slider("Saturation", 0, 255, 255, 1, "palette2")); | ||
} | ||
|
||
void loop() | ||
{ | ||
FastLEDHub.handle(); | ||
} |