grove: remove deprecated classes and examples

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu
2019-05-07 18:00:34 -07:00
parent 7d0600df1c
commit 33d0aee280
217 changed files with 11 additions and 12042 deletions

View File

@ -1,44 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var upmled = require("jsupm_grove");
// Initialize on GPIO 2
var myled = new upmled.GroveLed(2);
myled.on();
// Dummy setInterval, just to keep program from quitting
// This way, the LED turns off when you quit the program
var myInterval = setInterval(function()
{
;
}, 1000);
// When exiting: turn off LED, clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
myled.off();
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,35 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the button object using GPIO pin 0
var button = new groveSensor.GroveButton(0);
// Read the input and print, waiting one second between readings
function readButtonValue() {
console.log(button.name() + " value is " + button.value());
}
setInterval(readButtonValue, 1000);

View File

@ -1,60 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var collision_lib = require("jsupm_grovecollision");
// The was tested with the Grove Collision Sensor
// Instantiate a Grove Collision on digital pin D2
var collision_obj = new collision_lib.GroveCollision(2);
var collisionState = false;
console.log("No collision");
// Having an infinate loop prevents nodeJS from catching Cntl-C
// We need to catch Cntl-C to clean up memory
// Instead, we check the collision sensor every millisecond
var myInterval = setInterval(function()
{
if (collision_obj.isColliding() && !collisionState)
{
console.log("Collision!");
collisionState = true;
}
else if (!collision_obj.isColliding() && collisionState)
{
console.log("No collision");
collisionState = false;
}
}, 1);
// When exiting: clear interval, clean up memory, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
collision_obj = null;
collision_lib.cleanUp();
collision_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,62 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load heart rate sensor module
var heartRateSensor = require('jsupm_groveehr');
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
var myHeartRateSensor = new heartRateSensor.GroveEHR(2);
// set the beat counter to 0, init the clock and start counting beats
myHeartRateSensor.clearBeatCounter();
myHeartRateSensor.initClock();
myHeartRateSensor.startBeatCounter();
var millis, beats, hr;
var myInterval = setInterval(function()
{
// we grab these just for display purposes in this example
millis = myHeartRateSensor.getMillis();
beats = myHeartRateSensor.beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
hr = myHeartRateSensor.heartRate();
// output milliseconds passed, beat count, and computed heart rate
console.log("Millis: " + millis + " Beats: " + beats +
" Heart Rate: " + hr);
}, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
clearInterval(myInterval);
myHeartRateSensor.stopBeatCounter();
myHeartRateSensor = null
heartRateSensor.cleanUp();
heartRateSensor = null;
console.log("Exiting");
process.exit(0);
});

View File

