forked from Makuna/NeoPixelBus
Update ReadMe.md
Cleanup API section
This commit is contained in:
130
ReadMe.md
130
ReadMe.md
@@ -1,5 +1,5 @@
|
|||||||
NeoPixelBus
|
# NeoPixelBus
|
||||||
====
|
|
||||||
Arduino NeoPixel library
|
Arduino NeoPixel library
|
||||||
|
|
||||||
Clone this into your Arduino\Library folder
|
Clone this into your Arduino\Library folder
|
||||||
@@ -7,89 +7,75 @@ Clone this into your Arduino\Library folder
|
|||||||
This library is a modification of the Adafruit NeoPixel library.
|
This library is a modification of the Adafruit NeoPixel library.
|
||||||
The Api is similiar, but it removes the overal brightness feature and adds animation support.
|
The Api is similiar, but it removes the overal brightness feature and adds animation support.
|
||||||
|
|
||||||
Installing This Library
|
## Installing This Library
|
||||||
------------------------
|
|
||||||
Create a directory in your Arduino\Library folder named "NeoPixelBus"
|
Create a directory in your Arduino\Library folder named "NeoPixelBus"
|
||||||
Clone (Git) this project into that folder.
|
Clone (Git) this project into that folder.
|
||||||
It should now show up in the import list.
|
It should now show up in the import list.
|
||||||
|
|
||||||
Samples
|
## Samples
|
||||||
-------
|
### NeoPixelTest
|
||||||
NeoPixelTest - this is simple example that sets four neopixels to red, green, blue, and then white in order; and then flashes them. If the first pixel is green and the second is red, you need to pass the NEO_RGB flag into the NeoPixelBus constructor.
|
this is simple example that sets four neopixels to red, green, blue, and then white in order; and then flashes them. If the first pixel is green and the second is red, you need to pass the NEO_RGB flag into the NeoPixelBus constructor.
|
||||||
NeoPixelFun - this is a more complex example, that includes code for three effects, and demonstrates animations.
|
### NeoPixelFun
|
||||||
|
this is a more complex example, that includes code for three effects, and demonstrates animations.
|
||||||
|
|
||||||
API Documentation
|
## API Documentation
|
||||||
-----------------
|
|
||||||
|
|
||||||
RgbColor object:
|
### RgbColor object
|
||||||
This represents a color and exposes useful methods to manipulate colors.
|
This represents a color and exposes useful methods to manipulate colors.
|
||||||
<pre><code>
|
|
||||||
RgbColor(uint8_t r, uint8_t g, uint8_t b)
|
|
||||||
</code></pre>
|
|
||||||
instantiates a RgbColor object with the given r, g, b values.
|
|
||||||
<pre><code>
|
|
||||||
RgbColor(uint8_t brightness)
|
|
||||||
</code></pre>
|
|
||||||
instantiates a RgbColor object with the given brightness. 0 is black, 128 is grey, 255 is white.
|
|
||||||
<pre><code>
|
|
||||||
uint8_t CalculateBrightness()
|
|
||||||
</code></pre>
|
|
||||||
returns the general brightness of the pixe, averaging color.
|
|
||||||
<pre><code>
|
|
||||||
void Darken(uint8_t delta)
|
|
||||||
</code></pre>
|
|
||||||
this will darken the color by the given amount
|
|
||||||
<pre><code>
|
|
||||||
void Lighten(uint8_t delta)
|
|
||||||
</code></pre>
|
|
||||||
this will lighten the color by the given amount
|
|
||||||
<pre><code>
|
|
||||||
static RgbColor LinearBlend(RgbColor left, RgbColor right, uint8_t progress)
|
|
||||||
</code></pre>
|
|
||||||
this will return a color that is a blend between the given colors. The amount to blend is given by the value of progress, 0 will return the left value, 255 will return the right value, 128 will return the value between them.
|
|
||||||
NOTE: This is not an accurate "visible light" color blend but is fast and in most cases good enough.
|
|
||||||
|
|
||||||
NeoPixelBus object:
|
#### RgbColor(uint8_t r, uint8_t g, uint8_t b)
|
||||||
|
instantiates a RgbColor object with the given r, g, b values.
|
||||||
|
|
||||||
|
#### RgbColor(uint8_t brightness)
|
||||||
|
instantiates a RgbColor object with the given brightness. 0 is black, 128 is grey, 255 is white.
|
||||||
|
|
||||||
|
#### uint8_t CalculateBrightness()
|
||||||
|
returns the general brightness of the pixe, averaging color.
|
||||||
|
|
||||||
|
#### void Darken(uint8_t delta)
|
||||||
|
this will darken the color by the given amount
|
||||||
|
|
||||||
|
#### void Lighten(uint8_t delta)
|
||||||
|
this will lighten the color by the given amount
|
||||||
|
|
||||||
|
#### static RgbColor LinearBlend(RgbColor left, RgbColor right, uint8_t progress)
|
||||||
|
this will return a color that is a blend between the given colors. The amount to blend is given by the value of progress, 0 will return the left value, 255 will return the right value, 128 will return the value between them.
|
||||||
|
|
||||||
|
NOTE: This is not an accurate "visible light" color blend but is fast and in most cases good enough.
|
||||||
|
|
||||||
|
### NeoPixelBus object
|
||||||
This represents a single NeoPixel Bus that is connected by a single pin. Please see Adafruit's documentation for details, but the differences are documented below.
|
This represents a single NeoPixel Bus that is connected by a single pin. Please see Adafruit's documentation for details, but the differences are documented below.
|
||||||
|
|
||||||
<pre><code>
|
#### NeoPixelBus(uint16_t n, uint8_t p = 6, uint8_t t = NEO_GRB | NEO_KHZ800);
|
||||||
NeoPixelBus(uint16_t n, uint8_t p = 6, uint8_t t = NEO_GRB | NEO_KHZ800);
|
|
||||||
<pre><code>
|
|
||||||
instantiates a NewoPixelBus object, with n number of pixels on the bus, over the p pin, using the defined NeoPixel type.
|
instantiates a NewoPixelBus object, with n number of pixels on the bus, over the p pin, using the defined NeoPixel type.
|
||||||
There are some NeoPixels that address the color values differently, so if you set the green color but it displays as red, use the NEO_RGB type flag.
|
There are some NeoPixels that address the color values differently, so if you set the green color but it displays as red, use the NEO_RGB type flag.
|
||||||
<pre><code>
|
|
||||||
NeoPixelBus strip = NeoPixelBus(4, 8, NEO_GRB | NEO_KHZ800);
|
#### NeoPixelBus strip = NeoPixelBus(4, 8, NEO_RGB | NEO_KHZ800);
|
||||||
</code></pre>
|
|
||||||
It is rare, but some older NeoPixels require a slower communications speed, to include this support you must include the following define before the NeoPixelBus library include and then include the NEO_KHZ400 type flag to enable this slower speed.
|
It is rare, but some older NeoPixels require a slower communications speed, to include this support you must include the following define before the NeoPixelBus library include and then include the NEO_KHZ400 type flag to enable this slower speed.
|
||||||
<pre><code>
|
|
||||||
|
```
|
||||||
#define INCLUDE_NEO_KHZ400_SUPPORT
|
#define INCLUDE_NEO_KHZ400_SUPPORT
|
||||||
#include <NeoPixelBus.h>
|
#include <NeoPixelBus.h>
|
||||||
|
|
||||||
NeoPixelBus strip = NeoPixelBus(4, 8, NEO_GRB | NEO_KHZ400);
|
NeoPixelBus strip = NeoPixelBus(4, 8, NEO_RGB | NEO_KHZ400);
|
||||||
</code></pre>
|
```
|
||||||
|
|
||||||
<pre><code>
|
#### void SetPixelColor(uint16_t n, RgbColor c)
|
||||||
void SetPixelColor(uint16_t n, RgbColor c)
|
This allows setting a pixel on the bus to a color as defined by a color object. If an animation is actively running on a pixel, it will be stopped.
|
||||||
</code></pre>
|
|
||||||
This allows setting a pixel on the bus to a color as defined by a color object. If an animation is actively running on a pixel, it will be stopped.
|
#### RgbColor GetPixelColor(uint16_t n) const
|
||||||
<pre><code>
|
this allows retrieving the current pixel color
|
||||||
RgbColor GetPixelColor(uint16_t n) const
|
|
||||||
</code></pre>
|
#### void LinearFadePixelColor(uint16_t time, uint16_t n, RgbColor color)
|
||||||
this allows retrieving the current pixel color
|
this will setup an animation for a pixel to linear fade between the current color and the given color over the time given. The time is in milliseconds.
|
||||||
<pre><code>
|
|
||||||
void LinearFadePixelColor(uint16_t time, uint16_t n, RgbColor color)
|
#### void StartAnimating()
|
||||||
</code></pre>
|
this method will initialize the animation state. This should be called only if there are no active animations and new animations are started.
|
||||||
this will setup an animation for a pixel to linear fade between the current color and the given color over the time given. The time is in milliseconds.
|
|
||||||
<pre><code>
|
#### void UpdateAnimations()
|
||||||
void StartAnimating()
|
this method will allow the animations to be processed and update the pixel color state.
|
||||||
</code></pre>
|
|
||||||
this method will initialize the animation state. This should be called only if there are no active animations and new animations are started.
|
NOTE: Show must still be called to push the color state to the physical NeoPixels.
|
||||||
<pre><code>
|
|
||||||
void UpdateAnimations()
|
#### bool IsAnimating() const
|
||||||
</code></pre>
|
this method will return the current animation state. It will return false if there are no active animations.
|
||||||
this method will allow the animations to processed and update the pixel color state.
|
|
||||||
NOTE: Show must still be called to push the color state to the physical NeoPixels.
|
|
||||||
<pre><code>
|
|
||||||
bool IsAnimating() const
|
|
||||||
</code></pre>
|
|
||||||
this method will return the current animation state. It will return false if there are no active animations.
|
|
||||||
|
Reference in New Issue
Block a user