未验证 提交 3007425b 编写于 作者: K Krzysztof Wicher 提交者: GitHub

Update samples to work on Windows (#528)

上级 13e0fe39
......@@ -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);
// pass in I2cDevice
// measure the voltage AIN0
......
......@@ -18,9 +18,7 @@ namespace Ads1115.Samples
// 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
......
......@@ -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
......
# 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)
......@@ -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);
......
......@@ -10,7 +10,7 @@ namespace Iot.Device.Ags01db.Samples
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))
{
......
......@@ -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))
{
......
......@@ -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))
{
......@@ -21,4 +18,4 @@ using (Bh1750fvi sensor = new Bh1750fvi(device))
```
## References
https://cdn.datasheetspdf.com/pdf-down/B/H/1/BH1750FVI_Rohm.pdf
\ No newline at end of file
https://cdn.datasheetspdf.com/pdf-down/B/H/1/BH1750FVI_Rohm.pdf
......@@ -14,7 +14,7 @@ namespace Iot.Device.Bh1750fvi.Samples
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))
{
......
......@@ -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))
{
......
......@@ -21,8 +21,8 @@ namespace Iot.Device.Bmp180.Samples
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)
{
......@@ -31,7 +31,7 @@ namespace Iot.Device.Bmp180.Samples
//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();
......@@ -47,7 +47,7 @@ namespace Iot.Device.Bmp180.Samples
preValue = i2cBmp280.ReadPressure();
Console.WriteLine($"Pressure {preValue} Pa");
altValue = i2cBmp280.ReadAltitude();
Console.WriteLine($"Altitude {altValue:0.##} m");
Console.WriteLine($"Altitude {altValue:0.##} m");
}
}
}
......
......@@ -24,7 +24,7 @@ namespace Iot.Device.Samples
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)
......
......@@ -24,7 +24,7 @@ namespace Iot.Device.Samples
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)
......
......@@ -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}");
......
......@@ -16,7 +16,7 @@ namespace Bno055sample
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}");
......
......@@ -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!");
......@@ -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
......
......@@ -30,7 +30,7 @@ namespace Iot.Device.CharacterLcd.Samples
/// </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;
......
......@@ -25,12 +25,12 @@ namespace Iot.Device.CharacterLcd.Samples
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));
......@@ -359,4 +359,3 @@ namespace Iot.Device.CharacterLcd.Samples
}
}
}
......@@ -26,7 +26,7 @@ namespace Iot.Device.CharacterLcd.Samples
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);
......
......@@ -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))
{
......@@ -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)
\ No newline at end of file
* **DHT22** [datasheet](https://cdn-shop.adafruit.com/datasheets/DHT22.pdf)
......@@ -15,7 +15,7 @@ class Program
// 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))
......
# 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)
......@@ -7,10 +7,7 @@ The DS1307 serial real-time clock (RTC) is a lowpower, full binary-coded decimal
## 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))
{
......
......@@ -16,10 +16,7 @@ namespace Iot.Device.Ds1307.Samples
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))
{
......
......@@ -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))
{
......
......@@ -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))
{
......
......@@ -14,10 +14,7 @@ namespace Iot.Device.Ds3231.Samples
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))
{
......
......@@ -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))
{
......
......@@ -35,7 +35,7 @@ This version include a pure driver so you can directly access to the raw results
High level classes has been built for those sensors. Generic Digital Input, Digital Output, Analogic Input, PWM Output has been built as well. You can build your own classes looking at the sensors provided in the [Sensors folder](./Sensors).
More sensors are supported and being tested like the Grove Led Bar. Note that this sensor as the Ultrasonic sensor have native support and accessing their data is different than for the other sensors.
More sensors are supported and being tested like the Grove Led Bar. Note that this sensor as the Ultrasonic sensor have native support and accessing their data is different than for the other sensors.
## How to use the driver
......@@ -45,7 +45,7 @@ Create a ```GrovePi``` class.
```csharp
I2cConnectionSettings i2CConnectionSettings = new I2cConnectionSettings(1, GrovePi.GrovePiSefaultI2cAddress);
grovePi = new GrovePi(new UnixI2cDevice(i2CConnectionSettings));
grovePi = new GrovePi(I2cDevice.Create(i2CConnectionSettings));
// Do something with the sensors
// At the end, the IEC Device will be disposed
```
......@@ -60,7 +60,7 @@ The GrovePiInfo class offers information like the firmware version, manufacturer
```csharp
I2cConnectionSettings i2CConnectionSettings = new I2cConnectionSettings(1, GrovePi.GrovePiSefaultI2cAddress);
grovePi = new GrovePi(new UnixI2cDevice(i2CConnectionSettings));
grovePi = new GrovePi(I2cDevice.Create(i2CConnectionSettings));
Console.WriteLine($"Manufacturer :{grovePi.GrovePiInfo.Manufacturer}");
Console.WriteLine($"Board: {grovePi.GrovePiInfo.Board}");
Console.WriteLine($"Firmware version: {grovePi.GrovePiInfo.SoftwareVersion}");
......@@ -82,7 +82,7 @@ Their usage is very similar to Arduino usage. For example, if you want to read a
```csharp
// Set the pin as Input, should be done only once but you
// can change it as well over time
// can change it as well over time
grovePi.PinMode(GrovePort.Grove1, PinMode.Input);
// Then read results, you can do it as much as you want
var result = grovePi.AnalogRead(GrovePort.Grove1);
......@@ -102,16 +102,16 @@ Note that Analogic pins can be used for both analogic and digital sensors. In ca
There are high level classes to handle directly sensors like analogic sensors, buzzers, leds, buttons. All the sensors are using only 1 pin out of the 2 available. There is nothing presenting you to use the 2 pins if you have a sensor using 2 pins. Just make sue you won't use the adjacent Grove plug in this case.
Using the sensor classes is straight forward. Just reference a class and initialized it. Access properties which are common to all sensors, ```Value``` and ```ToString()```.
Using the sensor classes is straight forward. Just reference a class and initialized it. Access properties which are common to all sensors, ```Value``` and ```ToString()```.
Example creating an Ultrasonic sensor on Grove1 port:
```csharp
UltrasonicSensor ultrasonic = new UltrasonicSensor(grovePi, GrovePort.DigitalPin6);
while (!Console.KeyAvailable)
{
Console.WriteLine($"Ultrasonic: {ultrasonic}");
Thread.Sleep(2000);
{
Console.WriteLine($"Ultrasonic: {ultrasonic}");
Thread.Sleep(2000);
}
```
......@@ -123,7 +123,7 @@ A series of hardware tests for sensors are available in [GrovePi.samples](./samp
Console.WriteLine("Hello GrovePi!");
PinLevel relay = PinLevel.Low;
I2cConnectionSettings i2CConnectionSettings = new I2cConnectionSettings(1, GrovePi.GrovePiSefaultI2cAddress);
grovePi = new GrovePi(new UnixI2cDevice(i2CConnectionSettings));
grovePi = new GrovePi(I2cDevice.Create(i2CConnectionSettings));
Console.WriteLine($"Manufacturer :{grovePi.GrovePiInfo.Manufacturer}");
Console.WriteLine($"Board: {grovePi.GrovePiInfo.Board}");
Console.WriteLine($"Firmware version: {grovePi.GrovePiInfo.SoftwareVersion}");
......@@ -147,11 +147,8 @@ while (!Console.KeyAvailable)
dhtSensor.ReadSensor();
Console.WriteLine($"{dhtSensor.DhtType}: {dhtSensor}");
Thread.Sleep(2000);
Console.CursorTop -= 5;
Console.CursorTop -= 5;
}
Console.CursorTop += 5;
```
......@@ -21,7 +21,7 @@ namespace GrovePisample
Console.WriteLine("Hello GrovePi!");
PinValue relay = PinValue.Low;
I2cConnectionSettings i2CConnectionSettings = new I2cConnectionSettings(1, GrovePi.DefaultI2cAddress);
grovePi = new GrovePi(new UnixI2cDevice(i2CConnectionSettings));
grovePi = new GrovePi(I2cDevice.Create(i2CConnectionSettings));
Console.WriteLine($"Manufacturer :{grovePi.GrovePiInfo.Manufacturer}");
Console.WriteLine($"Board: {grovePi.GrovePiInfo.Board}");
Console.WriteLine($"Firmware version: {grovePi.GrovePiInfo.SoftwareVersion}");
......@@ -42,13 +42,13 @@ namespace GrovePisample
relay = (relay == PinValue.Low) ? PinValue.High : PinValue.Low;
grovePi.DigitalWrite(GrovePort.DigitalPin2, relay);
Console.WriteLine($"Relay: {relay}");
grovePi.AnalogWrite(GrovePort.DigitalPin3, (byte)(poten * 100 / 1023));
grovePi.AnalogWrite(GrovePort.DigitalPin3, (byte)(poten * 100 / 1023));
Console.WriteLine($"Button: {grovePi.DigitalRead(GrovePort.DigitalPin4)}");
Console.WriteLine($"Ultrasonic: {ultrasonic}");
dhtSensor.Read();
Console.WriteLine($"{dhtSensor.DhtType}: {dhtSensor}");
Thread.Sleep(2000);
}
Thread.Sleep(2000);
}
}
}
}
......@@ -8,7 +8,7 @@ HMC5883L is a surface-mount, multi-chip module designed for low-field magnetic s
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
......
......@@ -14,10 +14,7 @@ namespace Iot.Device.Hmc5883l.Samples
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.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 (Hmc5883l sensor = new Hmc5883l(device))
{
......
......@@ -15,8 +15,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Hmc5883l sensor = new Hmc5883l(device))
{
......
......@@ -29,7 +29,7 @@ namespace Iot.Device.Hts221.Samples
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -19,7 +19,7 @@ class Program
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
```
......@@ -7,10 +7,7 @@ The LM75 is a temperature sensor, Delta-Sigma analog-to-digital converter, and d
## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Lm75.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(Lm75 sensor = new Lm75(device))
{
......
......@@ -14,7 +14,7 @@ namespace Iot.Device.Lm75.Samples
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Lm75.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Lm75 sensor = new Lm75(device))
{
......
......@@ -15,7 +15,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Lm75.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using(Lm75 sensor = new Lm75(device))
{
......
......@@ -29,7 +29,7 @@ namespace Iot.Device.Lps25h.Samples
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -21,7 +21,7 @@ class Program
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
```
......@@ -19,7 +19,7 @@ namespace Iot.Device.Lsm9Ds1.Samples
{
while (true)
{
Console.WriteLine($"Acceleration={ag.Acceleration}");
Console.WriteLine($"Acceleration={ag.Acceleration}");
Console.WriteLine($"AngularRate={ag.AngularRate}");
Thread.Sleep(100);
}
......@@ -29,7 +29,7 @@ namespace Iot.Device.Lsm9Ds1.Samples
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -85,7 +85,7 @@ namespace Iot.Device.Lsm9Ds1.Samples
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -13,7 +13,7 @@ class Program
{
while (true)
{
Console.WriteLine($"Acceleration={ag.Acceleration}");
Console.WriteLine($"Acceleration={ag.Acceleration}");
Console.WriteLine($"AngularRate={ag.AngularRate}");
Thread.Sleep(100);
}
......@@ -23,7 +23,7 @@ class Program
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
```
......@@ -34,7 +34,7 @@ class Program
class Magnetometer
{
public const int I2cAddress = 0x1C;
public static void Run()
{
using (var m = new Lsm9Ds1Magnetometer(CreateI2cDevice()))
......@@ -95,7 +95,7 @@ class Magnetometer
private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
```
\ No newline at end of file
```
......@@ -7,10 +7,7 @@ The MAX44009 ambient light sensor features an I2C digital output that is ideal f
## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Max44009.DefaultI2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// integration time is 100ms
using (Max44009 sensor = new Max44009(device, IntegrationTime.Time100))
......
......@@ -14,7 +14,7 @@ namespace Iot.Device.Max44009.Samples
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Max44009.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// integration time is 100ms
using (Max44009 sensor = new Max44009(device, IntegrationTime.Time100))
......@@ -30,4 +30,4 @@ namespace Iot.Device.Max44009.Samples
}
}
}
}
\ No newline at end of file
}
......@@ -11,11 +11,11 @@
* SDA - SDA
* VCC - 5V
* GND - GND
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Max44009.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// integration time is 100ms
using (Max44009 sensor = new Max44009(device, IntegrationTime.Time100))
......
......@@ -21,7 +21,7 @@ This binding includes an `Mcp23xxx` abstract class and derived abstract classes
```csharp
// 0x20 is the device address in this example.
var connectionSettings = new I2cConnectionSettings(1, 0x20);
var i2cDevice = new UnixI2cDevice(connectionSettings);
var i2cDevice = I2cDevice.Create(connectionSettings);
var mcp23S17 = new Mcp23017(i2cDevice);
```
......@@ -88,6 +88,6 @@ PinValue interruptA = mcp23S17.ReadInterruptA();
PinValue interruptB = mcp23S17.ReadInterruptB();
```
## References
## References
https://www.adafruit.com/product/732
https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython/overview
......@@ -54,7 +54,7 @@ namespace Iot.Device.Mcp23xxx.Samples
private static Mcp23xxx GetMcp23xxxDevice(Mcp23xxxDevice mcp23xxxDevice)
{
var i2cConnectionSettings = new I2cConnectionSettings(1, s_deviceAddress);
var i2cDevice = new UnixI2cDevice(i2cConnectionSettings);
var i2cDevice = I2cDevice.Create(i2cConnectionSettings);
// I2C.
switch (mcp23xxxDevice)
......
......@@ -15,7 +15,7 @@ The binding provides different options of device configuration. The device can b
#### Default configuration with manually updating of channel statuses
```csharp
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var mpr121 = new Mpr121(device: i2cDevice);
var statuses = mpr121.ReadChannelStatuses();
......@@ -29,7 +29,7 @@ Console.WriteLine($"The 1st channel is {status}");
#### Channel statuses auto refresh
```csharp
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
// Initialize controller with default configuration and auto-refresh the channel statuses every 100 ms.
var mpr121 = new Mpr121(device: i2cDevice, periodRefresh: 100);
......@@ -45,7 +45,7 @@ mpr121.ChannelStatusesChanged += (object sender, ChannelStatusesChangedEventArgs
#### Custom MPR121 registers configuration
```csharp
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var config = new Mpr121Configuration
{
MaxHalfDeltaRising = 0x01,
......@@ -63,4 +63,4 @@ var config = new Mpr121Configuration
};
var mpr121 = new Mpr121(device: i2cDevice, configuration: config);
```
\ No newline at end of file
```
......@@ -12,7 +12,7 @@ namespace Iot.Device.Mpr121.Samples
{
static void Main(string[] args)
{
var i2cDevice = new UnixI2cDevice(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
// Initialize controller with default configuration and auto-refresh the channel statuses every 100 ms.
var mpr121 = new Mpr121(device: i2cDevice, periodRefresh: 100);
......
......@@ -29,7 +29,7 @@ namespace Iot.Device.Pca95x4.Samples
private static Pca95x4 GetPca95x4Device()
{
var i2cConnectionSettings = new I2cConnectionSettings(1, s_deviceAddress);
var i2cDevice = new UnixI2cDevice(i2cConnectionSettings);
var i2cDevice = I2cDevice.Create(i2cConnectionSettings);
return new Pca95x4(i2cDevice);
}
......
......@@ -22,7 +22,7 @@ namespace Iot.Device.Pca9685.Samples
var deviceAddress = deviceAddress_fixed | deviceAddress_selectable;
var settings = new I2cConnectionSettings(busId, deviceAddress);
var device = new UnixI2cDevice(settings);
var device = I2cDevice.Create(settings);
using (var pca9685 = new Pca9685(device))
{
......
......@@ -19,7 +19,6 @@ This binding includes an `Pcx857x` abstract base class and derived abstract clas
```csharp
// 0x20 is the device address in this example.
var connectionSettings = new I2cConnectionSettings(1, 0x20);
var i2cDevice = new UnixI2cDevice(connectionSettings);
var i2cDevice = I2cDevice.Create(connectionSettings);
var pcf8574 = new Pcf8574(i2cDevice);
```
......@@ -25,7 +25,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -44,7 +44,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
public void Dispose()
......
......@@ -139,7 +139,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
public override void Dispose()
......
......@@ -24,7 +24,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -21,7 +21,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -21,7 +21,7 @@ namespace Iot.Device.SenseHat
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return new UnixI2cDevice(settings);
return I2cDevice.Create(settings);
}
}
}
......@@ -8,7 +8,7 @@ SHT3x is the next generation of Sensirion’s temperature and humidity sensors.
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, (byte)I2cAddress.AddrLow);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
......
......@@ -14,7 +14,7 @@ namespace Iot.Device.Sht3x.Samples
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, (byte)I2cAddress.AddrLow);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Sht3x sensor = new Sht3x(device))
{
......
......@@ -16,7 +16,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, (byte)I2cAddress.AddrLow);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Sht3x sensor = new Sht3x(device))
{
......
......@@ -7,10 +7,7 @@ The Si7021 device provides temperature and humidity sensor readings with an I2C
## Usage
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Si7021.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 (Si7021 sensor = new Si7021(device, Resolution.Resolution1))
{
......
......@@ -14,7 +14,7 @@ namespace Iot.Device.Si7021.Samples
static void Main(string[] args)
{
I2cConnectionSettings settings = new I2cConnectionSettings(1, Si7021.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Si7021 sensor = new Si7021(device, Resolution.Resolution1))
{
......
......@@ -15,7 +15,7 @@
## Code
```C#
I2cConnectionSettings settings = new I2cConnectionSettings(1, Si7021.DefaultI2cAddress);
UnixI2cDevice device = new UnixI2cDevice(settings);
I2cDevice device = I2cDevice.Create(settings);
using (Si7021 sensor = new Si7021(device, Resolution.Resolution1))
{
......
......@@ -50,11 +50,12 @@ namespace Iot.Device.Ssd13xx.Samples
#endif
}
private static UnixI2cDevice GetI2CDevice(){
private static I2cDevice GetI2CDevice()
{
Console.WriteLine("Using I2C protocol");
var connectionSettings = new I2cConnectionSettings(1, 0x3C);
return new UnixI2cDevice(connectionSettings);
return I2cDevice.Create(connectionSettings);
}
private static Ssd1327 GetSsd1327WithI2c()
......@@ -66,7 +67,7 @@ namespace Iot.Device.Ssd13xx.Samples
{
return new Ssd1306(GetI2CDevice());
}
// Display size 128x32.
private static void Initialize(Ssd1306 device)
{
......@@ -91,7 +92,7 @@ namespace Iot.Device.Ssd13xx.Samples
}
// Display size 96x96.
private static void Initialize(Ssd1327 device)
private static void Initialize(Ssd1327 device)
{
device.SendCommand(new Ssd1327Cmnds.SetUnlockDriver(true));
device.SendCommand(new SetDisplayOff());
......@@ -187,8 +188,8 @@ namespace Iot.Device.Ssd13xx.Samples
}
private static void DisplayImages(Ssd1306 ssd1306)
{
Console.WriteLine("Display Images");
{
Console.WriteLine("Display Images");
foreach(var image_name in Directory.GetFiles("images", "*.bmp").OrderBy(f => f))
{
using (Image<Gray16> image = Image.Load<Gray16>(image_name))
......@@ -208,7 +209,7 @@ namespace Iot.Device.Ssd13xx.Samples
var y = 0;
foreach(var i in Enumerable.Range(0,100))
{
{
using (Image<Rgba32> image = new Image<Rgba32>(128, 32))
{
image.Mutate(ctx => ctx
......@@ -225,11 +226,11 @@ namespace Iot.Device.Ssd13xx.Samples
if(y >= image.Height) y = 0;
Thread.Sleep(100);
}
}
}
}
// Referencing https://stackoverflow.com/questions/6803073/get-local-ip-address
// Referencing https://stackoverflow.com/questions/6803073/get-local-ip-address
private static string GetIpAddress()
{
// Get a list of all network interfaces (usually one per network card, dialup, and VPN connection).
......@@ -268,8 +269,8 @@ namespace Iot.Device.Ssd13xx.Samples
public static void DisplayImage(this Ssd1306 s, Image<Gray16> image)
{
Int16 width = 128;
Int16 pages = 4;
List<byte> buffer = new List<byte>();
Int16 pages = 4;
List<byte> buffer = new List<byte>();
for (int page = 0; page < pages; page++)
{
......@@ -277,15 +278,15 @@ namespace Iot.Device.Ssd13xx.Samples
{
int bits = 0;
for (byte bit = 0; bit < 8; bit++)
{
{
bits = bits << 1;
bits |= image[x, page * 8 + 7 - bit].PackedValue > 0 ? 1 : 0;
}
bits |= image[x, page * 8 + 7 - bit].PackedValue > 0 ? 1 : 0;
}
buffer.Add((byte)bits);
buffer.Add((byte)bits);
}
}
int chunk_size = 16;
for(int i = 0; i < buffer.Count; i += chunk_size)
{
......
......@@ -12,7 +12,7 @@ Device Family contains TCS34721, TCS34723, TCS34725 and TCS34727.
You will find this device as ["Light and Color Sensor" at Dexter Industries"](https://www.dexterindustries.com/product/light-color-sensor/) or ["RGB Color Sensor with IR filter and White LED - TCS34725"](https://www.adafruit.com/product/1334)
Note: TCS34721 and TCS34723 have a default I2C address which is 0x39 while TCS34725 and TCS34727 have 0x29.
Note: TCS34721 and TCS34723 have a default I2C address which is 0x39 while TCS34725 and TCS34727 have 0x29.
## Usage
......@@ -20,7 +20,7 @@ Create a ```Tcs3472xSensor``` class and pass the I2C device. Please see above fo
```csharp
var i2cSettings = new I2cConnectionSettings(1, Tcs3472xSensor.DefaultAddress);
I2cDevice i2cDevice = new UnixI2cDevice(i2cSettings);
I2cDevice i2cDevice = I2cDevice.Create(i2cSettings);
Tcs3472xSensor tcs3472X = new Tcs3472xSensor(i2cDevice);
while(!Console.KeyAvailable)
{
......@@ -32,6 +32,6 @@ while(!Console.KeyAvailable)
}
```
You can as well adjust the time for integration, so the time needed to read the data either in the constructor either later one. Minimum time is 0.0024 seconds and maximum time is 7.4 seconds. This is not a linear function and it will be set to the closest lower value supported by the chip.
You can as well adjust the time for integration, so the time needed to read the data either in the constructor either later one. Minimum time is 0.0024 seconds and maximum time is 7.4 seconds. This is not a linear function and it will be set to the closest lower value supported by the chip.
when calling ```tcs3472X.GetColor()``` you get a ```Color``` type with RGB as the normal RGB. A contains the *Clear* value of the sensor.
\ No newline at end of file
when calling ```tcs3472X.GetColor()``` you get a ```Color``` type with RGB as the normal RGB. A contains the *Clear* value of the sensor.
......@@ -8,7 +8,7 @@ Create a ```Tcs3472xSensor``` class and pass the I2C device. Please see above fo
```csharp
var i2cSettings = new I2cConnectionSettings(1, Tcs3472xSensor.DefaultAddress);
I2cDevice i2cDevice = new UnixI2cDevice(i2cSettings);
I2cDevice i2cDevice = I2cDevice.Create(i2cSettings);
Tcs3472xSensor tcs3472X = new Tcs3472xSensor(i2cDevice);
while(!Console.KeyAvailable)
{
......@@ -20,6 +20,6 @@ while(!Console.KeyAvailable)
}
```
You can as well adjust the time for integration, so the time needed to read the data either in the constructor either later one. Minimum time is 0.0024 seconds and maximum time is 7.4 seconds. This is not a linear function and it will be set to the closest lower value supported byt the system.
You can as well adjust the time for integration, so the time needed to read the data either in the constructor either later one. Minimum time is 0.0024 seconds and maximum time is 7.4 seconds. This is not a linear function and it will be set to the closest lower value supported byt the system.
when calling ```tcs3472X.GetColor()``` you get a ```Color``` type with RGB as the normal RGB. A contains the *Clear* value of the sensor.
\ No newline at end of file
when calling ```tcs3472X.GetColor()``` you get a ```Color``` type with RGB as the normal RGB. A contains the *Clear* value of the sensor.
......@@ -16,7 +16,7 @@ namespace Tcs3472xsample
{
Console.WriteLine("Hello TCS3472x!");
var i2cSettings = new I2cConnectionSettings(1, Tcs3472x.DefaultI2cAddress);
I2cDevice i2cDevice = new UnixI2cDevice(i2cSettings);
I2cDevice i2cDevice = I2cDevice.Create(i2cSettings);
using(Tcs3472x tcs3472X = new Tcs3472x(i2cDevice))
{
while(!Console.KeyAvailable)
......@@ -27,7 +27,7 @@ namespace Tcs3472xsample
Console.WriteLine($"Valid data: {tcs3472X.IsValidData} Clear Interrupt: {tcs3472X.IsClearInterrupt}");
Thread.Sleep(1000);
}
}
}
}
......
......@@ -17,12 +17,12 @@ You will find this device as ["Distance Sensor"](https://www.dexterindustries.co
All calibration and all setup of the sensor is done fully transparently for you. Just create a class and read either once the distance, either using the continuous measurement method.
```csharp
Vl53L0X vL53L0X = new Vl53L0X(new UnixI2cDevice(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Vl53L0X vL53L0X = new Vl53L0X(I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Console.WriteLine($"Rev: {vL53L0X.Info.Revision}, Prod: {vL53L0X.Info.ProductId}, Mod: {vL53L0X.Info.ModuleId}");
while (!Console.KeyAvailable)
{
try
{
{
Console.WriteLine($"Distance: {vL53L0X.Distance}");
}
catch (Exception ex)
......@@ -37,7 +37,7 @@ Be aware that when reading a distance using the Continuous or Single measurement
You can as well get a single measurement, in this case, the precision can be lower. Use the property ```MeasurementMode``` to change the mode.
You can adjust the type of measurement you want. By default, the sensor is put into long range. This does allow to have a quite accurate (+-5%) precision within 2 meters but still can measure distances up to 8 meters (accuracy much less correct). You can switch to short range using the ```SetPrecision``` function. If you want to setup your own mode, you should use in conjunction the ```SetSignalRateLimit``` and the ```SetVcselPulsePeriod``` functions plus the ```HighResolution``` property like in the below example:
You can adjust the type of measurement you want. By default, the sensor is put into long range. This does allow to have a quite accurate (+-5%) precision within 2 meters but still can measure distances up to 8 meters (accuracy much less correct). You can switch to short range using the ```SetPrecision``` function. If you want to setup your own mode, you should use in conjunction the ```SetSignalRateLimit``` and the ```SetVcselPulsePeriod``` functions plus the ```HighResolution``` property like in the below example:
```csharp
HighResolution = false;
......@@ -46,4 +46,4 @@ SetVcselPulsePeriod(VcselType.VcselPeriodPreRange, PeriodPulse.Period14);
SetVcselPulsePeriod(VcselType.VcselPeriodFinalRange, PeriodPulse.Period10);
```
Please refer to the documentation to understand the impact of changing the various pulses as well as using the high resolution precision measurement. The sensor can't be precise in long range and in general, the longer it can see, the less precise are the data. High resolution will return a more precise measurement but mainly in short distance.
\ No newline at end of file
Please refer to the documentation to understand the impact of changing the various pulses as well as using the high resolution precision measurement. The sensor can't be precise in long range and in general, the longer it can see, the less precise are the data. High resolution will return a more precise measurement but mainly in short distance.
......@@ -11,7 +11,7 @@ This sensor is an I2C sensor. So you need to connect the pins of your board to t
The usage is straight forward, just initiate a class and start reading the data. Calibration is done automatically in the background. Be aware that first data may not be valid.
```csharp
Vl53L0X vL53L0X = new Vl53L0X(new UnixI2cDevice(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Vl53L0X vL53L0X = new Vl53L0X(I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Console.WriteLine($"Rev: {vL53L0X.Info.Revision}, Prod: {vL53L0X.Info.ProductId}, Mod: {vL53L0X.Info.ModuleId}");
// Set high precision mode
vL53L0X.Precision = Precision.HighPrecision;
......@@ -37,4 +37,4 @@ while (!Console.KeyAvailable)
}
Thread.Sleep(500);
}
```
\ No newline at end of file
```
......@@ -15,7 +15,7 @@ namespace Vl53L0Xsample
static void Main(string[] args)
{
Console.WriteLine("Hello VL53L0X!");
Vl53L0X vL53L0X = new Vl53L0X(new UnixI2cDevice(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Vl53L0X vL53L0X = new Vl53L0X(I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Console.WriteLine($"Rev: {vL53L0X.Information.Revision}, Prod: {vL53L0X.Information.ProductId}, Mod: {vL53L0X.Information.ModuleId}");
Console.WriteLine($"Offset in µm: {vL53L0X.Information.OffsetMicrometers}, Signal rate fixed 400 µm: {vL53L0X.Information.SignalRateMeasuementFixed400Micrometers}");
vL53L0X.MeasurementMode = MeasurementMode.Continuous;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册