@ -1,52 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var eldriver_lib = require("jsupm_groveeldriver");
// The was tested with the Grove El Driver Module
// Instantiate a Grove El Driver on digital pin D2
var eldriver_obj = new eldriver_lib.GroveElDriver(2);
var lightState = true;
var myInterval = setInterval(function()
{
if (lightState)
eldriver_obj.on();
else
eldriver_obj.off();
lightState = !lightState;
}, 1000);
// When exiting: turn off EL wire, clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
eldriver_obj.off();
eldriver_obj = null;
eldriver_lib.cleanUp();
eldriver_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,55 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var electromagnet_lib = require("jsupm_groveelectromagnet");
// The was tested with the Grove Electromagnetic Module
// Instantiate a Grove Electromagnet on digital pin D2
var electromagnet_obj = new electromagnet_lib.GroveElectromagnet(2);
console.log("Starting up magnet....");
electromagnet_obj.off();
var magnetState = false;
// Turn magnet on and off every 5 seconds
var myInterval = setInterval(function()
{
magnetState = !magnetState;
if (magnetState)
electromagnet_obj.on();
else
electromagnet_obj.off();
console.log("Turning magnet " + ((magnetState) ? "on" : "off"));
}, 5000);
// When exiting: clear interval, turn off magnet, run memory cleanup, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
electromagnet_obj.off();
electromagnet_obj = null;
electromagnet_lib.cleanUp();
electromagnet_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var groveemg_lib = require("jsupm_groveemg");
// The was tested with the GroveEMG Muscle Signal Reader Sensor Module
// Instantiate a GroveEMG on analog pin A0
var groveemg_obj = new groveemg_lib.GroveEMG(0);
console.log("Calibrating....");
groveemg_obj.calibrate();
var myInterval = setInterval(function()
{
console.log(groveemg_obj.value());
}, 100);
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
groveemg_obj = null;
groveemg_lib.cleanUp();
groveemg_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,111 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var sensorObj = require('jsupm_grovegprs');
/************** Functions **************/
function printUsage(progname)
{
var outputStr = "Usage: " + progname + " [AT command]\n\n" +
"If an argument is supplied on the command line, that argument is\n" +
"sent to the module and the response is printed out.\n\n" +
"If no argument is used, then the manufacturer and the current\n" +
"saved profiles are queried and the results printed out.\n\n"
console.log(outputStr);
}
// simple helper function to send a command and wait for a response
function sendCommand(sensor, cmd, callback)
{
// commands need to be terminated with a carriage return
cmd += "\r";
sensor.writeDataStr(cmd);
// wait up to 1 second
if (sensor.dataAvailable(1000))
{
console.log("Returned: " + sensor.readDataStr(1024));
}
else
console.log("Timed out waiting for response");
if (callback)
callback();
}
/************** Main code **************/
// Instantiate a GROVEGPRS Module on UART 0
var sensor = new sensorObj.GroveGPRS(0);
// Set the baud rate, 19200 baud is the default.
if (sensor.setBaudRate(19200))
{
console.log("Failed to set baud rate");
process.exit(0);
}
printUsage(process.argv[1]);
// Note: in nodeJS, command-line argument 0 is "node".
// Command-line argument 1 is "grovegprs.js"
// If you have a third argument, then it's a command
if (process.argv.length > 2)
{
console.log("Sending command line argument (" + process.argv[2] + ")...");
sendCommand(sensor, process.argv[2]);
}
else
{
// sending this command as a synchronous callback ensures better timing
var callbackFunc = function()
{
setTimeout(function()
{
// query the saved profiles
console.log("Querying the saved profiles (AT&V)...");
sendCommand(sensor, "AT&V");
// A comprehensive list is available from the
// datasheet at:
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
}, 1000);
};
// query the module manufacturer
console.log("Querying module manufacturer (AT+CGMI)...");
sendCommand(sensor, "AT+CGMI", callbackFunc);
}
/************** Exit code **************/
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,49 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var grovegsr_lib = require("jsupm_grovegsr");
// The was tested with the GroveGSR Galvanic Skin Response Sensor module.
// Instantiate a GroveGSR on analog pin A0
var grovegsr_obj = new grovegsr_lib.GroveGSR(0);
console.log("Calibrating....");
grovegsr_obj.calibrate();
var myInterval = setInterval(function()
{
console.log(grovegsr_obj.value());
}, 500);
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
grovegsr_obj = null;
grovegsr_lib.cleanUp();
grovegsr_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the Grove LED object using GPIO pin 2
var led = new groveSensor.GroveLed(2);
// Print the name
console.log(led.name());
// Turn the LED on and off 10 times, pausing one second
// between transitions
var i = 0;
var waiting = setInterval(function() {
if ( i % 2 == 0 ) {
led.on();
} else {
led.off();
}
i++;
if ( i == 20 ) clearInterval(waiting);
}, 1000);

View File

@ -1,37 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the light sensor object using AIO pin 0
var light = new groveSensor.GroveLight(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
function readLightSensorValue() {
console.log(light.name() + " raw value is " + light.raw_value() +
", which is roughly " + light.value() + " lux");
}
setInterval(readLightSensorValue, 1000);

View File

@ -1,44 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var lineFinderSensor = require('jsupm_grovelinefinder');
// Instantiate a Grove line finder sensor on digital pin D2
var myLineFinderSensor = new lineFinderSensor.GroveLineFinder(2);
// Check every second for the presence of white detection
setInterval(function()
{
if (myLineFinderSensor.whiteDetected())
console.log("White detected.");
else
console.log("Black detected.");
}, 1000);
// Turn relay off when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,92 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var grovemdObj = require('jsupm_grovemd');
// This example demonstrates using the GroveMD to drive a stepper motor
function start()
{
if (motor)
{
// configure it, for this example, we'll assume 200 steps per rev
motor.configStepper(200);
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CW, 10);
}
}
function reverse()
{
if (motor)
{
// now reverse
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CCW, 10);
}
}
function end()
{
if (motor)
{
motor.disableStepper();
}
exit();
}
// When exiting: clear memory and print exit message
function exit()
{
if (motor)
{
motor = null;
grovemdObj.cleanUp();
}
grovemdObj = null;
console.log("Exiting");
process.exit(0);
}
// Instantiate an I2C Grove Motor Driver on I2C bus 0
var motor = new grovemdObj.GroveMD(
grovemdObj.GROVEMD_I2C_BUS,
grovemdObj.GROVEMD_DEFAULT_I2C_ADDR);
start();
setTimeout(function()
{
reverse();
setTimeout(end, 3000);
}, 3000);
process.on('SIGINT', function()
{
exit();
});

View File

