Ejemplo n.º 1
0
        public bool SetSignalRateLimit(float limit)
        {
            if (limit < 0 || limit > 511.99)
            {
                return(false);
            }

            float val = limit * (1 << 7);

            byte[] bytes = BitConverter.GetBytes(limit);
            i2c.WriteRegister(address, (byte)Register.FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT, new byte[] { bytes[0], bytes[1] });
            return(true);
        }
Ejemplo n.º 2
0
        public void Configure(MPU6050Configuration Config)
        {
            Bus.WriteRegister(Address, 0x19, new byte[] { Config.SampleRateDivider });

            // Get Current Configs
            byte ConfigRegister = Bus.ReadRegister(Address, 0x1A, 1)[0];
            byte GyroConfig     = Bus.ReadRegister(Address, 0x1B, 1)[0];
            byte AccelConfig    = Bus.ReadRegister(Address, 0x1C, 1)[0];

            // Clean the configs
            GyroConfig     &= 0b11100111;
            AccelConfig    &= 0b11100111;
            ConfigRegister &= 0b11111100;

            // Set Config
            GyroConfig     |= (byte)(Config.GyroSensitivity << 3);
            AccelConfig    |= (byte)(Config.AccelSensitivity << 3);
            ConfigRegister |= Config.DLPFSetup;

            // Write the config
            Bus.WriteRegister(Address, 0x1A, new byte[] { ConfigRegister });
            Bus.WriteRegister(Address, 0x1B, new byte[] { GyroConfig });
            Bus.WriteRegister(Address, 0x1C, new byte[] { AccelConfig });

            // Ensure self test is disabled
            EnableSelfTest(false);
        }
Ejemplo n.º 3
0
 /// <summary> Writes the specified byte and to the Register. </summary>
 /// <param name="Register"> Register to write to. </param>
 /// <param name="Data"> Byte to write.</param>
 private void Write8(byte Register, byte Data) => I2C.WriteRegister(Address, Register, new byte[] { Data });
Ejemplo n.º 4
0
 private void write8(byte addr, byte d)
 {
     i2c.WriteRegister(i2caddr, addr, new byte[] { d });
 }