upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions
BH1749 Class Reference

Public Member Functions

 BH1749 (int bus=0, int addr=0x39)
 Initialize a sensor instance with bus and address. More...
 
virtual ~BH1749 ()
 Close and free sensor.
 
void Enable ()
 Enables RGB color measurement on the sensor. More...
 
void Disable ()
 Disables RGB color measurement on the sensor. More...
 
void CheckWhoAmI ()
 Check "who am I" register value to identify the sensor. More...
 
void SensorInit (OPERATING_MODES opMode, MEAS_TIMES measTime, RGB_GAINS rgbGain, IR_GAINS irGain, INT_SOURCES intSource)
 Initializes (writes) configuration values to sensor. More...
 
void SetOperatingMode (OPERATING_MODES opMode)
 Sets operating mode (interrupt persistance) More...
 
int GetOperatingMode ()
 Gets operating mode (interrupt persistance) value. More...
 
void SetMeasurementTime (MEAS_TIMES measTime)
 Sets measurement time (ODR) More...
 
int GetMeasurementTime ()
 Gets measurement time (ODR) value. More...
 
void SetRgbGain (RGB_GAINS rgbGain)
 Sets RGB gain value. More...
 
int GetRgbGain ()
 Gets RGB gain value. More...
 
void SetIrGain (IR_GAINS irGain)
 Sets IR gain value. More...
 
int GetIrGain ()
 Gets IR gain value. More...
 
void SetIntSource (INT_SOURCES intSource)
 Sets interrupt source value. More...
 
char GetInterruptSourceChar ()
 Gets interrupt source value. More...
 
void EnableInterrupt ()
 Enables interrupt mode. More...
 
void DisableInterrupt ()
 Disables interrupt mode. More...
 
void ResetInterrupt ()
 Resets interrupt status (clear) to allow new interrupt reads. More...
 
bool IsInterrupted ()
 Gets interrupt status, whether interrupt is raised or not. More...
 
bool IsInterruptEnabled ()
 Gets interrupt mode status. More...
 
void SoftReset ()
 Initiates a software reset to the sensor. All register values will be written to their defaults, thus sensor_init() must be called after this, and thresholds also needs to be set. More...
 
void SetThresholdHigh (uint16_t threshold)
 Sets threshold high value. More...
 
int GetThresholdHigh ()
 Gets threshold high value. More...
 
void SetThresholdLow (uint16_t threshold)
 Sets threshold low value. More...
 
int GetThresholdLow ()
 Gets threshold low value. More...
 
uint16_t GetRed ()
 Gets value of Red color channel. More...
 
uint16_t GetGreen ()
 Gets value of Green color channel. More...
 
uint16_t GetBlue ()
 Gets value of Blue color channel. More...
 
uint16_t GetIr ()
 Gets value of IR color channel. More...
 
uint16_t GetGeen2 ()
 Gets value of Green2 color channel. More...
 
std::vector< uint16_t > GetMeasurements ()
 Gets all channels measurements values. 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 RemoveISR ()
 Removes the ISR if it is installed.
 
std::string RegistersDump ()
 Gets a dump of configuration registers as a string. More...
 

Constructor & Destructor Documentation

BH1749 ( int  bus = 0,
int  addr = 0x39 
)

This calls SensorInit() to set default values for operating mode, gains, measurement time, interrupt source and then sets threshold high to 511.

Parameters
busI2C bus number
addrI2C sensor address
Exceptions
std::runtime_erroron initialization failure

Member Function Documentation

void Enable ( )
Exceptions
std::runtime_errorif bh1749_enable() fails

Here is the call graph for this function:

void Disable ( )
Exceptions
std::runtime_errorif bh1749_disable() fails

Here is the call graph for this function:

void CheckWhoAmI ( )
Exceptions
std::runtime_errorif this value is incorrect

Here is the call graph for this function:

