lytnin
12-22-2009, 12:28 AM
Hi All,
I have a script running fine with a few chases in it, as set out below:
What I would like to be able to do is reverse the direction of a chase, to get a "Knight Rider" effect.
Any thoughts?
My first thoughts would be a function with three inputs, but I'm no C# programmer. Give me PHP or javascript any day. ;)
Here is some pseudo code I thought might be a good starting point:
function ChaseBack(int A, int B, int Dur)
{
// A - First Channel, B - number of channels, Dur - Duration in ms
int period = Dur / B;
int end = A + B -1;
Off(ChannelRange(A,B) );
int x = end;
while (x >= A ) {
On(Channel(x), For(period).Milliseconds,Wait);
x = x -1;
}
}
Working Code
void Start() {
Off(All);
while(true)
{
DateTime now = DateTime.Now; //get the current time
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
//LIVE
DateTime start = new DateTime(now.Year, now.Month, now.Day, 19, 45, 00);
//TEST
// DateTime start = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 59, 00);
//We only want the channels to turn on while the current time is
//between 7:45 and 11:59 pm
// possibly a problem with EVERY or RANDOM so removed for now.
// Random (ChannelRange(16,19), 100, Every(1).Second);
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
// Turn on initial Lights
On (ChannelRange(0,16), At(100)); // Candy Canes
On (ChannelRange(16,19), At(100)); // Mini Trees
On (ChannelRange(56,6), At(100)); // Stars - White
On (ChannelRange(62,2), At(75)); // Icicles - White
On (ChannelRange(64,8), At(100)); // Bells
On (ChannelRange(72,20), At(100)); // Tree - White
On (ChannelRange(112,6), At(100)); // Arch1
On (ChannelRange(120,6), At(100)); // Arch2
// Set active light animations
// Chase Candy Canes
Chase(ChannelRange(0,16), Over(2400).Milliseconds, Wait );
Chase(ChannelRange(0,16), Over(2400).Milliseconds, Wait );
On(ChannelRange(0,16));
// Chase Stars -White
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
On(ChannelRange(56,6));
// Chase Main Tree -White
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
On (ChannelRange(72,20), At(100)); // Tree - White
// Chase Arch1 & Arch2
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
On (ChannelRange(112,6), At(100)); // Arch1
On (ChannelRange(120,6), At(100)); // Arch2
now = DateTime.Now; //update the current time
}
}
}
Before anyone asks, Yes the times are right. I'm in OZ in the middle of summer and it doesn't start getting dark until around 8pm. :eek:
I have a script running fine with a few chases in it, as set out below:
What I would like to be able to do is reverse the direction of a chase, to get a "Knight Rider" effect.
Any thoughts?
My first thoughts would be a function with three inputs, but I'm no C# programmer. Give me PHP or javascript any day. ;)
Here is some pseudo code I thought might be a good starting point:
function ChaseBack(int A, int B, int Dur)
{
// A - First Channel, B - number of channels, Dur - Duration in ms
int period = Dur / B;
int end = A + B -1;
Off(ChannelRange(A,B) );
int x = end;
while (x >= A ) {
On(Channel(x), For(period).Milliseconds,Wait);
x = x -1;
}
}
Working Code
void Start() {
Off(All);
while(true)
{
DateTime now = DateTime.Now; //get the current time
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
//LIVE
DateTime start = new DateTime(now.Year, now.Month, now.Day, 19, 45, 00);
//TEST
// DateTime start = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 59, 00);
//We only want the channels to turn on while the current time is
//between 7:45 and 11:59 pm
// possibly a problem with EVERY or RANDOM so removed for now.
// Random (ChannelRange(16,19), 100, Every(1).Second);
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
// Turn on initial Lights
On (ChannelRange(0,16), At(100)); // Candy Canes
On (ChannelRange(16,19), At(100)); // Mini Trees
On (ChannelRange(56,6), At(100)); // Stars - White
On (ChannelRange(62,2), At(75)); // Icicles - White
On (ChannelRange(64,8), At(100)); // Bells
On (ChannelRange(72,20), At(100)); // Tree - White
On (ChannelRange(112,6), At(100)); // Arch1
On (ChannelRange(120,6), At(100)); // Arch2
// Set active light animations
// Chase Candy Canes
Chase(ChannelRange(0,16), Over(2400).Milliseconds, Wait );
Chase(ChannelRange(0,16), Over(2400).Milliseconds, Wait );
On(ChannelRange(0,16));
// Chase Stars -White
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
Chase(ChannelRange(56,6), Over(800).Milliseconds, Wait );
On(ChannelRange(56,6));
// Chase Main Tree -White
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
Chase(ChannelRange(72,16), Over(1500).Milliseconds, Wait );
On (ChannelRange(72,20), At(100)); // Tree - White
// Chase Arch1 & Arch2
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(112,6), Over(600).Milliseconds, Wait );
Chase(ChannelRange(120,6), Over(600).Milliseconds, Wait );
On (ChannelRange(112,6), At(100)); // Arch1
On (ChannelRange(120,6), At(100)); // Arch2
now = DateTime.Now; //update the current time
}
}
}
Before anyone asks, Yes the times are right. I'm in OZ in the middle of summer and it doesn't start getting dark until around 8pm. :eek: