mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 09:51:14 +03:00
ads1x15: initial commit for ads1x15 adc
Initial commit of ADS1x15 adc converter. Support for both ADS1015 12 bit and ADS1115 16 bit adc. --signoff Signed-off-by: Marc Graham <marc@m2ag.net> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
d0cb2a032c
commit
4259aeab7b
46
examples/javascript/ads1x15.js
Normal file
46
examples/javascript/ads1x15.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*jslint node:true, vars:true, bitwise:true, unparam:true */
|
||||
/*jshint unused:true */
|
||||
/*
|
||||
* 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 mraa = require('mraa');
|
||||
var version = mraa.getVersion();
|
||||
|
||||
if (version >= 'v0.6.1') {
|
||||
console.log('mraa version (' + version + ') ok');
|
||||
}
|
||||
else {
|
||||
console.log('meaa version(' + version + ') is old - this code may not work');
|
||||
}
|
||||
|
||||
var ADS1X15 = require('jsupm_ads1x15');
|
||||
var ads1115 = new ADS1X15.ADS1115(1, 0x49);
|
||||
var ads1015 = new ADS1X15.ADS1015(1, 0x48);
|
||||
|
||||
setInterval(function(){
|
||||
console.log(ads1115.getSample());
|
||||
console.log(ads1015.getSample());
|
||||
console.log("*********************");
|
||||
}, 1000);
|
||||
|
||||
|
Reference in New Issue
Block a user