These are chat archives for nebrius/raspi-io

1st
Dec 2015
Tiago Alves
@tralves
Dec 01 2015 17:22
@nebrius Have you implemented the cleaner way in another module? I could update my implementation.
Bryan Hughes
@nebrius
Dec 01 2015 17:40
I haven’t yet, let me see if I can whip something up really quick though
Tiago Alves
@tralves
Dec 01 2015 17:42
Ok. What are the next steps with this module? Anything I can help?
Bryan Hughes
@nebrius
Dec 01 2015 17:45
ok, try this:
constructor(config) {
  if (typeof config == 'number' || typeof config == 'string') {
    config = { pin: config };
  }
  super(config.pin);
  (({ pin, frequency = 800, range = 255}) => {
    this.range = range;
    this.pwm = new Gpio(this.pins[0], {mode: Gpio.OUTPUT}); 
    this.pwm.pwmRange(range);
    this.pwm.pwmFrequency(frequency);
  })(config);
}
btw, that code is 100% untested and might have a bug in it :)
one other comment, can you change this.range and this.pwm to use symbols? http://www.2ality.com/2014/12/es6-symbols.html
symbols are the new way to do actually private properties on objects
Tiago Alves
@tralves
Dec 01 2015 17:48
@nebrius yeah... I had doubts when I implemented those properties. I'll do that and test that code.
Bryan Hughes
@nebrius
Dec 01 2015 17:50
thanks