コード例 #1
0
ファイル: Program.cs プロジェクト: nzaugg/FT232H.NET
        static void Main(string[] args)
        {
            var ft232Device = FT232HDetector.Detect();

            if (ft232Device.Ok)
            {
                System.Console.WriteLine(ft232Device.ToString());
            }

            // MCP3088 and MAX7219 is limited to 10Mhz
            var clockSpeed = MpsseSpiConfig._30Mhz;
            // clockSpeed = MpsseSpiConfig._10Mhz;
            var ft232hGpioSpiDevice = new GpioSpiDevice(MpsseSpiConfig.Make(clockSpeed));

            var spi   = ft232hGpioSpiDevice.SPI;
            var gpios = ft232hGpioSpiDevice.GPIO;

            GpioSample(gpios, true);

            CypressFlashMemorySample(spi);

            //Api102RgbLedSample(spi);
            // ADC_MCP3008Demo(spi);
            GpioSample(gpios, true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: hiroshica/FT232H.NET
        static void Main(string[] args)
        {
            var ft232Device = FT232HDetector.Detect();

            if (ft232Device.Ok)
            {
                System.Console.WriteLine(ft232Device.ToString());
            }
            else
            {
                Environment.Exit(1);
            }
            // MCP3088 and MAX7219 is limited to 10Mhz
            var clockSpeed = MpsseSpiConfig._30Mhz;
            // clockSpeed = MpsseSpiConfig._10Mhz;
            var ft232hGpioSpiDevice = new GpioSpiDevice(MpsseSpiConfig.Make(clockSpeed));

            var spi   = ft232hGpioSpiDevice.SPI;
            var gpios = ft232hGpioSpiDevice.GPIO;
            var max   = gpios.MaxGpio;
            var pin   = 3;

            gpios.SetPinMode(pin, PinMode.Output);
            for (var iI = 0; iI < 10; ++iI)
            {
                //for (var pin = 0; pin < gpios.MaxGpio; ++pin)
                {
                    gpios.DigitalWrite(pin, PinState.High);
                    Thread.Sleep(500);
                    gpios.DigitalWrite(pin, PinState.Low);
                    Thread.Sleep(500);
                }
            }

            Thread.Sleep(100);
            //GpioSample(gpios, true);
        }
コード例 #3
0
        static async Task Main(string[] args)
        {
            var ft232Device = FT232HDetector.Detect();

            if (ft232Device.Ok)
            {
                Console.WriteLine(ft232Device.ToString());
            }
            else
            {
                throw new Exception("Could not find a device");
            }

            var i2cDevice = new GpioI2CDevice(new I2C_CHANNEL_CONFIG
            {
                ClockRate    = I2C_CLOCKRATE.I2C_CLOCK_FAST_MODE,
                LatencyTimer = 1
            }, channelIndex: 0);

            try
            {
                var gpios = i2cDevice.GPIO;
                await Blink(gpios, 4, 5, 250);

                var tempSensor = new Mlx90614(i2cDevice, 0x2A)
                {
                    TempInF = true
                };

                // Trying to figure out sane values for these:
                gsensor.SetGestureThreshold(0x30, 0x20, 0b11);
                gsensor.SetGainAndIrIntensity(0b11 /* Full Gain */, 0b11 /* Full Intensity */);

                do
                {
                    while (!gsensor.GestureAvailable())
                    {
                        //byte status = await gsensor.ReadStatus();
                        //byte gstatus = await gsensor.ReadGestureStatus();
                        //Debug.WriteLine($"Status: {status.ToString("X")}; GStatus: {gstatus.ToString("X")}");
                        await Task.Delay(10);
                    }

                    //Console.WriteLine("Gesture is available!");
                    //byte[] data = await gsensor.ReadAvailableGestureData();
                    //string hexstring = BytesToHexString(data);
                    //WriteLine($"Gesture Data:\n{hexstring}");

                    var result = await gsensor.ReadGesture();

                    WriteLine(result);

                    //await Task.Delay(1000);
                    //Read(i2cDevice).Wait();
                } while (true);
                //try
                //{
                //	await tempSensor.SetAddress(0x2A);
                //}
                //catch { }

                var temperatures = new List <string>();

                for (int i = 0; i < 100; i++)
                {
                    var ambientTemp = await tempSensor.ReadAmbientTemperature();

                    var objectTemp = await tempSensor.ReadObjectTemperature();

                    Console.WriteLine($"Ambient: {ambientTemp}, Object: {objectTemp}");
                    temperatures.Add($"Ambient: {ambientTemp}, Object: {objectTemp}");

                    await Task.Delay(1000);
                }
            }
            catch (Exception e)
            {
                WriteLine(e);
            }
            WriteLine("Press any key to exit...");
            Console.Read();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: nzaugg/FT232H.NET
        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);
                }
            }
        }