A library for the Avago ADJD-S311-CR999 Color Light Sensor

Dependents:   ADJD-S311_HelloWorld

Embed: (wiki syntax)

« Back to documentation index

ADJDs311 Class Reference

ADJDs311 Class Reference

A ADJD-S311 color sensor class. More...

#include <ADJDs311.h>

Public Member Functions

 ADJDs311 (PinName sda, PinName scl, PinName led)
 Create a color sensor interface.
void calibrate ()
 Calibrate the capacitance and integration time slot so that the current readings are as close to 1000 as possible and the difference between RGB readings are as small as possible.
void ledMode (bool ledOn)
 Turn the on board LED on/off.
RGBC getOffset ()
 Get the current offset stored in offset registers.
RGBC setOffset (bool useOffset=true)
 Use the current light condition to set the offset.
void offsetMode (bool useOffset)
 Use the offset registers to automatically subtract offset from the readings.
RGBC read ()
 Read in the color value from the sensor.
RGBC getColorCap ()
 Get the gain of number of capacitor for each channel, in the range of 0 to 15.
RGBC getColorInt ()
 Get the gain of number of integration time slot, in the range of 0 to 4095.
void setColorCap (int red, int green, int blue, int clear)
 Set the gain of number of capacitor for each channel, in the range of 0 to 15.
void setColorInt (int red, int green, int blue, int clear)
 Set the gain of number of integration time slot, in the range of 0 to 4095.

Detailed Description

A ADJD-S311 color sensor class.

Definition at line 55 of file ADJDs311.h.


Constructor & Destructor Documentation

ADJDs311 ( PinName  sda,
PinName  scl,
PinName  led 
)

Create a color sensor interface.

Parameters:
sdaPin connected to sda of color sensor
sclPin connected to scl of color sensor
ledPin connected to on board led of the sensor

Definition at line 5 of file ADJDs311.cpp.


Member Function Documentation

void calibrate (  )

Calibrate the capacitance and integration time slot so that the current readings are as close to 1000 as possible and the difference between RGB readings are as small as possible.

Definition at line 276 of file ADJDs311.cpp.

RGBC getColorCap (  )

Get the gain of number of capacitor for each channel, in the range of 0 to 15.

Less capacitor will give higher sensitivity.

Returns:
Structure containing the gain of number of capacitor for each channel.

Definition at line 52 of file ADJDs311.cpp.

RGBC getColorInt (  )

Get the gain of number of integration time slot, in the range of 0 to 4095.

More integration time slot will give higher sensitivity.

Returns:
Structure containing the gain of number of integration time slot for each channel.

Definition at line 58 of file ADJDs311.cpp.

RGBC getOffset (  )

Get the current offset stored in offset registers.

Returns:
Current offset stored in offset registers

Definition at line 301 of file ADJDs311.cpp.

void ledMode ( bool  ledOn )

Turn the on board LED on/off.

Parameters:
ledOnWhether to turn the LED on.

Definition at line 285 of file ADJDs311.cpp.

void offsetMode ( bool  useOffset )

Use the offset registers to automatically subtract offset from the readings.

Parameters:
useOffsetWether to use the offset

Definition at line 290 of file ADJDs311.cpp.

RGBC read (  )

Read in the color value from the sensor.

Returns:
Structure containing the value of red, green, blue and clear

Definition at line 38 of file ADJDs311.cpp.

void setColorCap ( int  red,
int  green,
int  blue,
int  clear 
)

Set the gain of number of capacitor for each channel, in the range of 0 to 15.

Less capacitor will give higher sensitivity.

Parameters:
redgain value for red
greengain value for green
bluegain value for blue
cleargain value for clear

Definition at line 64 of file ADJDs311.cpp.

void setColorInt ( int  red,
int  green,
int  blue,
int  clear 
)

Set the gain of number of integration time slot, in the range of 0 to 4095.

More integration time slot will give higher sensitivity.

Parameters:
redgain value for red
greengain value for green
bluegain value for blue
cleargain value for clear

Definition at line 78 of file ADJDs311.cpp.

RGBC setOffset ( bool  useOffset = true )

Use the current light condition to set the offset.

Parameters:
useOffsetWether to use the offset
Returns:
The offset set

Definition at line 306 of file ADJDs311.cpp.