SparkFun Spectral UV Sensor - AS7331  v2.1.2-21-g3e22fb4
Library for the SparkFun Spectral UV Sensor - AS7331
Loading...
Searching...
No Matches
SfeAS7331ArdI2C Class Reference

Arduino I2C implementation for the AS7331 UV sensor. More...

#include <SparkFun_AS7331.h>

Inheritance diagram for SfeAS7331ArdI2C:

Public Member Functions

 SfeAS7331ArdI2C ()
 
bool begin (const uint8_t &address=kDefaultAS7331Addr, TwoWire &wirePort=Wire)
 Initializes the AS7331 UV sensor with I2C communication. More...
 
bool isConnected (void)
 Checks if the AS7331 UV sensor is connected and responding. More...
 
bool setDeviceAddress (const uint8_t &deviceAddress)
 Sets the I2C address for communicating with the AS7331 sensor. More...
 
uint8_t getDeviceAddress (void)
 Gets the currently configured I2C address of the AS7331 sensor. More...
 
bool begin (sfTkIBus *theBus=nullptr)
 This method is called to initialize the AS7331 device through the specified bus. More...
 
uint8_t getDeviceID (void)
 Requests the device ID from the sensor. More...
 
void setCommunicationBus (sfTkIBus *theBus)
 Sets the communication bus to the specified bus. More...
 
bool runDefaultSetup (const bool &runSoftReset=false)
 Helper class that sets up the sensor and state in the POR configuration. More...
 
bool prepareMeasurement (const as7331_meas_mode_t &measMode=MEAS_MODE_CONT, const bool &startMeasure=false)
 Puts the sensor in the specified measurement mode. More...
 
bool reset (void)
 Performs a soft reset of the sensor. More...
 
sfTkError_t readTemp (void)
 Reads the sensor's temperature, converts it to a usable form, and saves it to the internal temperature variable. More...
 
sfTkError_t readUVA (void)
 Reads the sensor's UVA register, converts it to a usable form, and saves it to the internal UVA variable. More...
 
sfTkError_t readUVB (void)
 Reads the sensor's UVB register, converts it to a usable form, and saves it to the internal UVB variable. More...
 
sfTkError_t readUVC (void)
 Reads the sensor's UVC register, converts it to a usable form, and saves it to the internal UVC variable. More...
 
sfTkError_t readAllUV (void)
 Read's all three UV registers, converts them to a usable form, then saves them to their respective internal variable. More...
 
sfTkError_t readAll (void)
 Read the sensor's temperature, UV, and external time conversion clock counts, converts them, and then saves them to their respective internal variable. More...
 
sfTkError_t readOutConv (void)
 Read the conversion clock counts register and saves it to the internal output conversion time variable. More...
 
float getUVA (void)
 Returns the last valid UVA reading. More...
 
float getUVB (void)
 Returns the last valid UVB reading. More...
 
float getUVC (void)
 Returns the last valid UVC reading. More...
 
float getTemp (void)
 Returns the last valid Temperature reading. More...
 
uint32_t getOutConv (void)
 Returns the last valid output conversion. More...
 
as7331_gain_t getGainRaw (void)
 Getter for the currently configured gain. More...
 
uint16_t getGainValue (void)
 Getter for the currently configured gain. More...
 
sfTkError_t setGain (const as7331_gain_t &gain)
 Sets the UV sensor's gain. More...
 
as7331_conv_clk_freq_t getCClkRaw (void)
 Getter for the currently configured conversion clock. More...
 
uint16_t getCClkKHz (void)
 Getter for the currently configured conversion clock. More...
 
sfTkError_t setCClk (const as7331_conv_clk_freq_t &cclk)
 Set the sensor's internal clock speed. More...
 
as7331_conv_time_t getConversionTimeRaw (void)
 Getter for the currently configured conversion time. More...
 
uint16_t getConversionTimeMillis (void)
 Getter for the currently configured conversion time. More...
 
sfTkError_t setConversionTime (const as7331_conv_time_t &convTime)
 Sets the conversion time that the sensor will run to. More...
 
bool getReadyPinMode (void)
 Getter for the currently configured pin mode. More...
 
sfTkError_t setReadyPinMode (const bool &pinMode)
 Sets the ready pin type to push-pull or open-drain. More...
 
