Syntax
public abstract class Mcp960x : ByteCommsSensorBase<(Temperature? TemperatureHot, Temperature? TemperatureCold)>, IObservable<IChangeResult<(Temperature? TemperatureHot, Temperature? TemperatureCold)>>, ISamplingSensor<(Temperature? TemperatureHot, Temperature? TemperatureCold)>, ISensor<(Temperature? TemperatureHot, Temperature? TemperatureCold)>, IDisposable, ITemperatureSensor, ISamplingSensor<Temperature>, ISensor<Temperature>, II2cPeripheral
Constructors
Mcp960x(II2cBus, byte)
Create a new Mcp960x object using the default configuration for the sensor
Declaration
public Mcp960x(II2cBus i2cBus, byte address)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
byte | address | I2C address of the sensor |
Properties
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Temperature
The Hot Temperature value from the last reading
Declaration
public Temperature? Temperature { get; }
Property Value
Type | Description |
---|---|
Temperature? |
TemperatureCold
The Cold Temperature value from the last reading
Declaration
public Temperature? TemperatureCold { get; protected set; }
Property Value
Type | Description |
---|---|
Temperature? |
TemperatureHot
The Hot Temperature value from the last reading
Declaration
public Temperature? TemperatureHot { get; protected set; }
Property Value
Type | Description |
---|---|
Temperature? |
Methods
ConfigureAlert(AlertNumber, bool, bool, bool, bool, bool)
Configures the alert settings for the MCP960x
Declaration
public void ConfigureAlert(Mcp960x.AlertNumber alertNumber, bool enabled, bool rising, bool alertColdJunction, bool activeHigh, bool interruptMode)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.AlertNumber | alertNumber | The alert number (Alert1-Alert4) to configure |
bool | enabled | Whether the alert is enabled |
bool | rising | Whether the alert triggers on a rising temperature. Set to false for falling temperature |
bool | alertColdJunction | Whether the alert triggers on cold junction temperature. Set to false for thermocouple temperature |
bool | activeHigh | Whether the alert pin is active high. Set to false for active low |
bool | interruptMode | Whether the alert pin is in interrupt mode. Set to false for comparator mode |
Enable(bool)
Enables or disables the MCP960x sensor
Declaration
public void Enable(bool enable)
Parameters
Type | Name | Description |
---|---|---|
bool | enable | True to enable the sensor, false to enter sleep mode |
GetAdcResolution()
Gets the ADC resolution currently configured for the MCP960x
Declaration
public Mcp960x.AdcResolution GetAdcResolution()
Returns
Type | Description |
---|---|
Mcp960x.AdcResolution | The currently configured ADC resolution |
GetAlertTemperature(AlertNumber)
Gets the alert temperature for the specified alert number of the MCP960x
Declaration
public Temperature GetAlertTemperature(Mcp960x.AlertNumber alertNumber)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.AlertNumber | alertNumber | The alert number (1-4) to get the temperature for |
Returns
Type | Description |
---|---|
Temperature | The alert temperature value |
GetFilterCoefficient()
Gets the filter coefficient for the MCP960x
Declaration
public Mcp960x.FilterCoefficient GetFilterCoefficient()
Returns
Type | Description |
---|---|
Mcp960x.FilterCoefficient | The currently configured filter coefficient |
GetThermocoupleType()
Gets the thermocouple type currently configured for the MCP960x
Declaration
public Mcp960x.ThermocoupleType GetThermocoupleType()
Returns
Type | Description |
---|---|
Mcp960x.ThermocoupleType | The currently configured thermocouple type |
IsEnabled()
Checks whether the MCP960x sensor is enabled and working or in sleep mode
Declaration
public bool IsEnabled()
Returns
Type | Description |
---|---|
bool | True if in awake mode, false if in sleep mode |
RaiseEventsAndNotify(IChangeResult<(Temperature? TemperatureHot, Temperature? TemperatureCold)>)
Raise events for subscribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Temperature? TemperatureHot, Temperature? TemperatureCold)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<(Temperature? TemperatureHot, Temperature? TemperatureCold)> | changeResult | The updated sensor data |
Overrides
ReadSensor()
Update the Temperature property
Declaration
protected override Task<(Temperature? TemperatureHot, Temperature? TemperatureCold)> ReadSensor()
Returns
Type | Description |
---|---|
Task<(Temperature? TemperatureHot, Temperature? TemperatureCold)> |
Overrides
SetAdcResolution(AdcResolution)
Sets the ADC resolution for the MCP960x
Declaration
public void SetAdcResolution(Mcp960x.AdcResolution resolution)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.AdcResolution | resolution | The ADC resolution to set |
SetAlertTemperature(AlertNumber, Temperature)
Sets the alert temperature for the specified alert number of the MCP960x
Declaration
public void SetAlertTemperature(Mcp960x.AlertNumber alertNumber, Temperature temperature)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.AlertNumber | alertNumber | The alert number (1-4) to set the temperature for |
Temperature | temperature | The temperature value |
SetFilterCoefficient(FilterCoefficient)
Sets the filter coefficient for the MCP960x
Declaration
public void SetFilterCoefficient(Mcp960x.FilterCoefficient coefficient)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.FilterCoefficient | coefficient | The filter coefficient to set |
SetThermocoupleType(ThermocoupleType)
Sets the thermocouple type for the MCP960x
Declaration
public void SetThermocoupleType(Mcp960x.ThermocoupleType type)
Parameters
Type | Name | Description |
---|---|---|
Mcp960x.ThermocoupleType | type | The thermocouple type to set |
Events
TemperatureColdUpdated
Raised when the Cold / ambient temperature value changes
Declaration
public event EventHandler<IChangeResult<Temperature>> TemperatureColdUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Temperature>> |
TemperatureHotUpdated
Raised when the Hot temperature value changes
Declaration
public event EventHandler<IChangeResult<Temperature>> TemperatureHotUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Temperature>> |
TemperatureUpdated
Raised when the Hot temperature value changes
Declaration
public event EventHandler<IChangeResult<Temperature>> TemperatureUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Temperature>> |