#include <FastLED.h>
#define UG_LED_COUNT 50
#define DATA_PIN 16
CRGB ugleds[UG_LED_COUNT];
uint8_t ugHue = 140;
uint8_t ugSat = 255;
uint8_t ugVal = 100;
uint8_t ugVal2 = 40;
CHSV underglowColor1 = CHSV(140, 255, 100);
#define MAX_FRAMES 28
// #define MAX_FRAMES 42
int frameIndex = 0;
int nextFrameIndex() {
if (frameIndex < MAX_FRAMES - 1) {
return frameIndex + 1;
} else {
return 0;
}
}
const uint16_t NUM_OF_UG_SIDE = 50;
const uint16_t NUM_OF_UG_PER_SIDE = 25;
const uint16_t NUM_OF_UG_FRONT = UG_LED_COUNT - ( NUM_OF_UG_SIDE );
const uint16_t UG_FX1_START_INDEX_RIGHT = (( UG_LED_COUNT - NUM_OF_UG_FRONT ) - NUM_OF_UG_PER_SIDE - 1 );
const uint16_t UG_FX1_START_INDEX_LEFT = (( UG_LED_COUNT - NUM_OF_UG_FRONT ) - NUM_OF_UG_SIDE) ;
// CHSV ugleds[UG_LED_COUNT];
void MirrorSideStrips(uint16_t ledindex, CHSV tempcolor){
uint16_t row1index = ledindex;
uint16_t row2index = ledindex + NUM_OF_UG_PER_SIDE;
// Serial.print("Mirror from: ");
// Serial.print(row1index);
// Serial.print(" to: ");
// Serial.println(row2index);
ugleds[row1index] = tempcolor;
ugleds[row2index] = tempcolor;
}
void setUGFX1(CHSV tempColor){
// CHSV tempColor = CHSV(0, 0, 0);
for (uint8_t i = 0; i < NUM_OF_UG_PER_SIDE; i++) {
MirrorSideStrips(i, tempColor);
}
}
void underglowEffect1(uint8_t frameindex){
CHSV offColor = CHSV(0, 0, 0);
CHSV dimColor = CHSV(ugHue, ugSat, ugVal2);
CHSV brightColor = CHSV(50, ugSat, ugVal);
uint8_t frame1;
uint8_t frame2;
static bool oneout = false;
frame1 = frameindex;
frame2 = frameindex;
// int8_t index1 = frame1 - ; //0:24
// int8_t index2 = frame1 - 13; //-1:23
// int8_t index3 = frame1 - 14; //-2:22
// int8_t index4 = frame1 - 3; //-3:21
// int8_t index5 = frame1 - ;
// int8_t index6 = frame1 - 1;
// int8_t index7 = frame1 - 1;
// int8_t index8 = frame1 - 1;
int8_t index1;
int8_t index2;
int8_t index3;
int8_t index4;
int8_t index5;
int8_t index6;
int8_t index7;
int8_t index8;
// if (frameindex == MAX_FRAMES - 1){
// oneout = true;
// }
if (frameindex < 14){
// fi 0:13
index1 = frame1 - 0; //0:13
index2 = frame1 - 1; //-1:12
index3 = frame1 - 2; //-2:11
index4 = frame1 - 3; //-3:10
index5 = frame2 + 11; //11-24
index6 = frame2 + 12; //12-25
index7 = frame2 + 13; //13-26
index8 = frame2 + 14; //14-27
}else{
// fi 14:24
index1 = frame1 - 14; //0-13
index2 = frame1 - 15; //-1:12
index3 = frame1 - 16; //-2:11
index4 = frame1 - 17; //-3:10
index5 = frame2 - 3; //11-24
index6 = frame2 - 2; //12-25
index7 = frame2 - 1; //13-26
index8 = frame2 - 0; //14-27
}
if ( (index4 > -1 ) && ( index4 < MAX_FRAMES - 2 )){ MirrorSideStrips(index4, offColor); }
if ( (index3 > -1 ) && ( index3 < MAX_FRAMES - 2 )){ MirrorSideStrips(index3, dimColor); }
if ( (index2 > -1 ) && ( index2 < MAX_FRAMES - 2 )){ MirrorSideStrips(index2, brightColor); }
if ( (index1 > -1 ) && ( index1 < MAX_FRAMES - 2 )){ MirrorSideStrips(index1, dimColor); }
// if ( (index8 > -1 ) && ( index8 < MAX_FRAMES - 2 )){ MirrorSideStrips(index8, offColor); }
// if ( (index7 > -1 ) && ( index7 < MAX_FRAMES - 2 )){ MirrorSideStrips(index7, dimColor); }
// if ( (index6 > -1 ) && ( index6 < MAX_FRAMES - 2 )){ MirrorSideStrips(index6, brightColor); }
// if ( (index5 > -1 ) && ( index5 < MAX_FRAMES - 2 )){ MirrorSideStrips(index5, dimColor); }
Serial.print("UGFX1 frameindex: ");
Serial.print(frameindex);
Serial.print(" frame1: ");
Serial.print(frame1);
Serial.print(" index1: ");
Serial.print(index1);
Serial.print(" index2: ");
Serial.print(index2);
Serial.print(" index3: ");
Serial.print(index3);
Serial.print(" index4: ");
Serial.print(index4);
Serial.print(" frame2: ");
Serial.print(frame2);
Serial.print(" index5: ");
Serial.print(index5);
Serial.print(" index6: ");
Serial.print(index6);
Serial.print(" index7: ");
Serial.print(index7);
Serial.print(" index8: ");
Serial.print(index8);
Serial.print(" oneout = ");
Serial.println(oneout ? "true" : "false");
}
void setup() {
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(ugleds, UG_LED_COUNT);
// setUGFX1(underglowColor1);
delay(1000);
}
void loop() {
EVERY_N_MILLISECONDS(50) {
frameIndex = nextFrameIndex();
underglowEffect1(frameIndex);
}
FastLED.show();
}