UNPKG

di-sensors

Version:

Drivers and examples for using DI_Sensors in Node.js

49 lines (34 loc) 2.55 kB
'use strict'; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // https://www.dexterindustries.com/GoPiGo/ // https://github.com/DexterInd/DI_Sensors // // Copyright (c) 2017 Dexter Industries // Released under the MIT license (http://choosealicense.com/licenses/mit/). // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md var Sensor = require('./base/sensor'); var PCA9570 = function (_Sensor) { _inherits(PCA9570, _Sensor); function PCA9570() { var bus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'RPI_1'; _classCallCheck(this, PCA9570); return _possibleConstructorReturn(this, (PCA9570.__proto__ || Object.getPrototypeOf(PCA9570)).call(this, bus, PCA9570.ADDRESS)); } _createClass(PCA9570, [{ key: 'setPins', value: function setPins(value) { this.i2c.write8(value & 0x0F); } }, { key: 'getPins', value: function getPins() { return this.i2c.read8u() & 0x0F; } }]); return PCA9570; }(Sensor); PCA9570.ADDRESS = 0x24; module.exports = PCA9570;