Represents a driver for I2C devices.
Inheritance: IDisposable
コード例 #1
0
        private IPwmDevice GetRealDevice()
        {
            PwmFrequency = new Frequency(60);
            DeviceAddress = 0x40;

            try
            {
                Log.Info("Creating pins");
                var sdaPin = SdaPin.ToProcessor();
                var sclPin = SclPin.ToProcessor();

                Log.Info("Creating i2cDriver");
                _i2cDriver = new I2cDriver(sdaPin, sclPin);
            }
            catch (Exception e)
            {
                Log.Error("Failed to initialise i2c driver. Did you forget sudo?", e);
            }

            Log.Info("Creating real device...");
            var device = new Pca9685Connection(_i2cDriver.Connect(DeviceAddress));
            Log.Info("Setting frequency...");
            device.SetPwmUpdateRate(PwmFrequency); //                        # Set frequency to 60 Hz


            IsConnected = true;
            return device;
        }
コード例 #2
0
        public AmplifierConnection()
        {
            log.Debug(m => m("Init amplifier connection"));

            // connect volume via i2c
            _i2cDriver = new I2cDriver(ProcessorPin.Pin2, ProcessorPin.Pin3);
            _connection = _i2cDriver.Connect(0x4b);

            // connect shutdown via gpio
            _shutdownPin = ConnectorPin.P1Pin36.Output().Revert();
            _gpioConnection = new GpioConnection(_shutdownPin);
        }
コード例 #3
0
        private IPwmDevice GetRealDevice()
        {
            PwmFrequency = 60;
            DeviceAddress = 0x40;

            _i2cDriver = new I2cDriver(SdaPin.ToProcessor(), SclPin.ToProcessor());

            Log.Info("Creating device...");
            var device = Pca9685Connection.Create(_i2cDriver.Connect(DeviceAddress));
            Log.Info("Setting frequency...");
            device.SetPwmUpdateRate(PwmFrequency); //                        # Set frequency to 60 Hz


            IsConnected = true;
            return device;
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var options = ParseOptions(args);
            if (options == null)
                return;

            log.Info("-=Pca9685 Sample=-");
            log.Info(m => m("Running {0}", Environment.OSVersion));
            log.Info("Options:" + Environment.NewLine + options);

            var pulse = CalculatePulse(options.PwmFrequency, 50);
            log.Info(m => m("Pulse={0}", pulse));

            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                log.Warn("Windows detected. Exiting");
                return;
            }
            
            log.Info("Connecting...");

            try
            {
                using (var driver = new I2cDriver(options.SdaPin.ToProcessor(), options.SclPin.ToProcessor()))
                {
                    log.Info("Creating device...");
                    var device = Pca9685Connection.Create(driver.Connect(options.DeviceAddress));

                    log.Info("Setting frequency...");
                    device.SetPwmUpdateRate(options.PwmFrequency);
                    while (!Console.KeyAvailable)
                    {
                        log.Info(m => m("Set channel={0} to {1}", options.Channel, options.PwmOn));
                        device.SetPwm(options.Channel, 0, options.PwmOn);
                        Thread.Sleep(1000);
                        log.Info(m => m("Set channel={0} to {1}", options.Channel, options.PwmOff));
                        device.SetPwm(options.Channel, 0, options.PwmOff);
                        Thread.Sleep(1000);
                    }
                    log.Info("Key pressed. Exiting.");
                }
            }
            catch (InvalidOperationException e)
            {
                log.Error("Failed to connect? Do you have a Pca9685 IC attached to the i2c line and powered on?", e);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: spokino/raspberry-sharp-io
        static void Main(string[] args)
        {
            var sdaPin = ConnectorPin.P1Pin03.ToProcessor();
            var sclPin = ConnectorPin.P1Pin05.ToProcessor();

            using (var driver = new I2cDriver(sdaPin, sclPin))
            {
                var deviceConnection =  new Mcp23017I2cConnection(driver.Connect(0x20));
                deviceConnection.SetDirection(Mcp23017Pin.B0, Mcp23017PinDirection.Output);

                while (!Console.KeyAvailable)
                {
                    deviceConnection.Toogle(Mcp23017Pin.B0);
                    Thread.Sleep(1000);
                }
            }
        }
コード例 #6
0
        private static Hd44780Configuration LoadMcp23017Configuration(IEnumerable<string> args)
        {
            var addressText = args.SkipWhile(s => !String.Equals(s, "mcp23017", StringComparison.InvariantCultureIgnoreCase)).Skip(1).DefaultIfEmpty("0x20").First();
            var address = addressText.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)
                ? Int32.Parse(addressText.Substring(2), NumberStyles.HexNumber)
                : Int32.Parse(addressText);

            const Mcp23017Pin registerSelectPin = Mcp23017Pin.B7;
            const Mcp23017Pin clockPin = Mcp23017Pin.B5;
            var dataPins = new[]
            {
                Mcp23017Pin.B1,
                Mcp23017Pin.B2,
                Mcp23017Pin.B3,
                Mcp23017Pin.B4
            };

            Console.WriteLine();
            Console.WriteLine("Using I2C connection over MCP23017 Expander");
            Console.WriteLine("\tRegister Select: {0}", registerSelectPin);
            Console.WriteLine("\tClock: {0}", clockPin);
            Console.WriteLine("\tData 1: {0}", dataPins[0]);
            Console.WriteLine("\tData 2: {0}", dataPins[1]);
            Console.WriteLine("\tData 3: {0}", dataPins[2]);
            Console.WriteLine("\tData 4: {0}", dataPins[3]);
            Console.WriteLine("\tBacklight: VCC");
            Console.WriteLine("\tRead/write: GND");
            Console.WriteLine();

            const ConnectorPin sdaPin = ConnectorPin.P1Pin03;
            const ConnectorPin sclPin = ConnectorPin.P1Pin05;

            var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor()) { ClockDivider = 512 };
            var connection = new Mcp23017I2cConnection(driver.Connect(address));

            return new Hd44780Configuration(driver)
            {
                Pins = new Hd44780Pins(
                    connection.Out(registerSelectPin),
                    connection.Out(clockPin),
                    dataPins.Select(pin => (IOutputBinaryPin)connection.Out(pin)))
            };
        }
