You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-11Lines changed: 40 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# control ws281x-LEDs with node.js
2
2
3
-
> if you happen to know C++ and node/V8, I would really appreciate any help and feedback on this module.
3
+
> if you happen to know C++ and node/iojs/V8, I would really appreciate any help
4
+
> and feedback on this module.
4
5
> There is certainly lots of room for improvement.
5
6
6
7
This module provides native bindings to the [rpi_ws281x](https://github.com/jgarff/rpi_ws281x)
@@ -23,7 +24,7 @@ if you prefer installing from source:
23
24
24
25
## usage
25
26
26
-
this module exports only three functions to send data to the LED-String.
27
+
this module mainly exports four functions to send data to the LED-String.
27
28
28
29
```javascript
29
30
exports= {
@@ -61,6 +62,23 @@ exports = {
61
62
};
62
63
```
63
64
65
+
### Index-Mapping
66
+
67
+
As the wiring of the LEDs not neccessarily corresponds to the pixel-ordering in the
68
+
data-array, this module supports index-remapping. So, if you are building a grid of LEDs you can just use an alternating, top-to-bottom or mirrored wiring and use the remapping in order to use a unified structure in the incoming data-arrays.
69
+
70
+
### Events
71
+
72
+
In Addition to that, the exported object is an `EventEmitter` that will emit the following Events:
73
+
74
+
*`beforeRender`: emitted just before the data is prepared and sent to the LED-driver.
75
+
The handler will receive the pixel-data array (an `Uint32Array`) as single argument.
76
+
As this event is handled synchronously, you can use this to manipulate the data before
77
+
it is sent to the LED-Strip.
78
+
*`render`: emitted after the data has been sent to the LED-Strip. The single argument
79
+
passed to the handler is the final pixel-data array, after index-remapping and
80
+
gamma-correction.
81
+
64
82
## testing basic functionality
65
83
66
84
connect the WS2812-strip to the raspberry-pi as described [here](https://learn.adafruit.com/neopixels-on-raspberry-pi/wiring)
@@ -70,15 +88,26 @@ You should now see some rainbow-colors animation on the LED-strip.
70
88
71
89
## hardware
72
90
73
-
There is a guide [over at adafruit.com](https://learn.adafruit.com/neopixels-on-raspberry-pi) on how
74
-
to get the hardware up and running. Essentially, you need the Raspberry Pi, a logic-level converter
75
-
to shift the output-voltage of the GPIO from 3.3V up to 5V (should be fast enough to handle 800kHz,
76
-
the guide mentions the 74AHCT125, mine is an 74HCT125N) and of course an LED-Strip or other types of WS2812-LEDs.
91
+
There is a guide [over at adafruit.com](https://learn.adafruit.com/neopixels-on-raspberry-pi)
92
+
on how to get the hardware up and running. I followed these instructions by the word and had a working LED-strip.
93
+
94
+
Essentially, you need the Raspberry Pi, a logic-level converter to shift the output-voltage of the GPIO from 3.3V up to 5V (the guide mentions the 74AHCT125, mine is an 74HCT125N which works just as well) and of course a LED-Strip or other types of WS2812-LEDs.
77
95
78
96
To connect all that together, I'd recommend buying a small breadboard and some jumper-wires.
79
-
Also, consider buing a 5V power-supply that can deliver up to 60mA per LED (so you'll need 6A to fully power 100 LEDs).
80
-
For smaller applications, a decent USB-charger should do.
97
+
Also, consider buying a 5V power-supply that can deliver up to 60mA per LED (so you'll need
98
+
up to 6A to fully power 100 LEDs). For smaller applications, a decent USB-charger should do.
99
+
100
+
### Buying stuff
101
+
102
+
A short checklist of what you will need:
103
+
104
+
* Raspberry-PI and SD-Card
105
+
* 5V power-supply (Meanwell for instance builds really good ones)
106
+
* LED-Strip with WS2811/WS2812 Controllers (there are several other controller-variations
107
+
that are not supported)
108
+
* a breadboard and some jumper-wires (m/m as well as at least two f/m to connect the GPIO-Pins)
109
+
* a 3.3V to 5V logic-level converter (74AHCT125 or 74HCT125N, others will probably also work)
110
+
* more wire to connect the LED-strips
81
111
82
-
You can buy everything you need at adafruit or any other electronics reseller
83
-
(germany: check [conrad electronic](http://www.conrad.de) or [watterott](http://watterott.com) – this is
84
-
where i bought most of my stuff).
112
+
You can buy everything at [adafruit.com](https://adafruit.com), [sparkfun](https://sparkfun.com), on ebay or your favourite electronics retailer (germany: check [conrad electronic](http://www.conrad.de) or [watterott](http://watterott.com)
0 commit comments