upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _bh1750_context |
Functions | |
bh1750_context | bh1750_init (int bus, uint8_t addr, BH1750_OPMODES_T mode) |
void | bh1750_close (const bh1750_context dev) |
upm_result_t | bh1750_get_lux (const bh1750_context dev, float *lux) |
bool | bh1750_power_up (const bh1750_context dev) |
bool | bh1750_power_down (const bh1750_context dev) |
bool | bh1750_reset (const bh1750_context dev) |
upm_result_t | bh1750_send_command (const bh1750_context dev, uint8_t cmd) |
upm_result_t | bh1750_read_data (const bh1750_context dev, uint16_t *data) |
upm_result_t | bh1750_set_opmode (const bh1750_context dev, BH1750_OPMODES_T mode) |
Typedefs | |
typedef struct _bh1750_context * | bh1750_context |
bh1750_context bh1750_init | ( | int | bus, |
uint8_t | addr, | ||
BH1750_OPMODES_T | mode | ||
) |
Initialize the BH1750
bus | I2C bus |
addr | I2C address |
mode | operating mode, one of the BH1750_OPMODES_T values |
void bh1750_close | ( | const bh1750_context | dev | ) |
Sensor destructor function. Frees any allocated resources.
dev | The device context |
upm_result_t bh1750_get_lux | ( | const bh1750_context | dev, |
float * | lux | ||
) |
Gets the Lux value.
dev | The device context |
lux | float pointer in which to store the lux value |
bool bh1750_power_up | ( | const bh1750_context | dev | ) |
Power up the device.
dev | The device context |
bool bh1750_power_down | ( | const bh1750_context | dev | ) |
Power down the device.
dev | The device context |
bool bh1750_reset | ( | const bh1750_context | dev | ) |
Reset the device. This doesn't really have much purpose. The device must be powered up for this command to work. In addition, this command will simply clear the measurement register to 0.
dev | The device context |
upm_result_t bh1750_send_command | ( | const bh1750_context | dev, |
uint8_t | cmd | ||
) |
Write a command to the device via I2C.
dev | The device context |
cmd | The command to write, one of the BH1750_CMD* values |
upm_result_t bh1750_read_data | ( | const bh1750_context | dev, |
uint16_t * | data | ||
) |
Read the 2 result bytes from the device via I2C.
dev | The device context |
data | Data read in from the device as a uint16_t |
upm_result_t bh1750_set_opmode | ( | const bh1750_context | dev, |
BH1750_OPMODES_T | mode | ||
) |
Setup the device context parameters and the device to match the selected operating mode.
dev | The device context |
mode | operating mode, one of the BH1750_OPMODES_T values |
typedef struct _bh1750_context * bh1750_context |
device context