bool getDigitalDividerEnabled (void)
 Getter for the currently configured divider status. More...
 
sfTkError_t setDigitalDividerEnabled (const bool &isEnabled)
 Enables or disables the internal UV result divider. More...
 
as7331_divider_val_t getDigitalDividerRange (void)
 Getter for the currently configured divider range. More...
 
sfTkError_t setDigitalDividerRange (const as7331_divider_val_t &divider, const bool &enableDiv=true)
 Sets the value of the internal UV result divider. More...
 
bool getSyndTempConversionEnabled (void)
 Getter for the SYND temperature conversion status. More...
 
sfTkError_t setSyndTempConversionEnabled (const bool &isEnabled)
 Enables or disables temperature conversion when in SYND mode. More...
 
bool getIndexMode (void)
 Getter for the currently configured I2C compatibility mode. More...
 
sfTkError_t setIndexMode (const bool &indexMode)
 Set the index mode for compatibility with I2C controllers that don't support repeated start. More...
 
uint8_t getBreakTime (void)
 Getter for the currently configured minimum break time in CONT, CMD, SYNS modes. More...
 
sfTkError_t setBreakTime (const uint8_t &breakTime)
 Set the minimum time between measurements in CONT, SYNS, SYND modes. More...
 
uint8_t getNumEdges (void)
 Getter for the currently configured minimum number of edges to end conversion when in SYND mode. More...
 
sfTkError_t setNumEdges (const uint8_t &numEdges)
 Set the minimum number of falling edges required at the SYN input until the conversion is terminated. Only operational in SYND mode. More...
 
bool getPowerDownState (void)
 Getter for the current power state. More...
 
sfTkError_t setPowerDownState (const bool &pd)
 Sets the power state of the sensor. More...
 
as7331_dev_op_state_t getOperationMode (void)
 Getter for the current operational state. More...
 
sfTkError_t setOperationMode (const as7331_dev_op_state_t &opMode)
 Set the sensor's operating mode. More...
 
as7331_meas_mode_t getMeasurementMode (void)
 Getter for the current measurement state. More...
 
sfTkError_t setMeasurementMode (const as7331_meas_mode_t &measMode)
 Sets the sensor's measurement mode. More...
 
bool getStandbyState (void)
 Getter for the current standby state. More...
 
sfTkError_t setStandbyState (const bool &standby)
 Sets the sensor's standby mode. More...
 
bool getStartState (void)
 Getter for the current start state. More...
 
sfTkError_t setStartState (const bool &startState)
 Sets the sensor's start state. This begins measurement. More...
 
sfTkError_t getStatus (sfe_as7331_reg_meas_osr_status_t &statusReg)
 Gets the sensor's status when in measurement operation mode. More...
 
sfTkError_t getOSR (sfe_as7331_reg_cfg_osr_t &osrReg)
 Gets the operational state register when in configuration operation mode. More...
 
sfTkError_t setOSR (const sfe_as7331_reg_cfg_osr_t &osrReg)
 Sets the operational state register when in configuration operation mode. More...
 
sfTkError_t getCReg1 (sfe_as7331_reg_cfg_creg1_t &creg1)
 Gets the configuration register #1 when in configuration operation mode. More...
 
sfTkError_t setCReg1 (const sfe_as7331_reg_cfg_creg1_t &creg1)
 Sets the configuration register #1 when in configuration operation mode. More...
 
sfTkError_t getCReg2 (sfe_as7331_reg_cfg_creg2_t &creg2)
 Gets the configuration register #2 when in configuration operation mode. More...
 
sfTkError_t setCReg2 (const sfe_as7331_reg_cfg_creg2_t &creg2)
 Sets the configuration register #2 when in configuration operation mode. More...
 
sfTkError_t getCReg3 (sfe_as7331_reg_cfg_creg3_t &creg3)
 Gets the configuration register #3 when in configuration operation mode. More...
 
sfTkError_t setCReg3 (const sfe_as7331_reg_cfg_creg3_t &creg3)
 Sets the configuration register #3 when in configuration operation mode. More...
 
sfTkError_t getBreak (uint8_t &breakReg)
 Gets the break register when in configuration operation mode. More...
 