@ -1,91 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var groveMotorDriver_lib = require('jsupm_grovemd');
function start()
{
if (my_MotorDriver_obj)
{
// set direction to CW and set speed to 50%
console.log("Spin M1 and M2 at half speed for 3 seconds");
my_MotorDriver_obj.setMotorDirections(groveMotorDriver_lib.GroveMD.DIR_CW,
groveMotorDriver_lib.GroveMD.DIR_CW);
my_MotorDriver_obj.setMotorSpeeds(127, 127);
}
}
function reverse()
{
if (my_MotorDriver_obj)
{
// counter clockwise
console.log("Reversing M1 and M2 for 3 seconds");
my_MotorDriver_obj.setMotorDirections(groveMotorDriver_lib.GroveMD.DIR_CCW,
groveMotorDriver_lib.GroveMD.DIR_CCW);
}
}
function end()
{
if (my_MotorDriver_obj)
{
console.log("Stopping motors");
my_MotorDriver_obj.setMotorSpeeds(0, 0);
}
exit();
}
// When exiting: clear memory and print exit message
function exit()
{
if (my_MotorDriver_obj)
{
my_MotorDriver_obj = null;
groveMotorDriver_lib.cleanUp();
}
groveMotorDriver_lib = null;
console.log("Exiting");
process.exit(0);
}
// Instantiate an I2C Grove Motor Driver on I2C bus 0
var my_MotorDriver_obj = new groveMotorDriver_lib.GroveMD(
groveMotorDriver_lib.GROVEMD_I2C_BUS,
groveMotorDriver_lib.GROVEMD_DEFAULT_I2C_ADDR);
start();
setTimeout(function()
{
reverse();
setTimeout(end, 3000);
}, 3000);
process.on('SIGINT', function()
{
exit();
});

View File

