mhz16: fixed JS/Python examples to match driver API

Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Zion Orent 2015-12-09 10:32:39 -05:00 committed by Mihai Tudor Panu
parent 66aaa97955
commit d04f93ffca
2 changed files with 16 additions and 16 deletions

View File

@ -47,16 +47,17 @@ console.log(outputStr);
outputStr = "but rather the temperature of the sensor elements.";
console.log(outputStr);
var gas = CO2_lib.new_intp();
var temp = CO2_lib.new_intp();
function writeCO2data()
{
myCO2_obj.getData(gas, temp);
outputStr = "CO2 concentration: " + CO2_lib.intp_value(gas) +
" PPM, " +
"Temperature (in C): " + CO2_lib.intp_value(temp);
console.log(outputStr);
if (!myCO2_obj.getData())
console.log("Failed to retrieve data");
else
{
outputStr = "CO2 concentration: " + myCO2_obj.getGas() +
" PPM, " +
"Temperature (in C): " + myCO2_obj.getTemperature();
console.log(outputStr);
}
}
var myInterval;
setTimeout(function()

View File

@ -56,16 +56,15 @@ print ("Make sure that the sensor has had "
"The temperature reported is not the ambient temperature,\n"
"but rather the temperature of the sensor elements.")
gas = upmMhz16.new_intp()
temp = upmMhz16.new_intp()
time.sleep(1)
while(1):
myCO2.getData(gas, temp)
outputStr = ("CO2 concentration: {0} PPM, "
"Temperature (in C): {1}".format(
upmMhz16.intp_value(gas), upmMhz16.intp_value(temp)))
print outputStr
if (not myCO2.getData()):
print "Failed to retrieve data"
else:
outputStr = ("CO2 concentration: {0} PPM, "
"Temperature (in C): {1}".format(
myCO2.getGas(), myCO2.getTemperature()))
print outputStr
time.sleep(2)