Socket
Socket
Sign inDemoInstall

node-red-contrib-anolog-to-digital-converter-raspberry-pi

Package Overview
Dependencies
25
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.19 to 0.4.21

58

ads1x15.js

@@ -25,3 +25,4 @@

this.channel = config.channel || "CHANNEL_0";
this.samplesPerSecond = config.samplesPerSecond || "SPS_250";
this.samplesPerSecond1 = config.samplesPerSecond1 || "SPS_128";
this.samplesPerSecond0 = config.samplesPerSecond0 || "SPS_920";
this.progGainAmp = config.progGainAmp || "PGA_4_096V";

@@ -47,8 +48,19 @@

{
// If this is pre-1.0, 'send' will be undefined, so fallback to node.send
send = send || function() { node.send.apply(node,arguments) }
// If this is pre-1.0, 'send' will be undefined, so fallback to node.send
send = send || function() { node.send.apply(node,arguments); };
//clear status icon every new trigger input
node.status({});
//define samplesPerSecond to a var based on user selection that is based on chipset
var samples_per_second = "SPS_250"; //value that works for both chips .....
if ( this.chip == "IC_ADS1115" )
{
samples_per_second = this.samplesPerSecond1;
}
else if ( this.chip == "IC_ADS1015" )
{
samples_per_second = this.samplesPerSecond0;
}
//Check to see if a job is already waiting in que / drop msg and next job and warn user about trigger rate

@@ -58,3 +70,5 @@ var is_que_full = globalContext.get("node_red_contrib_anolog_to_digital_converter_raspberry_pi_"+this.chip+this.i2c_address+this.channel);

{
await sleep(100);
return node.error('Dropped Request to fetch value from ADC, Chip:'+this.chip+' '+this.i2c_address+' '+this.channel+' , Please increse the ammount of time/rate of trigger when requesting this voltage');
}

@@ -66,4 +80,4 @@ else

//sleep 100ms to drop any extra requests made on this chip,i2c_address, and channel
await sleep(100);
//sleep to drop any extra requests made on this chip,i2c_address, and channel
await sleep(1);

@@ -75,8 +89,8 @@ //check to see if ads is busy with another job from another node/tree and wait for job to finish before sending this nodes work

{
node.warn('Upstream Treeing of node anolog_to_digital_converter_raspberry_pi detected. Please do not trigger more than one of these nodes at a time as Asynchronous message passing is not recomended; though supported it adds a delay to the output of these nodes. See documentation for this node on treeing ELSE: increase the time between triggers.');
node.warn('Did not wait until all the nodes were finished. increase the time between triggers. ELSE: Upstream Treeing of node anolog_to_digital_converter_raspberry_pi detected. Please do not trigger more than one of these nodes at a time as Asynchronous message passing is not recomended; though supported it adds a delay to the output of these nodes. See documentation for this node on treeing.');
while(adc_busy === true)
{
//Math.floor(Math.random() * (max - min + 1) + min);
var random_number_between_100_200 = Math.floor(Math.random() * (300 - 100 + 1) + 100);
await sleep(random_number_between_100_300);
var random_number_between_100_500 = Math.floor(Math.random() * (300 - 100 + 1) + 100);
await sleep(random_number_between_100_500);
adc_busy = globalContext.get("adc_is_busy_node_red_contrib_anolog_to_digital_converter_raspberry_pi");

@@ -89,4 +103,4 @@ }

//sleep 100ms to drop any extra requests made to the ads
await sleep(100);
//sleep to drop any extra requests made to the ads
await sleep(1);

@@ -110,3 +124,3 @@

pga: ADS1x15.pga[this.progGainAmp], // power-gain-amplifier range
sps: ADS1x15.spsADS1115[this.samplesPerSecond] // data rate (samples per second)
sps: ADS1x15.spsADS1115[samples_per_second] // data rate (samples per second)
});

@@ -137,4 +151,12 @@

//<option value="CHANNEL_0">A0-GND</option>
//put all msgs into a object
var voltage_output_object =
{
[[this.chip.slice(this.chip.length - 7)] + " • " + ["I2C_" + [this.i2c_address]] + " • " + "Channel " + ["A" + [this.channel.slice(this.channel.length - 1)] + "-GND"] + " • " + "Voltage"]:volts
};
//send to volts to payload
RED.util.setMessageProperty(msg,node.property,volts);
RED.util.setMessageProperty(msg,node.property,voltage_output_object);
send(msg);

@@ -167,4 +189,12 @@ }

//<option value="DIFF_0_1">A0-A1</option>
//put all msgs into a object
var voltage_output_object =
{
[[this.chip.slice(this.chip.length - 7)] + " • " + ["I2C_" + [this.i2c_address]] + " • " + "Channel " + ["A" + [this.channel.slice(5, - 2)]] + "-A" + [this.channel.slice(this.channel.length - 1)] + " • " + "Voltage"]:volts
};
//send to volts to payload
RED.util.setMessageProperty(msg,node.property,volts);
RED.util.setMessageProperty(msg,node.property,voltage_output_object);
send(msg);

@@ -180,3 +210,3 @@ }

globalContext.set("node_red_contrib_anolog_to_digital_converter_raspberry_pi_"+this.chip+this.i2c_address+this.channel, false);
await sleep(100);
await sleep(1);
if (done) {

@@ -183,0 +213,0 @@ done();

{
"name": "node-red-contrib-anolog-to-digital-converter-raspberry-pi",
"version": "0.4.19",
"version": "0.4.21",
"description": "A node-red node providing access to a ADS1x15 I2C analog to digital converter using a raspberry pi",

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

@@ -99,3 +99,7 @@ node-red-contrib-anolog-to-digital-converter-raspberry-pi

```
<br>
Please import this flow as an example of how to use.
NOTE: Make sure you name your msg.payload for each node or it will be deleted by the next. Again please import the example above.
<br>

@@ -180,1 +184,13 @@

<br>
version 0.4.21
<br>
Fixed Samples Per second issue. Users unable to set and keep value wanted.
<br>
Fixed a timeout issue that crashed node-red proper. THIS WAS BAD. But a rare case if a user had 4 ADC's connected and polled them at a rate of less than 100ms. Thankyou odd balls. never thought people would go pushing the limits of this node.
<br>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc