Firmware SDK
twr_opt3001

Driver for OPT3001 ambient light sensor. More...

Typedefs

typedef struct twr_opt3001_t twr_opt3001_t
 OPT3001 instance.
 

Enumerations

enum  twr_opt3001_event_t {
  TWR_OPT3001_EVENT_ERROR = 0 ,
  TWR_OPT3001_EVENT_UPDATE = 1
}
 Callback events. More...
 

Functions

void twr_opt3001_init (twr_opt3001_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
 Initialize OPT3001 driver. More...
 
void twr_opt3001_deinit (twr_opt3001_t *self)
 Deinitialize OPT3001 driver. More...
 
void twr_opt3001_set_event_handler (twr_opt3001_t *self, void(*event_handler)(twr_opt3001_t *, twr_opt3001_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_opt3001_set_update_interval (twr_opt3001_t *self, twr_tick_t interval)
 Set measurement interval. More...
 
bool twr_opt3001_measure (twr_opt3001_t *self)
 Start measurement manually. More...
 
bool twr_opt3001_get_illuminance_raw (twr_opt3001_t *self, uint16_t *raw)
 Get measured illuminance as raw value. More...
 
bool twr_opt3001_get_illuminance_lux (twr_opt3001_t *self, float *lux)
 Get measured illuminance in lux. More...
 

Detailed Description

Driver for OPT3001 ambient light sensor.

Enumeration Type Documentation

◆ twr_opt3001_event_t

Callback events.

Enumerator
TWR_OPT3001_EVENT_ERROR 

Error event.

TWR_OPT3001_EVENT_UPDATE 

Update event.

Definition at line 13 of file twr_opt3001.h.

Function Documentation

◆ twr_opt3001_deinit()

void twr_opt3001_deinit ( twr_opt3001_t self)

Deinitialize OPT3001 driver.

Parameters
[in]selfInstance

Definition at line 26 of file twr_opt3001.c.

Here is the call graph for this function:

◆ twr_opt3001_get_illuminance_lux()

bool twr_opt3001_get_illuminance_lux ( twr_opt3001_t self,
float *  lux 
)

Get measured illuminance in lux.

Parameters
[in]selfInstance
[in]luxPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 83 of file twr_opt3001.c.

Referenced by twr_module_climate_get_illuminance_lux(), and twr_tag_lux_meter_get_illuminance_lux().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_opt3001_get_illuminance_raw()

bool twr_opt3001_get_illuminance_raw ( twr_opt3001_t self,
uint16_t *  raw 
)

Get measured illuminance as raw value.

Parameters
[in]selfInstance
[in]rawPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 71 of file twr_opt3001.c.

Referenced by twr_opt3001_get_illuminance_lux(), and twr_tag_lux_meter_get_illuminance_raw().

Here is the caller graph for this function:

◆ twr_opt3001_init()

void twr_opt3001_init ( twr_opt3001_t self,
twr_i2c_channel_t  i2c_channel,
uint8_t  i2c_address 
)

Initialize OPT3001 driver.

Parameters
[in]selfInstance
[in]i2c_channelI2C channel
[in]i2c_addressI2C device address

Definition at line 11 of file twr_opt3001.c.

Referenced by twr_module_climate_init(), and twr_tag_lux_meter_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_opt3001_measure()

bool twr_opt3001_measure ( twr_opt3001_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 57 of file twr_opt3001.c.

Referenced by twr_module_climate_measure_all_sensors(), twr_module_climate_measure_lux_meter(), twr_opt3001_set_update_interval(), and twr_tag_lux_meter_measure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_opt3001_set_event_handler()

void twr_opt3001_set_event_handler ( twr_opt3001_t self,
void(*)(twr_opt3001_t *, twr_opt3001_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 35 of file twr_opt3001.c.

Referenced by twr_module_climate_init(), and twr_tag_lux_meter_set_event_handler().

Here is the caller graph for this function:

◆ twr_opt3001_set_update_interval()

void twr_opt3001_set_update_interval ( twr_opt3001_t self,
twr_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 41 of file twr_opt3001.c.

Referenced by twr_module_climate_set_update_interval_all_sensors(), twr_module_climate_set_update_interval_lux_meter(), and twr_tag_lux_meter_set_update_interval().

Here is the call graph for this function:
Here is the caller graph for this function: