parallaxinc / Simple-Libraries

Contents of the SimpleIDE workspace folder and its Parallax Learn Simple Libraries subfolder.
http://learn.parallax.com/propeller-c-set-simpleide/update-your-learn-folder
21 stars 20 forks source link

Please add to ColorPal library #29

Closed MatzElectronics closed 8 years ago

MatzElectronics commented 8 years ago

To make the ColorPal sensor more useful when combined with modules, displays, or sensors that also use color in some way, this function is an attempt to output a "standardized" color value:

// ColorPal RRGGBB converter

/*
 * Takes the 12-bit red, green, and blue outputs from a ColorPal
 * sensor and generates an approximate RRGGBB (24-bit) output
 * compatible with HTML color codes and some RGB leds.
 */

unsigned int colorPalRRGGBB( int __r, int __g, int __b )
{

  __r = 21 * __r / 11 - 65 - ( __r * __r / 415  );
  __g = 48 * __g / 17 - 70 - ( __g * __g / 170  );
  __b = 8  * __b / 9  - 30 - ( __b * __b / 1680 );

  if( __r < 0 ) __r = 0; if( __r > 255 ) r = 255;
  if( __g < 0 ) __g = 0; if( __g > 255 ) g = 255;
  if( __b < 0 ) __b = 0; if( __b > 255 ) b = 255;

  return ((r & 0xFF) << 16 | (b & 0xFF) << 8 | (b & 0xFF));
}
AndyLindsay commented 8 years ago

Done.

zfi commented 8 years ago

I need a copy of this in the BlocklyProp branch please.

PropGit commented 8 years ago

Done.

MatzElectronics commented 8 years ago

@PropGit @zfi Found a typo in this library, submitted PR - @AndyLindsay will merge

AndyLindsay commented 8 years ago

New commits merged into master. Thanks Matt!

Andy

PropGit commented 8 years ago

@MatzElectronics @AndyLindsay - Was this done through the web interface? The space character in "Simple Libraries" was translated into %20, resulting in a whole new folder path instead of overwriting the files in the libcolorpal cmm/lmm folders.

image

I fixed this and pushed back.

MatzElectronics commented 8 years ago

It was the web, thanks for the catch!

On Aug 29, 2016 7:06 PM, "Parallax Git Administrator" < notifications@github.com> wrote:

@MatzElectronics https://github.com/MatzElectronics @AndyLindsay https://github.com/AndyLindsay - Was this done through the web interface? The space character in "Simple Libraries" was translated into %20, resulting in a whole new folder path instead of overwriting the files in the libcolorpal cmm/lmm folders.

[image: image] https://cloud.githubusercontent.com/assets/1266318/18073409/a439283e-6e1a-11e6-806d-b126855c2200.png

I fixed this and pushed back.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/Simple-Libraries/issues/29#issuecomment-243312391, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0quHA0RIkouNSltUnyZwFjztvptK-Uks5qk5AugaJpZM4JaDr- .