public void fadeTo(int ch1, int ch2, int ch3, int ch4, int ch5, int seconds, int offset=0)
{
int step1 = (int)Math.Ceiling((double)(Math.Abs(this.off[0 + offset] - ch1)) / (double)(seconds));
int step2 = (int)Math.Ceiling((double)(Math.Abs(this.off[1 + offset] - ch2)) / (double)(seconds));
int step3 = (int)Math.Ceiling((double)(Math.Abs(this.off[2 + offset] - ch3)) / (double)(seconds));
int step4 = (int)Math.Ceiling((double)(Math.Abs(this.off[3 + offset] - ch4)) / (double)(seconds));
int step5 = (int)Math.Ceiling((double)(Math.Abs(this.off[4 + offset] - ch5)) / (double)(seconds));
while (seconds > 1)
{
if (this.off[0 + offset] > ch1)
{
this.setPWM((byte) (0 + offset), 0, (ushort)(this.off[0+offset] - step1));
}
else
{
setPWM((byte)(0 + offset), 0, (ushort)(this.off[0 + offset] + step1));
}
//ch2
if (this.off[1 + offset] > ch2)
{
this.setPWM((byte)(1 + offset), 0, (ushort)(this.off[1 + offset] - step2));
}
else
{
this.setPWM((byte)(1 + offset), 0, (ushort)(this.off[1 + offset] + step2));
}
//ch3
if (this.off[2 + offset] > ch3)
{
this.setPWM((byte)(2 + offset), 0, (ushort)(this.off[2 + offset] - step3));
}
else
{
this.setPWM((byte)(2 + offset), 0, (ushort)(this.off[2 + offset] + step3));
}
//ch4
if (this.off[3 + offset] > ch4)
{
this.setPWM((byte)(3 + offset), 0, (ushort)(this.off[3 + offset] - step4));
}
else
{
this.setPWM((byte)(3 + offset), 0, (ushort)(this.off[3 + offset] + step4));
}
//ch5
if (this.off[4 + offset] > ch5)
{
this.setPWM((byte)(4 + offset), 0, (ushort)(this.off[4 + offset] - step5));
}
else
{
this.setPWM((byte)(4 + offset), 0, (ushort)(this.off[4 + offset] + step5));
}
Thread.Sleep(1000);
//Debug.Print(this.off[0 + offset] + " - " + this.off[1 + offset] + " - " + this.off[2 + offset]);
seconds--;
}
setPWM((byte)(0 + offset), 0, (ushort)(ch1));
setPWM((byte)(1 + offset), 0, (ushort)(ch2));
setPWM((byte)(2 + offset), 0, (ushort)(ch3));
setPWM((byte)(3 + offset), 0, (ushort)(ch4));
setPWM((byte)(4 + offset), 0, (ushort)(ch5));
}