private static NusbioMatrix InitializeMatrix( Nusbio nusbio, NusbioMatrix.MAX7219_WIRING_TO_8x8_LED_MATRIX origin, int matrixChainedCount) { NusbioMatrix matrix = null; if (nusbio.Type == NusbioType.NusbioType1_Light) { matrix = NusbioMatrix.Initialize(nusbio, selectGpio: NusbioGpio.Gpio6, // RX mosiGpio: NusbioGpio.Gpio5, // TX clockGpio: NusbioGpio.Gpio4, // CTS gndGpio: NusbioGpio.None, MAX7218Wiring: origin, deviceCount: matrixChainedCount); //matrix.SPIEngine.SoftwareBitBangingMode = true; } else { matrix = NusbioMatrix.Initialize(nusbio, #if NUSBIO_WAVESHARE selectGpio: NusbioGpio.Gpio6, // r mosiGpio: NusbioGpio.Gpio5, // t clockGpio: NusbioGpio.Gpio7, // rt #else selectGpio: NusbioGpio.Gpio3, mosiGpio: NusbioGpio.Gpio1, clockGpio: NusbioGpio.Gpio0, #endif gndGpio: NusbioGpio.None, MAX7218Wiring: origin, deviceCount: matrixChainedCount); // If you have MAX7219 LED Matrix chained together increase the number } SetBrightnesses(matrix); return(matrix); }
static void Main(string[] args) { var ft232Device = FT232HDetector.Detect(); if (ft232Device.Ok) { System.Console.WriteLine(ft232Device.ToString()); } else { Environment.Exit(1); } Cls(ft232Device.ToString()); // MAX7219 is limited to 10Mhz var ft232hGpioSpiDevice = new GpioSpiDevice(MpsseSpiConfig.Make(MpsseSpiConfig._10Mhz)); var spi = ft232hGpioSpiDevice.SPI; #if DEMO_WITH_4_8x8_LED_MATRIX_CHAINED var matrixChainedCount = 8; var origin = NusbioMatrix.MAX7219_WIRING_TO_8x8_LED_MATRIX.OriginUpperLeftCorner; // Different Wiring for 4 8x8 LED Matrix sold by MadeInTheUSB #else var matrixChainedCount = 1; var origin = NusbioMatrix.MAX7219_WIRING_TO_8x8_LED_MATRIX.OriginBottomRightCorner; #endif var matrix = NusbioMatrix.Initialize(spi, origin, matrixChainedCount); matrix.DrawRect(1, 1, 4, 4, true); matrix.WriteDisplay(0); while (true) { if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.D0) { Animate(matrix, 0); } if (k == ConsoleKey.D1) { DisplaySquareImage1(matrix, 0); } if (k == ConsoleKey.D2) { DisplaySquareImage2(matrix, 0); } if (k == ConsoleKey.Q) { break; } if (k == ConsoleKey.A) { DrawAxis(matrix, 0); } if (k == ConsoleKey.R) { RotateMatrix(matrix, 0); } if (k == ConsoleKey.S) { ScrollDemo(matrix, 0); } if (k == ConsoleKey.P) { PerformanceTest(matrix, 0); // Speed test } if (k == ConsoleKey.C) { matrix.Clear(all: true, refresh: true); } if (k == ConsoleKey.T) { ScrollText(matrix); } if (k == ConsoleKey.L) { LandscapeDemo(matrix); } Cls(ft232Device.ToString()); matrix.Clear(all: true, refresh: true); } } }