We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents aefa8ce + f5856f7 commit 0d6ebe6Copy full SHA for 0d6ebe6
examples/iterate.js
@@ -0,0 +1,30 @@
1
+var ws281x = require('../index.js');
2
+
3
+var NUM_LEDS = parseInt(process.argv[2], 10) || 10,
4
+ pixelData = new Uint32Array(NUM_LEDS);
5
6
+ws281x.init(NUM_LEDS);
7
8
+ws281x.setIndexMapping(ws281x.indexMapping.mirrorMatrixX(10,10));
9
10
+// ---- trap the SIGINT and reset before exit
11
+process.on('SIGINT', function () {
12
+ ws281x.reset();
13
+ process.nextTick(function () { process.exit(0); });
14
+});
15
16
17
+// ---- animation-loop
18
+var offset = 0;
19
+setInterval(function () {
20
+ var i=NUM_LEDS;
21
+ while(i--) {
22
+ pixelData[i] = 0;
23
+ }
24
+ pixelData[offset] = 0xffffff;
25
26
+ offset = (offset + 1) % NUM_LEDS;
27
+ ws281x.render(pixelData);
28
+}, 100);
29
30
+console.log('Press <ctrl>+C to exit.');
0 commit comments