grovevdiv: python example and js modification for grovevdiv voltage divider

Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Zion Orent
2015-03-26 09:58:41 -04:00
committed by Mihai Tudor Panu
parent 6c93816a77
commit 2ceee8bf26
2 changed files with 61 additions and 4 deletions

View File

@ -1,6 +1,5 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*global */
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
@ -31,11 +30,12 @@ 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()
{
var val = myVoltageDivider.value(100);
var gain3val = myVoltageDivider.computedValue(3, val);
var gain10val = myVoltageDivider.computedValue(10, val);
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");
}
@ -45,6 +45,9 @@ setInterval(getVoltageInfo, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
myVoltageDivider = null;
voltageDivider.cleanUp();
voltageDivider = null;
console.log("Exiting...");
process.exit(0);
});