예제 #1
0
    public static void Main(string[] args)
    {
        // Create a logger
        var logger = new PiLogger();

        logger.Info("Init Wiring Pi...");
        Pi.Init <BootstrapWiringPi>();

        logger.Info("Creating I2C...");
        var i2C = new PiI2cCore();

        logger.Info("Create Oled...");

        // Create the Oled Object, with the wrapper for the I2C and the logger.
        // Set the defaults for the testing screen used
        var oled = new OledCore(i2C, 128, 64, logger: logger,
                                screenDriver: DefaultTestScreenDriver);

        logger.Info("Init Oled...");
        // Init the Oled (setup params, clear display, etc)
        var init = oled.Initialise();

        logger.Info($"Init returned {init}");

        logger.Info("Writing to output...");
        oled.WriteString(0, 0, "My Test 1", 1);

        logger.Info("Calling oled update...");
        oled.UpdateDirtyBytes();

        logger.Info("done. Press enter to exit");

        Console.ReadLine();
    }
예제 #2
0
        public async Task AutoReconnect()
        {
            // Create the I2C Controller
            var ftdi = new FtdiI2cCore(DeviceIndexForTesting, Logger);

            ftdi.InitCommandRegister(() =>
            {
                if (!ftdi.SetupMpsse())
                {
                    Assert.Fail("Could not Init Mpsse on FTDI chip");
                    return(false);
                }

                return(true);
            });

            var oled = new OledCore(new I2CWrapper2(ftdi, Logger), 128, 64, logger: Logger,
                                    screenDriver: DefaultTestScreenDriver);

            oled.InitCommandRegister(() =>
            {
                var r = oled.Initialise();
                Assert.IsTrue(r, "Failed to init oled");
                return(r);
            });

            oled.InitCommandRegister(() =>
            {
                oled.WriteString(0, 0, "My Test 1", 1.6);
                oled.UpdateDirtyBytes();
                return(true);
            });


            ftdi.InitAutoReconnectStart();

            Assert.IsTrue(ftdi.Ready, "Failed to init ftdi");

            // Delay so it can be tested.
            await Task.Delay(TimeSpan.FromSeconds(10));
        }