Firmware SDK
|
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... | |
Driver for OPT3001 ambient light sensor.
enum 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.
void twr_opt3001_deinit | ( | twr_opt3001_t * | self | ) |
Deinitialize OPT3001 driver.
[in] | self | Instance |
Definition at line 26 of file twr_opt3001.c.
bool twr_opt3001_get_illuminance_lux | ( | twr_opt3001_t * | self, |
float * | lux | ||
) |
Get measured illuminance in lux.
[in] | self | Instance |
[in] | lux | Pointer to variable where result will be stored |
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().
bool twr_opt3001_get_illuminance_raw | ( | twr_opt3001_t * | self, |
uint16_t * | raw | ||
) |
Get measured illuminance as raw value.
[in] | self | Instance |
[in] | raw | Pointer to variable where result will be stored |
Definition at line 71 of file twr_opt3001.c.
Referenced by twr_opt3001_get_illuminance_lux(), and twr_tag_lux_meter_get_illuminance_raw().
void twr_opt3001_init | ( | twr_opt3001_t * | self, |
twr_i2c_channel_t | i2c_channel, | ||
uint8_t | i2c_address | ||
) |
Initialize OPT3001 driver.
[in] | self | Instance |
[in] | i2c_channel | I2C channel |
[in] | i2c_address | I2C device address |
Definition at line 11 of file twr_opt3001.c.
Referenced by twr_module_climate_init(), and twr_tag_lux_meter_init().
bool twr_opt3001_measure | ( | twr_opt3001_t * | self | ) |
Start measurement manually.
[in] | self | Instance |
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().
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.
[in] | self | Instance |
[in] | event_handler | Function address |
[in] | event_param | Optional 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().
void twr_opt3001_set_update_interval | ( | twr_opt3001_t * | self, |
twr_tick_t | interval | ||
) |
Set measurement interval.
[in] | self | Instance |
[in] | interval | Measurement 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().