コード例 #7
0
        static void Main(string[] args)
        {
            const ConnectorPin sdaPin = ConnectorPin.P1Pin03;
            const ConnectorPin sclPin = ConnectorPin.P1Pin05;

            Console.WriteLine("PCF-8563 Sample: Read RTC");
            Console.WriteLine();

            Console.WriteLine ("Program Started at:"+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            using (var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor()))
            {
                var deviceConnection = new Pcf8563I2cConnection(driver.Connect(0x51));

                while (!Console.KeyAvailable)
                {
                    Console.WriteLine(deviceConnection.ReadSeconds().ToString()); 
                    Thread.Sleep(1000);
                }
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            using (var i2cDriver = new I2cDriver(ProcessorPin.Pin2,  ProcessorPin.Pin3))
            {
                I2cDeviceConnection i2c = i2cDriver.Connect(0x70);

                var bargraph = new BiColor24Bargraph(i2c);

                bargraph.Clear();

                while (true)
                {
                    foreach (BiColor24Bargraph.LEDState state in Enum.GetValues(typeof(BiColor24Bargraph.LEDState)))
                    {
                        for (int i=0; i<24;i++)
                        {
                            bargraph.SetLed((uint)i, state);
                            Thread.Sleep(50);
                        }
                    }
                }
            }
        }
コード例 #9
0
        static void Main()
        {
            const ConnectorPin sdaPin = ConnectorPin.P1Pin03;
            const ConnectorPin sclPin = ConnectorPin.P1Pin05;

            Console.WriteLine("MCP-23008 Sample: Switch LED on Pin0 pin");
            Console.WriteLine();
            Console.WriteLine("\tSDA: {0}", sdaPin);
            Console.WriteLine("\tSCL: {0}", sclPin);
            Console.WriteLine();

            using (var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor()))
            {
                var deviceConnection = new Mcp23008I2cConnection(driver.Connect(0x20));
                deviceConnection.SetDirection(Mcp23008Pin.Pin0, Mcp23008PinDirection.Output);

                while (!Console.KeyAvailable)
                {
                    deviceConnection.Toogle(Mcp23008Pin.Pin0);
                    Thread.Sleep(1000);
                }
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: JelleLoeve/Raspberry-LED
        public static void Main()
        {
            Console.Title = "Raspberry-LED Domotica client";
            if (!Helpers.IsLinux)
            {
                Console.WriteLine("Sorry, almost everything in this script can only run on the Raspberry Pi.");
                Console.WriteLine("Press enter to close the script.");
                Console.Read();
                Environment.Exit(0);
            }
            Console.CancelKeyPress += delegate
            {
                Console.WriteLine("Stopping the program");
                HubConnection.Closed -= StartHubConnection;
                HubConnection.Closed += null;
                HubConnection.Stop();
                Console.WriteLine("Stopped SignalR communication");
                for (var i = 0; i == 32;)
                {
                    string str = $"gpio{i}";
                    if (Directory.Exists(Path.Combine("/sys/class/gpio", str)))
                    {
                        driver.Release((ProcessorPin) i);
                    }
                    i++;
                }
                gpio.Close();
                Console.WriteLine("Stopped driver allocating");
                Thread.Sleep(1000);
                Environment.Exit(0);
            };
            // Connection to the signalr hub
            HubConnection = new HubConnection("http://192.168.1.100");
            RaspberryHub = HubConnection.CreateHubProxy("Raspberry");
            // If the server decides to close the connection we need to start it again
            HubConnection.Closed += StartHubConnection;
            // Starts the connection
            StartHubConnection();

            gpio = new GpioConnection();
            driver = new GpioConnectionDriver();
            I2CDriver = new I2cDriver(ConnectorPin.P1Pin3.ToProcessor(), ConnectorPin.P1Pin5.ToProcessor());
            ArduinoConnection = I2CDriver.Connect(0x04);
            var switchButton = ConnectorPin.P1Pin13.Input().Revert().OnStatusChanged(x =>
            {
                Console.WriteLine(x);
                RaspberryHub.Invoke("SendChangedValue", ConnectorPin.P1Pin37, x ? "On" : "Off");
            });
            var doorSensor = ConnectorPin.P1Pin7.Input().PullUp().OnStatusChanged(x =>
            {
                RaspberryHub.Invoke("SendChangedValue", ConnectorPin.P1Pin7, x ? "Open" : "Closed");
            });
            var motionSensor = ConnectorPin.P1Pin13.Input().OnStatusChanged(x =>
            {
                RaspberryHub.Invoke("SendChangedValue", ConnectorPin.P1Pin11, x ? "Detected" : "Not detected");
                Console.WriteLine( DateTime.Now + ":Motion {0}", x ? "Detected" : "Not detected");
            });
            //            gpio.Add(switchButton);
            //            gpio.Add(doorSensor);
            //            gpio.Add(motionSensor);

            RaspberryHub.On<string>("ChangePiLed", pinnumber =>
            {
                int ledid = int.Parse(pinnumber);
                var procpin = ((ConnectorPin) ledid).ToProcessor();

                string str = string.Format("gpio{0}",procpin.ToString().Replace("Pin0","").Replace("Pin",""));
                if (!Directory.Exists(Path.Combine("/sys/class/gpio", str)))
                {
                    Console.WriteLine($"OutputPin {procpin} is not allocated!\nAllocating now.");
                    driver.Allocate(procpin, PinDirection.Output);
                    Console.WriteLine("Pin allocated");
                }
                driver.Write(procpin, !driver.Read(procpin));
                RaspberryHub.Invoke("SendChangedValue", pinnumber, driver.Read(procpin) ? "On" : "Off");
            });

            RaspberryHub.On<string, string>("SetupConfig", (pinnumber, type) =>
            {
                int pin = int.Parse(pinnumber);
                if (pin > 7)
                {
                    Action<bool> onstatusaction =
                        b =>
                        {
                            RaspberryHub.Invoke("SendChangedValue", pin,
                                driver.Read(((ConnectorPin) pin).ToProcessor()) ? "On" : "Off");
                        };
                    string str = string.Format("gpio{0}", ((ConnectorPin)pin).ToProcessor().ToString().Replace("Pin0", "").Replace("Pin", ""));
                    Console.WriteLine(str);
                    if (!Directory.Exists(Path.Combine("/sys/class/gpio", str)))
                    {
                        Console.WriteLine("Adding button");
                        var button = CreatePinConfig.CreateOutputPinConfiguration((ConnectorPin) pin, onstatusaction, "Button");
                        gpio.Add(button);
                    }
                }
            });

            RaspberryHub.On<int, string>("GetPinStatus", (pin, type) =>
            {
                driver.Read(((ConnectorPin) pin).ToProcessor());
                string status = string.Empty;
                if (type.Equals("Button"))
                {
                    status = driver.Read(((ConnectorPin) pin).ToProcessor()) ? "Pressed" : "Not pressed";
                }
                if (type.Equals("LED"))
                {
                    status = driver.Read(((ConnectorPin) pin).ToProcessor()) ? "On" : "Off";
                }
                if (type.Equals("Door sensor"))
                {
                    status = driver.Read(((ConnectorPin)pin).ToProcessor()) ? "Open" : "Closed";
                }

                RaspberryHub.Invoke("SendChangedValue", pin, status);
            });

            ServerWorkThread objThread = new ServerWorkThread();
            SendToArduino(1);
            while (true)
            {
                Thread.Sleep(50);
                ReadFromArduino();
                //objThread.HandleConnection(objThread.mySocket.Accept());
            }
        }
コード例 #11
0
        private static Hd44780Configuration LoadPcf8574Configuration(IEnumerable<string> args)
        {
            var addressText = args.SkipWhile(s => !String.Equals(s, "pcf8574", StringComparison.InvariantCultureIgnoreCase)).Skip(1).DefaultIfEmpty("0x20").First();
            var address = addressText.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)
                ? Int32.Parse(addressText.Substring(2), NumberStyles.HexNumber)
                : Int32.Parse(addressText);

            const Pcf8574Pin clockPin = Pcf8574Pin.P2;
            const Pcf8574Pin readWritePin = Pcf8574Pin.P1;
            const Pcf8574Pin registerSelectPin = Pcf8574Pin.P0;
            const Pcf8574Pin backlightPin = Pcf8574Pin.P3;
            var dataPins = new[]
            {
                Pcf8574Pin.P4,
                Pcf8574Pin.P5,
                Pcf8574Pin.P6,
                Pcf8574Pin.P7
            };

            Console.WriteLine();
            Console.WriteLine("Using I2C connection over PCF8574 expander");
            Console.WriteLine("\tRegister Select: {0}", registerSelectPin);
            Console.WriteLine("\tClock: {0}", clockPin);
            Console.WriteLine("\tData 1: {0}", dataPins[0]);
            Console.WriteLine("\tData 2: {0}", dataPins[1]);
            Console.WriteLine("\tData 3: {0}", dataPins[2]);
            Console.WriteLine("\tData 4: {0}", dataPins[3]);
            Console.WriteLine("\tBacklight: {0}", backlightPin);
            Console.WriteLine("\tRead/write: {0}", readWritePin);
            Console.WriteLine();

            const ConnectorPin sdaPin = ConnectorPin.P1Pin03;
            const ConnectorPin sclPin = ConnectorPin.P1Pin05;

            var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor()) { ClockDivider = 512 };
            var connection = new Pcf8574I2cConnection(driver.Connect(address));

            return new Hd44780Configuration(driver)
            {
                Pins = new Hd44780Pins(
                    connection.Out(registerSelectPin),
                    connection.Out(clockPin),
                    dataPins.Select(p => (IOutputBinaryPin)connection.Out(p)))
                {
                    Backlight = connection.Out(backlightPin),
                    ReadWrite = connection.Out(readWritePin),
                }
            };
        }
