Ejemplo n.º 1
0
        /// <summary>
        ///     Get a GraphicDisplay built from one or more 8x8 MAX7219-powered LED displays commonly available from hobbyist
        ///     vendors.
        /// </summary>
        /// <param name="port">The SPI port these displays are attached to</param>
        /// <param name="latch">The latch pin to use with these displays</param>
        /// <param name="numDevices">The number of 8x8 units that are daisy-chained together</param>
        /// <returns></returns>
        public static LedGraphicDisplay GetMax7219GraphicLedDisplay(Spi port, Pin latch, int numDevices)
        {
            IEnumerable <Led> finalList = new List <Led>();

            for (var i = 0; i < numDevices; i++)
            {
                Max7219 driver;

                driver = new Max7219(port, latch, i);

                var tempList = new List <Led>();

                // We have to re-order the LEDs from the Max7219
                {
                    for (var k = 62; k >= 56; k--)
                    {
                        for (var m = k; m >= 0; m -= 8)
                        {
                            tempList.Add(driver.Leds[m]);
                        }
                    }

                    for (var k = 63; k >= 0; k -= 8)
                    {
                        tempList.Add(driver.Leds[k]);
                    }
                }

                finalList = finalList.Concat(tempList);
            }

            var display = new LedGraphicDisplay(finalList.ToList(), 8 * numDevices, 8);

            return(display);
        }
        public static LedGraphicDisplay GetMax7219GraphicLedDisplay(Spi port, Pin latch, int numDevices)
        {
            IEnumerable<Led> finalList = new List<Led>();
            for (int i = 0; i < numDevices; i++)
            {
                Max7219 driver;

                driver = new Max7219(port, latch, i);

                var tempList = new List<Led>();

                // We have to re-order the LEDs from the Max7219
                {
                    for (int k = 62; k >= 56; k--)
                    {
                        for (int m = k; m >= 0; m -= 8)
                        {
                            tempList.Add(driver.Leds[m]);
                        }
                    }

                    for (int k = 63; k >= 0; k -= 8)
                    {
                        tempList.Add(driver.Leds[k]);
                    }
                }

                finalList = finalList.Concat(tempList);
            }

            var display = new LedGraphicDisplay(finalList.ToList(), 8 * numDevices, 8);

            return display;
        }