Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/devices/Ads1115/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ ADS1115 is an Analog-to-Digital converter (ADC) with 16 bits of resolution.
// set I2C bus ID: 1
// ADS1115 Addr Pin connect to GND
I2cConnectionSettings settings = new I2cConnectionSettings(1, (int)I2cAddress.GND);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a comment, now that we have I2cDevice.Create method, we might want to think again how most bindings take a I2cDevice as part of their constructor, such that insted they would just create a new one inside their class. There were only two reasons to have it passed in: support for windows/unix (which we no longer need) and in order to allow passing in a device that is not a Unix or Windows I2c device, but instead something that implementes the II2cDevice interface, like a I2C extender.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the guidance be to pass in I2cDevice? or SpiDevice? similar to IGpioController. As you mentioned, I could see other flavors (i. e. GpioI2cDevice, GpioSpiDevice) in the future.

Inside the binding constructor, have something like...

_i2cDevice = I2cDevice ?? I2cDevice.Create(settings);
_spiDevice = SpiDevice ?? SpiDevice.Create(settings);

Also, with guidance showing the nullable types to pass... could hopefully trigger binding devs to code the binding API with the new C# 8 feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd refrain from that for now unless it covers 95% of the cases. Example thing what I did for SenseHat:

  • Lsm9Ds1AccelerometerAndGyroscope doesn't know anything about I2C addresses
  • SenseHatAccelerometerAndGyroscope thin wrapper on top of Lsm9Ds1AccelerometerAndGyroscope which only defaults I2C address since it's constant in context of SenseHat

Ideally I think we should create an issue and set up guidelines for this but I think this is non-issue at this point and regardless of this issue we need at least one constructor which takes already existing I2cDevice object.

I don't personally like default value as the ownership is not immediately obvious. Having two classes one which always default and one which never does makes stuff much clearer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we made this non-nullable and create second implementation like DefaultXyzDevice which just inherits, creates I2cDevice and disposes of it. This way you got covered 90% of the cases and advanced usage


// pass in I2cDevice
// measure the voltage AIN0
Expand Down
4 changes: 1 addition & 3 deletions src/devices/Ads1115/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ static void Main(string[] args)
// ADS1115 Addr Pin connect to GND
I2cConnectionSettings settings = new I2cConnectionSettings(1, (int)I2cAddress.GND);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

// pass in I2cDevice
// measure the voltage AIN0
Expand Down
3 changes: 1 addition & 2 deletions src/devices/Ads1115/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ Rotary Potentiometer
// set I2C bus ID: 1
// ADS1115 Addr Pin connect to GND
I2cConnectionSettings settings = new I2cConnectionSettings(1, (int)I2cAddress.GND);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

// pass in I2cDevice
// measure the voltage AIN0
Expand Down
4 changes: 2 additions & 2 deletions src/devices/Ags01db/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AGS01DB - MEMS VOC Gas Sensor
AGS01DB is a MEMS VOC gas sensor with calibrated digital signal output. It uses special digital module acquisition technology and gas sensing technology to ensure that the product has high reliability and excellent long-term stability.
AGS01DB is a MEMS VOC gas sensor with calibrated digital signal output. It uses special digital module acquisition technology and gas sensing technology to ensure that the product has high reliability and excellent long-term stability.