コード例 #12
0
        private static Hd44780Configuration LoadI2cConfiguration()
        {
            const Mcp23017Pin registerSelectPin = Mcp23017Pin.B0;
            const Mcp23017Pin clockPin = Mcp23017Pin.B1;
            var dataPins = new[]
                {
                    Mcp23017Pin.B2,
                    Mcp23017Pin.B3,
                    Mcp23017Pin.B4,
                    Mcp23017Pin.B5
                };

            Console.WriteLine();
            Console.WriteLine("Using I2C connection");
            Console.WriteLine("\tRegister Select: {0}", registerSelectPin);
            Console.WriteLine("\tClock: {0}", clockPin);
            Console.WriteLine("\tData 1: {0}", dataPins[0]);
            Console.WriteLine("\tData 2: {0}", dataPins[1]);
            Console.WriteLine("\tData 3: {0}", dataPins[2]);
            Console.WriteLine("\tData 4: {0}", dataPins[3]);
            Console.WriteLine();

            const ConnectorPin sdaPin = ConnectorPin.P1Pin03;
            const ConnectorPin sclPin = ConnectorPin.P1Pin05;

            var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor());
            driver.ClockDivider = 2048;

            var connection = new Mcp23017I2cConnection(driver.Connect(0x20));

            return new Hd44780Configuration(driver)
                {
                    RegisterSelect = connection.Out(registerSelectPin),
                    Clock = connection.Out(clockPin),
                    Data = dataPins.Select(pin=>connection.Out(pin))
                };
        }
