forked from dotnet/iot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSenseHatMagnetometer.cs
37 lines (33 loc) · 1.19 KB
/
SenseHatMagnetometer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Device.I2c;
using Iot.Device.Lsm9Ds1;
namespace Iot.Device.SenseHat
{
/// <summary>
/// SenseHAT - Magnetometer sensor
/// </summary>
public class SenseHatMagnetometer : Lsm9Ds1Magnetometer
{
/// <summary>
/// Default I2C address
/// </summary>
public const int I2cAddress = 0x1C;
/// <summary>
/// Constructs SenseHatMagnetometer instance
/// </summary>
/// <param name="i2cDevice">I2C device used to communicate with the device</param>
/// <param name="magneticInduction">Magnetic induction</param>
public SenseHatMagnetometer(
I2cDevice? i2cDevice = null,
MagneticInductionScale magneticInduction = MagneticInductionScale.Scale04G)
: base(i2cDevice ?? CreateDefaultI2cDevice(), magneticInduction)
{
}
private static I2cDevice CreateDefaultI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return I2cDevice.Create(settings);
}
}
}