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."; outputStr = "but rather the temperature of the sensor elements.";
console.log(outputStr); console.log(outputStr);
var gas = CO2_lib.new_intp();
var temp = CO2_lib.new_intp();
function writeCO2data() function writeCO2data()
{ {
myCO2_obj.getData(gas, temp); if (!myCO2_obj.getData())
outputStr = "CO2 concentration: " + CO2_lib.intp_value(gas) + console.log("Failed to retrieve data");
" PPM, " + else
"Temperature (in C): " + CO2_lib.intp_value(temp); {
console.log(outputStr); outputStr = "CO2 concentration: " + myCO2_obj.getGas() +
" PPM, " +
"Temperature (in C): " + myCO2_obj.getTemperature();
console.log(outputStr);
}
} }
var myInterval; var myInterval;
setTimeout(function() 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" "The temperature reported is not the ambient temperature,\n"
"but rather the temperature of the sensor elements.") "but rather the temperature of the sensor elements.")
gas = upmMhz16.new_intp()
temp = upmMhz16.new_intp()
time.sleep(1) time.sleep(1)
while(1): while(1):
myCO2.getData(gas, temp) if (not myCO2.getData()):
outputStr = ("CO2 concentration: {0} PPM, " print "Failed to retrieve data"
"Temperature (in C): {1}".format( else:
upmMhz16.intp_value(gas), upmMhz16.intp_value(temp))) outputStr = ("CO2 concentration: {0} PPM, "
print outputStr "Temperature (in C): {1}".format(
myCO2.getGas(), myCO2.getTemperature()))
print outputStr
time.sleep(2) time.sleep(2)