Syntax
public abstract class ByteCommsSensorBase<UNIT> : PollingSensorBase<UNIT>, IObservable<IChangeResult<UNIT>>, ISamplingSensor<UNIT>, ISensor<UNIT>, IDisposable where UNIT : struct
Type Parameters
Name | Description |
---|---|
UNIT | The unit type |
Constructors
ByteCommsSensorBase(II2cBus, byte, int, int)
Creates a new ByteCommsSensorBase object
Declaration
protected ByteCommsSensorBase(II2cBus i2cBus, byte address, int readBufferSize = 8, int writeBufferSize = 8)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
byte | address | The I2C address |
int | readBufferSize | Read buffer size in bytes |
int | writeBufferSize |
ByteCommsSensorBase(ISpiBus, IDigitalOutputPort?, Frequency, Mode, int, int, ChipSelectMode)
ByteCommsSensorBase abstract ctor for SPI
Declaration
protected ByteCommsSensorBase(ISpiBus spiBus, IDigitalOutputPort? chipSelect, Frequency busSpeed, SpiClockConfiguration.Mode busMode = Mode.Mode0, int readBufferSize = 8, int writeBufferSize = 8, ChipSelectMode chipSelectMode = ChipSelectMode.ActiveLow)
Parameters
Type | Name | Description |
---|---|---|
ISpiBus | spiBus | SPI bus object |
IDigitalOutputPort | chipSelect | Chip select port |
Frequency | busSpeed | The SPI bus speed |
SpiClockConfiguration.Mode | busMode | The SPI bus mode (0-3) |
int | readBufferSize | Read buffer size |
int | writeBufferSize | Write buffer size |
ChipSelectMode | chipSelectMode | Chip select mode |
ByteCommsSensorBase(int, int)
ByteCommsSensorBase abstract ctor with no bus
Declaration
protected ByteCommsSensorBase(int readBufferSize = 8, int writeBufferSize = 8)
Parameters
Type | Name | Description |
---|---|---|
int | readBufferSize | Read buffer size |
int | writeBufferSize | Write buffer size |
Properties
BusComms
Bus communications object, i.e. an I2cCommunications or SpiCommunications
Declaration
protected IByteCommunications? BusComms { get; set; }
Property Value
Type | Description |
---|---|
IByteCommunications |
ReadBuffer
The read buffer
Declaration
protected Memory<byte> ReadBuffer { get; }
Property Value
Type | Description |
---|---|
Memory<byte> |
WriteBuffer
The write buffer
Declaration
protected Memory<byte> WriteBuffer { get; }
Property Value
Type | Description |
---|---|
Memory<byte> |
Methods
Dispose()
Dispose managed resources
Declaration
public virtual void Dispose()
Dispose(bool)
Dispose object
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | is disposing |
Init(int, int)
Simple constructor for peripherals that don't use a bus and don't need an IByteCommunications
Declaration
protected virtual void Init(int readBufferSize = 8, int writeBufferSize = 8)
Parameters
Type | Name | Description |
---|---|---|
int | readBufferSize | |
int | writeBufferSize |