#include "FastLED.h"
#include "IRremote.hpp"
#include <Adafruit_NeoPixel.h>
const long int ON = 0x5DA2FF00; //ON
const long int OFF = 0x1DE2FF00; //MENU
const long int BRIGHT_UP = 0xFD02FF00; //+
const long int BRIGHT_DOWN = 0x6798FF00; //-
const long int COLORS = 0x57A8FF00; //PLAY
const long int TIMER = 0xDD22FF00; //TEST
const long int TIMER_120_m = 0x11111111;
const long int TIMER_60_m = 0xA55AFF00; //6
const long int TIMER_30_m = 0xBD42FF00; //7
const long int TIMER_15_m = 0xB54AFF00; //8
const long int TIMER_10_m = 0xAD52FF00; //9
const long int TIMER_05_m = 0x9768FF00; //0
const long int KEY_1 = 0xCF30FF00; //1
const long int KEY_2 = 0xE718FF00; //2
const long int KEY_3 = 0x857AFF00; //3
const long int KEY_4 = 0xEF10FF00; //4
const long int KEY_5 = 0xC738FF00; //5
const long int KEY_6 = 0xA55AFF0A; //6*
const long int KEY_7 = 0xBD42FF0A; //7*
const long int KEY_8 = 0xB54AFF0A; //8*
const long int KEY_9 = 0xAD52FF0A; //9*
const long int KEY_10 = 0x9768FF0A; //0*
const long int KEY_11 = 0x22222222;
const long int KEY_12 = 0x33333333;
const long int MONITOR = 0x44444444;
const long int ESCRITORIO = 0x55555555;
const long int ACCESORIOS = 0x66666666;
const long int IMPRESORA_3D = 0x77777777;
const long int ESTANTE_1 = 0x88888888;
const long int ESTANTE_2 = 0x99999999;
const long int RELE_ON = 0x12121212;
const long int RELE_OFF = 0x13131313;
#define LEDPIN 4
#define BTN_PIN 2
#define IR_RECEIVE_PIN 11
#define LED_TYPE WS2811
#define NUM_LEDS 103
#define FRAMES_PER_SECOND 120
#define CLOCK_PIN 13
CRGB leds[NUM_LEDS];
CRGB endclr;
CRGB midclr;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LEDPIN, NEO_GRB + NEO_KHZ800);
int Relay = 6;
int Efecto;
int Menu;
int brightness = 250;
int colorIndex = 0;
// Arreglo que contiene los colores que deseas mostrar
CRGB colors[] =
{
CRGB::Black, // Apagado
CRGB(0, 250, 10), // Terracota (AZ-RO-VE) (RO-AZ-VE)
CRGB(0, 250, 25), // Naranja x
CRGB(40, 210, 10), // Rosado x
CRGB(150, 0, 200), // Cyan x
CRGB(15, 100, 200), // Verde Limon x
CRGB(30, 0, 255), // Verde
CRGB(200, 100, 5), // Morado x
CRGB(200, 0, 40), // Azul x
};
//unsigned long tiempo_anterior = 0; // variable para almacenar el tiempo anterior
//int duracion_efecto = 15000; // duración de cada efecto en milisegundos
//int efecto_actual = 1;
//VOID SETUP -----------------------------------------------------------------------------------------------------------------------
void setup()
{
strip.begin();
Serial.begin(115200);
delay(2000);
Serial.println("IR Receive test");
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
pinMode(Relay, OUTPUT);
FastLED.addLeds<LED_TYPE, LEDPIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(brightness);
Efecto = 0;
Menu = 0;
}
typedef void (*SimplePatternList[])(); // List of patterns to cycle through. Each is defined as a separate function below.
SimplePatternList gPatterns = { sinelon, sinelon, rainbow, rainbowWithGlitter, colorSolid };
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
void fadeall() { for (int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
//VOID LOOP———————————————————————————————--------------------------------------------------------------------
void loop()
{
LeerSensor();
ChangePalette();
FastLED.show();
FastLED.delay(1000/120);
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
}
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
CRGBPalette16 pacifica_palette_1 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x14554B, 0x28AA50 };
CRGBPalette16 pacifica_palette_2 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x0C5F52, 0x19BE5F };
CRGBPalette16 pacifica_palette_3 =
{ 0x000208, 0x00030E, 0x000514, 0x00061A, 0x000820, 0x000927, 0x000B2D, 0x000C33,
0x000E39, 0x001040, 0x001450, 0x001860, 0x001C70, 0x002080, 0x1040BF, 0x2060FF };
//VOID LEER SENSOR------------------------------------------------------------------------------------------------------------------
void LeerSensor()
{
while (!IrReceiver.isIdle());
if (IrReceiver.decode())
{
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
switch (IrReceiver.decodedIRData.decodedRawData)
{
case ON:
Serial.println("ENCENDIDO");
Menu = 1;
break;
case OFF:
Serial.println("APAGADO");
Menu = 2;
break;
case BRIGHT_UP:
Serial.println("AUMENTAR BRILLO");
brightness = min(brightness + 25, 255);
FastLED.setBrightness(brightness);
break;
case BRIGHT_DOWN:
Serial.println("DISMINUIR BRILLO");
brightness = max(brightness - 25, 0);
FastLED.setBrightness(brightness);
break;
case COLORS:
Serial.println("COLORES");
Menu = 3;
break;
//----------------------------------------------------------------------
case TIMER:
Menu = 4;
Serial.println("TEMPORIZADOR");
break;
//----------------------------------------------------------------------
case KEY_1:
Serial.println("SINELON");
Efecto = 1;
break;
case KEY_2:
Serial.println("RAINBOW");
Efecto = 2;
break;
case KEY_3:
Serial.println("RAINBOW - GLITTER");
Efecto = 3;
break;
case KEY_4:
Serial.println("PACIFICA");
Efecto = 4;
break;
case KEY_5:
Serial.println("STORM");
Efecto = 5;
break;
case KEY_6:
Serial.println("SNOW");
Efecto = 6;
break;
case KEY_7:
Serial.println("NARANJA");
Efecto = 7;
break;
case KEY_8:
Serial.println("ROSADO");
Efecto = 8;
break;
case KEY_9:
Serial.println("VERDE LIMON");
Efecto = 9;
break;
case KEY_10:
Serial.println("CYAN");
Efecto = 10;
break;
case KEY_11:
Serial.println("MORADO");
Efecto = 11;
break;
case KEY_12:
Serial.println("AZUL");
Efecto = 12;
break;
//-------------------------------------------------------------------
case MONITOR:
Serial.println("MONITOR");
Efecto = 13;
break;
case ESCRITORIO:
Serial.println("ESCRITORIO");
Efecto = 14;
break;
case ACCESORIOS:
Serial.println("ACCESORIOS");
Efecto = 15;
break;
case IMPRESORA_3D:
Serial.println("IMPRESORA_3D");
Efecto = 16;
break;
case ESTANTE_1:
Serial.println("ESTANTE_1");
Efecto = 17;
break;
case ESTANTE_2:
Serial.println("ESTANTE_2");
Efecto = 18;
break;
case RELE_ON:
Serial.println("ENCENDIENDO PC");
digitalWrite(Relay, HIGH); // encender el relé
Serial.println("Relay 1 Encendido");
delay(500); // esperar 1/2 segundo
digitalWrite(Relay, LOW); // apagar el relé
Serial.println("Relay 1 Encendido");
break;
case RELE_OFF:
Serial.println("APAGANDO PC");
digitalWrite(Relay, HIGH); // encender el relé
Serial.println("Relay 1 Apagado");
delay(500); // esperar 1/2 segundo
digitalWrite(Relay, LOW); // apagar el relé
Serial.println("Relay 1 Apagado");
break;
}
delay(200);
IrReceiver.resume();
}
}
//VOID CHANGE PALETTE --------------------------------------------------------------------------------------------------------------
void ChangePalette()
{
if (Menu == 1)
{
// Call the current pattern function once, updating the 'leds' array
gPatterns[gCurrentPatternNumber]();
// send the 'leds' array out to the actual LED strip
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000/FRAMES_PER_SECOND);
// do some periodic updates
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
EVERY_N_SECONDS( 15 ) { nextPattern(); } // change patterns periodically
}
if (Menu == 2) // APAGADO
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(100, 200, 5); // MORADO
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
for (int i = NUM_LEDS - 1; i >= 0; i--) // NEGRO
{
leds[i] = CRGB::Black;
FastLED.show();
delay(17);
}
Menu = 0;
}
if (Menu == 3) // COLORES
{
colorIndex++;
if (colorIndex >= 9)
{
colorIndex = 0;
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(255);
FastLED.show();
}
Efecto = 0;
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(15);
leds[i].nscale8(30);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Menu = 0;
}
if (Menu == 4) // TIMER
{
while (!IrReceiver.isIdle());
if (IrReceiver.decodedIRData.decodedRawData == TIMER_120_m) // (120 MINUTOS)
{
Serial.println("CRONOMETRO 120 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(200, 150, 0); // (CYAN)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(72000); // (1 MINUTO = 600)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
if (IrReceiver.decodedIRData.decodedRawData == TIMER_60_m) // (60 MINUTOS)
{
Serial.println("CRONOMETRO 60 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 250, 30); // (NARANJA)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(36000); // (60 MIN)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
if (IrReceiver.decodedIRData.decodedRawData == TIMER_30_m) // (30 MINUTOS)
{
Serial.println("CRONOMETRO 30 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(15, 100, 200); // (VERDE LIMON)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(18000); // (30 MIN)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
if (IrReceiver.decodedIRData.decodedRawData == TIMER_15_m) // (15 MINUTOS)
{
Serial.println("CRONOMETRO 15 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(200, 100, 5); // (MORADO)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(9000); // (15 MIN)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
if (IrReceiver.decodedIRData.decodedRawData == TIMER_10_m) // (10 MINUTOS)
{
Serial.println("CRONOMETRO 10 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(200, 0, 40); // (AZUL)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6000); // (10 MIN)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
if (IrReceiver.decodedIRData.decodedRawData == TIMER_05_m) // (5 MINUTOS)
{
Serial.println("CRONOMETRO 5 MINUTOS");
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(6);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(40, 210, 10); // (ROSADO)
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(3000); // (5 MIN)
if (i == NUM_LEDS - 1)
{
for (int j = 0; j < NUM_LEDS; j++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
}
}
Serial.println("CONCLUIDO");
Menu = 0;
}
}
//----------------------------------------------------------------------------------------------------------
if (Efecto == 1) // SINELON
{
sinelon();
}
if (Efecto == 2) // RAINBOW
{
rainbow();
}
if (Efecto == 3) // RAINBOW - GLITTER
{
rainbow();
addGlitter(80);
}
if (Efecto == 4) // PACIFICA
{
// Increment the four "color index start" counters, one for each wave layer.
// Each is incremented at a different speed, and the speeds vary over time.
static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
static uint32_t sLastms = 0;
uint32_t ms = GET_MILLIS();
uint32_t deltams = ms - sLastms;
sLastms = ms;
uint16_t speedfactor1 = beatsin16(3, 179, 269);
uint16_t speedfactor2 = beatsin16(4, 179, 269);
uint32_t deltams1 = (deltams * speedfactor1) / 256;
uint32_t deltams2 = (deltams * speedfactor2) / 256;
uint32_t deltams21 = (deltams1 + deltams2) / 2;
sCIStart1 += (deltams1 * beatsin88(1011,10,13));
sCIStart2 -= (deltams21 * beatsin88(777,8,11));
sCIStart3 -= (deltams1 * beatsin88(501,5,7));
sCIStart4 -= (deltams2 * beatsin88(257,4,6));
// Clear out the LED array to a dim background blue-green
fill_solid( leds, NUM_LEDS, CRGB( 2, 6, 10));
// Render each of four layers, with different scales and speeds, that vary over time
pacifica_one_layer( pacifica_palette_1, sCIStart1, beatsin16( 3, 11 * 256, 14 * 256), beatsin8( 10, 70, 130), 0-beat16( 301) );
pacifica_one_layer( pacifica_palette_2, sCIStart2, beatsin16( 4, 6 * 256, 9 * 256), beatsin8( 17, 40, 80), beat16( 401) );
pacifica_one_layer( pacifica_palette_3, sCIStart3, 6 * 256, beatsin8( 9, 10,38), 0-beat16(503));
pacifica_one_layer( pacifica_palette_3, sCIStart4, 5 * 256, beatsin8( 8, 10,28), beat16(601));
// Add brighter 'whitecaps' where the waves lines up more
pacifica_add_whitecaps();
// Deepen the blues and greens a bit
pacifica_deepen_colors();
}
if (Efecto == 5) // STORM
{
fadeToBlackBy( leds, NUM_LEDS, 30);
fill_solid(leds,NUM_LEDS,CHSV(0,0,50));
addGlitter(60);
lightning();
}
if (Efecto == 6) // SNOW
{
fadeToBlackBy( leds, NUM_LEDS, 30);
addGlitter(50);
}
if (Efecto == 7) // NARANJA
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 250, 25);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(0, 250, 25);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 8) // ROSADO
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(40, 210, 10);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(40, 210, 10);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 9) // VERDE LIMON
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(15, 100, 200);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(15, 100, 200);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 10) // CYAN
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(150, 0, 200);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(150, 0, 200);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 11) // MORADO
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(200, 100, 5);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(200, 100, 5);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 12) // AZUL
{
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(200, 0, 40);
FastLED.show();
delay(15);
leds[i].nscale8(40);
FastLED.show();
}
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB(200, 0, 40);
FastLED.show();
delay(2);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 14) // ESCRITORIO
{
colorIndex++;
if (colorIndex >= 9)
{
colorIndex = 0;
}
for (int i = 39 - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(255);
FastLED.show();
}
for (int i = 0; i < 39; i++)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(15);
leds[i].nscale8(30);
FastLED.show();
}
for (int i = 39 - 1; i >= 0; i--)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 15) // ACCESORIOS
{
colorIndex++;
if (colorIndex >= 9)
{
colorIndex = 0;
}
for (int i = 63 - 1; i >= 39; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(255);
FastLED.show();
}
for (int i = 39; i < 63; i++)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(15);
leds[i].nscale8(30);
FastLED.show();
}
for (int i = 63 - 1; i >= 39; i--)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 16) // IMPRESORA 3D
{
colorIndex++;
if (colorIndex >= 9)
{
colorIndex = 0;
}
for (int i = 79 - 1; i >= 63; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(255);
FastLED.show();
}
for (int i = 63; i < 79; i++)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(15);
leds[i].nscale8(30);
FastLED.show();
}
for (int i = 79 - 1; i >= 63; i--)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
if (Efecto == 17) // ESTANTE 1
{
colorIndex++;
if (colorIndex >= 9)
{
colorIndex = 0;
}
for (int i = 103 - 1; i >= 79; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(20);
leds[i].nscale8(255);
FastLED.show();
}
for (int i = 79; i < 103; i++)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(15);
leds[i].nscale8(30);
FastLED.show();
}
for (int i = 103 - 1; i >= 79; i--)
{
leds[i] = colors[colorIndex];
FastLED.show();
delay(3);
leds[i].nscale8(250);
FastLED.show();
}
Efecto = 0;
}
}
//GADGETS --------------------------------------------------------------------------------------------------------------------------
void pacifica_one_layer( CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
{
uint16_t ci = cistart;
uint16_t waveangle = ioff;
uint16_t wavescale_half = (wavescale / 2) + 20;
for( uint16_t i = 0; i < NUM_LEDS; i++) {
waveangle += 250;
uint16_t s16 = sin16( waveangle ) + 32768;
uint16_t cs = scale16( s16 , wavescale_half ) + wavescale_half;
ci += cs;
uint16_t sindex16 = sin16( ci) + 32768;
uint8_t sindex8 = scale16( sindex16, 240);
CRGB c = ColorFromPalette( p, sindex8, bri, LINEARBLEND);
leds[i] += c;
}
}
void pacifica_add_whitecaps()
{
uint8_t basethreshold = beatsin8( 9, 55, 65);
uint8_t wave = beat8( 7 );
for( uint16_t i = 0; i < NUM_LEDS; i++)
{
uint8_t threshold = scale8( sin8( wave), 20) + basethreshold;
wave += 7;
uint8_t l = leds[i].getAverageLight();
if( l > threshold)
{
uint8_t overage = l - threshold;
uint8_t overage2 = qadd8( overage, overage);
leds[i] += CRGB( overage, overage2, qadd8( overage2, overage2));
}
}
}
void pacifica_deepen_colors()
{
for( uint16_t i = 0; i < NUM_LEDS; i++)
{
leds[i].blue = scale8( leds[i].green, 200);
leds[i].green= scale8( leds[i].red, 250);
leds[i] |= CRGB( 2, 5, 7);
}
}
void lightning ()
{
EVERY_N_MILLISECONDS (4000)
{
uint8_t i = beatsin8(6, 0, 255);
fill_solid(leds, NUM_LEDS, CHSV(160, 10, i));
}
}
void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 10, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}
void rainbow()
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, 7);
}
void rainbowWithGlitter()
{
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
addGlitter(80);
}
void addGlitter( fract8 chanceOfGlitter)
{
if( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;}
}
void colorSolid()
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 250, 15);
FastLED.show();
delay(15);
leds[i].nscale8(50);
FastLED.show();
}
delay(100);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 250, 15);
FastLED.show();
delay(15);
leds[i].nscale8(150);
FastLED.show();
}
delay(100);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 250, 13);
FastLED.show();
delay(15);
leds[i].nscale8(250);
FastLED.show();
}
delay(25000);
for (int i = NUM_LEDS - 1; i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay(10);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 0; i < 39; i++)
{
leds[i] = CRGB(0, 250, 20);
FastLED.show();
delay(15);
leds[i].nscale8(250);
FastLED.show();
}
for (int i = 79; i < 103; i++)
{
leds[i] = CRGB(0, 250, 20);
FastLED.show();
delay(15);
leds[i].nscale8(250);
FastLED.show();
}
Menu = 0;
}