Giter VIP home page Giter VIP logo

rgbconverter's People

Contributors

floriancargoet avatar kumy avatar randysuen avatar ratkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rgbconverter's Issues

Arduino 1.0+ support

did not want to clone the whole repo just for this.

diff --git a/RGBConverter.h b/RGBConverter.h
index 1a3c960..da92c41 100644
--- a/RGBConverter.h
+++ b/RGBConverter.h
@@ -12,7 +12,11 @@
#ifndef RGBConverter_h
#define RGBConverter_h

-#include "WProgram.h"
+#if (ARDUINO < 100)
+#include <WProgram.h>
+#else
+#include <Arduino.h>
+#endif

class RGBConverter {

Add the license, please

I want to use your code in my future project, but you haven't given any license. Could you add it please?

comands

I'm trying to use this library but I can't work out commands for it. Can some plz build an example for me that's HSV to RGB
many thanks

Truncated division

Hi! I have slightly modified your library to match existing data structure I used for led lighting.

So that I had int[3] as rgb value instead of byte[3], inside a struct. I'm not so expert in C programming but seems that this change messed up the division between double and int and hslToRgb gives me only or 255-255-255 or 0-0-0.

I have casted all number in double (adding a .0 after each number) and avoided to use 1 as hue/saturation/light value but 0.99 and everything works ok.

Like this snippet of code:

void hslToRgb(double h, double s, double l, double rgb[]) {
  double r, g, b;

  if (s == 0) {
    r = g = b = l; // achromatic
  } else {
    double q = l < 0.5 ? l * (1.0 + s) : l + s - l * s;
    double p = 2 * l - q;
    r = hue2rgb(p, q, h + 1.0 / 3.0);
    g = hue2rgb(p, q, h);
    b = hue2rgb(p, q, h - 1.0 / 3.0);
  }

  rgb[0] = r * 255;
  rgb[1] = g * 255;
  rgb[2] = b * 255;
}

double hue2rgb(double p, double q, double t) {
  if (t < 0) t += 1;
  if (t > 1.0) t -= 1;
  if (t < 1.0 / 6.0) return p + (q - p) * 6.0 * t;
  if (t < 1.0 / 2.0) return q;
  if (t < 2.0 / 3.0) return p + (q - p) * (2.0 / 3.0 - t) * 6.0;
  return p;
}

Now it works like a charm, thanks!

Integer division rounding to zero in hue2rgb

Hi, I needed an HSL to RGB converter and was really excited to find this. However, when I started to use your library in my arduino project I kept getting grey values, as if my saturation was zero. After some digging I realized the cause of the issue was in the hue2rgb function in the cpp file - it would always fail the if statements with fractions and return p. This is because the integer division was rounding to zero. If you change the fractions from 1/2 to 1/2.0 this problem goes away and the converter works as it should!

Making the library more portable

Hi!

I've recently forked your project and decided to detach it from its Arduino dependency. We can still have the Arduino part as something extra but how about making the library more portable? I'm currently using it for a project that involves some ROS actions and LEDs where it is really handy. I also have a Raspberry Pi which I will soon attach to an LED stripe to play with it. The Arduino header (and types used in your version) pose the problem of using the library out of the box on non-Arduino platforms. Can you please view the changes I have made on my fork and maybe we can merge them with your project (if support for Arduino is to remain I can simply wrap my version of the library so that it can also use Arduino's data types)? I'm also considering (and even started) adding some testing for the library to check its behaviour.

Can't call any functions

Hello,
For each function that I try to call, it returns e.g. "hslToRgb was not declared in this scope".

However the library seems to be easy enough, I can't find a way to make it work.
Can you provide some instruction, please?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.