12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
-
-
-
-
-
- var OTP538U_AREF = 5.0;
-
- var tempIRSensor_lib = require('jsupm_otp538u');
-
-
-
-
- var tempIRSensor_obj = new tempIRSensor_lib.OTP538U(0, 1, OTP538U_AREF);
-
-
- function checkTemp()
- {
- var outputStr = "Ambient temp: " +
- roundNum(tempIRSensor_obj.ambientTemperature(), 2) +
- " C, Object temp: " +
- roundNum(tempIRSensor_obj.objectTemperature(), 2) +
- " C";
- console.log(outputStr);
- }
-
- var myInterval = setInterval(checkTemp, 1000);
-
- 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));
- }
-
-
- process.on('SIGINT', function()
- {
- clearInterval(myInterval);
- console.log("Exiting...");
- process.exit(0);
- });
|