ev3js
Version:
LEGO Mindstorms EV3 API for Node.js
37 lines (31 loc) • 1.11 kB
JavaScript
var Device = require('./device.js');
var Sensor = function(port){
if(1 <= port && port <= 4){
this.path += '/' + this.search('in' + port) + '/';
}else{
throw new Error('Port should be 1-4.');
}
};
Sensor.prototype = new Device();
(function(){
this.path = '/sys/class/msensor';
this.accessor('bin_data', true, true);
this.accessor('bin_data_format', true, false);
this.accessor('dp', 'str2num', false);
this.accessor('fw_version', true, false);
this.accessor('address', true, false);
this.accessor('modes', true, false);
this.accessor('mode', true, true);
this.accessor('num_values', 'str2num', false);
this.accessor('poll_ms', 'str2num', true);
this.accessor('port_name', true, false);
this.accessor('units', true, false);
this.accessor('name', true, false);
this.accessor('state', true, false);
this.accessor('pin1_mv', true, false);
this.accessor('pin6_mv', true, false);
for(var i = 0; i < 8; i++){
this.accessor('value' + i, true, false);
}
}.bind(Sensor.prototype))();
module.exports = Sensor;