39 #include <linux/i2c-dev.h>
40 #include <sys/ioctl.h>
42 #include <sys/types.h>
136 errno, strerror(errno));
142 int result = close(bus);
145 errno, strerror(errno));
153 return ioctl(
sensor_bus, I2C_SLAVE, device_address);
160 "List of available ambient sensors:\n\t- ";
163 int sensor_count = 0;
164 int multi_channel_initialized = -1;
174 sensor_available[i] =
true;
180 strncat(message,
"\n\t- ",
sizeof(message) - 1);
183 sensor_available[i] =
false;
184 multi_channel_initialized = -1;
189 if (sensor_count > 0) {
190 message[strlen(message) - 3] = 0;
200 int sensor_count = 0;
201 int multi_channel_read = -1;
204 if (sensor_available[i]) {
224 if (sensor_available[i]) {
int bme280_init(int sensor_identifier)
int32_t bme280_get_value(int sensor_identifier, int channel)
int bme280_read(int sensor_identifier)
void bme280_deinit(int sensor_identifier)
#define BME280_CHANNEL_TEMPERATURE
#define BME280_CHANNEL_PRESSURE
#define BME280_I2C_ADDRESS_LEFT
#define BME280_CHANNEL_HUMIDITY
int rl_log(rl_log_level_t log_level, char const *const format,...)
@ RL_LOG_INFO
Information.
#define SUCCESS
Function return value for successful completion.
@ RL_UNIT_LUX
Lux (illuminance)
@ RL_UNIT_INTEGER
Integer channel (numeric)
@ RL_UNIT_PASCAL
Pascal (pressure)
@ RL_UNIT_DEG_C
Degree celsius (temperature)
int sensor_bus
I2C sensor bus identifier for communication.
int sensors_open_bus(void)
int sensors_scan(bool sensor_available[SENSOR_REGISTRY_SIZE])
int sensors_close_bus(int bus)
const rl_sensor_t SENSOR_REGISTRY[SENSOR_REGISTRY_SIZE]
int sensors_get_bus(void)
void sensors_close(bool const sensor_available[SENSOR_REGISTRY_SIZE])
void sensors_deinit(void)
int sensors_init_comm(uint8_t device_address)
int sensors_read(int32_t *const sensor_data, bool const sensor_available[SENSOR_REGISTRY_SIZE])
#define SENSOR_REGISTRY_SIZE
Number of sensor registered.
#define MAX_MESSAGE_LENGTH
int32_t(* get_value)(int, int)
int32_t tsl4531_get_value(int sensor_identifier, int channel)
int tsl4531_init(int sensor_identifier)
int tsl4531_read(int sensor_identifier)
void tsl4531_deinit(int sensor_identifier)
#define TSL4531_CHANNEL_DEFAULT
#define TSL4531_I2C_ADDRESS_RIGHT
#define TSL4531_I2C_ADDRESS_LEFT