## Sensor Image
![](sensor.jpg)
Expand All @@ -8,7 +8,7 @@ AGS01DB is a MEMS VOC gas sensor with calibrated digital signal output. It uses
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ags01db.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);

Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ags01db/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Program
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ags01db.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ags01db sensor = new Ags01db(device))
{
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ags01db/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SDA, SCL need pull-up resistance.
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ags01db.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ags01db sensor = new Ags01db(device))
{
Expand Down
7 changes: 2 additions & 5 deletions src/devices/Bh1750fvi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ BH1750FVI is an digital Ambient Light Sensor IC for I2C bus interface. This IC i
## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(busId: 1, (int)I2cAddress.AddPinLow);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Bh1750fvi sensor = new Bh1750fvi(device))
{
Expand All @@ -21,4 +18,4 @@ using (Bh1750fvi sensor = new Bh1750fvi(device))
```

## References
https://cdn.datasheetspdf.com/pdf-down/B/H/1/BH1750FVI_Rohm.pdf
https://cdn.datasheetspdf.com/pdf-down/B/H/1/BH1750FVI_Rohm.pdf
2 changes: 1 addition & 1 deletion src/devices/Bh1750fvi/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Program
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(busId: 1, (int)I2cAddress.AddPinLow);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Bh1750fvi sensor = new Bh1750fvi(device))
{
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Bh1750fvi/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(busId: 1, (int)I2cAddress.AddPinLow);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Bh1750fvi sensor = new Bh1750fvi(device))
{
Expand Down
8 changes: 4 additions & 4 deletions src/devices/Bmp180/samples/Bmp180.Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static void Main(string[] args)
const int busId = 1;

var i2cSettings = new I2cConnectionSettings(busId, Bmp180.DefaultI2cAddress);
var i2cDevice = new UnixI2cDevice(i2cSettings);
var i2cBmp280 = new Bmp180(i2cDevice);
var i2cDevice = I2cDevice.Create(i2cSettings);
var i2cBmp280 = new Bmp180(i2cDevice);

using (i2cBmp280)
{
Expand All @@ -31,7 +31,7 @@ static void Main(string[] args)

//read values
Temperature tempValue = i2cBmp280.ReadTemperature();
Console.WriteLine($"Temperature {tempValue.Celsius} °C");
Console.WriteLine($"Temperature {tempValue.Celsius} °C");
double preValue = i2cBmp280.ReadPressure();
Console.WriteLine($"Pressure {preValue} Pa");
double altValue = i2cBmp280.ReadAltitude();
Expand All @@ -47,7 +47,7 @@ static void Main(string[] args)
preValue = i2cBmp280.ReadPressure();
Console.WriteLine($"Pressure {preValue} Pa");
altValue = i2cBmp280.ReadAltitude();
Console.WriteLine($"Altitude {altValue:0.##} m");
Console.WriteLine($"Altitude {altValue:0.##} m");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Bmx280/samples/Bme280.sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static async Task Main(string[] args)
const double defaultSeaLevelPressure = 1033.00;

var i2cSettings = new I2cConnectionSettings(busId, Bme280.DefaultI2cAddress);
var i2cDevice = new UnixI2cDevice(i2cSettings);
var i2cDevice = I2cDevice.Create(i2cSettings);
var i2CBmpe80 = new Bme280(i2cDevice);

using (i2CBmpe80)
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Bmx280/samples/Bmp280.sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static async Task Main(string[] args)
const double defaultSeaLevelPressure = 1033.00;

var i2cSettings = new I2cConnectionSettings(busId, Bmp280.DefaultI2cAddress);
var i2cDevice = new UnixI2cDevice(i2cSettings);
var i2cDevice = I2cDevice.Create(i2cSettings);
var i2CBmp280 = new Bmp280(i2cDevice);

using (i2CBmp280)
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Bno055/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You will find this device as ["Inertial Measurement Unit"](https://www.dexterind
Create a ```Bno055Sensor``` class and pass the I2C device. The default I2C address is provided in the class.

```csharp
I2cDevice i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(1, Bno055Sensor.DefaultI2cAddress));
I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(1, Bno055Sensor.DefaultI2cAddress));
Bno055Sensor bno055Sensor = new Bno055Sensor(i2cDevice);
Console.WriteLine($"Id: {bno055Sensor.Info.ChipId}, AccId: {bno055Sensor.Info.AcceleratorId}, GyroId: {bno055Sensor.Info.GyroscopeId}, MagId: {bno055Sensor.Info.MagnetometerId}");
Console.WriteLine($"Firmware version: {bno055Sensor.Info.FirmwareVersion}, Bootloader: {bno055Sensor.Info.BootloaderVersion}");
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Bno055/samples/Bno055.sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Program
static void Main(string[] args)
{
Console.WriteLine("Hello BNO055!");
I2cDevice i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(1, Bno055Sensor.DefaultI2cAddress));
I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(1, Bno055Sensor.DefaultI2cAddress));
Bno055Sensor bno055Sensor = new Bno055Sensor(i2cDevice);
Console.WriteLine($"Id: {bno055Sensor.Info.ChipId}, AccId: {bno055Sensor.Info.AcceleratorId}, GyroId: {bno055Sensor.Info.GyroscopeId}, MagId: {bno055Sensor.Info.MagnetometerId}");
Console.WriteLine($"Firmware version: {bno055Sensor.Info.FirmwareVersion}, Bootloader: {bno055Sensor.Info.BootloaderVersion}");
Expand Down
8 changes: 4 additions & 4 deletions src/devices/CharacterLcd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Grove LCD RGB Backlight uses two i2c devices:

Here is a Hello World example of how to consume Grove LCD RGB Backlight binding:
```c#
var i2cLcdDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x3E));
var i2cRgbDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x62));
var i2cLcdDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x3E));
var i2cRgbDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x62));
using (var lcd = new LcdRgb1602(i2cLcdDevice, i2cRgbDevice))
{
lcd.Write("Hello World!");
Expand All @@ -37,14 +37,14 @@ using (var lcd = new LcdRgb1602(i2cLcdDevice, i2cRgbDevice))
PCF8574T/PCF8574AT Sample
The I2C backpack based on the PCF8574T/AT IC uses specific pin mapping, to consume this device binding on this backpack use like so
```c#
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x27));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x27));
var controller = new Pcf8574(i2cDevice);
var lcd = new Lcd1602(registerSelectPin: 0, enablePin: 2, dataPins: new int[] { 4, 5, 6, 7}, backlightPin: 3, readWritePin: 1, controller: controller);
```
there is a full working example in the samples directory called Pcf8574tSample.cs
For PCF8574T i2c addresses can be between 0x27 and 0x20 depending on bridged solder jumpers and for PCF8574AT i2c addresses can be between 0x3f and 0x38 depending on bridged solder jumpers

## References
## References
- Very complete tutorial on how to connect and work with one of these displays: https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/overview
- Good guide explaining how the device works internally: http://www.site2241.net/november2014.htm
- Seeedstudio, Grove - LCD RGB Backlight library: https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight
Expand Down
2 changes: 1 addition & 1 deletion src/devices/CharacterLcd/samples/CharacterLcd.Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void Main(string[] args)
/// </summary>
static void UsingMcp()
{
UnixI2cDevice i2CDevice = new UnixI2cDevice(new I2cConnectionSettings(1, 0x21));
I2cDevice i2CDevice = I2cDevice.Create(new I2cConnectionSettings(1, 0x21));
Mcp23008 mcpDevice = new Mcp23008(i2CDevice);
int[] dataPins = { 3, 4, 5, 6 };
int registerSelectPin = 1;
Expand Down
7 changes: 3 additions & 4 deletions src/devices/CharacterLcd/samples/Hd44780.ExtendedSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public static void Test()
Console.WriteLine("Starting...");

#if USEI2C
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x21));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x21));
var controller = new Mcp23008(i2cDevice);
var lcd = new Lcd1602(registerSelectPin: 1, enablePin: 2, dataPins: new int[] { 3, 4, 5, 6 }, backlightPin: 7, controller: controller);
#elif USERGB
var i2cLcdDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x3E));
var i2cRgbDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x62));
var i2cLcdDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x3E));
var i2cRgbDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x62));
var lcd = new LcdRgb1602(i2cLcdDevice, i2cRgbDevice);
#else
Hd44780 lcd = new Hd44780(new Size(20, 4), LcdInterface.CreateGpio(12, 26, new int[] { 16, 17, 18, 19, 20, 21, 22, 23 }, readWritePin: 13));
Expand Down Expand Up @@ -359,4 +359,3 @@ static void CreateTensCharacters(Hd44780 lcd)
}
}
}

2 changes: 1 addition & 1 deletion src/devices/CharacterLcd/samples/Pcf8574tSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void SampleEntryPoint()
Console.WriteLine("Starting...");
//for PCF8574T i2c addresses can be between 0x27 and 0x20 depending on bridged solder jumpers
//for PCF8574AT i2c addresses can be between 0x3f and 0x38 depending on bridged solder jumpers
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: 0x27));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x27));
var controller = new Pcf8574(i2cDevice);
var lcd = new Lcd1602(registerSelectPin: 0, enablePin: 2, dataPins: new int[] { 4, 5, 6, 7 }, backlightPin: 3, readWritePin: 1, controller: controller);

Expand Down
4 changes: 2 additions & 2 deletions src/devices/Dhtxx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Only DHT12 can use I2C protocol.

```csharp
I2cConnectionSettings settings = new I2cConnectionSettings(1, DhtSensor.DefaultI2cAddressDht12);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (DhtSensor dht = new DhtSensor(device))
{
Expand All @@ -35,4 +35,4 @@ using (DhtSensor dht = new DhtSensor(device))
* **DHT11** [datasheet](https://cdn.datasheetspdf.com/pdf-down/D/H/T/DHT11-Aosong.pdf)
* **DHT12** [datasheet](https://cdn.datasheetspdf.com/pdf-down/D/H/T/DHT12-Aosong.pdf)
* **DHT21** [datasheet](https://cdn.datasheetspdf.com/pdf-down/A/M/2/AM2301-Aosong.pdf)
* **DHT22** [datasheet](https://cdn-shop.adafruit.com/datasheets/DHT22.pdf)
* **DHT22** [datasheet](https://cdn-shop.adafruit.com/datasheets/DHT22.pdf)
2 changes: 1 addition & 1 deletion src/devices/Dhtxx/samples/DhtSensor.sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void Main(string[] args)

// Init DHT12 through I2C
//I2cConnectionSettings settings = new I2cConnectionSettings(1, DhtSensor.Dht12DefaultI2cAddress);
//UnixI2cDevice device = new UnixI2cDevice(settings);
//I2cDevice device = I2cDevice.Create(settings);
//DhtSensor dht = new DhtSensor(device);

using (DhtSensor dht = new DhtSensor(4, DhtType.Dht11))
Expand Down
7 changes: 2 additions & 5 deletions src/devices/Ds1307/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# DS1307 - Realtime Clock
The DS1307 serial real-time clock (RTC) is a lowpower, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus.
The DS1307 serial real-time clock (RTC) is a lowpower, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus.

## Sensor Image
![](sensor.jpg)

## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds1307.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds1307 rtc = new Ds1307(device))
{
Expand Down
5 changes: 1 addition & 4 deletions src/devices/Ds1307/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ static void Main(string[] args)
Console.WriteLine("Hello, Realtime Clock DS1307!");

I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds1307.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds1307 rtc = new Ds1307(device))
{
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ds1307/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Console.WriteLine("Hello, Realtime Clock DS1307!");

I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds1307.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds1307 rtc = new Ds1307(device))
{
Expand Down
5 changes: 1 addition & 4 deletions src/devices/Ds3231/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ DS3231 is a low-cost, extremely accurate I2C realtime clock (RTC) with an integr
## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds3231.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds3231 rtc = new Ds3231(device))
{
Expand Down
5 changes: 1 addition & 4 deletions src/devices/Ds3231/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class Program
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds3231.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds3231 rtc = new Ds3231(device))
{
Expand Down
3 changes: 1 addition & 2 deletions src/devices/Ds3231/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds3231.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);

using (Ds3231 rtc = new Ds3231(device))
{
Expand Down
Loading