Hi,
I have this issue, that I can't understand with assigning CHSV member hue to a CHSV variable I made.
It is within a function, but I don't think that is the issue, since I declaired the variable outside of the function.
#include <FastLED.h>
#define LEDTYPE WS2812B //when changing strips
#define PL 9 // LED pin
#define STRIP 60 //num LED in strip
//User contants
#define NOG 3
#define GROUP_SIZE 7
CRGB led[STRIP];
byte hue;
byte sat;
byte val;
CHSV ledHSV[STRIP] = CHSV(hue, sat, val);
bool even;
int ID[NOG];
int groupNum;
CHSV color[NOG];
int lastGroup = STRIP % GROUP_SIZE;
int colorIndexLastGroup = ((STRIP - lastGroup / GROUP_SIZE) % NOG + 1);
bool colorReady = false;
int colorIndex = 0;
void setup() {
Serial.begin(9600);
delay(200);
Serial.println("setup");
FastLED.addLeds<LEDTYPE, PL, GRB>(led, STRIP); //strip details
if (STRIP % 2 == 0) {
even = true;
} else {
even = false;
}
}
void makeColor(int groupNum, byte hue, byte sat, byte val) {
color[groupNum - 1] = CHSV(150, sat, val); // -1 so that the array starts at 0
color[groupNum - 1].hue = (byte) 150;
Serial.println("hue"); //whats up with the hue? i pass a different one
Serial.println(hue);
Serial.println(groupNum);
Serial.println(color[groupNum].hue);
}
void loop() {
if (!colorReady) {
makeColor(1, 220, 250, 255);
colorReady = true;
}
}
Hi,
I have this issue, that I can't understand with assigning CHSV member hue to a CHSV variable I made.
It is within a function, but I don't think that is the issue, since I declaired the variable outside of the function.
#include <FastLED.h>
#define LEDTYPE WS2812B //when changing strips
#define PL 9 // LED pin
#define STRIP 60 //num LED in strip
//User contants
#define NOG 3
#define GROUP_SIZE 7
CRGB led[STRIP];
byte hue;
byte sat;
byte val;
CHSV ledHSV[STRIP] = CHSV(hue, sat, val);
bool even;
int ID[NOG];
int groupNum;
CHSV color[NOG];
int lastGroup = STRIP % GROUP_SIZE;
int colorIndexLastGroup = ((STRIP - lastGroup / GROUP_SIZE) % NOG + 1);
bool colorReady = false;
int colorIndex = 0;
void setup() {
Serial.begin(9600);
delay(200);
Serial.println("setup");
FastLED.addLeds<LEDTYPE, PL, GRB>(led, STRIP); //strip details
if (STRIP % 2 == 0) {
even = true;
} else {
even = false;
}
}
void makeColor(int groupNum, byte hue, byte sat, byte val) {
color[groupNum - 1] = CHSV(150, sat, val); // -1 so that the array starts at 0
color[groupNum - 1].hue = (byte) 150;
Serial.println("hue"); //whats up with the hue? i pass a different one
Serial.println(hue);
Serial.println(groupNum);
Serial.println(color[groupNum].hue);
}
void loop() {
if (!colorReady) {
makeColor(1, 220, 250, 255);
colorReady = true;
}
}
The output on serial monitor is:
setup
hue
220
1
0
I expect to get this:
setup
hue
220
1
220
what am I doing wrong?
I want the variable color to hold that input also outside of the function