hybridgroup / cylon-gpio

Cylon drivers for GPIO devices
http://cylonjs.com
Other
19 stars 14 forks source link

Typo in range() function infrared proximity sensor driver #28

Closed nishendra closed 10 years ago

nishendra commented 10 years ago

The range() function in the infrared proximity sensor driver has a typo that causes a run time exception:

IrRangeSensor.prototype.range = function() {
  return(this.rangecm() / 2.54);
};

where rangeCm() is typed as rangecm(). This causes the following exception:

TypeError: Object #<IrRangeSensor> has no method 'rangecm'
    at IrRangeSensor.range (E:\Experiments\CylonJS\Arduino\arduino-uno-test1\node_modules\cylon-gpio\lib\ir-range-sensor.js:66:15)
    at Device.base.(anonymous function) [as range] (E:\Experiments\CylonJS\Arduino\arduino-uno-test1\node_modules\cylon\lib\utils.js:124:31)
    at null.<anonymous> (E:\Experiments\CylonJS\Arduino\arduino-uno-test1\ir_sensor.js:15:35)
    at wrapper [as _onTimeout] (timers.js:258:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Similar mistake can be seen here as well:

if (opts.extraParams.model) {
    this.rangeTable = require(path.join(__dirname, './ir_range_tables/' + opts.extraParams.model.toLowerCase() + '.js'));
    this.device.on('analogRead', function(readVal) {
      this.device.emit('range', this.range());
      this.device.emit('rangeCm', this.rangecm());
    }.bind(this));
deadprogram commented 10 years ago

In similar fashion to #27 please review the dev branch, and thanks!

deadprogram commented 10 years ago

That message was for @nishendra

nishendra commented 10 years ago

Hi @deadprogram, reviewed the dev branch and now it works perfectly. Thank you!

edgarsilva commented 10 years ago

solved.