sfTkError_t setBreak (const uint8_t &breakReg)
 Sets the break register when in configuration operation mode. More...
 
sfTkError_t getEdges (uint8_t &edgesReg)
 Gets the edges register when in configuration operation mode. More...
 
sfTkError_t setEdges (const uint8_t &edgesReg)
 Sets the edges register when in configuration operation mode. More...
 
sfTkError_t getOptIndex (sfe_as7331_reg_cfg_optreg_t &optReg)
 Gets the option register when in configuration operation mode. More...
 
sfTkError_t setOptIndex (const sfe_as7331_reg_cfg_optreg_t &optReg)
 Sets the option register when in configuration operation mode. More...
 

Detailed Description

Arduino I2C implementation for the AS7331 UV sensor.

This class provides Arduino-specific I2C communication implementation for the AS7331 UV sensor. It inherits from the base driver class and implements the I2C interface using Arduino's Wire library. The class manages device addressing and connection verification.

Example usage:

SfeAS7331ArdI2C uvSensor;
if (uvSensor.begin()) {
// Sensor initialized successfully
}
Arduino I2C implementation for the AS7331 UV sensor.
Definition: SparkFun_AS7331.h:73
bool begin(const uint8_t &address=kDefaultAS7331Addr, TwoWire &wirePort=Wire)
Initializes the AS7331 UV sensor with I2C communication.
Definition: SparkFun_AS7331.h:105
Note
This class uses the Arduino Wire library for I2C communication
See also
sfDevAS7331
TwoWire

Constructor & Destructor Documentation

◆ SfeAS7331ArdI2C()

SfeAS7331ArdI2C::SfeAS7331ArdI2C ( )
inline

Member Function Documentation

◆ begin() [1/2]

bool SfeAS7331ArdI2C::begin ( const uint8_t &  address = kDefaultAS7331Addr,
TwoWire &  wirePort = Wire 
)
inline

Initializes the AS7331 UV sensor with I2C communication.

This method performs the following initialization steps:

  1. Initializes I2C communication with specified address and Wire port
  2. Enables repeat start support
  3. Sets up communication bus
  4. Verifies device connection
  5. Calls base class initialization
Parameters
addressI2C address of the device (default: kDefaultAS7331Addr)
wirePortTwoWire instance to use for I2C communication (default: Wire)
Returns
true If initialization successful
false If any initialization step fails

Example:

if (!sensor.begin()) {
Serial.println("Sensor initialization failed!");
while (1); // halt
}

◆ begin() [2/2]

bool sfDevAS7331::begin ( sfTkIBus *  theBus = nullptr)
inherited

This method is called to initialize the AS7331 device through the specified bus.

Parameters
theBusPointer to the bus object.
Returns
True if successful, false if it fails.

◆ getBreak()

sfTkError_t sfDevAS7331::getBreak ( uint8_t &  breakReg)
inherited

Gets the break register when in configuration operation mode.

Parameters
breakRegPointer to a register struct to store the sensor's current break register.
Returns
0 if successful, negative if error, positive for warning.

◆ getBreakTime()

uint8_t sfDevAS7331::getBreakTime ( void  )
inherited

Getter for the currently configured minimum break time in CONT, CMD, SYNS modes.

Returns
Sensor's breaktime in 8us steps.

◆ getCClkKHz()

uint16_t sfDevAS7331::getCClkKHz ( void  )
inherited

Getter for the currently configured conversion clock.

Returns
Sensor's conversion clock expressed in kHz.

◆ getCClkRaw()

as7331_conv_clk_freq_t sfDevAS7331::getCClkRaw ( void  )
inherited

Getter for the currently configured conversion clock.

Returns
Sensor's conversion clock expressed as 1024*(1 << cclk).

◆ getConversionTimeMillis()

uint16_t sfDevAS7331::getConversionTimeMillis ( void  )
inherited

Getter for the currently configured conversion time.

Returns
Sensor's conversion time in milliseconds.

◆ getConversionTimeRaw()

as7331_conv_time_t sfDevAS7331::getConversionTimeRaw ( void  )
inherited

Getter for the currently configured conversion time.

Returns
Sensor's conversion time expressed as (1 << time).

◆ getCReg1()

