Adafruit AS726x Arduino Library
Classes | Public Member Functions | List of all members
Adafruit_AS726x Class Reference

Class that stores state and functions for interacting with AS726x spectral sensors. More...

#include <Adafruit_AS726x.h>

Public Member Functions

 Adafruit_AS726x (int8_t addr=AS726x_ADDRESS)
 Class constructor. More...
 
bool begin (TwoWire *theWire=&Wire)
 Set up hardware and begin communication with the sensor. More...
 
void setIndicateCurrent (uint8_t current)
 set the current limit for the driver LED. More...
 
void indicateLED (boolean on)
 turn on/off the indicator LED More...
 
void drvOn ()
 turn on the driver LED
 
void drvOff ()
 turn off the driver LED
 
void setDrvCurrent (uint8_t current)
 set the current limit for the driver LED. More...
 
void setConversionType (uint8_t type)
 Set the conversion mode. More...
 
void setGain (uint8_t gain)
 Set the sensor gain. More...
 
void setIntegrationTime (uint8_t time)
 Set the integration time for the sensor. More...
 
void enableInterrupt ()
 enable the device interrupt
 
void disableInterrupt ()
 disable the device interrupt
 
void startMeasurement ()
 begin a measurement. This sets the conversion mode to ONE_SHOT.
 
bool dataReady ()
 Check if the sensor is ready to return data. More...
 
uint8_t readTemperature ()
 Read the on-board temperature sensor. More...
 
uint16_t readChannel (uint8_t channel)
 read an individual raw spectral channel More...
 
uint16_t readViolet ()
 Read raw violet color value (AS7262 only) More...
 
uint16_t readBlue ()
 Read raw blue color value (AS7262 only) More...
 
uint16_t readGreen ()
 Read raw green color value (AS7262 only) More...
 
uint16_t readYellow ()
 Read raw yellow color value (AS7262 only) More...
 
uint16_t readOrange ()
 Read raw orange color value (AS7262 only) More...
 
uint16_t readRed ()
 Read raw red color value (AS7262 only) More...
 
void readRawValues (uint16_t *buf, uint8_t num=AS726x_NUM_CHANNELS)
 read the raw channels More...
 
float readCalibratedValue (uint8_t channel)
 read an individual calibrated spectral channel More...
 
float readCalibratedViolet ()
 Read calibrated violet color value (AS7262 only) More...
 
float readCalibratedBlue ()
 Read calibrated blue color value (AS7262 only) More...
 
float readCalibratedGreen ()
 Read calibrated green color value (AS7262 only) More...
 
float readCalibratedYellow ()
 Read calibrated yellow color value (AS7262 only) More...
 
float readCalibratedOrange ()
 Read calibrated orange color value (AS7262 only) More...
 
float readCalibratedRed ()
 Read calibrated red color value (AS7262 only) More...
 
void readCalibratedValues (float *buf, uint8_t num=AS726x_NUM_CHANNELS)
 read the calibrated channels More...
 

Detailed Description

Class that stores state and functions for interacting with AS726x spectral sensors.

Constructor & Destructor Documentation

◆ Adafruit_AS726x()

Adafruit_AS726x::Adafruit_AS726x ( int8_t  addr = AS726x_ADDRESS)
inline

Class constructor.

Parameters
addrOptional I2C address the sensor can be found on. Defaults to 0x49.

Member Function Documentation

◆ begin()

bool Adafruit_AS726x::begin ( TwoWire *  theWire = &Wire)

Set up hardware and begin communication with the sensor.

Parameters
theWirea TwoWire object to use for I2C communication
Returns
true on success, fale otherwise.

◆ setIndicateCurrent()

void Adafruit_AS726x::setIndicateCurrent ( uint8_t  current)

set the current limit for the driver LED.

Parameters
currentthe current limit setting. Should be one of LIMIT_1MA, LIMIT_2MA, LIMIT_4MA, or LIMIT_8MA

◆ indicateLED()

void Adafruit_AS726x::indicateLED ( boolean  on)

turn on/off the indicator LED

Parameters
onTrue if you want the LED on, False to turn off

◆ setDrvCurrent()

void Adafruit_AS726x::setDrvCurrent ( uint8_t  current)

set the current limit for the driver LED.

Parameters
currentthe current limit setting. Should be one of LIMIT_12MA5, LIMIT_25MA, LIMIT_50MA, or LIMIT_100MA = 0b11.

◆ setConversionType()

void Adafruit_AS726x::setConversionType ( uint8_t  type)

