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.1 to 0.1.2

68

main.js

@@ -53,2 +53,18 @@ #!/usr/bin/env node

var blink1Blink = function( onoff, repeats, millis, r, g, b, ledn ) {
// console.log("blink1Blink:", onoff, repeats, millis, r, g, b, ledn );
if( onoff ) {
blink1Fade( millis/2, r, g, b, ledn );
} else {
blink1Fade( millis/2, 0, 0, 0, ledn );
repeats--;
}
onoff = !onoff;
if( repeats ) {
setTimeout( function() {
blink1Blink(onoff, repeats, millis, r, g, b, ledn);
}, millis );
}
};
app.get('/blink1', function(req, res) {

@@ -70,18 +86,16 @@ blink1TryConnect();

app.get('/blink1/fadeToRGB', function(req, res) {
var rgb;
var color = parsecolor(req.query.rgb);
var time = Number(req.query.time) || 0.1;
var ledn = Number(req.query.ledn) || 0;
var status = "success";
if( req.query.rgb ) {
var color = parsecolor(req.query.rgb);
if( !color.rgb ) {
status = "bad hex color specified " + req.query.rgb;
} else {
rgb = color.rgb;
lastColor = color.hex;
lastTime = time;
lastLedn = ledn;
status = blink1Fade( time*1000, rgb[0], rgb[1], rgb[2], ledn );
}
var rgb = color.rgb;
if( rgb ) {
lastColor = color.hex;
lastTime = time;
lastLedn = ledn;
status = blink1Fade( time*1000, rgb[0], rgb[1], rgb[2], ledn );
}
else {
status = "bad hex color specified " + req.query.rgb;
}
var response = {

@@ -100,2 +114,32 @@ blink1Connected: blink1 !== null,

app.get('/blink1/blink', function(req, res) {
var color = parsecolor(req.query.rgb);
var time = Number(req.query.time) || 0.1;
var ledn = Number(req.query.ledn) || 0;
var repeats = Number(req.query.repeats) || Number(req.query.count) || 3;
var status = "success";
var rgb = color.rgb;
if( rgb ) {
lastColor = color.hex;
lastTime = time;
lastLedn = ledn;
lastRepeats = repeats;
blink1Blink( true, repeats, time*1000, rgb[0], rgb[1], rgb[2], ledn );
}
else {
status = "bad hex color specified " + req.query.rgb;
}
var response = {
blink1Connected: blink1 !== null,
blink1Serials: devices,
lastColor: lastColor,
lastTime: lastTime,
lastLedn: lastLedn,
lastRepeats: lastRepeats,
cmd: "blink1",
status: status
};
res.json( response );
});
// respond with "Hello World!" on the homepage

@@ -102,0 +146,0 @@ app.get('/', function(req, res) {

2

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

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

@@ -26,3 +26,11 @@ # node-blink1-server

- `/blink1` -- status info about connected blink1s, lastColor, etc.
- `/blink1/fadeToRGB` -- fade blink(1) to a color
- `/blink1/fadeToRGB` -- fade blink(1) to a color. query args:
- `rgb` -- hex color code (e.g. "#ff00ff") [required]
- `time` -- fade time in seconds (default: 0.1)
- `ledn` -- LED to control (0=both, 1=top, 2=bottom; default: 0)
- `/blink1/blink` -- blink a color, query args:
- `rgb` -- hex color code (e.g. "`#ff00ff`") [required]
- `time` -- fade & blink time in seconds (default: 0.1)
- `ledn` -- LED to control (0=both, 1=top, 2=bottom; default: 0)
- `repeats` -- number of times to blink (default: 3)

@@ -29,0 +37,0 @@ ### Examples:

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