コード例 #13
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                // If you need thread safety, use a lock around these  
                // operations, as well as in your methods that use the resource. 
                if (disposing)
                {
                    // Free the necessary managed disposable objects. 
                    if (_i2cDriver != null)
                    {
                        _i2cDriver.Dispose();
                    }
                }

                _i2cDriver = null;
                _disposed = true;
            }
        }
コード例 #14
0
 internal I2cDeviceConnection(I2cDriver driver, int deviceAddress)
 {
     this.driver        = driver;
     this.deviceAddress = deviceAddress;
 }
コード例 #15
0
ファイル: Display.cs プロジェクト: Equitis/RPiAqua
        public Display()
        {
            driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor());
            //driver.ClockDivider = 400;
            connection = driver.Connect(LCDADRESS);
            //connection.WriteByte();
            this.Write(0x03);
            this.Write(0x03);
            this.Write(0x03);
            this.Write(0x02);

            this.Write(LCD_FUNCTIONSET | LCD_2LINE | LCD_5x8DOTS | LCD_4BITMODE);
            this.Write(LCD_DISPLAYCONTROL | LCD_DISPLAYON);
            this.Write(LCD_CLEARDISPLAY);
            this.Write(LCD_ENTRYMODESET | LCD_ENTRYLEFT);
        }
