dotstar | Library to control Adafruit DotStar LED strip
kandi X-RAY | dotstar Summary
kandi X-RAY | dotstar Summary
A javascript library to use the Adafruit DotStar LED strip with raspberry pi.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dotstar
dotstar Key Features
dotstar Examples and Code Snippets
Community Discussions
Trending Discussions on dotstar
QUESTION
I've set up a node server on a raspberry pi to display a sequence of colors on an Adafruit Dotstar light strip. The functionality works as follows: I make an HTTP request to localhost:8000/fade
, and the server responds by running the fade.js file, which is an infinite loop that fades through different colors on the light strip. Unfortunately, I'd like to be able to exit this command and shut off the light strip with another request to localhost:8000/off
.
I've experimented with the child_process
package in order to run the "fade" code, while also listening to new requests. However, I'm unable to kill the "fade" process.
Posted below is my app.js code. Any suggestions on how to kill the child_process, or perhaps restructure the code in some other way to accomplish the same goal? I really just need to be able to run the "fade" code continuously, while also responding to new requests.
p.s. This is my first JS project so go easy! Any help is appreciated.
app.js:
...ANSWER
Answered 2018-Jun-27 at 02:26var child; // Outer scope, available in both functions.
app.get('/fade', function (req, res) {
var fork = require('child_process').fork;
child = fork('./sequences/fade.js');
});
app.get('/off', function (req, res) {
// (might be a good idea to check if child exists and is running first...)
child.kill('SIGHUP');
});
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dotstar
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page