mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
mcp9808: Initial commit for MCP9808 precision temperature sensor.
Add support for MCP9808 precision temp sensor. Implements all features except for TCrit and TUpper and TLower locking. Functionality includes alert, interrupt, resolution and hysteresis control. Signed-off-by: Marc Graham <marc@m2ag.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
422592f993
commit
85b5c8a64e
70
examples/javascript/mcp9808.js
Normal file
70
examples/javascript/mcp9808.js
Normal file
@ -0,0 +1,70 @@
|
||||
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||
/*jshint unused:true */
|
||||
// Leave the above lines for propper jshinting
|
||||
//Type Node.js Here :)
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Author: Marc Graham <marc@m2ag.net>
|
||||
* 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 mcp = require('jsupm_mcp9808');
|
||||
|
||||
var temp = new mcp.MCP9808(6);
|
||||
|
||||
console.log(temp.getTemp());
|
||||
|
||||
//Sleep mode:
|
||||
temp.shutDown();
|
||||
//wake up
|
||||
temp.shutDown(false);
|
||||
//set mode to report fahrenheit
|
||||
temp.setMode(false);
|
||||
//check reporting mode
|
||||
console.log(temp.isCelsius()) //False = fahrenheit
|
||||
//set mode to celsius
|
||||
temp.setMode();
|
||||
//read temp
|
||||
temp.getTemp();
|
||||
//check Tcrit, Tupper or Tlower status bits
|
||||
temp.isTcrit(); // true if over boundry.
|
||||
temp.isTupper();
|
||||
temp.isTlower();
|
||||
//set the values of monitior registers
|
||||
temp.setMonitorReg(mcp.MCP9808.CRIT_TEMP, 23);
|
||||
temp.setMonitorReg(mcp.MCP9808.LOWER_TEMP, 20);
|
||||
temp.setMonitorReg(mcp.MCP9808.UPPER_TEMP, 22);
|
||||
//read MonitorReg
|
||||
console.log("Tcrit = " + temp.getMonitorReg(mcp.MCP9808.CRIT_TEMP));
|
||||
console.log("Tcrit = " + temp.getMonitorReg(mcp.MCP9808.LOWER_TEMP));
|
||||
console.log("Tcrit = " + temp.getMonitorReg(mcp.MCP9808.UPPER_TEMP));
|
||||
|
||||
|
||||
process.exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user