コード例 #16
0
 internal I2cDeviceConnection(I2cDriver driver, int deviceAddress)
 {
     this.driver = driver;
     this.deviceAddress = deviceAddress;
 }
コード例 #17
0
 /// <summary>
 /// Initializes the connection
 /// </summary>
 /// <param name="addr">I2C address for the matrix.</param>
 private void InitializeConnection(int addr)
 {
     driver = new I2cDriver(Raspberry.IO.GeneralPurpose.ProcessorPin.Pin2, Raspberry.IO.GeneralPurpose.ProcessorPin.Pin3);
     connection = driver.Connect(addr);
 }
コード例 #18
0
ファイル: Rtc_PCF8563.cs プロジェクト: gamondue/GOR-4H-16
 public Rtc_PCF8563(int deviceAddress, I2cDriver driver)
 {
     connection = driver.Connect(deviceAddress);
 }
コード例 #19
0
ファイル: BMP085.cs プロジェクト: Equitis/RPiAqua
 public BMP085()
 {
     driver = new I2cDriver(SDAPIN.ToProcessor(), SCLPIN.ToProcessor());
     connection = new Bmp085I2cConnection(driver.Connect(ADDRESS));
 }
コード例 #20
0
        public static void Main(string[] args)
        {
            const byte ssdI2cAddress = 0x3C;

            var sdaPin = ConnectorPin.P1Pin03;
            var sclPin = ConnectorPin.P1Pin05;
            var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor());
            var ssd1306 = new Ssd1306Connection(driver.Connect(ssdI2cAddress));

            // Clear the screen and turn the display on
            ssd1306.ClearScreen();
            ssd1306.On();

            // Flash screen
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();
            Thread.Sleep(1000);
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();

            // Write "Hello world!" with different fonts
            var fontFixed = new Fixed1L();
            var font2L = new Proportional2L();
            var font3L = new Proportional3L();
            ssd1306.GotoXY(0, 0);
            ssd1306.DrawText(fontFixed, "Hello World!");
            ssd1306.GotoXY(0, 2);
            ssd1306.DrawText(font2L, "Raspberry Pi");
            ssd1306.GotoXY(0, 5);
            ssd1306.DrawText(font3L, "Ssd 1306");

            Thread.Sleep(5000);

            // Draw test image logo
            var logo = new byte[]{
                0x40,
                0xC0, 0xF0, 0xF8, 0x1C, 0x0C, 0x06, 0xF6, 0xFE, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0xFE,
                0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00,
                0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x7E, 0x1E, 0x0E, 0x07, 0x03, 0x03, 0x03, 0x23, 0x7E, 0x3E,
                0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x9E,
                0xBE, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
                0x01, 0x03, 0x03, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x06, 0x06, 0x86, 0xFE, 0xFF, 0xFF,
                0xFF, 0x0F, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0x7F, 0x07, 0x03, 0x01, 0x99, 0xFF, 0xFF, 0x10, 0x10,
                0xD8, 0xFE, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x06, 0x03, 0xFF,
                0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFF, 0xDF, 0xC7, 0x41, 0x71, 0x3F, 0x1F,
                0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFC, 0xFC, 0x3C,
                0x00, 0xC0, 0xF0, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x71, 0x3F, 0x0F, 0x00, 0xE0, 0xFF, 0xFF,
                0xFF, 0x3F, 0x07, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF,
                0x1F, 0x00, 0x00, 0xC0, 0xF8, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x39, 0x1F, 0x0F, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x3C, 0x3F, 0x3F, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F,
                0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x1C, 0x0F, 0x07, 0x01, 0x00, 0x38,
                0x3F, 0x3F, 0x3F, 0x0F, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x3F,
                0x3F, 0x3F, 0x39, 0x38, 0x18, 0x0E, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x18, 0x04, 0x00,
                0x00, 0x00, 0x01, 0xE1, 0xF3, 0x73, 0x77, 0x77, 0x67, 0x03, 0xF3, 0xFF, 0xFF, 0x7F, 0x07, 0x00,
                0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x30, 0x38, 0x18, 0x08, 0x04, 0x3E, 0x3F, 0x3F, 0x3F,
                0x07, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x1C, 0x0F, 0x3F, 0x3F, 0x3F, 0x3F,
                0x38, 0x18, 0x0C, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x38, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x07, 0x07, 0x0C, 0x0C, 0x0C, 0x0C, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };
            ssd1306.ClearScreen();
            ssd1306.GotoXY(0, 3);
            ssd1306.DrawImage(logo);

            ((IDisposable)driver).Dispose();
        }
コード例 #21
0
 public BarometricPressure_BMP180(int deviceAddress, I2cDriver driver)
     : base(false)
 {
     conn = driver.Connect(deviceAddress);
     Initialization();
 }
コード例 #22
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ds1307 Test");
            Console.WriteLine("===========");

            Console.WriteLine("Opening Connection...");

            try
            {
                driver = new I2cDriver(ProcessorPin.Pin02, ProcessorPin.Pin03);
                i2cConnection = driver.Connect(0x68);
                clock = new Ds1307Connection(i2cConnection);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Unable to open connection.");
                Console.WriteLine(ex);
                Console.WriteLine("Press any key to close.");
                Console.Read();
                Environment.Exit(1);
            }

            Console.WriteLine("Connection open!");

            AskForKey();
        }