changed range of S and V to be 0-100 instead of 0-1
But still use float so that values of 50.3, 99.5, etc. are still distinguishable.
This commit is contained in:
parent
3020b800a6
commit
1b402b5ebc
|
|
@ -30,7 +30,7 @@ void Pixel::setRGB(uint8_t r, uint8_t g, uint8_t b, int nPixels){
|
|||
|
||||
///////////////////
|
||||
|
||||
void Pixel::setColor(color_t *color, int nPixels){
|
||||
void Pixel::setColors(color_t *color, int nPixels){
|
||||
|
||||
if(!*rf)
|
||||
return;
|
||||
|
|
@ -46,7 +46,7 @@ void Pixel::setColor(color_t *color, int nPixels){
|
|||
|
||||
void Pixel::setHSV(float h, float s, float v, int nPixels){
|
||||
float r,g,b;
|
||||
LedPin::HSVtoRGB(h,s,v,&r,&g,&b);
|
||||
LedPin::HSVtoRGB(h,s/100.0,v/100.0,&r,&g,&b);
|
||||
setRGB(r*255,g*255,b*255,nPixels);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ color_t Pixel::getColorRGB(uint8_t r, uint8_t g, uint8_t b){
|
|||
|
||||
color_t Pixel::getColorHSV(float h, float s, float v){
|
||||
float r,g,b;
|
||||
LedPin::HSVtoRGB(h,s,v,&r,&g,&b);
|
||||
LedPin::HSVtoRGB(h,s/100.0,v/100.0,&r,&g,&b);
|
||||
return(getColorRGB(r*255,g*255,b*255));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ class Pixel {
|
|||
Pixel(int pin) : Pixel(pin, 0.32, 0.88, 0.64, 0.56, 80.0) {}; // default parameters for SK68XXMINI-HS LEDs, though will likely work with many other variations as well
|
||||
|
||||
void setRGB(uint8_t r, uint8_t g, uint8_t b, int nPixels=1); // sets color of nPixels to RGB values (0-255)
|
||||
void setHSV(float h, float s, float v, int nPixels=1); // sets color of nPixels to HSV values where h=[0,360], s=[0,1], v=[0,1]
|
||||
void setColor(color_t *color, int nPixels); // sets color of nPixels from array of Colors
|
||||
void setHSV(float h, float s, float v, int nPixels=1); // sets color of nPixels to HSV values where h=[0,360], s=[0,100], v=[0,100]
|
||||
void setColors(color_t *color, int nPixels); // sets colors of nPixels from array of Colors
|
||||
int getPin(){return(rf->getPin());} // returns pixel pin if valid, else returns -1
|
||||
|
||||
static color_t getColorRGB(uint8_t r, uint8_t g, uint8_t b); // return pixel Color from RGB values
|
||||
static color_t getColorHSV(float h, float s, float v); // return pixel Color from HSV values
|
||||
static color_t getColorRGB(uint8_t r, uint8_t g, uint8_t b); // return pixel Color from RGB values
|
||||
static color_t getColorHSV(float h, float s, float v); // return pixel Color from HSV values
|
||||
|
||||
operator bool(){ // override boolean operator to return true/false if creation succeeded/failed
|
||||
return(*rf);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,25 @@ void setup() {
|
|||
|
||||
Serial.printf("PX on Pin=%d check: %s\n",px.getPin(),px?"OKAY":"BAD");
|
||||
|
||||
px.setRGB(0,0,0,8);
|
||||
int H=0;
|
||||
color_t x[8];
|
||||
int s;
|
||||
|
||||
while(1){
|
||||
|
||||
for(int i=0;i<8;i++)
|
||||
x[i]=px.getColorHSV(H,i*3+79,i*2+5);
|
||||
|
||||
px.setColors(x,8);
|
||||
delay(20);
|
||||
H=H+1;
|
||||
if(H>=360)
|
||||
H=0;
|
||||
|
||||
s++;
|
||||
if(s>8)
|
||||
s=0;
|
||||
}
|
||||
|
||||
} // end of setup()
|
||||
|
||||
|
|
@ -51,47 +69,47 @@ void loop(){
|
|||
uint32_t d=2;
|
||||
|
||||
while(1){
|
||||
px.setColor(x1,8);
|
||||
px.setColors(x1,8);
|
||||
delay(d);
|
||||
px.setColor(x2,8);
|
||||
px.setColors(x2,8);
|
||||
delay(d);
|
||||
px.setColor(x3,8);
|
||||
px.setColors(x3,8);
|
||||
delay(d);
|
||||
px.setColor(x4,8);
|
||||
px.setColors(x4,8);
|
||||
delay(d);
|
||||
px.setColor(x5,8);
|
||||
px.setColors(x5,8);
|
||||
delay(d);
|
||||
px.setColor(x6,8);
|
||||
px.setColors(x6,8);
|
||||
delay(d);
|
||||
px.setColor(x7,8);
|
||||
px.setColors(x7,8);
|
||||
delay(d);
|
||||
px.setColor(x0,8);
|
||||
px.setColors(x0,8);
|
||||
delay(d);
|
||||
px.setColor(x8,8);
|
||||
px.setColors(x8,8);
|
||||
delay(d);
|
||||
px.setColor(x9,8);
|
||||
px.setColors(x9,8);
|
||||
delay(d);
|
||||
px.setColor(x10,8);
|
||||
px.setColors(x10,8);
|
||||
delay(d);
|
||||
px.setColor(x11,8);
|
||||
px.setColors(x11,8);
|
||||
delay(d);
|
||||
px.setColor(x12,8);
|
||||
px.setColors(x12,8);
|
||||
delay(d);
|
||||
px.setColor(x13,8);
|
||||
px.setColors(x13,8);
|
||||
delay(d);
|
||||
px.setColor(x14,8);
|
||||
px.setColors(x14,8);
|
||||
delay(d);
|
||||
px.setColor(x0,8);
|
||||
px.setColors(x0,8);
|
||||
delay(d);
|
||||
}
|
||||
|
||||
// x[0]=Pixel::getColorHSV(0,1,0.2);
|
||||
// x[1]=px.getColorHSV(0,0.7,0.2);
|
||||
// px.setColor(x,2);
|
||||
// px.setColors(x,2);
|
||||
// delay(1000);
|
||||
// x[0]=px.getColorHSV(0,0.7,0.2);
|
||||
// x[1]=px.getColorHSV(0,1,0.2);
|
||||
// px.setColor(x,2);
|
||||
// px.setColors(x,2);
|
||||
// delay(1000);
|
||||
|
||||
} // end of loop()
|
||||
|
|
|
|||
Loading…
Reference in New Issue