Exemplo n.º 1
0
        private static async Task Set(ITLC5947 tlc, Color color, ConsoleColor cc, CancellationToken cancellationToken)
        {
            int          x     = Console.CursorLeft;
            int          y     = Console.CursorTop;
            ConsoleColor oldcc = Console.BackgroundColor;

            try
            {
                Console.SetCursorPosition(0, 0);
                Console.BackgroundColor = cc;
                Console.Write(" ");
            }
            finally
            {
                Console.BackgroundColor = oldcc;
                Console.SetCursorPosition(x, y);
            }
            tlc.SetLED(0, color);
            tlc.Write();
            //await Task.Delay(333, cancellationToken);
        }
 /// <summary>
 /// Set RGB led color (for a 12 bits PWM)
 /// </summary>
 /// <param name="comp">The component</param>
 /// <param name="ledNum">LED number</param>
 /// <param name="color"></param>
 public static void SetLED(this ITLC5947 comp, int ledNum, Color color)
 {
     comp.SetLED(ledNum, color.R, color.G, color.B);
 }
 /// <summary>
 /// Set PWM for a RGB LED
 /// </summary>
 /// <param name="comp">The component</param>
 /// <param name="ledNum">LED number</param>
 /// <param name="r">R value</param>
 /// <param name="g">G value</param>
 /// <param name="b">B value</param>
 public static void SetLED(this ITLC5947 comp, int ledNum, byte r, byte g, byte b)
 {
     comp.SetPWM(ledNum * 3, (int)(r * colorRatio));
     comp.SetPWM(ledNum * 3 + 1, (int)(g * colorRatio));
     comp.SetPWM(ledNum * 3 + 2, (int)(b * colorRatio));
 }