node-red-contrib-i2c
Advanced tools
Comparing version 0.8.4 to 0.9.0
module.exports = function(RED) { | ||
"use strict"; | ||
var I2C = require("i2c-bus"); | ||
try { | ||
var I2C = require("i2c-bus"); | ||
} catch (error) { | ||
var I2C_ERROR = error; | ||
I2C = null; | ||
} | ||
function validateI2C(node) { | ||
if (!I2C) { | ||
node.log("Couldn't load i2c-bus, is your platform supported ?"); | ||
node.status({fill:"gray",shape:"dot",text:"unsupported"}); | ||
if (I2C_ERROR) console.error(I2C_ERROR); | ||
return false; | ||
} | ||
return true; | ||
} | ||
// The Scan Node | ||
@@ -10,3 +25,5 @@ function I2CScanNode(n) { | ||
var node = this; | ||
if (!validateI2C(node)) return; | ||
node.port = I2C.openSync(node.busno); | ||
@@ -42,2 +59,4 @@ node.on("input", function(msg) { | ||
var node = this; | ||
if (!validateI2C(node)) return; | ||
@@ -124,2 +143,4 @@ node.port = I2C.openSync(node.busno); | ||
var node = this; | ||
if (!validateI2C(node)) return; | ||
@@ -193,2 +214,2 @@ node.port = I2C.openSync(node.busno); | ||
RED.nodes.registerType("i2c out", I2COutNode); | ||
} | ||
} |
{ | ||
"name": "node-red-contrib-i2c", | ||
"version": "0.8.4", | ||
"version": "0.9.0", | ||
"description": "A Node-RED node to talk to the Raspiberry PI's I2C port", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29605
196