5 #include <twr_scheduler.h>
31 TWR_OPT3001_STATE_ERROR = -1,
32 TWR_OPT3001_STATE_INITIALIZE = 0,
33 TWR_OPT3001_STATE_MEASURE = 1,
34 TWR_OPT3001_STATE_READ = 2,
35 TWR_OPT3001_STATE_UPDATE = 3
37 } twr_opt3001_state_t;
47 bool _measurement_active;
49 twr_opt3001_state_t _state;
51 bool _illuminance_valid;
twr_i2c_channel_t
I2C channels.
void twr_opt3001_init(twr_opt3001_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize OPT3001 driver.
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.
struct twr_opt3001_t twr_opt3001_t
OPT3001 instance.
void twr_opt3001_set_update_interval(twr_opt3001_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_opt3001_get_illuminance_lux(twr_opt3001_t *self, float *lux)
Get measured illuminance in lux.
void twr_opt3001_deinit(twr_opt3001_t *self)
Deinitialize OPT3001 driver.
bool twr_opt3001_measure(twr_opt3001_t *self)
Start measurement manually.
twr_opt3001_event_t
Callback events.
bool twr_opt3001_get_illuminance_raw(twr_opt3001_t *self, uint16_t *raw)
Get measured illuminance as raw value.
@ TWR_OPT3001_EVENT_UPDATE
Update event.
@ TWR_OPT3001_EVENT_ERROR
Error event.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
uint64_t twr_tick_t
Timestamp data type.