sfTkError_t sfDevAS7331::getCReg1 ( sfe_as7331_reg_cfg_creg1_t creg1)
inherited

Gets the configuration register #1 when in configuration operation mode.

Parameters
creg1Pointer to a register struct to store the sensor's current creg1 register.
Returns
0 if successful, negative if error, positive for warning.

◆ getCReg2()

sfTkError_t sfDevAS7331::getCReg2 ( sfe_as7331_reg_cfg_creg2_t creg2)
inherited

Gets the configuration register #2 when in configuration operation mode.

Parameters
creg2Pointer to a register struct to store the sensor's current creg2 register.
Returns
0 if successful, negative if error, positive for warning.

◆ getCReg3()

sfTkError_t sfDevAS7331::getCReg3 ( sfe_as7331_reg_cfg_creg3_t creg3)
inherited

Gets the configuration register #3 when in configuration operation mode.

Parameters
creg3Pointer to a register struct to store the sensor's current creg3 register.
Returns
0 if successful, negative if error, positive for warning.

◆ getDeviceAddress()

uint8_t SfeAS7331ArdI2C::getDeviceAddress ( void  )
inline

Gets the currently configured I2C address of the AS7331 sensor.

Returns the I2C address currently being used to communicate with the sensor. The address will be one of:

  • kDefaultAS7331Addr
  • kSecondaryAS7331Addr
  • kTertiaryAS7331Addr
  • kQuaternaryAS7331Addr
Returns
uint8_t The current I2C address

Example:

uint8_t address = sensor.getDeviceAddress();
Serial.print("Current I2C address: 0x");
Serial.println(address, HEX);
uint8_t getDeviceAddress(void)
Gets the currently configured I2C address of the AS7331 sensor.
Definition: SparkFun_AS7331.h:212

◆ getDeviceID()

uint8_t sfDevAS7331::getDeviceID ( void  )
inherited

Requests the device ID from the sensor.

Returns
The device ID of the sensor.

◆ getDigitalDividerEnabled()

bool sfDevAS7331::getDigitalDividerEnabled ( void  )
inherited

Getter for the currently configured divider status.

Returns
True if Internal predivider is enabled, false otherwise.

◆ getDigitalDividerRange()

as7331_divider_val_t sfDevAS7331::getDigitalDividerRange ( void  )
inherited

Getter for the currently configured divider range.

Returns
Sensor's internal UV predivider range.

◆ getEdges()

sfTkError_t sfDevAS7331::getEdges ( uint8_t &  edgesReg)
inherited

Gets the edges register when in configuration operation mode.

Parameters
edgesRegPointer to a register struct to store the sensor's current edges register.
Returns
0 if successful, negative if error, positive for warning.

◆ getGainRaw()

as7331_gain_t sfDevAS7331::getGainRaw ( void  )
inherited

Getter for the currently configured gain.

Returns
Sensor's gain expressed as (1 << (11 - gain)).

◆ getGainValue()

uint16_t sfDevAS7331::getGainValue ( void  )
inherited

Getter for the currently configured gain.

Returns
Sensor's gain expressed as a unitless scalar.

◆ getIndexMode()

bool sfDevAS7331::getIndexMode ( void  )
inherited

Getter for the currently configured I2C compatibility mode.

Returns
True if the device will respond to repeat starts, false otherwise.

◆ getMeasurementMode()

as7331_meas_mode_t sfDevAS7331::getMeasurementMode ( void  )
inherited

Getter for the current measurement state.

Returns
Sensor's measurement state.

◆ getNumEdges()

uint8_t sfDevAS7331::getNumEdges ( void  )
inherited

Getter for the currently configured minimum number of edges to end conversion when in SYND mode.

Returns
Sensor's minimum number of edges, minimum 1 edge.

◆ getOperationMode()

as7331_dev_op_state_t sfDevAS7331::getOperationMode ( void  )
inherited

Getter for the current operational state.

Returns
Sensor's operational mode.

◆ getOptIndex()

sfTkError_t sfDevAS7331::getOptIndex ( sfe_as7331_reg_cfg_optreg_t optReg)
inherited

Gets the option register when in configuration operation mode.

Parameters
optRegPointer to a register struct to store the sensor's current option register.
Returns
0 if successful, negative if error, positive for warning.