@ -1,54 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//Load Grove Moisture module
var grove_moisture = require('jsupm_grovemoisture');
// Instantiate a Grove Moisture sensor on analog pin A0
var myMoistureObj = new grove_moisture.GroveMoisture(0);
// Values (approximate):
// 0-300, sensor in air or dry soil
// 300-600, sensor in humid soil
// 600+, sensor in wet soil or submerged in water
// Read the value every second and print the corresponding moisture level
setInterval(function()
{
var result;
var moisture_val = parseInt(myMoistureObj.value());
if (moisture_val >= 0 && moisture_val < 300)
result = "Dry";
else if (moisture_val >= 300 && moisture_val < 600)
result = "Moist";
else
result = "Wet";
console.log("Moisture value: " + moisture_val + ", " + result);
}, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,50 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var groveO2_lib = require("jsupm_groveo2");
// The was tested with the O2 Oxygen Concentration Sensor Module
// Instantiate a GroveO2 on analog pin A0
var groveO2_obj = new groveO2_lib.GroveO2(0);
var myInterval = setInterval(function()
{
console.log("The output voltage is: " + roundNum(groveO2_obj.voltageValue(), 5) + "mV");
}, 100);
function roundNum(num, decimalPlaces)
{
var extraNum = (1 / (Math.pow(10, decimalPlaces) * 1000));
return (Math.round((num + extraNum) * (Math.pow(10, decimalPlaces))) / Math.pow(10, decimalPlaces));
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
groveO2_obj = null;
groveO2_lib.cleanUp();
groveO2_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,49 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the relay switch object using GPIO pin 0
var relay = new groveSensor.GroveRelay(0);
// Close and then open the relay switch 3 times,
// waiting one second each time. The LED on the relay switch
// will light up when the switch is on (closed).
// The switch will also make a noise between transitions.
var i = 0;
var waiting = setInterval(function() {
if ( i % 2 == 0 ) {
relay.on();
if ( relay.isOn() )
console.log(relay.name() + " is on");
} else {
relay.off();
if ( relay.isOff() )
console.log(relay.name() + " is off");
}
i++;
if ( i == 6) clearInterval(waiting);
}, 1000);

View File

@ -1,49 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//setup/Initialization
var upm_grove = require('jsupm_grove');
//setup access analog input Analog pin #0 (A0)
var groveRotary = new upm_grove.GroveRotary(0);
loop();
function loop()
{
var abs = groveRotary.abs_value();
var absdeg = groveRotary.abs_deg();
var absrad = groveRotary.abs_rad();
var rel = groveRotary.rel_value();
var reldeg = groveRotary.rel_deg();
var relrad = groveRotary.rel_rad();
//write the knob value to the console in different formats
console.log("Abs: " + abs + " " + Math.round(parseInt(absdeg)) + " " + absrad.toFixed(3));
console.log("Rel: " + rel + " " + Math.round(parseInt(reldeg)) + " " + relrad.toFixed(3));
//wait 2 s and call function again
setTimeout(loop, 2000);
}

View File

@ -1,69 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var cameraObj = require('jsupm_grovescam');
// Instantiate a Grove Serial Camera on UART 0
var camera = new cameraObj.GROVESCAM(0);
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty())
{
console.log("Failed to setup tty port parameters");
process.exit(1);
}
if (camera.init())
console.log("Initialized...");
else
console.log("init() failed");
if (camera.preCapture())
console.log("preCapture succeeded...");
else
console.log("preCapture failed.");
if (camera.doCapture())
console.log("doCapture succeeded...");
else
console.log("doCapture failed.");
console.log("Image size is " + camera.getImageSize() + " bytes");
if (camera.getImageSize() > 0)
{
console.log("Storing image.jpg...");
if (camera.storeImage("image.jpg"))
console.log("storeImage succeeded...");
else
console.log("storeImage failed.");
}
camera = null;
cameraObj.cleanUp();
cameraObj = null;
console.log("Exiting.");
process.exit(0);

View File

@ -1,42 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var upm_grove = require('jsupm_grove');
//setup access analog input Analog pin #0 (A0)
var groveSlide = new upm_grove.GroveSlide(0);
loop();
function loop()
{
var raw = groveSlide.raw_value();
var volts = groveSlide.voltage_value();
//write the slider values to the console
console.log("Slider Value: " + raw + " = " + volts.toFixed(2) + " V");
//wait 2 s then call function again
setTimeout(loop, 2000);
}

View File

@ -1,41 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//Load Grove Speaker module
var groveSpeaker = require('jsupm_grovespeaker');
// Instantiate a Grove Speaker on digital pin D2
var mySpeaker = new groveSpeaker.GroveSpeaker(2);
// Play all 7 of the lowest notes
mySpeaker.playAll();
// Play a medium C-sharp
mySpeaker.playSound('c', true, "med");
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,42 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the temperature sensor object using AIO pin 0
var temp = new groveSensor.GroveTemp(0);
console.log(temp.name());
// Read the temperature ten times, printing both the Celsius and
// equivalent Fahrenheit temperature, waiting one second between readings
var i = 0;
var waiting = setInterval(function() {
var celsius = temp.value();
var fahrenheit = celsius * 9.0/5.0 + 32.0;
console.log(celsius + " degrees Celsius, or " +
Math.round(fahrenheit) + " degrees Fahrenheit");
i++;
if (i == 10) clearInterval(waiting);
}, 1000);

View File

@ -1,45 +0,0 @@
/*
* Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var ultrasonic = require("jsupm_groveultrasonic");
var sensor = new ultrasonic.GroveUltraSonic(2);
var myInterval = setInterval(function()
{
var travelTime = sensor.getDistance();
if (travelTime > 0) {
var distance = (travelTime / 29 / 2).toFixed(3);
console.log("distance: " + distance + " [cm]");
}
}, 200);
// When exiting: clear interval and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,51 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var voltageDivider = require('jsupm_grovevdiv');
// Instantiate a Grove Voltage Divider sensor on analog pin A0
var myVoltageDivider = new voltageDivider.GroveVDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)
var val, gain3val, gain10val;
function getVoltageInfo()
{
val = myVoltageDivider.value(100);
gain3val = myVoltageDivider.computedValue(3, val);
gain10val = myVoltageDivider.computedValue(10, val);
console.log("ADC value: " + val + " Gain 3: " + gain3val
+ "v Gain 10: " + gain10val + "v");
}
setInterval(getVoltageInfo, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
myVoltageDivider = null;
voltageDivider.cleanUp();
voltageDivider = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Load Grove module
var waterSensor = require('jsupm_grovewater');
// Instantiate a Grove Water sensor on digital pin D2
var water = new waterSensor.GroveWater(2);
// Read whether the sensor is wet/dry, waiting one second between readings
function readWaterState()
{
if (water.isWet())
console.log("Sensor is wet");
else
console.log("Sensor is dry");
}
setInterval(readWaterState, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,66 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var waterFlow_lib = require('jsupm_grovewfs');
// Instantiate a Grove Water Flow Sensor on digital pin D2
var myWaterFlow_obj = new waterFlow_lib.GroveWFS(2);
// set the flow counter to 0 and start counting
myWaterFlow_obj.clearFlowCounter();
myWaterFlow_obj.startFlowCounter();
var millis, flowCount, fr;
var myInterval = setInterval(function()
{
// we grab these (millis and flowCount) just for display
// purposes in this example
millis = myWaterFlow_obj.getMillis();
flowCount = myWaterFlow_obj.flowCounter();
fr = myWaterFlow_obj.flowRate();
// output milliseconds passed, flow count, and computed flow rate
outputStr = "Millis: " + millis + " Flow Count: " + flowCount +
" Flow Rate: " + fr + " LPM";
console.log(outputStr);
// best to gather data for at least one second for reasonable
// results.
}, 2000);
// When exiting: clear interval and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
myWaterFlow_obj.stopFlowCounter();
myWaterFlow_obj = null
waterFlow_lib.cleanUp();
waterFlow_lib = null;
console.log("Exiting");
process.exit(0);
});