Skip to content

Commit

Permalink
Moved main source file. Trying a sine wave approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
jphays committed Dec 28, 2014
1 parent 54b7e5e commit 619f1d5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions xmas-lights.ino → src/xmas-lights.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <TCL.h>

const int LEDS = 50;
const int NUM_COLORS = 8;
const int NUM_COLORS = 9;
const int FPS = 25;

const bool MIXIN_POTS = false;
Expand Down Expand Up @@ -67,10 +67,9 @@ void rainbow_loop()
{
if (time >= change_time[i])
{
change_time[i] = time + random(update_time_min, update_time_max);
{
current_color[i] = (current_color[i] + 1) % NUM_COLORS;
}
//change_time[i] = time + random(update_time_min, update_time_max);
change_time[i] = time + update_time_min + sin(time / 2000 + 6.28 * i / LEDS) * 100;
current_color[i] = (current_color[i] + 1) % NUM_COLORS;
}
}

Expand Down Expand Up @@ -148,7 +147,7 @@ void clear_strand()

void assign_color(int led, int color)
{
int tick = change_time[i] - millis();
int tick = change_time[led] - millis();

if (tick < 200)
{
Expand Down Expand Up @@ -191,11 +190,11 @@ void rainbow_init()
current_color[i] = color;
assign_color(i, color);

if (i % 5 == 4)
{
//if (i % 5 == 4)
//{
//color = (color + 1) % NUM_COLORS;
color = random(0, NUM_COLORS);
}
// color = random(0, NUM_COLORS);
//}

change_time[i] = millis();
}
Expand Down Expand Up @@ -243,11 +242,11 @@ void init_colors()
color_values[BLUE][1]=0x00;
color_values[BLUE][2]=0xa0;

color_values[PURPLE][0]=0x30;
color_values[PURPLE][0]=0x20;
color_values[PURPLE][1]=0x00;
color_values[PURPLE][2]=0x80;

color_values[WHITE][0]=0xa0;
color_values[WHITE][0]=0x90;
color_values[WHITE][1]=0xa0;
color_values[WHITE][2]=0x90;
}

0 comments on commit 619f1d5

Please sign in to comment.