◆ getOSR()

sfTkError_t sfDevAS7331::getOSR ( sfe_as7331_reg_cfg_osr_t osrReg)
inherited

Gets the operational state register when in configuration operation mode.

Parameters
osrRegPointer to a register struct to store the sensor's current OSR register.
Returns
0 if successful, negative if error, positive for warning.

◆ getOutConv()

uint32_t sfDevAS7331::getOutConv ( void  )
inherited

Returns the last valid output conversion.

Returns
The output conversion time in number of clock cycles.

◆ getPowerDownState()

bool sfDevAS7331::getPowerDownState ( void  )
inherited

Getter for the current power state.

Returns
Sensor's power state.

◆ getReadyPinMode()

bool sfDevAS7331::getReadyPinMode ( void  )
inherited

Getter for the currently configured pin mode.

Returns
False if push-pull, true if open-drain.

◆ getStandbyState()

bool sfDevAS7331::getStandbyState ( void  )
inherited

Getter for the current standby state.

Returns
Sensor's standby state.

◆ getStartState()

bool sfDevAS7331::getStartState ( void  )
inherited

Getter for the current start state.

Returns
Sensor's start state.

◆ getStatus()

sfTkError_t sfDevAS7331::getStatus ( sfe_as7331_reg_meas_osr_status_t statusReg)
inherited

Gets the sensor's status when in measurement operation mode.

Parameters
statusRegPointer to a register struct to store the sensor's current status.
Returns
0 if successful, negative if error, positive for warning.

◆ getSyndTempConversionEnabled()

bool sfDevAS7331::getSyndTempConversionEnabled ( void  )
inherited

Getter for the SYND temperature conversion status.

Returns
True if temperature conversion is enabled in SYND mode.

◆ getTemp()

float sfDevAS7331::getTemp ( void  )
inherited

Returns the last valid Temperature reading.

Returns
A float of the Temperature reading.

◆ getUVA()

float sfDevAS7331::getUVA ( void  )
inherited

Returns the last valid UVA reading.

Returns
A float of the UVA reading.

◆ getUVB()

float sfDevAS7331::getUVB ( void  )
inherited

Returns the last valid UVB reading.

Returns
A float of the UVB reading.

◆ getUVC()

float sfDevAS7331::getUVC ( void  )
inherited

Returns the last valid UVC reading.

Returns
A float of the UVC reading.

◆ isConnected()

bool SfeAS7331ArdI2C::isConnected ( void  )
inline

Checks if the AS7331 UV sensor is connected and responding.

This method performs two checks:

  1. Attempts to ping the device at the current I2C address
  2. Verifies the device ID matches the expected AS7331 ID
Returns
true If device responds to ping and returns correct device ID
false If communication fails or device ID is incorrect

Example:

if (!sensor.isConnected()) {
Serial.println("Device not found or incorrect ID!");
return;
}
bool isConnected(void)
Checks if the AS7331 UV sensor is connected and responding.
Definition: SparkFun_AS7331.h:141

◆ prepareMeasurement()

bool sfDevAS7331::prepareMeasurement ( const as7331_meas_mode_t measMode = MEAS_MODE_CONT,
const bool &  startMeasure = false 
)
inherited

Puts the sensor in the specified measurement mode.

Parameters
measModeMeasurement mode to enter.
startMeasureFlag to start measuring immediately if set.
Returns
True if successful, false otherwise.

◆ readAll()

sfTkError_t sfDevAS7331::readAll ( void  )
inherited

Read the sensor's temperature, UV, and external time conversion clock counts, converts them, and then saves them to their respective internal variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readAllUV()

sfTkError_t sfDevAS7331::readAllUV ( void  )
inherited

Read's all three UV registers, converts them to a usable form, then saves them to their respective internal variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readOutConv()

sfTkError_t sfDevAS7331::readOutConv ( void  )
inherited

Read the conversion clock counts register and saves it to the internal output conversion time variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readTemp()

sfTkError_t sfDevAS7331::readTemp ( void  )
inherited

Reads the sensor's temperature, converts it to a usable form, and saves it to the internal temperature variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readUVA()

sfTkError_t sfDevAS7331::readUVA ( void  )
inherited

