Skip to content

Commit

Permalink
starting to integrate the manometer
Browse files Browse the repository at this point in the history
  • Loading branch information
theClarkSell committed Feb 28, 2015
1 parent 294a1a1 commit 98bf7c2
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 15 deletions.
41 changes: 41 additions & 0 deletions adc.js
@@ -0,0 +1,41 @@
var ADC = require('adc-pi-gpio'),
config = {
tolerance : 2,
interval : 300,
channels : [ 0 ],
//SPICLK: 12, 23,
//SPIMISO: 16, 21,
//SPIMOSI: 18, 19,
//SPICS: 22, 24
SPICLK: 23,
SPIMISO: 21,
SPIMOSI: 19,
SPICS: 24
};

var adc = new ADC(config);
adc.init();

adc.on('ready', function() {
console.log('Pins ready, listening to channel');
});

adc.on('change', function(data) {
//Pressure((((adc+0.3)/255)-0.04)/0.009)
//console.log("caculated", ((((data.value + 0.3) / 255) - 0.04) / 0.009) );
console.log('Channel ' + data.channel + ' value is now ' + data.value + ' which in proportion is: ' + data.percent);
});

//clean up.
adc.on('close', function() {
console.log('ADC terminated');
process.exit();
});

process.on('SIGTERM', function(){
adc.close();
});

process.on('SIGINT', function(){
adc.close();
});
3 changes: 3 additions & 0 deletions default.js
Expand Up @@ -255,6 +255,9 @@ var relayController = {
}

//gracefull exit
process.on('SIGTERM', function() {
}

process.on('SIGINT', function() {
console.log("\nGracefully shutting down from SIGINT (Ctrl+C)");

Expand Down
3 changes: 2 additions & 1 deletion settings.json
Expand Up @@ -2,7 +2,8 @@
{
"fanThreshold": "62",
"deIcerThreshold": "61",
"checkInterval": "300000",
//"checkInterval": "300000",
"checkInterval": "10000",
"pushNotificaitonUrl": "http://test.com/test",
"tempSensors": {
"outDoor": "28-0000069695fa",
Expand Down
27 changes: 13 additions & 14 deletions tests.js
Expand Up @@ -14,29 +14,28 @@ var ADC = require('adc-pi-gpio'),
};

var adc = new ADC(config);

process.on('SIGTERM', function(){
adc.close();
});

process.on('SIGINT', function(){
adc.close();
});

adc.init();

adc.on('ready', function() {
console.log('Pins ready, listening to channel');
});

adc.on('change', function(data) {
//Pressure((((adc+0.3)/255)-0.04)/0.009)
//console.log("caculated", ((((data.value + 0.3) / 255) - 0.04) / 0.009) );
console.log('Channel ' + data.channel + ' value is now ' + data.value + ' which in proportion is: ' + data.percent);
});

//clean up.
adc.on('close', function() {
console.log('ADC terminated');
process.exit();
});

adc.on('change', function(data) {

//Pressure((((adc+0.3)/255)-0.04)/0.009)
//console.log("caculated", ((((data.value + 0.3) / 255) - 0.04) / 0.009) );
console.log('Channel ' + data.channel + ' value is now ' + data.value + ' which in proportion is: ' + data.percent);
process.on('SIGTERM', function(){
adc.close();
});

process.on('SIGINT', function(){
adc.close();
});

0 comments on commit 98bf7c2

Please sign in to comment.