Ejemplo n.º 1
0
        public IActionResult ChangeColor(int green, int red, int blue)
        {
            Console.WriteLine("Changing color...");
            var color    = Color.FromArgb(1, red, green, blue);
            var pin      = _options.Value.NeoPixelPin;
            var ledCount = _options.Value.LedCount;

            try
            {
                var neoPixel = new
                               Neopixel(ledCount, pin, rpi_ws281x.WS2811_STRIP_GRB, invert: true);

                neoPixel.Begin();
                for (var i = 0; i < neoPixel.GetNumberOfPixels(); i++)
                {
                    neoPixel.SetPixelColor(i, color);
                }
                //neoPixel.Dispose();
                neoPixel.Show();
                return(Ok());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(StatusCode(500, ex));
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var a = new Neopixel(1, 18);

            a.Begin();
        }
Ejemplo n.º 3
0
 /**
  * Returns a string of what value a neopixel is currently set to with three deimal places for red green and blue
  * @param aNeopixel structure to retrieve the string value from
  */
 static string getLightString(Neopixel aNeopixel)
 {
     return(aNeopixel.redValue.ToString("D3") + aNeopixel.greenValue.ToString("D3") + aNeopixel.blueValue.ToString("D3"));
 }