/// <summary> /// Class handling the Texas Instruments TMP102 Temperature Sensor, connected to an I2C bus connected to the Raspberry Pi GPIO Pin Header. /// For more inforation, see: <see cref="http://www.ti.com.cn/cn/lit/ds/symlink/tmp102.pdf"/> /// </summary> /// <param name="Address">Address (0-3) of the TMP102 device on the I2C bus.</param> /// <param name="I2CBus">I2C Bus to which the device is connected.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if the <paramref name="Address"/> is not valid.</exception> public TexasInstrumentsTMP102 (byte Address, I2C I2CBus) { if (Address > 3) throw new ArgumentOutOfRangeException ("Address", "Valid addresses are 0-3."); this.i2cBus = I2CBus; this.address = (byte)(Address + 0x48); }
/// <summary> /// Class handling the Analog Devices 7991/7995/7999 Analog to Digital Conversion circuits. /// For more inforation, see: <see cref="http://www.analog.com/static/imported-files/data_sheets/AD7991_7995_7999.pdf"/> /// </summary> /// <param name="Address">Address of the AD799x device on the I2C bus.</param> /// <param name="I2CBus">I2C Bus to which the device is connected.</param> /// <param name="Channel1">If Channel 1 is used and should be included in the A/D conversion.</param> /// <param name="Channel2">If Channel 2 is used and should be included in the A/D conversion.</param> /// <param name="Channel3">If Channel 3 is used and should be included in the A/D conversion.</param> /// <param name="Channel4">If Channel 4 is used and should be included in the A/D conversion.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if the <paramref name="Address"/> is not valid.</exception> public AD799x (byte Address, bool Channel1, bool Channel2, bool Channel3, bool Channel4, I2C I2CBus) { if (Address > 1) throw new ArgumentOutOfRangeException ("Address", "Valid addresses are 0-1."); this.i2cBus = I2CBus; this.address = (byte)(Address + 0x28); this.channel1 = Channel1; this.channel2 = Channel2; this.channel3 = Channel3; this.channel4 = Channel4; this.CalcNrBytes (); }
public RegisterIO_I2C(I2C i2c_port) { port = i2c_port; }
/// <summary> /// Construct a new Seeed Grove I2c Motor Driver with a given address /// </summary> /// <param name="i2c">I2c module to use</param> /// <param name="address">The address to use</param> public SeeedGroveI2cMotorDriver(I2C i2c, byte address = 0x0f) { dev = new SMBusDevice(address, i2c); Frequency = PrescalerFrequency.Freq_3921Hz; }
public static void Setup() { pi = new PiGpioSharp("raspi", 8888); i2c = new I2C(pi); }
/// <summary> /// Construct an MCP4725 /// </summary> /// <param name="i2c">The I2c bus this DAC is attached to</param> /// <param name="address">The address to use</param> /// <param name="refVoltage">The voltage of the VDD pin</param> /// <param name="speed">The speed to use</param> public Mcp4725(I2C i2c, byte address, double refVoltage = 3.3, int speed = 400) { dev = new SMBusDevice(address, i2c, speed); ReferenceVoltage = refVoltage; }
/// <summary> /// Construct a new Seeed Grove I2c Motor Driver with the given address DIP switch pins /// </summary> /// <param name="i2c">I2c module to use</param> /// <param name="a1">A1</param> /// <param name="a2">A2</param> /// <param name="a3">A3</param> /// <param name="a4">A4</param> public SeeedGroveI2cMotorDriver(I2C i2c, bool a1, bool a2, bool a3, bool a4) : this(i2c, (byte)((a1 ? 1 : 0 << 3) | (a2 ? 1 : 0 << 2) | (a3 ? 1 : 0 << 1) | (a4 ? 1 : 0 << 0))) { }
/// <summary> /// Constructs the AHRS class using I2C Communication /// </summary> /// <remarks> /// The update rate may be between 4 Hz and 60 Hz, representing the number /// of updates per second sent by the sensor. /// <para/> /// This constructor should be used if communicating via I2C. /// <para/> /// Note that increasing the update rate may increase the CPU utilization. /// </remarks> /// <param name="i2CPortId">The <see cref="I2C.Port">I2C Port</see> to use.</param> /// <param name="updateRateHz">The Update Rate (Hz) [4..60] (Default 50)</param> public AHRS(I2C.Port i2CPortId, byte updateRateHz = NavxDefaultUpdateRateHz) { CommonInit(updateRateHz); if (RobotBase.IsSimulation) { m_io = new SimulatorIO(updateRateHz, m_ioCompleteSink, m_boardCapabilities); } else { m_io = new RegisterIO(new RegisterIO_I2C(new I2C(i2CPortId, 0x32)), updateRateHz, m_ioCompleteSink, m_boardCapabilities); } m_ioThread.Start(); }
/// <summary> /// Construct an MCP4725 /// </summary> /// <param name="i2c">The I2c bus this DAC is attached to</param> /// <param name="addr">The address pin state</param> /// <param name="refVoltage">The voltage of the VDD pin</param> /// <param name="speed">The speed to use</param> public Mcp4725(I2C i2c, bool addr = false, double refVoltage = 3.3, int speed = 400) : this(i2c, (byte)(0x62 | (addr ? 1 : 0)), refVoltage, speed) { }
public Mcp453x(I2C i2c, bool a0 = false, bool a1 = false, bool a2 = false, int rateKhz = 100) { this.dev = new SMBusDevice((byte)(0x28 | (a0 ? 1 : 0) | ((a1 ? 1 : 0) << 1) | ((a2 ? 1 : 0) << 2)), i2c, rateKhz); scale = 128; }
public I2cParallelInterface(I2C i2c) { dev = new SMBusDevice(0x3e, i2c); }
public HIH613x(I2C i2c) { I2c = i2c; }
public GroveI2cLcd(I2C i2c) : base(new I2cParallelInterface(i2c), 16, 2) { // It's undocumented, but the Grove I2C LCD uses a PCA9632 for the RGB backlight backlight = new Pca9632(i2c); }
/// <summary> /// Construct a new LM75 temperature sensor /// </summary> /// <param name="i2c">The i2C port to use</param> /// <param name="a0">the state of the A0 pin</param> /// <param name="a1">the state of the A1 pin</param> /// <param name="a2">the state of the A2 pin</param> public Lm75(I2C i2c, bool a0 = false, bool a1 = false, bool a2 = false) { dev = new SMBusDevice((byte)(0x48 | (a0 ? 1 : 0) | ((a1 ? 1 : 0) << 1) | ((a2 ? 1 : 0) << 2)), i2c); }
public Mcp455x(I2C i2c, bool a0 = false, bool a1 = false, bool a2 = false, int rateKhz = 100) : base(i2c, a0, a1, a2, rateKhz) { scale = 256; }
public Bh1750(I2C i2c, bool addressPin = false, int rate = 100) { this.dev = new SMBusDevice((byte)(addressPin ? 0x5C : 0x23), i2c, rate); Task.Run(() => dev.WriteByteAsync(0x07)).Wait(); // reset Resolution = LuxResolution.High; }
/// <summary> /// Construct a new AMIS30624 stepper motor controller /// </summary> /// <param name="module">The I2c module this stepper motor is attached to</param> /// <param name="address">The address of the module</param> /// <param name="speed">The speed to operate this peripheral at</param> public Amis30624(I2C module, byte address, int speed) { dev = new SMBusDevice(address, module, speed); ResetToDefault().ConfigureAwait(false); GetFullStatus().ConfigureAwait(false); }
/// <summary> /// Construct a new MCP23008 /// </summary> /// <param name="i2c">The I2c bus to use</param> /// <param name="a0">The state of the A0 pin</param> /// <param name="a1">The state of the A1 pin</param> /// <param name="a2">The state of the A2 pin</param> /// <param name="speedKHz"></param> public Mcp23008(I2C i2c, bool a0 = false, bool a1 = false, bool a2 = false, int speedKHz = 100) : this(i2c, (byte)(0x20 | (a0 ? 1 : 0) | ((a1 ? 1 : 0) << 1) | ((a2 ? 1 : 0) << 2)), speedKHz) { }
/// <summary> /// Construct a new LTC2305 /// </summary> /// <param name="address">The address to use</param> /// <param name="I2cModule">The I2c module this ADC is attached to</param> public Ltc2305(byte address, I2C I2cModule) { dev = new SMBusDevice(address, I2cModule, 100); }
static Accelerometer() { _i2c = new I2C(0x1c); _i2c.Write(new byte[2] { 0x2a, 0x01 }); }
/// <summary> /// Construct a new AMIS30624 stepper motor controller /// </summary> /// <param name="module">The I2c module this stepper motor is attached to</param> /// <param name="addressPin">The hardwired address pin state</param> /// <param name="speed">The speed to operate this peripheral at</param> public Amis30624(I2C module, bool addressPin = false, int speed = 400) : this(module, (byte)(addressPin ? 0x61 : 0x60), speed) { }