//#define FASTLED_RMT_BUILTIN_DRIVER 1
#include <FastLED.h>
#include "mapping.h"
#define NUM_LEDS 750
#define LED_PIN 13
#define NUM_PATH 100 // Total Number of LEDs
CRGB pattern[100]; // Used in Charles Goodwin effects
int path[125]; // Used in Charles Goodwin effects
int refLEDs[750]; // Used in Charles Goodwin effects
CRGB leds[NUM_LEDS];
//General app
uint8_t brightness_wifi = 255; // Wifi brightness value (0-255)
bool on_off_button_wifi = true; // Wifi on/off button
//Colors menu app
uint8_t hue_wifi = 0; // Wifi color value (0-255)
uint8_t saturation_wifi = 255; // Wifi sat value (0-255)
//Effects menu app
uint8_t effect_wifi = 1; // Wifi effect value
uint8_t speed_wifi = 30; // Wifi speed value (0-100)
uint8_t features_wifi = 100; // Wifi features value (0-100)
//Sounds page app
uint8_t effect_sound_wifi = 0; // Wifi sound value (0-255)
uint8_t sensitivity_sound_wifi = 125; // Wifi sensitivity value (0-255)
bool autoslider_wifi = false; // Wifi sensitivity slider
unsigned long CurrentTime = 0; // Used for millis effect delays
unsigned long LastTime = 0; // Used for millis effect delays
unsigned long wifitime = 0; // Used to track how long wifi has been inactive
double fps = 0; // FPS counter
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); // Add our LED strip to the FastLED library
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern CRGB leds[];
void Comet(uint8_t type) {
//FastLED.clear();
static int path[10][25] = {0};
static uint8_t eInd[10] = {0,1,2,8,18,9,10,18,12,21};
static uint8_t pInd[10] = {9,1,17,12,19,0,0,19,16,18};
static int position[10] = {0,3,6,9,11,14,16,18,21,23};
int speed = map(speed_wifi, 0,100,25,0);
int numbercomet = 10;
uint8_t sat = 0;
int colorshift = map(features_wifi, 0,100,0,255);
if(millis() >= LastTime + speed){
for (int i = 0; i<numbercomet; i++){
if (position[i] == 25){
getPath(eInd[i], pInd[i], random8(2), path[i]);
position[i] = 0;
}
}
for (int i = 0; i<numbercomet; i++){
if (type == 1) leds[path[i][position[i]]] = CHSV(hue_wifi+(i*(colorshift/numbercomet)),saturation_wifi,255);
if (type == 2){
if ((i == 0) || (i == 2) || (i == 4) || (i == 6) || (i == 8)) sat = 0;
else sat = 255;
leds[path[i][position[i]]] = CHSV(hue_wifi+(i*(colorshift/numbercomet)),sat,255);
}
}
for (int i = 0; i<numbercomet; i++){
position[i] = position[i] + 1;
}
fadeToBlackBy(leds,NUM_LEDS,80);
delay(speed);
LastTime = millis();
FastLED.show(brightness_wifi);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
CurrentTime = millis(); // define current clock time
Comet(1);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////