From c5b68ebf6c0cc8feadcc7397937737ec2793dbba Mon Sep 17 00:00:00 2001 From: Sarah GP Date: Thu, 6 Oct 2016 16:39:38 -0400 Subject: [PATCH] Fixes RGB bug based on p5 color object changes --- examples/example_scripts/03_rgbleds/01_RGBWrite.js | 2 +- examples/index.html | 2 +- examples/p5_scripts/p5bots.js | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/example_scripts/03_rgbleds/01_RGBWrite.js b/examples/example_scripts/03_rgbleds/01_RGBWrite.js index d7c537f..322158e 100644 --- a/examples/example_scripts/03_rgbleds/01_RGBWrite.js +++ b/examples/example_scripts/03_rgbleds/01_RGBWrite.js @@ -15,7 +15,7 @@ var b = p5.board('/dev/cu.usbmodem1421', 'arduino'); function setup() { var rgb = b.pin({r: 9, g: 10, b: 11}, 'RGBLED'); - var c = color(65); + var c = color(0, 255, 0); rgb.write(c); fill(c); noStroke(); diff --git a/examples/index.html b/examples/index.html index ec04b64..51f02f8 100644 --- a/examples/index.html +++ b/examples/index.html @@ -10,7 +10,7 @@ - + \ No newline at end of file diff --git a/examples/p5_scripts/p5bots.js b/examples/p5_scripts/p5bots.js index 1900b75..be81f4d 100644 --- a/examples/p5_scripts/p5bots.js +++ b/examples/p5_scripts/p5bots.js @@ -451,11 +451,13 @@ function rgb(pin) { // Invert values for common anode RGBs if (this.common === 'anode') { - this.color.writeArr[0] = 255 - this.color.rgba[0]; - this.color.writeArr[1] = 255 - this.color.rgba[1]; - this.color.writeArr[2] = 255 - this.color.rgba[2]; + this.color.writeArr[0] = 255 - red(color); + this.color.writeArr[1] = 255 - green(color); + this.color.writeArr[2] = 255 - blue(color); } else { - this.color.writeArr = this.color.rgba; + this.color.writeArr[0] = red(color); + this.color.writeArr[1] = green(color); + this.color.writeArr[2] = blue(color); } function rgbWrite() {