1 #include <twr_module_climate.h>
2 #include <twr_tmp112.h>
4 #include <twr_opt3001.h>
5 #include <twr_mpl3115a2.h>
25 } _twr_module_climate;
39 memset(&_twr_module_climate, 0,
sizeof(_twr_module_climate));
59 _twr_module_climate.event_handler = event_handler;
60 _twr_module_climate.event_param = event_param;
65 _twr_module_climate.update_interval.thermometer = interval;
66 _twr_module_climate.update_interval.hygrometer = interval;
83 _twr_module_climate.update_interval.thermometer = interval;
92 _twr_module_climate.update_interval.hygrometer = interval;
215 if (_twr_module_climate.event_handler == NULL)
235 if (_twr_module_climate.event_handler == NULL)
264 if (_twr_module_climate.event_handler == NULL)
298 if (_twr_module_climate.event_handler == NULL)
318 if (_twr_module_climate.event_handler == NULL)
@ TWR_I2C_I2C0
I2C channel I2C0.
void twr_module_climate_set_update_interval_barometer(twr_tick_t interval)
Set measurement interval for barometer.
bool twr_module_climate_get_temperature_kelvin(float *kelvin)
Get measured temperature in kelvin.
void twr_module_climate_set_update_interval_thermometer(twr_tick_t interval)
Set measurement interval for thermometer.
twr_module_climate_event_t
Callback events.
bool twr_module_climate_get_pressure_pascal(float *pascal)
Get measured pressure in Pascal.
bool twr_module_climate_get_temperature_fahrenheit(float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
bool twr_module_climate_measure_hygrometer(void)
Start hygrometer measurement manually.
bool twr_module_climate_get_temperature_celsius(float *celsius)
Get measured temperature in degrees of Celsius.
void twr_module_climate_set_event_handler(void(*event_handler)(twr_module_climate_event_t, void *), void *event_param)
Set callback function.
void twr_module_climate_set_update_interval_all_sensors(twr_tick_t interval)
Set measurement interval for all sensors.
bool twr_module_climate_measure_lux_meter(void)
Start lux meter measurement manually.
void twr_module_climate_init(void)
Initialize HARDWARIO Climate Module.
twr_module_climate_revision_t
Climate Module hardware revision.
bool twr_module_climate_measure_all_sensors(void)
Start measurement of all sensors manually.
bool twr_module_climate_measure_thermometer(void)
Start thermometer measurement manually.
void twr_module_climate_set_update_interval_hygrometer(twr_tick_t interval)
Set measurement interval for hygrometer.
bool twr_module_climate_get_illuminance_lux(float *lux)
Get measured illuminance in lux.
bool twr_module_climate_measure_barometer(void)
Start barometer measurement manually.
bool twr_module_climate_get_humidity_percentage(float *percentage)
Get measured humidity as percentage.
void twr_module_climate_set_update_interval_lux_meter(twr_tick_t interval)
Set measurement interval for lux meter.
bool twr_module_climate_get_altitude_meter(float *meter)
Get measured altitude in meters.
@ TWR_MODULE_CLIMATE_EVENT_UPDATE_LUX_METER
Update event for lux meter.
@ TWR_MODULE_CLIMATE_EVENT_UPDATE_HYGROMETER
Update event for hygrometer.
@ TWR_MODULE_CLIMATE_EVENT_ERROR_BAROMETER
Error event for barometer.
@ TWR_MODULE_CLIMATE_EVENT_UPDATE_THERMOMETER
Update event for thermometer.
@ TWR_MODULE_CLIMATE_EVENT_ERROR_LUX_METER
Error event for lux meter.
@ TWR_MODULE_CLIMATE_EVENT_UPDATE_BAROMETER
Update event for barometer.
@ TWR_MODULE_CLIMATE_EVENT_ERROR_HYGROMETER
Error event for hygrometer.
@ TWR_MODULE_CLIMATE_EVENT_ERROR_THERMOMETER
Error event for thermometer.
@ TWR_MODULE_CLIMATE_REVISION_R2
Hardware revision R2.
@ TWR_MODULE_CLIMATE_REVISION_R1
Hardware revision R1.
void twr_mpl3115a2_init(twr_mpl3115a2_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize MPL3115A2.
bool twr_mpl3115a2_get_pressure_pascal(twr_mpl3115a2_t *self, float *pascal)
Get measured pressured in Pascal.
bool twr_mpl3115a2_measure(twr_mpl3115a2_t *self)
Start measurement manually.
void twr_mpl3115a2_set_event_handler(twr_mpl3115a2_t *self, void(*event_handler)(twr_mpl3115a2_t *, twr_mpl3115a2_event_t, void *), void *event_param)
Set callback function.
struct twr_mpl3115a2_t twr_mpl3115a2_t
MPL3115A2 instance.
twr_mpl3115a2_event_t
Callback events.
void twr_mpl3115a2_set_update_interval(twr_mpl3115a2_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_mpl3115a2_get_altitude_meter(twr_mpl3115a2_t *self, float *meter)
Get measured altitude in meters.
@ TWR_MPL3115A2_EVENT_ERROR
Error event.
@ TWR_MPL3115A2_EVENT_UPDATE
Update event.
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.
bool twr_opt3001_measure(twr_opt3001_t *self)
Start measurement manually.
twr_opt3001_event_t
Callback events.
@ TWR_OPT3001_EVENT_UPDATE
Update event.
@ TWR_OPT3001_EVENT_ERROR
Error event.
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.
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.
@ TWR_SHT20_EVENT_UPDATE
Update event.
@ TWR_SHT20_EVENT_ERROR
Error event.
void twr_sht30_set_update_interval(twr_sht30_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_sht30_get_temperature_celsius(twr_sht30_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
bool twr_sht30_measure(twr_sht30_t *self)
Start measurement manually.
struct twr_sht30_t twr_sht30_t
SHT30 instance.
void twr_sht30_deinit(twr_sht30_t *self)
Deinitialize SHT30.
bool twr_sht30_get_temperature_kelvin(twr_sht30_t *self, float *kelvin)
Get measured temperature in kelvin.
bool twr_sht30_get_temperature_fahrenheit(twr_sht30_t *self, float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
twr_sht30_event_t
Callback events.
void twr_sht30_set_event_handler(twr_sht30_t *self, void(*event_handler)(twr_sht30_t *, twr_sht30_event_t, void *), void *event_param)
Set callback function.
bool twr_sht30_get_humidity_percentage(twr_sht30_t *self, float *percentage)
Get measured humidity as percentage.
void twr_sht30_init(twr_sht30_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize SHT30.
@ TWR_SHT30_EVENT_ERROR
Error event.
@ TWR_SHT30_EVENT_UPDATE
Update event.
#define TWR_TICK_INFINITY
Maximum timestamp value.
uint64_t twr_tick_t
Timestamp data type.
bool twr_tmp112_get_temperature_kelvin(twr_tmp112_t *self, float *kelvin)
Get measured temperature in kelvin.
twr_tmp112_event_t
Callback events.
void twr_tmp112_set_update_interval(twr_tmp112_t *self, twr_tick_t interval)
Set measurement interval.
void twr_tmp112_set_event_handler(twr_tmp112_t *self, void(*event_handler)(twr_tmp112_t *, twr_tmp112_event_t, void *), void *event_param)
Set callback function.
bool twr_tmp112_measure(twr_tmp112_t *self)
Start measurement manually.
struct twr_tmp112_t twr_tmp112_t
TMP112 instance.
void twr_tmp112_deinit(twr_tmp112_t *self)
Deinitialize TMP112.
bool twr_tmp112_get_temperature_celsius(twr_tmp112_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
bool twr_tmp112_get_temperature_fahrenheit(twr_tmp112_t *self, float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
void twr_tmp112_init(twr_tmp112_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize TMP112.
@ TWR_TMP112_EVENT_ERROR
Error event.
@ TWR_TMP112_EVENT_UPDATE
Update event.