#include <stdio.h>
#include <signal.h>
#include "upm_utilities.h"
bool isStopped;
#define SENSOR_ADDR 0x39
#define I2C_BUS 0
void signal_int_handler(int signo)
{
if (signo == SIGINT)
isStopped = true;
}
void print_data(void *dev)
{
uint16_t result[5];
printf("R: %d, G: %d, B: %d, IR: %d, G2: %d\n", result[0],
result[1], result[2], result[3], result[4]);
}
int main(int argc, char **argv)
{
signal(SIGINT, signal_int_handler);
if (!dev) {
printf("bh1749_init() failed.\n");
return -1;
}
printf("Installing ISR\n");
while(!isStopped) {
upm_delay_ms(1000);
}
return 0;
}
|
upm_result_t | bh1749_check_who_am_i (bh1749_context dev) |
| Check "who am I" register value to identify the sensor. More...
|
|
bh1749_context | bh1749_init (int bus, int addr) |
| Init the sensor with specific bus and address. This function calls the sensor_init() function to set default values for operating mode, gains, measurement time, interrupt source and then sets threshold high to 511. More...
|
|
void | bh1749_close (bh1749_context dev) |
| Close and free sensor context. More...
|
|
upm_result_t | bh1749_enable (bh1749_context dev) |
| Enables RGB color measurement on the sensor. More...
|
|
upm_result_t | bh1749_disable (bh1749_context dev) |
| Disables RGB color measurement on the sensor. More...
|
|
upm_result_t | bh1749_sensor_init (bh1749_context dev, OPERATING_MODES opMode, MEAS_TIMES measTime, RGB_GAINS rgbGain, IR_GAINS irGain, INT_SOURCES intSource) |
| Initializes (writes) configuration values to sensor. More...
|
|
upm_result_t | bh1749_set_operating_mode (bh1749_context dev, OPERATING_MODES opMode) |
| Sets operating mode (interrupt persistance) More...
|
|
upm_result_t | bh1749_get_operating_mode (bh1749_context dev, uint8_t *opMode) |
| Gets operating mode (interrupt persistance) value. More...
|
|
upm_result_t | bh1749_set_measurement_time (bh1749_context dev, MEAS_TIMES measTime) |
| Sets measurement time (ODR) More...
|
|
upm_result_t | bh1749_get_measurement_time (bh1749_context dev, uint8_t *meas_time) |
| Sets measurement time (ODR) More...
|
|
upm_result_t | bh1749_set_rgb_gain (bh1749_context dev, RGB_GAINS rgbGain) |
| Sets RGB gain values. More...
|
|
upm_result_t | bh1749_get_rgb_gain (bh1749_context dev, uint8_t *gain) |
| Gets RGB gain value. More...
|
|
upm_result_t | bh1749_set_ir_gain (bh1749_context dev, IR_GAINS irGain) |
| Sets IR gain values. More...
|
|
upm_result_t | bh1749_get_ir_gain (bh1749_context dev, uint8_t *gain) |
| Gets IR gain value. More...
|
|
upm_result_t | bh1749_set_int_source (bh1749_context dev, INT_SOURCES intSource) |
| Sets interrupt source value. More...
|
|
char | bh1749_get_interrupt_source_char (bh1749_context dev) |
| Gets interrupt source value. More...
|
|
upm_result_t | bh1749_enable_interrupt (bh1749_context dev) |
| Enables interrupt mode and resets the interrupt status (clear) More...
|
|
upm_result_t | bh1749_disable_interrupt (bh1749_context dev) |
| Disables interrupt mode. More...
|
|
upm_result_t | bh1749_reset_interrupt (bh1749_context dev) |
| Resets interrupt status (clear) to allow new interrupts. More...
|
|
bool | bh1749_is_interrupted (bh1749_context dev) |
| Checks the status of the interrupt. More...
|
|
bool | bh1749_is_interrupt_enabled (bh1749_context dev) |
| Checks whether interrupt mode is enabled. More...
|
|
upm_result_t | bh1749_soft_reset (bh1749_context dev) |
| 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...
|
|
upm_result_t | bh1749_set_threshold_high (bh1749_context dev, uint16_t threshold) |
| Sets interrupt threshold high value. More...
|
|
upm_result_t | bh1749_get_threshold_high (bh1749_context dev, uint16_t *threshold) |
| Gets interrupt threshold high value. More...
|
|
upm_result_t | bh1749_set_threshold_low (bh1749_context dev, uint16_t threshold) |
| Sets interrupt threshold low value. More...
|
|
upm_result_t | bh1749_get_threshold_low (bh1749_context dev, uint16_t *threshold) |
| Gets interrupt threshold low value. More...
|
|
upm_result_t | bh1749_get_red (bh1749_context dev, uint16_t *red) |
| Gets value of Red color channel. More...
|
|
upm_result_t | bh1749_get_green (bh1749_context dev, uint16_t *green) |
| Gets value of Green color channel. More...
|
|
upm_result_t | bh1749_get_blue (bh1749_context dev, uint16_t *blue) |
| Gets value of Blue color channel. More...
|
|
upm_result_t | bh1749_get_ir (bh1749_context dev, uint16_t *ir) |
| Gets value of IR color channel. More...
|
|
upm_result_t | bh1749_get_green2 (bh1749_context dev, uint16_t *green2) |
| Gets value of Green2 color channel. More...
|
|
upm_result_t | bh1749_get_measurements (bh1749_context dev, uint16_t *result) |
| Gets all channels measurements values. More...
|
|
upm_result_t | bh1749_install_isr (bh1749_context dev, mraa_gpio_edge_t edge, int pin, void(*isr)(void *), void *isr_args) |
| Installs the ISR to a given GPIO pin. More...
|
|
void | bh1749_remove_isr (bh1749_context dev) |
| Removes the ISR if it is installed. More...
|
|
upm_result_t | bh1749_registers_dump (bh1749_context dev, char *dump) |
| Gets a dump of configuration registers as a string. More...
|
|
|
enum | OPERATING_MODES { INT_JUDGE_0 = BH1749_PERSISTENCE_MODE_STATUS_ACTIVE_AFTER_MEASUREMENT,
INT_JUDGE_1 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_MEASUREMENT,
INT_JUDGE_4 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_4_SAME,
INT_JUDGE_8 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_8_SAME
} |
| Operation modes enum for interrupt modes (persistance)
|
|
enum | MEAS_TIMES { MEAS_35MS = BH1749_MODE_CONTROL1_ODR_28P6,
MEAS_120MS = BH1749_MODE_CONTROL1_ODR_8P333,
MEAS_240MS = BH1749_MODE_CONTROL1_ODR_4P167
} |
| Measuremnt time choices.
|
|
enum | RGB_GAINS { RGB_GAIN_1X = BH1749_MODE_CONTROL1_RGB_GAIN_1X,
RGB_GAIN_32X = BH1749_MODE_CONTROL1_RGB_GAIN_32X
} |
| RGB gain choices.
|
|
enum | IR_GAINS { IR_GAIN_1X = BH1749_MODE_CONTROL1_IR_GAIN_1X,
IR_GAIN_32X = BH1749_MODE_CONTROL1_IR_GAIN_32X
} |
| IR gain choices.
|
|
enum | INT_SOURCES { RED = BH1749_INTERRUPT_SOURCE_SELECT_RED,
GREEN = BH1749_INTERRUPT_SOURCE_SELECT_GREEN,
BLUE = BH1749_INTERRUPT_SOURCE_SELECT_BLUE
} |
| Interrupt source choices.
|
|