5 #include <twr_scheduler.h>
31 TWR_SPS30_STATE_ERROR = -1,
32 TWR_SPS30_STATE_READY = 0,
33 TWR_SPS30_STATE_INITIALIZE = 1,
34 TWR_SPS30_STATE_GET_SERIAL_NUMBER = 2,
35 TWR_SPS30_STATE_READ_SERIAL_NUMBER = 3,
36 TWR_SPS30_STATE_START_MEASUREMENT = 4,
37 TWR_SPS30_STATE_SET_DATAREADY_FLAG = 5,
38 TWR_SPS30_STATE_READ_DATAREADY_FLAG = 6,
39 TWR_SPS30_STATE_GET_MEASUREMENT_DATA = 7,
40 TWR_SPS30_STATE_READ_MEASUREMENT_DATA = 8,
41 TWR_SPS30_STATE_STOP_MEASUREMENT = 9
61 } twr_sps30_mass_concentration_t;
82 } twr_sps30_number_concentration_t;
93 twr_sps30_state_t _state;
94 bool _measurement_valid;
95 twr_sps30_mass_concentration_t _mass_concentration;
96 twr_sps30_number_concentration_t _number_concentration;
97 float _typical_particle_size;
twr_i2c_channel_t
I2C channels.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
twr_sps30_event_t
Callback events.
void twr_sps30_init(twr_sps30_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize SPS30.
struct twr_sps30_t twr_sps30_t
SPS30 instance.
bool twr_sps30_get_mass_concentration(twr_sps30_t *self, twr_sps30_mass_concentration_t *mass_concentration)
Get measured mass concentration in μg/m3.
void twr_sps30_set_startup_time(twr_sps30_t *self, twr_tick_t startup_time)
Set startup time (how long the fan blows air before the measurement)
void twr_sps30_set_update_interval(twr_sps30_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_sps30_measure(twr_sps30_t *self)
Start measurement manually.
void twr_sps30_set_event_handler(twr_sps30_t *self, void(*event_handler)(twr_sps30_t *, twr_sps30_event_t, void *), void *event_param)
Set callback function.
bool twr_sps30_get_typical_particle_size(twr_sps30_t *self, float *typical_particle_size)
Get measured typical particle size in μm.
bool twr_sps30_get_number_concentration(twr_sps30_t *self, twr_sps30_number_concentration_t *number_concentration)
Get measured number concentration in #/cm3.
@ TWR_SPS30_EVENT_UPDATE
Update event.
@ TWR_SPS30_EVENT_ERROR
Error event.
uint64_t twr_tick_t
Timestamp data type.