Exemplo n.º 1
0
        private static void Scan(I2cBus twi)
        {
            char keyChar;

            do
            {
                Console.Clear();
                keyChar = Console.KeyAvailable ? Console.ReadKey().KeyChar : ' ';
                // Scan
                for (int i = 3; i < 127; i++)
                {
                    twi.Start();
                    var result = twi.SendDeviceAddrAndCheckACK((byte)i, false);
                    if (result)
                    {
                        Console.WriteLine($"I2C Address {i,3} 0x{i:x}");
                    }
                    twi.Stop();
                }

                Console.WriteLine("Press x to exit");
                Thread.Sleep(1000);
            } while (keyChar != 'x');

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public bool Ping()
        {
            Twi.Start();
            var result = Twi.SendDeviceAddrAndCheckACK(DeviceAddress, false);

            Twi.Stop();
            return(result);
        }