Set the conversion mode.

Parameters
typethe mode to set the sensor to. Should be one of MODE_0, MODE_1, MODE_2, ONE_SHOT.

◆ setGain()

void Adafruit_AS726x::setGain ( uint8_t  gain)

Set the sensor gain.

Parameters
gainthe gain to set the sensor to. Should be one of GAIN_1X, GAIN_3X7, GAIN_16X, or GAIN_64X = 0b11.

◆ setIntegrationTime()

void Adafruit_AS726x::setIntegrationTime ( uint8_t  time)

Set the integration time for the sensor.

Parameters
timethe integration time to set. The actual integration time will be time*2.8ms

◆ dataReady()

bool Adafruit_AS726x::dataReady ( )
inline

Check if the sensor is ready to return data.

Returns
true if data is ready to be read, false otherwise.

◆ readTemperature()

uint8_t Adafruit_AS726x::readTemperature ( )
inline

Read the on-board temperature sensor.

Returns
the temperature in Centigrade.

◆ readChannel()

uint16_t Adafruit_AS726x::readChannel ( uint8_t  channel)

read an individual raw spectral channel

Parameters
channelthe channel to read
Returns
the reading as a raw 16-bit integer

◆ readViolet()

uint16_t Adafruit_AS726x::readViolet ( )
inline

Read raw violet color value (AS7262 only)

Returns
the violet reading as an unsigned 16-bit integer

◆ readBlue()

uint16_t Adafruit_AS726x::readBlue ( )
inline

Read raw blue color value (AS7262 only)

Returns
the blue reading as an unsigned 16-bit integer

◆ readGreen()

uint16_t Adafruit_AS726x::readGreen ( )
inline

Read raw green color value (AS7262 only)

Returns
the green reading as an unsigned 16-bit integer

◆ readYellow()

uint16_t Adafruit_AS726x::readYellow ( )
inline

Read raw yellow color value (AS7262 only)

Returns
the yellow reading as an unsigned 16-bit integer

◆ readOrange()

uint16_t Adafruit_AS726x::readOrange ( )
inline

Read raw orange color value (AS7262 only)

Returns
the orange reading as an unsigned 16-bit integer

◆ readRed()

uint16_t Adafruit_AS726x::readRed ( )
inline

Read raw red color value (AS7262 only)

Returns
the red reading as an unsigned 16-bit integer

◆ readRawValues()

void Adafruit_AS726x::readRawValues ( uint16_t *  buf,
uint8_t  num = AS726x_NUM_CHANNELS 
)

read the raw channels

Parameters
bufthe buffer to read the data into
numOptional number of channels to read. Defaults to AS726x_NUM_CHANNELS

◆ readCalibratedValue()

float Adafruit_AS726x::readCalibratedValue ( uint8_t  channel)

read an individual calibrated spectral channel

Parameters
channelthe channel to read
Returns
the reading as a raw 16-bit integer

◆ readCalibratedViolet()

float Adafruit_AS726x::readCalibratedViolet ( )
inline

Read calibrated violet color value (AS7262 only)

Returns
the violet reading as a 32-bit floating point number

◆ readCalibratedBlue()

float Adafruit_AS726x::readCalibratedBlue ( )
inline

Read calibrated blue color value (AS7262 only)

Returns
the blue reading as a 32-bit floating point number

◆ readCalibratedGreen()

float Adafruit_AS726x::readCalibratedGreen ( )
inline

Read calibrated green color value (AS7262 only)

Returns
the green reading as a 32-bit floating point number

◆ readCalibratedYellow()

float Adafruit_AS726x::readCalibratedYellow ( )
inline

Read calibrated yellow color value (AS7262 only)

Returns
the yellow reading as a 32-bit floating point number

◆ readCalibratedOrange()

float Adafruit_AS726x::readCalibratedOrange ( )
inline

Read calibrated orange color value (AS7262 only)

Returns
the orange reading as a 32-bit floating point number

◆ readCalibratedRed()

float Adafruit_AS726x::readCalibratedRed ( )
inline

Read calibrated red color value (AS7262 only)

Returns
the red reading as a 32-bit floating point number

◆ readCalibratedValues()

void Adafruit_AS726x::readCalibratedValues ( float *  buf,
uint8_t  num = AS726x_NUM_CHANNELS 
)

read the calibrated channels

Parameters
bufthe buffer to read the data into
numOptional number of channels to read. Defaults to AS726x_NUM_CHANNELS

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