Skip to content

Commit

Permalink
Fixes RGB bug based on p5 color object changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahghp committed Oct 6, 2016
1 parent e863e10 commit c5b68eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/example_scripts/03_rgbleds/01_RGBWrite.js
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/index.html
Expand Up @@ -10,7 +10,7 @@
<script src="/p5_scripts/p5.dom.js"></script>
<script src="/p5_scripts/p5bots.js"></script>
<!-- Swap out the script below with any of the others in example_scripts. -->
<script src="/example_scripts/01_basics/03_ButtonDraw.js"></script>
<script src="/example_scripts/03_rgbleds/01_RGBWrite.js"></script>

</body>
</html>
10 changes: 6 additions & 4 deletions examples/p5_scripts/p5bots.js
Expand Up @@ -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() {
Expand Down

0 comments on commit c5b68eb

Please sign in to comment.