Table of Contents

Class Opt3001

Namespace
Pamoja.Sensors
Assembly
Pamoja.Sensors.dll

A Texas Instruments OPT3001 ambient light sensor. Every call goes straight to the pamoja C ABI, which decodes exactly what the manufacturer's datasheet specifies.

public static class Opt3001
Inheritance
Opt3001
Inherited Members

Methods

ConfigBits(PamojaOpt3001Config)

Assembles the 16-bit OPT3001 configuration register value.

public static ushort ConfigBits(PamojaOpt3001Config config)

Parameters

config PamojaOpt3001Config

The config.

Returns

ushort

The value the C ABI computes.

ConfigFromBits(ushort)

Parses a 16-bit OPT3001 configuration register value.

public static PamojaOpt3001Config ConfigFromBits(ushort bits)

Parameters

bits ushort

The bits.

Returns

PamojaOpt3001Config

The decoded value.

Exceptions

PamojaException

The device data is not valid.

ConversionMillis(bool)

Returns the conversion time an OPT3001 setting selects.

public static ushort ConversionMillis(bool longConversion)

Parameters

longConversion bool

The long conversion.

Returns

ushort

The value the C ABI computes.

FaultCount(byte)

Returns how many consecutive faults an OPT3001 fault-count code requires.

public static byte FaultCount(byte code)

Parameters

code byte

The code.

Returns

byte

The value the C ABI computes.

FullScaleMilliLux(byte)

Returns the full scale an OPT3001 range number covers.

public static uint? FullScaleMilliLux(byte rangeNumber)

Parameters

rangeNumber byte

The range number.

Returns

uint?

The value, or null where the part defines none.

IsAutomaticRange(byte)

Reports whether an OPT3001 range number sets the full scale automatically.

public static bool IsAutomaticRange(byte rangeNumber)

Parameters

rangeNumber byte

The range number.

Returns

bool

The value the C ABI computes.

LsbMilliLux(byte)

Returns the illuminance one count carries at an OPT3001 exponent.

public static uint? LsbMilliLux(byte exponent)

Parameters

exponent byte

The exponent.

Returns

uint?

The value, or null where the part defines none.

Lux(ushort)

Converts a raw OPT3001 result register to lux.

public static float Lux(ushort raw)

Parameters

raw ushort

The raw.

Returns

float

The value the C ABI computes.

MilliLux(ushort)

Converts a raw OPT3001 result register to milli-lux.

public static uint MilliLux(ushort raw)

Parameters

raw ushort

The raw.

Returns

uint

The value the C ABI computes.

RawFromMilliLux(uint)

Builds the OPT3001 result register that decodes to an illuminance.

public static ushort RawFromMilliLux(uint milliLux)

Parameters

milliLux uint

The milli lux.

Returns

ushort

The value the C ABI computes.

WordFromBytes(ReadOnlySpan<byte>)

Reads the two bytes an OPT3001 sends for a register, most significant first.

public static ushort WordFromBytes(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

The bytes.

Returns

ushort

The decoded value.

Exceptions

PamojaException

The device data is not valid.

WordToBytes(ushort)

Builds the two bytes an OPT3001 sends for a register, most significant first.

public static byte[] WordToBytes(ushort word)

Parameters

word ushort

The word.

Returns

byte[]

The decoded value.

Exceptions

PamojaException

The device data is not valid.