Reads the sensor's UVA register, converts it to a usable form, and saves it to the internal UVA variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readUVB()

sfTkError_t sfDevAS7331::readUVB ( void  )
inherited

Reads the sensor's UVB register, converts it to a usable form, and saves it to the internal UVB variable.

Returns
0 if successful, negative if error, positive for warning.

◆ readUVC()

sfTkError_t sfDevAS7331::readUVC ( void  )
inherited

Reads the sensor's UVC register, converts it to a usable form, and saves it to the internal UVC variable.

Returns
0 if successful, negative if error, positive for warning.

◆ reset()

bool sfDevAS7331::reset ( void  )
inherited

Performs a soft reset of the sensor.

Returns
True if successful, false otherwise.

◆ runDefaultSetup()

bool sfDevAS7331::runDefaultSetup ( const bool &  runSoftReset = false)
inherited

Helper class that sets up the sensor and state in the POR configuration.

Parameters
runSoftResetFlag that runs the soft reset function to reset the device.
Returns
True if successful, false otherwise.

◆ setBreak()

sfTkError_t sfDevAS7331::setBreak ( const uint8_t &  breakReg)
inherited

Sets the break register when in configuration operation mode.

Parameters
breakRegPointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setBreakTime()

sfTkError_t sfDevAS7331::setBreakTime ( const uint8_t &  breakTime)
inherited

Set the minimum time between measurements in CONT, SYNS, SYND modes.

Parameters
breakTimeTime between measurements, 8us step time, max 2048us. A 0 value is a minimum of 3 cclk cycles.
Returns
0 if successful, negative if error, positive for warning.

◆ setCClk()

sfTkError_t sfDevAS7331::setCClk ( const as7331_conv_clk_freq_t cclk)
inherited

Set the sensor's internal clock speed.

Parameters
cclkClock speed to set on the sensor.
Returns
0 if successful, negative if error, positive for warning.

◆ setCommunicationBus()

void sfDevAS7331::setCommunicationBus ( sfTkIBus *  theBus)
inherited

Sets the communication bus to the specified bus.

Parameters
theBusBus to set as the communication device.

◆ setConversionTime()

sfTkError_t sfDevAS7331::setConversionTime ( const as7331_conv_time_t convTime)
inherited

Sets the conversion time that the sensor will run to.

Parameters
convTimeConversion time to set the sensor to.
Returns
0 if successful, negative if error, positive for warning.

◆ setCReg1()

sfTkError_t sfDevAS7331::setCReg1 ( const sfe_as7331_reg_cfg_creg1_t creg1)
inherited

Sets the configuration register #1 when in configuration operation mode.

Parameters
creg1Pointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setCReg2()

sfTkError_t sfDevAS7331::setCReg2 ( const sfe_as7331_reg_cfg_creg2_t creg2)
inherited

Sets the configuration register #2 when in configuration operation mode.

Parameters
creg2Pointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setCReg3()

sfTkError_t sfDevAS7331::setCReg3 ( const sfe_as7331_reg_cfg_creg3_t creg3)
inherited

Sets the configuration register #3 when in configuration operation mode.

Parameters
creg3Pointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setDeviceAddress()

bool SfeAS7331ArdI2C::setDeviceAddress ( const uint8_t &  deviceAddress)
inline

Sets the I2C address for communicating with the AS7331 sensor.

This method validates and sets the I2C address for the sensor. Only specific addresses are allowed:

  • kDefaultAS7331Addr (default address)
  • kSecondaryAS7331Addr
  • kTertiaryAS7331Addr
  • kQuaternaryAS7331Addr
Parameters
deviceAddressThe I2C address to set
Returns
true If address is valid and was set successfully
false If address is invalid

Example:

// Change to secondary address
Serial.println("Invalid address!");
return;
}
bool setDeviceAddress(const uint8_t &deviceAddress)
Sets the I2C address for communicating with the AS7331 sensor.
Definition: SparkFun_AS7331.h:173
const uint8_t kSecondaryAS7331Addr
Definition: sfDevAS7331.h:60

◆ setDigitalDividerEnabled()

sfTkError_t sfDevAS7331::setDigitalDividerEnabled ( const bool &  isEnabled)
inherited

Enables or disables the internal UV result divider.

