Skip to content

Commit d7e3c55

Browse files
author
sarah t
committed
finished fixing transitions
1 parent c1aa10a commit d7e3c55

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.*~

LED_master_loop.ino

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define dataPin 2 // Yellow wire on Adafruit Pixels
1313
#define clockPin 3 // Green wire on Adafruit Pixels
14-
#define stripLen 200
14+
#define stripLen 40
1515

1616
volatile unsigned long int interrupt_counter; // how many ms have elapsed since the interrupt timer was last reset
1717
unsigned long int prev_interrupt_counter; // the main loop uses this to detect when the interrupt counter has changed
@@ -41,13 +41,12 @@ void setup()
4141
strip.begin();
4242
strip.setAll(rgbInfo_t(0,0,0));
4343

44-
library_update = &Zoa_WS2801::pushFront;
45-
46-
switch_after = 3000;
44+
switch_after = 5000;
4745
interrupt_counter = switch_after + 1;
4846
prev_interrupt_counter = interrupt_counter;
4947
active_routine = 0;
5048
update = NULL;
49+
library_update = NULL;
5150

5251
// update the interrupt counter (and thus the LEDs) every 30ms. The strip updating takes ~0.1ms
5352
// for each LED in the strip, and we are assuming a maximum strip length of 240, plus some extra wiggle room.
@@ -89,15 +88,15 @@ void loop()
8988
case 0:
9089
// green and blue waves going in and out of phase
9190
update = update_simple;
92-
waves[0] = new Sine_generator( 0, 15, 1, 0 );
91+
waves[0] = new Sine_generator( 0, 15, 1, PI/2 );
9392
// all the /3s are a quick way to get the speed looking right while maintaining prime number ratios
9493
waves[1] = new Sine_generator( 20, 255, 11/3, 0 );
9594
waves[2] = new Sine_generator( 20, 255, 17/3, 0 );
9695
break;
9796
case 1:
9897
// green and purple waves, same frequency but out of phase
9998
update = update_simple;
100-
waves[0] = new Sine_generator( 0, 5, 5/3, PI/2 );
99+
waves[0] = new Sine_generator( 0, 5, 5/3, 0 );
101100
waves[1] = new Sine_generator( 0, 200, 5/3, 0 );
102101
waves[2] = new Sine_generator( 0, 255, 5/3, PI/2 );
103102
break;
@@ -196,7 +195,7 @@ void linear_transition()
196195
void linear_transition( const rgbInfo& start_value, const rgbInfo& target_value, uint16_t ms )
197196
{
198197
float stop_cnt = interrupt_counter + ms;
199-
while ( interrupt_counter <= stop_cnt )
198+
while ( interrupt_counter < stop_cnt )
200199
{
201200
while ( interrupt_counter == prev_interrupt_counter ) {}
202201
prev_interrupt_counter = interrupt_counter;
@@ -222,8 +221,16 @@ void update_interrupt_counter()
222221
}
223222

224223
// Used for transitions between routines (hypothetically)
225-
float transitional_value( const float& from, const float& to, const float& multiplier )
224+
float transitional_value( const float& from, const float& to, float multiplier )
226225
{
226+
if ( multiplier < 0 )
227+
{
228+
multiplier = 0;
229+
}
230+
else if ( multiplier > 1 )
231+
{
232+
multiplier = 1;
233+
}
227234
float val = from * (1-multiplier) + to * multiplier;
228235
return val;
229236
}

0 commit comments

Comments
 (0)