Added setHSV() to sk68xx class
This commit is contained in:
parent
facba4c02a
commit
3b6bc13b1c
|
|
@ -15,6 +15,8 @@ void sk68xx::setRGB(uint8_t r, uint8_t g, uint8_t b){
|
|||
if(!*rf)
|
||||
return;
|
||||
|
||||
Serial.printf("%d %d %d\n",r,g,b);
|
||||
|
||||
rf->clear();
|
||||
loadColor(g);
|
||||
loadColor(r);
|
||||
|
|
@ -25,6 +27,14 @@ void sk68xx::setRGB(uint8_t r, uint8_t g, uint8_t b){
|
|||
|
||||
///////////////////
|
||||
|
||||
void sk68xx::setHSV(float h, float s, float v){
|
||||
float r,g,b;
|
||||
LedPin::HSVtoRGB(h,s,v,&r,&g,&b);
|
||||
setRGB(r*255,g*255,b*255);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
||||
void sk68xx::loadColor(uint8_t c){
|
||||
|
||||
for(int i=7;i>=0;i--){
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "RFControl.h"
|
||||
#include "PwmPin.h"
|
||||
|
||||
class sk68xx {
|
||||
private:
|
||||
|
|
@ -16,6 +17,7 @@ class sk68xx {
|
|||
public:
|
||||
sk68xx(int pin); // creates addressable SK68XX RGB LED on pin
|
||||
void setRGB(uint8_t r, uint8_t g, uint8_t b); // sets color to rgb values (0-255)
|
||||
void setHSV(float h, float s, float v); // sets color to hsv values where h=[0,360], s=[0,1], v=[0,1]
|
||||
int getPin(){return(rf->getPin());} // returns pin number
|
||||
|
||||
operator bool(){ // override boolean operator to return true/false if creation succeeded/failed
|
||||
|
|
|
|||
|
|
@ -18,6 +18,17 @@ void setup() {
|
|||
Serial.printf("Test 7 on Pin=%d check: %s\n",test7.getPin(),test7?"OKAY":"BAD");
|
||||
Serial.printf("Test 6 on Pin=%d check: %s\n",test6.getPin(),test6?"OKAY":"BAD");
|
||||
|
||||
while(1){
|
||||
px.setHSV(60,0.9,0.5);
|
||||
delay(1000);
|
||||
px.setHSV(120,0.9,0.5);
|
||||
delay(1000);
|
||||
px.setHSV(240,0.9,0.5);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
while(1);
|
||||
|
||||
while(1){
|
||||
for(int i=0;i<50;i++){
|
||||
px.setRGB(i,0,0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue