UNPKG

di-sensors

Version:

Drivers and examples for using DI_Sensors in Node.js

55 lines (44 loc) 2.35 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"); } } // 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 VL53L0X = require('./VL53L0X'); var DistanceSensor = function () { function DistanceSensor() { var bus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'RPI_1'; _classCallCheck(this, DistanceSensor); this.sensor = new VL53L0X(bus); this.sensor.setSignalRateLimit(0.1); this.sensor.setVcselPulsePeriod(this.sensor.VcselPeriodPreRange, 18); this.sensor.setVcselPulsePeriod(this.sensor.VcselPeriodFinalRange, 14); } _createClass(DistanceSensor, [{ key: 'startContinuous', value: function startContinuous() { var periodMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.startContinuous.startContinuous(periodMs); } }, { key: 'readRangeContinuous', value: function readRangeContinuous() { return this.sensor.readRangeContinuousMillimiters(); } }, { key: 'readRangeSingle', value: function readRangeSingle() { return this.sensor.readRangeSingleMillimiters(); } }, { key: 'timeoutOccurred', value: function timeoutOccurred() { return this.sensor.timeoutOccurred(); } }]); return DistanceSensor; }(); module.exports = DistanceSensor;