void SensorInit ( OPERATING_MODES  opMode,
MEAS_TIMES  measTime,
RGB_GAINS  rgbGain,
IR_GAINS  irGain,
INT_SOURCES  intSource 
)
Parameters
opModeOperating mode choice, a value of OPERATING_MODES enum
measTimeMeasurement time choice, a value of MEAS_TIMES enum
rgbGainRGB gain choice, a value of RGB_GAINS enum
irGainIR gain choice, a value of IR_GAINS enum
intSourceinterrupt source choice, a value of INT_SOURCES enum
Exceptions
std::runtime_errorif one of values setting fails

Here is the call graph for this function:

void SetOperatingMode ( OPERATING_MODES  opMode)
Parameters
opModeOperating mode choice, a value of OPERATING_MODES enum
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetOperatingMode ( )
Parameters
opModepointer (uint8_t) to save value
Returns
operating mode value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void SetMeasurementTime ( MEAS_TIMES  measTime)
Parameters
measTimemeasurement time choice, a value of MEAS_TIMES enum
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetMeasurementTime ( )
Returns
measurement time value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void SetRgbGain ( RGB_GAINS  rgbGain)
Parameters
rgbGainRGB gain choice, a value of RGB_GAINS enum
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetRgbGain ( )
Returns
RGB gain value value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void SetIrGain ( IR_GAINS  irGain)
Parameters
irGainIR gain choice, a value of IR_GAINS enum
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetIrGain ( )
Returns
IR gain value value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void SetIntSource ( INT_SOURCES  intSource)
Parameters
intSourceinterrupt source choice, a value of INT_SOURCES enum
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

char GetInterruptSourceChar ( )
Returns
interrupt source value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void EnableInterrupt ( )
Exceptions
std::runtime_errorif writing enable bit fails

Here is the call graph for this function:

void DisableInterrupt ( )
Exceptions
std::runtime_errorif writing disable bit fails

Here is the call graph for this function:

void ResetInterrupt ( )
Exceptions
std::runtime_errorif writing reset bit fails

Here is the call graph for this function:

bool IsInterrupted ( )
Returns
true if interrupt is raised, otherwise false

Here is the call graph for this function:

bool IsInterruptEnabled ( )
Returns
true if interrupt is enabled, otherwise false

Here is the call graph for this function:

void SoftReset ( )
Exceptions
std::runtime_errorif writing reset bit fails

Here is the call graph for this function:

void SetThresholdHigh ( uint16_t  threshold)
Parameters
thresholdinterrupt threshold high value, range 0-65536
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetThresholdHigh ( )
Returns
threshold high value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

void SetThresholdLow ( uint16_t  threshold)
Parameters
thresholdinterrupt threshold low value, range 0-65536
Exceptions
std::runtime_errorif writing value fails

Here is the call graph for this function:

int GetThresholdLow ( )
Returns
threshold low value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

uint16_t GetRed ( )
Returns
red channel value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

uint16_t GetGreen ( )
Returns
green channel value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

uint16_t GetBlue ( )
Returns
blue channel value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

uint16_t GetIr ( )
Returns
ir channel value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

uint16_t GetGeen2 ( )
Returns
green2 channel value
Exceptions
std::runtime_errorif reading the value fails

Here is the call graph for this function:

std::vector< uint16_t > GetMeasurements ( )
Returns
vector with all channels values ordered as: Red, Green, Blue, IR, Green2
Exceptions
std::runtime_errorif reading one of the values fails

Here is the call graph for this function:

void InstallISR ( mraa_gpio_edge_t  edge,
int  pin,
void(*)(void *)  isr,
void *  isr_args 
)
Parameters
edgeEdge type to raise ISR with, of type mraa_gpio_edge_t
pinGPIO pin number
isrPointer to ISR function
isr_argsArguments to pass the ISR function
Exceptions
std::runtime_errorif installing ISR fails

Here is the call graph for this function:

std::string RegistersDump ( )
Returns
string of dumped registers
Exceptions
std::runtime_errorif reading one of the registers fails

Here is the call graph for this function:


The documentation for this class was generated from the following files: