libyggdrasil  v1.0.0
color_sensor.h File Reference

Driver to use the TCS3472 color sensor. More...

Include dependency graph for color_sensor.h:

Go to the source code of this file.

Enumerations

enum  ColorSensorIntegrationTime {
  ColorSensorIntegrationTime_2_4ms = 0xFF, ColorSensorIntegrationTime_10ms = 0xFB, ColorSensorIntegrationTime_24ms = 0xF6, ColorSensorIntegrationTime_50ms = 0xEB,
  ColorSensorIntegrationTime_101ms = 0xD5, ColorSensorIntegrationTime_154ms = 0xC0, ColorSensorIntegrationTime_700ms = 0x00
}
 Integration time = (256 - IntegrationTime) * 2.4ms. More...
 
enum  ColorSensorGain { ColorSensorGain_1x = 0x00, ColorSensorGain_4x = 0x01, ColorSensorGain_16x = 0x02, ColorSensorGain_60x = 0x03 }
 Gain settings. More...
 

Functions

C_LINKAGE bool yggdrasil_ColorSensor_Init (void)
 Initialization of the TCS3472 color sensor. More...
 
C_LINKAGE void yggdrasil_ColorSensor_SetIntegrationTime (enum ColorSensorIntegrationTime integrationTime)
 Set the integration time. More...
 
C_LINKAGE void yggdrasil_ColorSensor_SetGain (enum ColorSensorGain gain)
 Set the gain. More...
 
C_LINKAGE void yggdrasil_ColorSensor_Enable (void)
 Enable the sensor. More...
 
C_LINKAGE void yggdrasil_ColorSensor_Disable (void)
 Disables the sensor. More...
 
C_LINKAGE u16 yggdrasil_ColorSensor_StartConversion (void)
 Start a conversion and returns the set integration time. More...
 
C_LINKAGE bool yggdrasil_ColorSensor_IsDone (void)
 Used to poll a conversion. More...
 
C_LINKAGE RGBA8 yggdrasil_ColorSensor_GetColor8 (bool restartConversion)
 Get the color values and start a new measurement (optional) More...
 
C_LINKAGE RGBA16 yggdrasil_ColorSensor_GetColor16 (bool restartConversion)
 Get the color values and start a new measurement (optional) More...
 

Detailed Description

Driver to use the TCS3472 color sensor.

Author
Fabian Weber, Nikolaij Saegesser

Enumeration Type Documentation

◆ ColorSensorGain

Gain settings.

Enumerator
ColorSensorGain_1x 

No gain.

ColorSensorGain_4x 

4x gain

ColorSensorGain_16x 

16x gain

ColorSensorGain_60x 

60x gain

◆ ColorSensorIntegrationTime

Integration time = (256 - IntegrationTime) * 2.4ms.

Enumerator
ColorSensorIntegrationTime_2_4ms 

2.4ms - 1 cycle

ColorSensorIntegrationTime_10ms 

10ms - 4 cycles

ColorSensorIntegrationTime_24ms 

24ms - 10 cycles

ColorSensorIntegrationTime_50ms 

50ms - 20 cycles

ColorSensorIntegrationTime_101ms 

101ms - 42 cycles

ColorSensorIntegrationTime_154ms 

154ms - 64 cycles

ColorSensorIntegrationTime_700ms 

700ms - 256 cycles

Function Documentation

◆ yggdrasil_ColorSensor_Disable()

C_LINKAGE void yggdrasil_ColorSensor_Disable ( void  )

Disables the sensor.

◆ yggdrasil_ColorSensor_Enable()

C_LINKAGE void yggdrasil_ColorSensor_Enable ( void  )

Enable the sensor.

Note
This function does not start a conversion

◆ yggdrasil_ColorSensor_GetColor16()

C_LINKAGE RGBA16 yggdrasil_ColorSensor_GetColor16 ( bool  restartConversion)

Get the color values and start a new measurement (optional)

Note
The integration time must be passed since the last read
Parameters
restartConversionRestart a measurement after reading with the same setting
Returns
Color RGB and brightness value (all 16 Bit)

◆ yggdrasil_ColorSensor_GetColor8()

C_LINKAGE RGBA8 yggdrasil_ColorSensor_GetColor8 ( bool  restartConversion)

Get the color values and start a new measurement (optional)

Note
The integration time must be passed since the last read
Parameters
restartConversionRestart a measurement after reading with the same setting
Returns
Color RGBA8 value

◆ yggdrasil_ColorSensor_Init()

C_LINKAGE bool yggdrasil_ColorSensor_Init ( void  )

Initialization of the TCS3472 color sensor.

Note
This function does start a conversion. Values for integration time (2.4ms) and gain (1x) are set
Returns
True when the connected device matched the device id, false when not

◆ yggdrasil_ColorSensor_IsDone()

C_LINKAGE bool yggdrasil_ColorSensor_IsDone ( void  )

Used to poll a conversion.

Returns
True when the conversion is finished, false when not

◆ yggdrasil_ColorSensor_SetGain()

C_LINKAGE void yggdrasil_ColorSensor_SetGain ( enum ColorSensorGain  gain)

Set the gain.

Note
value can be 1x, 4x, 16x and 60x
Parameters
gainGain value

◆ yggdrasil_ColorSensor_SetIntegrationTime()

C_LINKAGE void yggdrasil_ColorSensor_SetIntegrationTime ( enum ColorSensorIntegrationTime  integrationTime)

Set the integration time.

Note
Integration time = (256 - IntegrationTime) * 2.4ms
Parameters
integrationTimeIntegration time value

◆ yggdrasil_ColorSensor_StartConversion()

C_LINKAGE u16 yggdrasil_ColorSensor_StartConversion ( void  )

Start a conversion and returns the set integration time.

Returns
integration time in ms