diff --git a/examples/javascript/led.js b/examples/javascript/led.js index 24730b7f..8a5f110b 100644 --- a/examples/javascript/led.js +++ b/examples/javascript/led.js @@ -22,10 +22,10 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// Load Grove module +// Load UPM module var ledSensor = require('jsupm_led'); -// Create the Grove LED object using GPIO pin 2 +// Create the LED object using GPIO pin 2 var led = new ledSensor.Led(2); // Print the name diff --git a/examples/javascript/moisture.js b/examples/javascript/moisture.js index 28c9c221..b55a23d5 100644 --- a/examples/javascript/moisture.js +++ b/examples/javascript/moisture.js @@ -1,31 +1,31 @@ /* -* Author: Zion Orent -* 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. -*/ + * Author: Zion Orent + * 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 +//Load UPM module var moisture = require('jsupm_moisture'); -// Instantiate a Grove Moisture sensor on analog pin A0 +// Instantiate a Moisture sensor on analog pin A0 var myMoistureObj = new moisture.Moisture(0); // Values (approximate): @@ -33,22 +33,20 @@ var myMoistureObj = new moisture.Moisture(0); // 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); +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); +process.on('SIGINT', function() { + console.log("Exiting..."); + process.exit(0); }); diff --git a/examples/javascript/vdiv.js b/examples/javascript/vdiv.js index 497bc55e..bfb0a925 100644 --- a/examples/javascript/vdiv.js +++ b/examples/javascript/vdiv.js @@ -1,51 +1,49 @@ /* -* Author: Zion Orent -* 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. -*/ + * Author: Zion Orent + * 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_vdiv'); -// Instantiate a Grove Voltage Divider sensor on analog pin A0 +// Instantiate a Voltage Divider sensor on analog pin A0 var myVoltageDivider = new voltageDivider.VDiv(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"); + +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); +process.on('SIGINT', function() { + myVoltageDivider = null; + voltageDivider.cleanUp(); + voltageDivider = null; + console.log("Exiting..."); + process.exit(0); }); diff --git a/examples/javascript/water.js b/examples/javascript/water.js index 836de486..bf751e18 100644 --- a/examples/javascript/water.js +++ b/examples/javascript/water.js @@ -22,25 +22,23 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// Load Grove module +// Load UPM module var waterSensor = require('jsupm_water'); // Instantiate a Water sensor on digital pin D2 var water = new waterSensor.Water(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"); +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); +process.on('SIGINT', function() { + console.log("Exiting..."); + process.exit(0); }); diff --git a/examples/javascript/wfs.js b/examples/javascript/wfs.js index f24481d9..c9186ef8 100644 --- a/examples/javascript/wfs.js +++ b/examples/javascript/wfs.js @@ -1,30 +1,30 @@ /* -* Author: Zion Orent -* 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. -*/ + * Author: Zion Orent + * 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_wfs'); -// Instantiate a Grove Water Flow Sensor on digital pin D2 +// Instantiate a Water Flow Sensor on digital pin D2 var myWaterFlow_obj = new waterFlow_lib.WFS(2); // set the flow counter to 0 and start counting @@ -33,34 +33,32 @@ 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(); +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(); + 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); + // 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. + // 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; +process.on('SIGINT', function() { + clearInterval(myInterval); + myWaterFlow_obj.stopFlowCounter(); + myWaterFlow_obj = null + waterFlow_lib.cleanUp(); + waterFlow_lib = null; - console.log("Exiting"); - process.exit(0); + console.log("Exiting"); + process.exit(0); });