5 #include <twr_scheduler.h>
31 TWR_SHT20_STATE_ERROR = -1,
32 TWR_SHT20_STATE_INITIALIZE = 0,
33 TWR_SHT20_STATE_MEASURE_RH = 1,
34 TWR_SHT20_STATE_READ_RH = 2,
35 TWR_SHT20_STATE_MEASURE_T = 3,
36 TWR_SHT20_STATE_READ_T = 4,
37 TWR_SHT20_STATE_UPDATE = 5
49 bool _measurement_active;
51 twr_sht20_state_t _state;
54 bool _temperature_valid;
55 uint16_t _reg_humidity;
56 uint16_t _reg_temperature;
twr_i2c_channel_t
I2C channels.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
bool twr_sht20_get_temperature_celsius(twr_sht20_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
struct twr_sht20_t twr_sht20_t
SHT20 instance.
void twr_sht20_init(twr_sht20_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize SHT20.
bool twr_sht20_measure(twr_sht20_t *self)
Start measurement manually.
void twr_sht20_set_update_interval(twr_sht20_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_sht20_get_temperature_raw(twr_sht20_t *self, uint16_t *raw)
Get measured temperature as raw value.
bool twr_sht20_get_humidity_raw(twr_sht20_t *self, uint16_t *raw)
Get measured humidity as raw value.
bool twr_sht20_get_temperature_kelvin(twr_sht20_t *self, float *kelvin)
Get measured temperature in kelvin.
void twr_sht20_deinit(twr_sht20_t *self)
Deinitialize SHT20.
bool twr_sht20_get_humidity_percentage(twr_sht20_t *self, float *percentage)
Get measured humidity as percentage.
void twr_sht20_set_event_handler(twr_sht20_t *self, void(*event_handler)(twr_sht20_t *, twr_sht20_event_t, void *), void *event_param)
Set callback function.
twr_sht20_event_t
Callback events.
bool twr_sht20_get_temperature_fahrenheit(twr_sht20_t *self, float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
@ TWR_SHT20_EVENT_UPDATE
Update event.
@ TWR_SHT20_EVENT_ERROR
Error event.
uint64_t twr_tick_t
Timestamp data type.