Skip to content

File syn_lux.h

FileList > sensor > syn_lux.h

Go to the source code of this file

Generic Ambient Light & RGB Color Sensor Driver (BH1750, TSL2561, TCS34725).

  • #include "../common/syn_defs.h"
  • #include "../drivers/syn_soft_i2c.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Lux
Generic Light & Color Sensor Context.

Public Types

Type Name
enum SYN_LuxType
Light & Color Sensor Type.

Public Functions

Type Name
void syn_lux_feed_lux (SYN_Lux * sensor, float lux)
Feed raw illuminance reading in Lux (for BH1750/TSL2561).
void syn_lux_feed_rgbc (SYN_Lux * sensor, uint16_t r, uint16_t g, uint16_t b, uint16_t c)
Feed raw RGBC channels (for TCS34725).
uint16_t syn_lux_get_color_temp_k (const SYN_Lux * sensor)
Get Correlated Color Temperature in Kelvin.
float syn_lux_get_lux (const SYN_Lux * sensor)
Get ambient illuminance in Lux.
SYN_Status syn_lux_init (SYN_Lux * sensor, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint8_t i2c_addr, SYN_LuxType type)
Initialize Light & Color Sensor.

Public Types Documentation

enum SYN_LuxType

Light & Color Sensor Type.

enum SYN_LuxType {
    SYN_LUX_BH1750 = 0,
    SYN_LUX_TSL2561 = 1,
    SYN_LUX_TCS34725 = 2
};


Public Functions Documentation

function syn_lux_feed_lux

Feed raw illuminance reading in Lux (for BH1750/TSL2561).

void syn_lux_feed_lux (
    SYN_Lux * sensor,
    float lux
) 

Parameters:

  • sensor Lux sensor context.
  • lux Ambient light value in Lux.

function syn_lux_feed_rgbc

Feed raw RGBC channels (for TCS34725).

void syn_lux_feed_rgbc (
    SYN_Lux * sensor,
    uint16_t r,
    uint16_t g,
    uint16_t b,
    uint16_t c
) 

Parameters:

  • sensor Lux sensor context.
  • r Red channel raw ADC.
  • g Green channel raw ADC.
  • b Blue channel raw ADC.
  • c Clear channel raw ADC.

function syn_lux_get_color_temp_k

Get Correlated Color Temperature in Kelvin.

uint16_t syn_lux_get_color_temp_k (
    const SYN_Lux * sensor
) 

Parameters:

  • sensor Lux sensor context.

Returns:

Color Temp in K.


function syn_lux_get_lux

Get ambient illuminance in Lux.

float syn_lux_get_lux (
    const SYN_Lux * sensor
) 

Parameters:

  • sensor Lux sensor context.

Returns:

Lux value.


function syn_lux_init

Initialize Light & Color Sensor.

SYN_Status syn_lux_init (
    SYN_Lux * sensor,
    SYN_GPIO_Pin scl,
    SYN_GPIO_Pin sda,
    uint8_t i2c_addr,
    SYN_LuxType type
) 

Parameters:

  • sensor Lux sensor context.
  • scl I2C SCL GPIO pin.
  • sda I2C SDA GPIO pin.
  • i2c_addr I2C slave address (e.g. 0x23 or 0x29).
  • type Sensor type (BH1750, TSL2561, TCS34725).

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/sensor/syn_lux.h