C# Class Porrey.Uwp.IoT.Sensors.I2C.RegisterConverter

Helpers methods for reading and writing from the device registers.
Datei anzeigen Open project: porrey/iot Class Usage Examples

Public Methods

Method Description
BitIsHigh ( byte value, int bitIndex ) : bool

Determines if a bit in the given position of a byte is High (1) or Low (0).

BitIsLow ( byte value, int bitIndex ) : bool

Determines if a bit in the given position of a byte is High (1) or Low (0).

GetBit ( byte value, int bitIndex ) : bool

Gets a bit in the given position of a byte to the give value.

SetBit ( byte value, int bitIndex, bool bit ) : byte

Sets a bit in the given position of a byte to the give value.

ToByteArray ( float value ) : byte[]

Converts a float to a 2-byte value to be written to the device register.

ToFloat ( byte registerValue ) : float

Converts a 2-byte register value to a float.

Method Details

BitIsHigh() public static method

Determines if a bit in the given position of a byte is High (1) or Low (0).
public static BitIsHigh ( byte value, int bitIndex ) : bool
value byte The byte value to be checked.
bitIndex int The bit position from 0 to 7.
return bool

BitIsLow() public static method

Determines if a bit in the given position of a byte is High (1) or Low (0).
public static BitIsLow ( byte value, int bitIndex ) : bool
value byte The byte value to be checked.
bitIndex int The bit position from 0 to 7.
return bool

GetBit() public static method

Gets a bit in the given position of a byte to the give value.
public static GetBit ( byte value, int bitIndex ) : bool
value byte The byte value to be modified.
bitIndex int The index of the bit to modify. This /// value can be 0 to 7.
return bool

SetBit() public static method

Sets a bit in the given position of a byte to the give value.
public static SetBit ( byte value, int bitIndex, bool bit ) : byte
value byte The byte value to be modified.
bitIndex int The index of the bit to modify. This /// value can be 0 to 7.
bit bool The value to be set in the byte.
return byte

ToByteArray() public static method

Converts a float to a 2-byte value to be written to the device register.
public static ToByteArray ( float value ) : byte[]
value float The value to be converted.
return byte[]

ToFloat() public static method

Converts a 2-byte register value to a float.
public static ToFloat ( byte registerValue ) : float
registerValue byte A 2-byte register value /// read from the device to be converted.
return float