upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Public Member Functions | |
BH1792 (int bus=0, int addr=0x5b) | |
Init the sensor with specific bus and address. Before starting measurement, one of (EnableSyncMode, EnableNonSyncMode, or EnableSingleMode) has to be called. More... | |
virtual | ~BH1792 () |
Close and free sensor. | |
void | CheckWhoAmI () |
Check "who am I" register value to identify the sensor. More... | |
bool | IsEnabled () |
Checks if the measuremnt on sensor is enabled. More... | |
void | SoftReset () |
Initiates a software reset to the sensor. All register values will be written to their defaults, thus intended operation mode need to be enabled. More... | |
float | GetMeasurementTimeMS () |
Gets the value of measurement time is milli-seconds. More... | |
void | SetGreenLedsCurrent (uint16_t current) |
Sets the green LED Current value. More... | |
int | GetGreenLedsCurrent () |
Gets the green LED current value. More... | |
void | SetIrLedCurrent (uint16_t current) |
Sets the IR LED Current value. More... | |
int | GetIrLedCurrent () |
Gets the green LED current value. More... | |
void | SetIrThreshold (uint16_t threshold) |
Sets interrupt IR threshold value for non-synchronized mode. More... | |
int | GetIrThreshold () |
Gets interrupt IR threshold value. More... | |
int | GetFifoSize () |
Gets the current size of built-in FIFO. More... | |
void | DisableInterrupt () |
Disables interrupt function. Interrupt is enabled by default on all operation modes, so this have to be called after enabling a specific operation mode. More... | |
void | ClearInterrupt () |
Clears the interrupt flag allowing more interrupts to be raised. More... | |
void | StartMeasurement () |
Starts the measuremnt on sensor or enable the sensor. More... | |
void | StopMeasurement () |
void | RestartMeasurement () |
Restart the measurement, This function stops measurement, then re-writes the configuration registers again and start measurement with same configuration. More... | |
std::vector< std::vector< int > > | GetFifoData () |
Gets the fifo data of 32 entries and resets the WATERMARK interrupt flag. More... | |
void | DiscardFifoData () |
Reads and discard the 32 FIFO entries to reset the WATERMARK interrupt flag. More... | |
std::vector< int > | GetGreenData () |
Gets the values from using green LED light. More... | |
std::vector< int > | GetIrData () |
Gets the values from using IR LED light. More... | |
void | EnableSyncMode (uint16_t measFreq, uint16_t green_current) |
Enables and configures the sensor to use synchronized mode. This will use the built-in FIFO and raises a WATERMARK interrupt when FIFO size reaches 32 entries. To clear that interrupt flag FIFO must be read or discarded. This mode uses only green LED. More... | |
void | EnableNonSyncMode (uint16_t ir_current, uint16_t threshold) |
Enabled and configures the sensor to use non-synchronized mode. This mode uses IR_THRESHOLD interrupt, it will raise an interrupt if IR LED ON value is equal or greater than the threshold value. Interrupt must be cleared before receiving new interrupts. This mode uses only IR LED. More... | |
void | EnableSingleMode (LED_TYPES led_type, uint16_t current) |
Enables and configures the sensor to use single mode. This sets the sensor to take only one measurement and raise an interrupt after measurement is finished. Interrupt flags has to be cleared to recieved new interrupts. This mode uses both green and IR LEDs. More... | |
void | InstallISR (mraa_gpio_edge_t edge, int pin, void(*isr)(void *), void *isr_args) |
Installs the ISR to a given GPIO pin. More... | |
void | InstallISR (int pin, void(*isr)(void *), void *isr_args) |
Installs the ISR to a given GPIO pin. More... | |
void | RemoveISR () |
Removes the ISR if it is installed. | |
std::string | RegistersDump () |
Gets a dump of configuration registers as a string. More... | |
BH1792 | ( | int | bus = 0 , |
int | addr = 0x5b |
||
) |
bus | I2C bus number |
addr | I2C sensor address |
std::runtime_error | on initialization failure |
void CheckWhoAmI | ( | ) |
std::runtime_error | if this value is incorrect |
bool IsEnabled | ( | ) |
void SoftReset | ( | ) |
std::runtime_error | if software reset fails |
float GetMeasurementTimeMS | ( | ) |
std::runtime_error | if reading measurement time fails |
void SetGreenLedsCurrent | ( | uint16_t | current | ) |
current | The current value, accepted values are between 0-63 |
std::runtime_error | if setting current fails |
std::range_error | if current value out of range |
int GetGreenLedsCurrent | ( | ) |
std::runtime_error | if reading current fails |
void SetIrLedCurrent | ( | uint16_t | current | ) |
current | The current value, accepted values are between 0-63 |
std::runtime_error | if setting current fails |
std::range_error | if current value out of range |
int GetIrLedCurrent | ( | ) |
std::runtime_error | if reading current fails |
void SetIrThreshold | ( | uint16_t | threshold | ) |
threshold | Value to be written, range 0-65536 |
std::runtime_error | if setting threshold fails |
int GetIrThreshold | ( | ) |
std::runtime_error | if reading current fails |
int GetFifoSize | ( | ) |
std::runtime_error | if reading size fails |
void DisableInterrupt | ( | ) |
std::runtime_error | if setting interrupt disable bits fails |
void ClearInterrupt | ( | ) |
std::runtime_error | if clearing interrupt fails |
void StartMeasurement | ( | ) |
std::runtime_error | if starting measurement fails |
void StopMeasurement | ( | ) |
Stops the measurement by setting the software reset bit. This function will reset all config registers. To resume from previous configuration call RestartMeasurement().
std::runtime_error | if disabling measurement fails |
void RestartMeasurement | ( | ) |
std::runtime_error | if restarting measurement fails |
std::vector< std::vector< int > > GetFifoData | ( | ) |
std::runtime_error | if reading FIFO data fails |
void DiscardFifoData | ( | ) |
std::runtime_error | if reading FIFO data fails |
std::vector< int > GetGreenData | ( | ) |
std::runtime_error | if reading green data fails |
std::vector< int > GetIrData | ( | ) |
std::runtime_error | if reading IR data fails |
void EnableSyncMode | ( | uint16_t | measFreq, |
uint16_t | green_current | ||
) |
You need to call StartMeasurement() after this.
measFreq | Measurement frequncy mode, valid values 32, 64, 128, 256, 1024 |
green_current | Green LED current value |
std::runtime_error | if enabling synchronized mode fails |
std::invalid_argument | if measurement frequency is invalid |
void EnableNonSyncMode | ( | uint16_t | ir_current, |
uint16_t | threshold | ||
) |
You need to call StartMeasurement() after this.
ir_current | The IR LED current value |
threshold | The IR LED interrupt threshold value |
std::runtime_error | if enabling non-synchronized mode fails |
void EnableSingleMode | ( | LED_TYPES | led_type, |
uint16_t | current | ||
) |
You need to call StartMeasurement() after this. If you need to get continuous values, clear interrupt and StartMeasurement() continuously.
led_type | LED light type to use, takes GREEN or IR (0 or 1) |
current | The chosen led_type current value |
std::runtime_error | if enabling single mode fails |
void InstallISR | ( | mraa_gpio_edge_t | edge, |
int | pin, | ||
void(*)(void *) | isr, | ||
void * | isr_args | ||
) |
edge | Edge type to raise ISR with, of type mraa_gpio_edge_t |
pin | GPIO pin number |
isr | Pointer to ISR function |
isr_args | Arguments to pass the ISR function |
std::runtime_error | if installing ISR fails |
void InstallISR | ( | int | pin, |
void(*)(void *) | isr, | ||
void * | isr_args | ||
) |
pin | GPIO pin number |
isr | Pointer to ISR function |
isr_args | Arguments to pass the ISR function |
std::runtime_error | if installing ISR fails |
std::string RegistersDump | ( | ) |
std::runtime_error | if reading one of the registers fails |