sarahghp / p5bots

Use your microcontroller with p5.js
GNU Lesser General Public License v2.1
199 stars 45 forks source link

RGB Led in example isn't working #19

Open TomYeoman opened 7 years ago

TomYeoman commented 7 years ago

Hi nice library you've created

I'm running into an issue where i'm able to run examples found in the 02_leds folder, but the 03_rgbleds is erroring in the client (Falling over in the p5bots.js file)

Client Code:

var b = p5.board('COM9', 'arduino');

function setup() {
  var rgb = b.pin({ r: 20, g: 20, b: 20, common: 'anode' }, 'RGBLED');
  var c = color(0, 255, 0);
  rgb.write(c);
  fill(c);
  noStroke();
  ellipse(80, 80, 40, 40);
}

Errors:

image

The code appears like it's trying to read this.color.rgba which doesn't look like it's ever set (this.color only has a similar "levels" array but no rgba)

image

naimenz commented 7 years ago

Replacing 'rgba' with 'levels' fixes this. I think there must have been an update to p5 changing the color object.

sarahghp commented 7 years ago

Yes, I think so, too. I've updated master to use the accessor functions since the internal representation appears to keep changing, but I'll need to test it before I deploy a new version to NPM.