Hi, would anyone be willing to help? there are a few things I'm trying to adjust on my code.
I have 6 144leds WS2812B LED strips with the flora V3. The strips are being used in a costume. 4 from the waist to the ground in a skirt, and two over each shoulder connecting at the waist with the others.
I wanted to have the lights gradually brighten and fade up from the ground when the lights first come on but I can only get the fade to loop and not start and go to the next stage.
I also was trying to work out some different effects I can include, similar to the fade I wanted a watery effect like a waterfall. I have absolutely no idea how to create this and if anyone is willing to help it would be much appreciated!
#include <Adafruit_NeoPixel.h>
class Strip
{
public:
uint8_t effect;
uint8_t effects;
uint16_t effStep;
unsigned long effStart;
Adafruit_NeoPixel strip;
Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : strip(leds, pin, striptype) {
effect = -1;
effects = toteffects;
Reset();
}
void Reset() {
effStep = 0;
effect = (effect + 1) % effects;
effStart = millis();
}
};
struct Loop
{
uint8_t currentChild;
uint8_t childs;
bool timeBased;
uint16_t cycles;
uint16_t currentTime;
Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {
currentTime = 0;
currentChild = 0;
childs = totchilds;
timeBased = timebased;
cycles = tottime;
}
};
Strip strip_0(144, 6, 144, NEO_GRB + NEO_KHZ800);
Strip strip_1(144, 12, 144, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(1, false, 1);
struct Loop strip1loop0(1, false, 1);
//[GLOBAL_VARIABLES]
void setup() {
//Your setup here:
strip_0.strip.begin();
strip_0.strip.setBrightness(70);
strip_1.strip.begin();
strip_1.strip.setBrightness(10);
}
void loop() {
//Your code here:
strips_loop();
}
void strips_loop() {
if (strip0_loop0() & 0x01)
strip_0.strip.show();
if (strip1_loop0() & 0x01)
strip_1.strip.show();
}
uint8_t strip0_loop0() {
uint8_t ret = 0x00;
switch (strip0loop0.currentChild) {
case 0:
ret = strip0_loop0_eff0(); break;
}
if (ret & 0x02) {
ret &= 0xfd;
if (strip0loop0.currentChild + 1 >= strip0loop0.childs) {
strip0loop0.currentChild = 0;
if (++strip0loop0.currentTime >= strip0loop0.cycles) {
strip0loop0.currentTime = 0;
ret |= 0x02;
}
}
else {
strip0loop0.currentChild++;
}
};
return ret;
}
uint8_t strip0_loop0_eff0() {
// Strip ID: 0 - Effect: Rainbow - LEDS: 144
// Steps: 100 - Delay: 20
// Colors: 2 (180.255.255, 0.0.150)
// Options: rainbowlen=67, toLeft=false,
if (millis() - strip_0.effStart < 20 * (strip_0.effStep)) return 0x00;
float factor1, factor2;
uint16_t ind;
for (uint16_t j = 0; j < 144; j++) {
ind = 57 - (uint16_t)(strip_0.effStep - j * 0.8507462686567164) % 57;
switch ((int)((ind % 57) / 28.5)) {
case 0: factor1 = 1.0 - ((float)(ind % 57 - 0 * 28.5) / 28.5);
factor2 = (float)((int)(ind - 0) % 57) / 28.5;
strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 155 * factor1 + 0 * factor2, 160 * factor1 + 255 * factor2);
break;
case 1: factor1 = 1.0 - ((float)(ind % 57 - 1 * 28.5) / 28.5);
factor2 = (float)((int)(ind - 28.5) % 57) / 28.5;
strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 155 * factor2, 255 * factor1 + 160 * factor2);
break;
}
}
if (strip_0.effStep >= 57) {
strip_0.Reset();
return 0x03;
}
else strip_0.effStep++;
return 0x01;
}
uint8_t strip1_loop0() {
uint8_t ret = 0x00;
switch (strip1loop0.currentChild) {
case 0:
ret = strip1_loop0_eff0(); break;
}
if (ret & 0x02) {
ret &= 0xfd;
if (strip1loop0.currentChild + 1 >= strip1loop0.childs) {
strip1loop0.currentChild = 0;
if (++strip1loop0.currentTime >= strip1loop0.cycles) {
strip1loop0.currentTime = 0;
ret |= 0x02;
}
}
else {
strip1loop0.currentChild++;
}
};
return ret;
}
uint8_t strip1_loop0_eff0() {
// Strip ID: 1 - Effect: Rainbow - LEDS: 144
// Steps: 100 - Delay: 20
// Colors: 2 (180.255.255, 0.0.150)
// Options: rainbowlen=67, toLeft=false,
if (millis() - strip_1.effStart < 20 * (strip_1.effStep)) return 0x00;
float factor1, factor2;
uint16_t ind;
for (uint16_t j = 0; j < 144; j++) {
ind = 57 - (uint16_t)(strip_1.effStep - j * 0.8507462686567164) % 57;
switch ((int)((ind % 57) / 28.5)) {
case 0: factor1 = 1.0 - ((float)(ind % 57 - 0 * 28.5) / 28.5);
factor2 = (float)((int)(ind - 0) % 57) / 28.5;
strip_1.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 155 * factor1 + 0 * factor2, 160 * factor1 + 255 * factor2);
break;
case 1: factor1 = 1.0 - ((float)(ind % 57 - 1 * 28.5) / 28.5);
factor2 = (float)((int)(ind - 28.5) % 57) / 28.5;
strip_1.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 155 * factor2, 255 * factor1 + 160 * factor2);
break;
}
}
if (strip_1.effStep >= 57) {
strip_1.Reset();
return 0x03;
}
else strip_1.effStep++;
return 0x01;
}