コード例 #1
0
        public void InitHardware()
        {
            Console.WriteLine("Creating output ports...");

            //poling
            sensor = new Adxl345(Device.CreateI2cBus(), 83, 0);

            sensor.SetPowerState(false, false, true, false, Adxl345.Frequency.EightHz);

            while (true)
            {
                sensor.Update();

                Console.WriteLine($"{sensor.X}, {sensor.Y}, {sensor.Z}");

                Thread.Sleep(500);
            }

            //event

            /*sensor = new Adxl345(Device.CreateI2cBus(), 83);
             *
             * sensor.SetPowerState(false, false, true, false, Adxl345.Frequency.EightHz);
             *
             * sensor.AccelerationChanged += Sensor_AccelerationChanged;
             */
        }
コード例 #2
0
        public void InitHardware()
        {
            Console.WriteLine("Creating output ports...");

            //polling
            sensor = new Adxl345(Device.CreateI2cBus(), 83);

            sensor.SetPowerState(false, false, true, false, Adxl345.Frequency.EightHz);

            sensor.Updated += Sensor_Updated;

            sensor.StartUpdating(1000);
        }