Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-blink1-server

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-blink1-server - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

38

main.js

@@ -69,2 +69,8 @@ #!/usr/bin/env node

var blink1Pattern = function(time, rgb, position) {
blink1TryConnect();
blink1.writePatternLine(time * 1000 / 2, rgb[0], rgb[1], rgb[2], position*2);
blink1.writePatternLine(time * 1000 / 2, 0, 0, 0, position*2+1);
};
app.get('/blink1', function(req, res) {

@@ -143,2 +149,32 @@ blink1TryConnect();

app.get('/blink1/pattern', function(req, res) {
var colors = req.query.rgb.split(',');
var time = Number(req.query.time) || 0.1;
var repeats = Number(req.query.repeats) || Number(req.query.count) || 3;
var status = "success";
for (var i = 0, len = colors.length; i < len && i < 6; i++) {
var rgb = parsecolor(colors[i]).rgb;
blink1Pattern(time, rgb, i);
}
blink1.playLoop(0, colors.length > 6 ? 11 : colors.length*2-1, repeats);
if (colors.length > 6) {
status = "can only display first 6 colors. " + colors.length + " colors specified"
}
var response = {
blink1Connected: blink1 !== null,
blink1Serials: devices,
time: time,
colors: colors,
repeats: repeats,
cmd: "pattern",
status: status
};
res.json( response );
});
// respond with "Hello World!" on the homepage

@@ -154,2 +190,4 @@ app.get('/', function(req, res) {

"-- fade to a RGB color over time for led\n" +
"<li> <code> /blink1/pattern?rgb=%23ff0000,%23ffffff,%230000ff&time=.2&repeats=8 </code> " +
"-- blink a sequence of colors\n" +
"</ul></p>\n" +

@@ -156,0 +194,0 @@ "When starting server, argument specified is port to run on, e.g.:" +

4

package.json
{
"name": "node-blink1-server",
"version": "0.1.3",
"version": "0.1.4",
"description": "HTTP REST API server in Node for blink(1) devices",

@@ -29,5 +29,5 @@ "repository": {

"node-blink1": "^0.2.1",
"node-hid": "^0.5.0",
"node-hid": "^0.5.4",
"parse-color": "^1.0.0"
}
}

@@ -35,2 +35,6 @@ # node-blink1-server

- `repeats` -- number of times to blink (default: 3)
- `/blink1/pattern` -- blink a pattern of colors, query args:
- `rgb` -- hex color codes separated by a comma (,) (e.g. "`#ff00ff`") [required]
- `time` -- blink time in seconds (default: 0.1)
- `repeats` -- number of times to blink pattern (default: 3)

@@ -40,3 +44,3 @@ ### Examples:

$ blink1-server 8754 &
$ curl 'http://localhost8754/blink1'
$ curl 'http://localhost:8754/blink1'
{

@@ -54,3 +58,3 @@ "blink1Connected": true,

}
$ curl 'http://localhost:8754/blink1/fadeToRGB?rgb=%230000ff&time=2.5&ledn=2'
$ curl 'http://localhost:8754/blink1/fadeToRGB?rgb=%230000ff&time=2.5&ledn=2'
{

@@ -68,2 +72,19 @@ "blink1Connected": true,

}
$ curl 'http://localhost:8754/blink1/pattern?rgb=%23ff0000,%23ffffff,%230000ff&time=.2&repeats=8'
{
"blink1Connected": true,
"blink1Serials": [
"200026C1"
],
"time": 0.2,
"colors": [
"#ff0000",
"#ffffff",
"#0000ff"
],
"repeats": 8,
"cmd": "pattern",
"status": "success"
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc