/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="address">Address of the bus on the I2C display.</param> /// <param name="displayType">Type of SSD1306 display</param> public SSD1306Bitmap(II2cBus i2cBus, byte address, DisplayType displayType) { this.displayType = displayType; this.i2cPeripheral = new I2cPeripheral(i2cBus, address); this.connectionType = ConnectionType.I2C; this.InitSSD1306(displayType); }
/// <summary> /// Create a new SI1145 sensor object. /// </summary> /// <param name="address">Address of the chip on the I2C bus (default to 0x60).</param> /// <param name="iscBus">I2cBus (default to 400 KHz).</param> public SI1145(II2cBus i2cBus, byte address = 0x60) { _si1145 = new I2cPeripheral(i2cBus, address); if (_si1145.ReadRegister(Registers.PartID) != 0x45) { throw new Exception("Invalid part ID"); } }
/// <summary> /// Create a new AT24Cxx object using the default parameters for the component. /// </summary> /// <param name="address">Address of the At24Cxx (default = 0x50).</param> /// <param name="pageSize">Number of bytes in a page (default = 32 - AT24C32).</param> /// <param name="memorySize">Total number of bytes in the EEPROM (default = 8192 - AT24C32).</param> public At24Cxx(II2cBus i2cBus, byte address = 0x50, ushort pageSize = 32, ushort memorySize = 8192) { var device = new I2cPeripheral(i2cBus, address); _eeprom = device; _pageSize = pageSize; _memorySize = memorySize; }
/// <summary> /// Create a DHT sensor through I2C (Only DHT12) /// </summary> /// <param name="i2cDevice">The I2C device used for communication.</param> public DhtBase(II2cBus i2cBus, byte address = 0x5C) { _sensor = new I2cPeripheral(i2cBus, address); _protocol = BusType.I2C; //give the device time to initialize Thread.Sleep(1000); }
public SAS_I2C(Meadow.Hardware.II2cBus i2cBus) : base(MaxPacketSize) { #if DEBUGSERIAL Console.WriteLine($"Opening i2c {address} {i2cBus.Frequency}"); #endif this.i2cBus = i2cBus; sas = new I2cPeripheral(i2cBus, address); }
/// <summary> /// Create a new SHT31D object. /// </summary> /// <param name="address">Sensor address (should be 0x44 or 0x45).</param> /// <param name="i2cBus">I2cBus (0-1000 KHz).</param> public SHT31D(II2cBus i2cBus, byte address = 0x44) { if ((address != 0x44) && (address != 0x45)) { throw new ArgumentOutOfRangeException(nameof(address), "Address should be 0x44 or 0x45"); } sht31d = new I2cPeripheral(i2cBus, address); }
/// <summary> /// Create a new TMP102 object using the default configuration for the sensor. /// </summary> /// <param name="address">I2C address of the sensor.</param> public Tmp102(II2cBus i2cBus, byte address = 0x48) { tmp102 = new I2cPeripheral(i2cBus, address); var configuration = tmp102.ReadRegisters(0x01, 2); _sensorResolution = (configuration[1] & 0x10) > 0 ? Resolution.Resolution13Bits : Resolution.Resolution12Bits; }
public ArducamMini(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, II2cBus i2cBus, byte address = 0x30) { i2cDevice = new I2cPeripheral(i2cBus, address); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin); spiDevice = new SpiPeripheral(spiBus, chipSelectPort); Initialize(); }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="address">Address of the bus on the I2C display.</param> /// <param name="speed">Speed of the I2C bus.</param> /// <param name="displayType">Type of SSD1306 display (default = 128x64 pixel display).</param> public SSD1306(II2cBus i2cBus, IPin pinClock, IPin pinData, byte address = 0x3c, ushort speed = 400, DisplayType displayType = DisplayType.OLED128x64) { _displayType = displayType; _I2cPeriferal = new I2cPeripheral(i2cBus, address); connectionType = ConnectionType.I2C; InitSSD1306(displayType); }
/// <summary> /// Create a new SI1145 sensor object. /// </summary> /// <param name="address">Address of the chip on the I2C bus (default to 0x60).</param> /// <param name="i2cBus">I2cBus (default to 400 KHz).</param> public Si1145(II2cBus i2cBus, byte address = 0x60) { si1145 = new I2cPeripheral(i2cBus, address); if (si1145.ReadRegister(REG_PARTID) != 0x45) { throw new Exception("Invalid part ID"); } Initialize(); }
/// <summary> /// Create a new instance of the ADXL345 communicating over the I2C interface. /// </summary> /// <param name="address">Address of the I2C sensor</param> /// <param name="i2cBus">I2C bus</param> public Adxl345(II2cBus i2cBus, byte address = 0x53) { adxl345 = new I2cPeripheral(i2cBus, address); var deviceID = adxl345.ReadRegister(Registers.DeviceID); if (deviceID != 0xe5) { throw new Exception("Invalid device ID."); } }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="address">Address of the bus on the I2C display.</param> /// <param name="displayType">Type of SSD1306 display (default = 128x64 pixel display).</param> public SSD1306(II2cBus i2cBus, byte address = 0x3c, DisplayType displayType = DisplayType.OLED128x64) { _displayType = displayType; i2cPeriferal = new I2cPeripheral(i2cBus, address); connectionType = ConnectionType.I2C; InitSSD1306(displayType); }
/// <param name="i2cBus">I2C bus</param> /// <param name="address">VL53L0X address</param> /// <param name="units">Unit of measure</param> public Vl53l0x(IIODevice device, II2cBus i2cBus, IPin shutdownPin, byte address = DefaultI2cAddress, UnitType units = UnitType.mm) { i2cPeripheral = new I2cPeripheral(i2cBus, address); if (shutdownPin != null) { device.CreateDigitalOutputPort(shutdownPin, true); } Units = units; Initialize(); }
/// <summary> /// Provide a mechanism for reading the temperature and humidity from /// a Bmp085 temperature / humidity sensor. /// </summary> public Bmp085(II2cBus i2cBus, byte address = 0x77, DeviceMode deviceMode = DeviceMode.Standard) { bmp085 = new I2cPeripheral(i2cBus, address); oversamplingSetting = (byte)deviceMode; // Get calibration data that will be used for future measurement taking. GetCalibrationData(); // Take initial measurements. Update(); }
public I2cCharacterDisplay(II2cBus i2cBus, byte address = DefaultI2cAddress, byte rows = 4, byte columns = 20) { i2cPeripheral = new I2cPeripheral(i2cBus, address); DisplayConfig = new TextDisplayConfig() { Width = columns, Height = rows }; backlightValue = LCD_BACKLIGHT; Initialize(); }
/// <summary> /// Create a new instance of the APDS9960 communicating over the I2C interface. /// </summary> /// <param name="address">Address of the I2C sensor</param> /// <param name="i2cBus">SI2C bus object</param> public Apds9960(IIODevice device, II2cBus i2cBus, IPin interruptPin, byte address = 0x39) { apds9960 = new I2cPeripheral(i2cBus, address); if (interruptPin != null) { interruptPort = device.CreateDigitalInputPort(interruptPin, InterruptMode.EdgeRising, ResistorMode.Disabled); interruptPort.Changed += InterruptPort_Changed; } Apds9960Init(); }
/// <summary> /// Create a new MPL3115A2 object with the default address and speed settings. /// </summary> /// <param name="address">Address of the sensor (default = 0x60).</param> /// <param name="i2cBus">I2cBus (Maximum is 400 kHz).</param> public Mpl3115A2(II2cBus i2cBus, byte address = 0x60) { var device = new I2cPeripheral(i2cBus, address); _mpl3115a2 = device; if (_mpl3115a2.ReadRegister(Registers.WhoAmI) != 0xc4) { throw new Exception("Unexpected device ID, expected 0xc4"); } _mpl3115a2.WriteRegister(Registers.Control1, (byte)(ControlRegisterBits.Active | ControlRegisterBits.OverSample128)); _mpl3115a2.WriteRegister(Registers.DataConfiguration, (byte)(ConfigurationRegisterBits.DataReadyEvent | ConfigurationRegisterBits.EnablePressureEvent | ConfigurationRegisterBits.EnableTemperatureEvent)); }
/// <summary> /// Create a new instance of the ADXL345 communicating over the I2C interface. /// </summary> /// <param name="address">Address of the I2C sensor</param> /// <param name="i2cBus">I2C bus</param> public Adxl345(II2cBus i2cBus, byte address = 0x53) { if ((address != 0x1d) && (address != 0x53)) { throw new ArgumentOutOfRangeException(nameof(address), "ADXL345 address can only be 0x1d or 0x53."); } _adxl345 = new I2cPeripheral(i2cBus, address); var deviceID = _adxl345.ReadRegister(Registers.DeviceID); if (deviceID != 0xe5) { throw new Exception("Invalid device ID."); } }
/// <summary> /// Create a new MPL115A2 temperature and humidity sensor object. /// </summary> /// <param name="address">Sensor address (default to 0x60).</param> /// <param name="i2cBus">I2CBus (default to 100 KHz).</param> public Mpl115a2(II2cBus i2cBus, byte address = 0x60) { var device = new I2cPeripheral(i2cBus, address); mpl115a2 = device; // // Update the compensation data from the sensor. The location and format of the // compensation data can be found on pages 5 and 6 of the datasheet. // var data = mpl115a2.ReadRegisters(Registers.A0MSB, 8); var a0 = (short)(ushort)((data[0] << 8) | data[1]); var b1 = (short)(ushort)((data[2] << 8) | data[3]); var b2 = (short)(ushort)((data[4] << 8) | data[5]); var c12 = (short)(ushort)(((data[6] << 8) | data[7]) >> 2); // // Convert the raw compensation coefficients from the sensor into the // doubleing point equivalents to speed up the calculations when readings // are made. // // Datasheet, section 3.1 // a0 is signed with 12 integer bits followed by 3 fractional bits so divide by 2^3 (8) // coefficients.A0 = (double)a0 / 8; // // b1 is 2 integer bits followed by 7 fractional bits. The lower bits are all 0 // so the format is: // sign i1 I0 F12...F0 // // So we need to divide by 2^13 (8192) // coefficients.B1 = (double)b1 / 8192; // // b2 is signed integer (1 bit) followed by 14 fractional bits so divide by 2^14 (16384). // coefficients.B2 = (double)b2 / 16384; // // c12 is signed with no integer bits but padded with 9 zeroes: // sign 0.000 000 000 f12...f0 // // So we need to divide by 2^22 (4,194,304) - 13 doubleing point bits // plus 9 leading zeroes. // coefficients.C12 = (double)c12 / 4194304; }
/// <summary> /// Create a new MAG3110 object using the default parameters for the component. /// </summary> /// <param name="interruptPort">Interrupt port used to detect end of conversions.</param> /// <param name="address">Address of the MAG3110 (default = 0x0e).</param> /// <param name="i2cBus">I2C bus object - default = 400 KHz).</param> public Mag3110(II2cBus i2cBus, IDigitalInputPort interruptPort = null, byte address = 0x0e) { _mag3110 = new I2cPeripheral(i2cBus, address); var deviceID = _mag3110.ReadRegister((byte)Registers.WhoAmI); if (deviceID != 0xc4) { throw new Exception("Unknown device ID, " + deviceID + " retruend, 0xc4 expected"); } if (interruptPort != null) { _digitalInputPort = interruptPort; _digitalInputPort.Changed += DigitalInputPortChanged; } Reset(); }
public HMC5883L(II2cBus i2CBus, byte address = 0x1E, SamplesToAverage samplesToAverage = SamplesToAverage.One, DataOutputRate dataOutputRate = DataOutputRate._15Hz, MeasurementMode measurementMode = MeasurementMode.Normal, GainConfiguration gainConfiguration = GainConfiguration._1_30, OperatingMode operatingMode = OperatingMode.SingleMeasurement ) { Mode = operatingMode; Gain = gainConfiguration; _device = new I2cPeripheral(i2CBus, address); // Config - Register A byte configRegisterAData = 0b0000_0000; configRegisterAData |= (byte)samplesToAverage; configRegisterAData |= (byte)dataOutputRate; configRegisterAData |= (byte)measurementMode; _device.WriteRegister(CRA, configRegisterAData); Console.WriteLine($"CRA: {Convert.ToString(configRegisterAData, 2).PadLeft(8, '0')}"); // Config - Register A byte configRegisterBData = 0b0000_0000; configRegisterBData |= (byte)gainConfiguration; _device.WriteRegister(CRB, configRegisterBData); Console.WriteLine($"CRB: {Convert.ToString(configRegisterBData, 2).PadLeft(8, '0')}"); // Select Mode byte modeRegisterData = 0b00000000; modeRegisterData |= (byte)operatingMode; _device.WriteRegister(MR, modeRegisterData); Console.WriteLine($"MR: {Convert.ToString(modeRegisterData, 2).PadLeft(8, '0')}"); }
/// <summary> /// Create a new TEA5767 object using the default parameters /// </summary> /// <param name="address">Address of the bus on the I2C display.</param> public Tea5767(II2cBus i2cBus, byte address = TEA5767_ADDRESS) { i2cPeripheral = new I2cPeripheral(i2cBus, address); InitTEA5767(); }
/// <summary> /// Create a new SI7021 temperature and humidity sensor. /// </summary> /// <param name="address">Sensor address (default to 0x40).</param> /// <param name="i2cBus">I2CBus (default to 100 KHz).</param> public Si70xx(II2cBus i2cBus, byte address = 0x40) { si7021 = new I2cPeripheral(i2cBus, address); Initialize(); }
/// <summary> /// Create a new GroveTH02 object using the default parameters for the component. /// </summary> /// <param name="address">Address of the Grove TH02 (default = 0x4-).</param> /// <param name="i2cBus">I2C bus (default = 100 KHz).</param> public GroveTh02(II2cBus i2cBus, byte address = 0x40) { groveTH02 = new I2cPeripheral(i2cBus, address); }
/// <summary> /// Create a new SHT31D object. /// </summary> /// <param name="address">Sensor address (should be 0x44 or 0x45).</param> /// <param name="i2cBus">I2cBus (0-1000 KHz).</param> public Sht31D(II2cBus i2cBus, byte address = 0x44) { sht31d = new I2cPeripheral(i2cBus, address); }
/// <summary> /// Create a new TMP102 object using the default configuration for the sensor. /// </summary> /// <param name="address">I2C address of the sensor.</param> public Lm75(II2cBus i2cBus, byte address = 0x48) { lm75 = new I2cPeripheral(i2cBus, address); }
public Mcp9808(II2cBus i2CBus, byte address = DefaultAddress) { i2CPeripheral = new I2cPeripheral(i2CBus, address); Init(); }
readonly byte HT16K33_DDAP = 0; //display address pointer #endregion Member variables / fields #region Constructors /// <summary> /// Create a new HT16K33 object using the default parameters /// </summary> /// <param name="address">Address of the bus on the I2C display.</param> /// <param name="i2cBus">I2C bus instance</param> public Ht16K33(II2cBus i2cBus, byte address = 0x70) { i2cPeripheral = new I2cPeripheral(i2cBus, address); InitHT16K33(); }
/// <summary> /// Create a new HIH6130 object using the default parameters for the component. /// </summary> /// <param name="address">Address of the HIH6130 (default = 0x27).</param> /// <param name="i2cBus">I2C bus (default = 100 KHz).</param> public Hih6130(II2cBus i2cBus, byte address = 0x27) { hih6130 = new I2cPeripheral(i2cBus, address); }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="address">Address of the bus on the I2C display.</param> protected SSD1306(II2cBus i2cBus, byte address = 0x3c) { _I2cPeripheral = new I2cPeripheral(i2cBus, address); connectionType = ConnectionType.I2C; }