Skip to content

Commit 59604a4

Browse files
committed
Update README.md
1 parent 78c0ad6 commit 59604a4

File tree

1 file changed

+51
-26
lines changed

1 file changed

+51
-26
lines changed

README.md

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
[![arduino-library-badge](https://www.ardu-badge.com/badge/FastLEDHub.svg?)](https://www.ardu-badge.com/FastLEDHub)
44
[![LGPL-2.1 license](https://img.shields.io/github/license/stnkl/FastLEDHub)](https://github.com/stnkl/FastLEDHub/blob/master/LICENSE)
55

6-
FastLEDHub allows you to manage all of your [FastLED]([FastLED](https://github.com/FastLED/FastLED)) sketches on the ESP8266 with minimal changes to your existing code. FastLEDHub is compatible with most of the demo sketches at [atuline/FastLED-Demos](https://github.com/atuline/FastLED-Demos). It requires little knowledge about the ESP8266 platform making in an ideal playground for beginners getting started with FastLED animations.
6+
FastLEDHub allows you to manage all of your [FastLED]([FastLED](https://github.com/FastLED/FastLED)) sketches on the ESP8266 with minimal changes to your existing code. It requires little knowledge about the ESP8266 platform making it an ideal playground for beginners getting started with FastLED animations.
77

88
## Features
99

1010
- Control multiple animations via an intuitive web interface
11-
- Use hardware inputs to cycle through animations and adjust the brightness
12-
- Adjust the animation speed globally
13-
- Select any constant color via the web interface
11+
- Adjust brightness and animation speed globally
12+
- Define color pickers to use as parameters for your animations
1413
- Define custom numeric sliders to parameterize your animations
1514
- Alarm: Be woken up to an animation slowly fading in
1615
- Sunset: Automatically fade in an animation when the sun sets at your location
16+
- Control animations and brightness using hardware inputs
1717
- Control animations using HTTP requests for easy automation
1818

1919
## Demo
2020

21-
![FastLEDHub web app screenshot](https://user-images.githubusercontent.com/17520641/158074593-c8d84507-1317-4146-9735-651f1761ee38.gif)
21+
![FastLEDHub web app screenshot](https://user-images.githubusercontent.com/17520641/163568239-527e2239-536c-4324-8e0f-5c712b3d4635.gif)
2222

2323

2424
## Installation
@@ -71,16 +71,17 @@ Using FastLEDHub to manage your FastLED animations requires mainly three steps:
7171

7272
```cpp
7373
#include <FastLEDHub.h>
74-
#include <ESPEssentials.h>
7574

76-
#define NUM_LEDS 6
75+
#define NUM_LEDS 100
7776
#define LED_TYPE WS2812B
7877
#define LIGHTSTRIP_PIN 5
7978

79+
CRGB leds[NUM_LEDS];
80+
8081
void setup()
8182
{
82-
FastLEDHub.initialize("Project Name", NUM_LEDS);
83-
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(FastLEDHub.hardwareLeds, NUM_LEDS);
83+
FastLEDHub.initialize("Project Name");
84+
FastLEDHub.addLeds<LED_TYPE, LIGHTSTRIP_PIN, GRB>(leds, NUM_LEDS);
8485
}
8586

8687
void loop()
@@ -91,6 +92,8 @@ void loop()
9192

9293
Change `NUM_LEDS`, `LED_TYPE` and `LIGHTSTRIP_PIN` according to your hardware configuration. You may notice that this is not different than setting up a regular FastLED sketch apart from using `FastLEDHub` instead of `FastLED`.
9394

95+
*Note:* By default FastLEDHub will apply gamma correction to the brightness value. To disable this behavior call `FastLEDHub.initialize("Project Name", false)` instead.
96+
9497
### Adding a new animation
9598

9699
Create a new animation file `Animations/ExampleAnimation.h`:
@@ -100,6 +103,8 @@ Create a new animation file `Animations/ExampleAnimation.h`:
100103

101104
#include <FastLEDHub.h>
102105

106+
extern CRGB leds[];
107+
103108
class ExampleAnimation : public Animation
104109
{
105110
public:
@@ -122,12 +127,12 @@ public:
122127
While creating your animation proceed as you usually would with FastLED by defining the `reset` and `loop` functions. `reset` will be called each time an animation gets started. Use this function to reset the state variables of your animation to its starting values. It will not be called when resuming the animation from the paused status. `loop` will be called repeatedly as long as the animation is running.
123128

124129
Keep in mind the following important differences to just using FastLED:
125-
- The regular `setup` function is called `reset` to emphasize its purpose
126-
- Instead of creating your own `leds` array use the existing `FastLEDHub.leds`
127-
- Within your animation use `FastLEDHub.numLeds` instead of `NUM_LEDS`
130+
- The regular `setup` function is called `reset` to emphasize its purpose.
131+
- Since `leds` has already been defined in the main sketch, simply indicate its existence with `extern CRGB leds[]`.
132+
- Within your animation use `FastLEDHub[0].size()` instead of `NUM_LEDS` to get the number of leds. If you are using multiple lightstrips change the index accordingly.
128133
- Every time you may want to use `FastLED` use `FastLEDHub` instead. Since `FastLEDHub` inherits from `FastLED` all member functions will be available just like before. FastLEDHub just adds some stuff on top of that.
129134

130-
If you want to convert an existing FastLED sketch (e.g. from [atuline/FastLED-Demos](https://github.com/atuline/FastLED-Demos)), so it can be handled by FastLEDHub, those are the necessary changes you have to perform.
135+
If you want to convert an existing FastLED sketch (e.g. from [atuline/FastLED-Demos](https://github.com/atuline/FastLED-Demos)), so it can be handled by FastLEDHub, generally those are the necessary changes you have to perform.
131136

132137
### Registering animations
133138

@@ -138,47 +143,63 @@ In your main sketch include your animations and register them at the end of the
138143

139144
...
140145

141-
registerAnimation(new ExampleAnimation("Example animation name"));
146+
FastLEDHub.registerAnimation(new ExampleAnimation("Example animation name"));
142147
```
143148

144149
The animation name can be any unique string and will be used to identify animations in the web interface.
145150

146151
## Additional features
147152

148-
### Static color display
153+
### Custom color pickers
154+
155+
FastLEDHub allows you to register multiple color pickers to use as parameters for your animations. This allows you to integrate custom colors, gradients and more.
156+
157+
To add a color picker use
158+
159+
```cpp
160+
FastLEDHub.registerColorPicker(new ColorPicker("Primary Color", CRGB(255, 0, 0)));
161+
FastLEDHub.registerColorPicker(new ColorPicker("Secondary Color", CRGB(0, 255, 0), "paint-bucket"));
162+
```
163+
164+
Within the web interface FastLEDHub uses [Bootstrap icons](https://icons.getbootstrap.com/#icons) to allow you to further differentiate between color pickers. Here `paint-bucket` refers to the respective icon class.
165+
166+
To access those colors within your animation use
149167

150-
FastLEDHub allows you to display a static color in the web interface. It will be handled as a separate animation and will always have animation index `0`. This is important if you want to trigger animations using HTTP requests.
168+
```cpp
169+
CRGB primaryColor = FastLEDHub.getColorPicker("Primary Color")->value; // access by name
170+
CRGB secondaryColor = FastLEDHub.getColorPicker(1)->value; // access by index
171+
```
151172

152173
### Pre-defined and custom sliders
153174

154-
You can add custom numeric sliders of type `int16_t` to adjust variables of animations dynamically. FastLEDHub automatically adds two sliders for brightness (0-1023, default: 1023) and animation speed (0-255, default: 127). Both of these fixed sliders have been integrated tightly into FastLEDHub and don't require any further attention. Changing the brightness will apply gamma correction automatically. Adjusting the speed will affect the effective delay of `FastLEDHub.delay()` to speed up or slow down animations. To prevent this explicitly use `FastLED.delay()` or Arduino's standard `delay()`.
175+
You can add custom numeric sliders of type `int16_t` to adjust variables of animations dynamically. FastLEDHub automatically adds two sliders for brightness (0-255, default: 127) and animation speed (0-255, default: 127). Both of these fixed sliders have been integrated tightly into FastLEDHub and don't require any further attention. By default changing the brightness will apply gamma correction automatically. Adjusting the speed will affect the effective delay of `FastLEDHub.delay()` to speed up or slow down animations. To prevent this explicitly use `FastLED.delay()`.
155176

156177
To add more custom sliders simply register them in the main sketch via
157178

158179
```cpp
159-
FastLEDHub.registerSlider(new Slider("Saturation", 150, 255, 200, 1));
180+
FastLEDHub.registerSlider(new Slider("Hue", 0, 359, 180, 1));
181+
FastLEDHub.registerSlider(new Slider("Saturation", 150, 255, 200, 1, "palette"));
160182
```
161183

162-
This example registers a slider with a range of `150-255` and step size `1` defaulting to the value `200`. Again the slider name `"Saturation"` can be any unique string identifying the slider in the web interface.
184+
Again `"palette"` refers to an optional [Bootstrap icon](https://icons.getbootstrap.com/#icons) and the slider name can be any unique string identifying the slider in the web interface.
163185

164186
To access custom slider values inside of your animation use
165187

166188
```cpp
167-
int16_t saturation = FastLEDHub.getSlider("Saturation")->value;
189+
int16_t hue = FastLEDHub.getSlider(2)->value; // access by index
190+
int16_t saturation = FastLEDHub.getSlider("Saturation")->value; // access by name
168191
```
169192

193+
*Remember:* Since FastLEDHub comes with two pre-defined sliders `Brightness` and `Speed` the first custom slider will have index `2`.
194+
170195
### Hardware inputs
171196

172-
FastLEDHub supports a potentiometer for brightness adjustments and a push button to cycle through animations. They have to be specifically enabled with
197+
FastLEDHub supports a potentiometer for brightness adjustments and push buttons to play/pause and cycle through animations. They have to be specifically enabled with
173198

174199
```cpp
175200
FastLEDHub.enablePotentiometer(potentiometerPin);
176-
```
177-
178-
and
179-
180-
```cpp
181201
FastLEDHub.enableToggleButton(togglePin);
202+
FastLEDHub.enableCycleButton(cyclePin);
182203
```
183204

184205
### Alarm and sunset
@@ -202,6 +223,10 @@ Most functions can be triggered via HTTP requests:
202223
- Trigger alarm: `http://<device-ip>/alarm`
203224
- Reset ESP8266: `http://<device-ip>/reboot`
204225

226+
```cpp
227+
FastLEDHub.initialize("Project Name", true);
228+
```
229+
205230
## License & Attribution
206231

207232
FastLEDHub is licensed under LGPL-2.1 and uses the [sunrise-sunset.org](https://sunrise-sunset.org/api) api to retrieve sunset times.

0 commit comments

Comments
 (0)