Parameters
isEnabledEnable or disable the divder.
Returns
0 if successful, negative if error, positive for warning.

◆ setDigitalDividerRange()

sfTkError_t sfDevAS7331::setDigitalDividerRange ( const as7331_divider_val_t divider,
const bool &  enableDiv = true 
)
inherited

Sets the value of the internal UV result divider.

Parameters
dividerDivider value to set.
setEnableDivOption to turn on the divider if desired.
Returns
0 if successful, negative if error, positive for warning.

◆ setEdges()

sfTkError_t sfDevAS7331::setEdges ( const uint8_t &  edgesReg)
inherited

Sets the edges register when in configuration operation mode.

Parameters
edgesRegPointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setGain()

sfTkError_t sfDevAS7331::setGain ( const as7331_gain_t gain)
inherited

Sets the UV sensor's gain.

Parameters
gainThe gain to set the sensor to.
Returns
0 if successful, negative if error, positive for warning.

◆ setIndexMode()

sfTkError_t sfDevAS7331::setIndexMode ( const bool &  indexMode)
inherited

Set the index mode for compatibility with I2C controllers that don't support repeated start.

Parameters
indexModeSimple or standard I2C addressing mode.
Returns
0 if successful, negative if error, positive for warning.

◆ setMeasurementMode()

sfTkError_t sfDevAS7331::setMeasurementMode ( const as7331_meas_mode_t measMode)
inherited

Sets the sensor's measurement mode.

Parameters
measModeMeasurement mode to set.
Returns
0 if successful, negative if error, positive for warning.

◆ setNumEdges()

sfTkError_t sfDevAS7331::setNumEdges ( const uint8_t &  numEdges)
inherited

Set the minimum number of falling edges required at the SYN input until the conversion is terminated. Only operational in SYND mode.

Parameters
numEdgesNumber of edges prior to terminating conversion in SYND mode. 0 is not allowed, 1 is the minimum.
Returns
0 if successful, negative if error, positive for warning.

◆ setOperationMode()

sfTkError_t sfDevAS7331::setOperationMode ( const as7331_dev_op_state_t opMode)
inherited

Set the sensor's operating mode.

Parameters
opModeOperating mode to set.
Returns
0 if successful, negative if error, positive for warning.

◆ setOptIndex()

sfTkError_t sfDevAS7331::setOptIndex ( const sfe_as7331_reg_cfg_optreg_t optReg)
inherited

Sets the option register when in configuration operation mode.

Parameters
optRegPointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setOSR()

sfTkError_t sfDevAS7331::setOSR ( const sfe_as7331_reg_cfg_osr_t osrReg)
inherited

Sets the operational state register when in configuration operation mode.

Parameters
osrRegPointer to a register struct that has the new register configuration.
Returns
0 if successful, negative if error, positive for warning.

◆ setPowerDownState()

sfTkError_t sfDevAS7331::setPowerDownState ( const bool &  pd)
inherited

Sets the power state of the sensor.

Parameters
pdPower state to set.
Returns
0 if successful, negative if error, positive for warning.

◆ setReadyPinMode()

sfTkError_t sfDevAS7331::setReadyPinMode ( const bool &  pinMode)
inherited

Sets the ready pin type to push-pull or open-drain.

Parameters
pinModeMode to set the ready pin to.
Returns
0 if successful, negative if error, positive for warning.

◆ setStandbyState()

sfTkError_t sfDevAS7331::setStandbyState ( const bool &  standby)
inherited

Sets the sensor's standby mode.

Parameters
standbyState to set.
Returns
0 if successful, negative if error, positive for warning.

◆ setStartState()

sfTkError_t sfDevAS7331::setStartState ( const bool &  startState)
inherited

Sets the sensor's start state. This begins measurement.

Parameters
startStateStart state to set.
Returns
0 if successful, negative if error, positive for warning.

◆ setSyndTempConversionEnabled()

sfTkError_t sfDevAS7331::setSyndTempConversionEnabled ( const bool &  isEnabled)
inherited

Enables or disables temperature conversion when in SYND mode.

Parameters
isEnabledEnable or disable the feature.
Returns
0 if successful, negative if error, positive for warning.

The documentation for this class was generated from the following file: