color3 2.0.0.0
color3.h File Reference

This file contains API for Color 3 Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  color3_t
 Click ctx object definition. More...
 
struct  color3_cfg_t
 Click configuration structure definition. More...
 
struct  color3_channels_t
 Color 3 RGBC channels data object. More...
 
struct  color3_hsl_t
 Color 3 HSL color data object. More...
 

Macros

#define COLOR3_MAP_MIKROBUS(cfg, mikrobus)
 
#define COLOR3_OK   0
 
#define COLOR3_ERROR   -1
 
#define COLOR3_COMMAND_TYPE_SPECIAL   ( 3 << 5 )
 
#define COLOR3_COMMAND_TYPE_AUTOINC   ( 1 << 5 )
 
#define COLOR3_COMMAND_SELECT   ( 1 << 7 )
 
#define COLOR3_I2C_SLAVE_ADDR   0x29
 
#define COLOR3_ENABLE   0x00
 
#define COLOR3_ATIME   0x01
 
#define COLOR3_PTIME   0x02
 
#define COLOR3_WTIME   0x03
 
#define COLOR3_AILTL   0x04
 
#define COLOR3_AILTH   0x05
 
#define COLOR3_AIHTL   0x06
 
#define COLOR3_AIHTH   0x07
 
#define COLOR3_PILTL   0x08
 
#define COLOR3_PILTH   0x09
 
#define COLOR3_PIHTL   0x0A
 
#define COLOR3_PIHTH   0x0B
 
#define COLOR3_PERS   0x0C
 
#define COLOR3_CONFIG   0x0D
 
#define COLOR3_PPCOUNT   0x0E
 
#define COLOR3_CONTROL   0x0F
 
#define COLOR3_ID   0x12
 
#define COLOR3_STATUS   0x13
 
#define COLOR3_CDATA   0x14
 
#define COLOR3_CDATAH   0x15
 
#define COLOR3_RDATA   0x16
 
#define COLOR3_RDATAH   0x17
 
#define COLOR3_GDATA   0x18
 
#define COLOR3_GDATAH   0x19
 
#define COLOR3_BDATA   0x1A
 
#define COLOR3_BDATAH   0x1B
 
#define COLOR3_PDATA   0x1C
 
#define COLOR3_PDATAH   0x1D
 
#define COLOR3_ENABLE_REG_DEFAULT   0x00
 
#define COLOR3_ENABLE_REG_PON   0x01
 
#define COLOR3_ENABLE_REG_AEN   0x02
 
#define COLOR3_ENABLE_REG_PEN   0x04
 
#define COLOR3_ENABLE_REG_WEN   0x08
 
#define COLOR3_ENABLE_REG_AIEN   0x10
 
#define COLOR3_ENABLE_REG_PIEN   0x20
 
#define COLOR3_RGBC_TIMING_1_CYC   0xFF
 
#define COLOR3_RGBC_TIMING_4_CYC   0xFC
 
#define COLOR3_RGBC_TIMING_10_CYC   0xF6
 
#define COLOR3_RGBC_TIMING_42_CYC   0xD6
 
#define COLOR3_RGBC_TIMING_64_CYC   0xAD
 
#define COLOR3_RGBC_TIMING_256_CYC   0x00
 
#define COLOR3_PROXY_PULSE_1   0xFF
 
#define COLOR3_PROXY_PULSE_10   0xF6
 
#define COLOR3_PROXY_PULSE_42   0xD6
 
#define COLOR3_PROXY_PULSE_64   0xAD
 
#define COLOR3_PROXY_PULSE_256   0x00
 
#define COLOR3_WAIT_TIME_REG_1_CYC   0xFF
 
#define COLOR3_WAIT_TIME_REG_42_CYC   0xD8
 
#define COLOR3_WAIT_TIME_REG_64_CYC   0xAD
 
#define COLOR3_WAIT_TIME_REG_256_CYC   0x00
 
#define COLOR3_LOW_THRESHOLD_VALUE   0x0130
 
#define COLOR3_HIGH_THRESHOLD_VALUE   0x0170
 
#define COLOR3_EVERY_CYC_INTER   0x00
 
#define COLOR3_1_OR_INTER   0x01
 
#define COLOR3_2_OR_INTER   0x02
 
#define COLOR3_3_OR_INTER   0x03
 
#define COLOR3_5_OR_INTER   0x04
 
#define COLOR3_10_OR_INTER   0x05
 
#define COLOR3_15_OR_INTER   0x06
 
#define COLOR3_20_OR_INTER   0x07
 
#define COLOR3_25_OR_INTER   0x08
 
#define COLOR3_30_OR_INTER   0x09
 
#define COLOR3_35_OR_INTER   0x0A
 
#define COLOR3_40_OR_INTER   0x0B
 
#define COLOR3_45_OR_INTER   0x0C
 
#define COLOR3_50_OR_INTER   0x0D
 
#define COLOR3_55_OR_INTER   0x0E
 
#define COLOR3_60_OR_INTER   0x0F
 
#define COLOR3_LONG_WAIT   0x02
 
#define COLOR3_A_GAIN_1   0x00
 
#define COLOR3_A_GAIN_4   0x01
 
#define COLOR3_A_GAIN_16   0x02
 
#define COLOR3_A_GAIN_60   0x03
 
#define COLOR3_CLEAR_DIODE   0x10
 
#define COLOR3_IR_DIODE   0x20
 
#define COLOR3_BOTH_DIODE   0x30
 
#define COLOR3_LED_STR_100   0x00
 
#define COLOR3_LED_STR_50   0x40
 
#define COLOR3_LED_STR_25   0x80
 
#define COLOR3_LED_STR_12_5   0xC0
 
#define COLOR3_UNKNOWN_COLOR   0
 Color 3 color flags.
 
#define COLOR3_RED_COLOR   1
 
#define COLOR3_YELLOW_COLOR   2
 
#define COLOR3_GREEN_COLOR   3
 
#define COLOR3_CYAN_COLOR   4
 
#define COLOR3_BLUE_COLOR   5
 
#define COLOR3_MAGENTA_COLOR   6
 
#define COLOR3_WHITE_COLOR   7
 
#define COLOR3_BLACK_COLOR   8
 
#define COLOR3_WHITE_COLOR_LIGHTNESS   97
 Color 3 color from HSL thresholds.
 
#define COLOR3_BLACK_COLOR_LIGHTNESS   3
 
#define COLOR3_YELLOW_COLOR_HUE_ANGLE   30
 
#define COLOR3_GREEN_COLOR_HUE_ANGLE   90
 
#define COLOR3_CYAN_COLOR_HUE_ANGLE   150
 
#define COLOR3_BLUE_COLOR_HUE_ANGLE   210
 
#define COLOR3_MAGENTA_COLOR_HUE_ANGLE   270
 
#define COLOR3_RED_COLOR_HUE_ANGLE   330
 
#define COLOR3_HSL_HUE_RESOLUTION   360
 Color 3 RGB to HSL calculation values.
 
#define COLOR3_HSL_SATURATION_RESOLUTION   100
 
#define COLOR3_HSL_LIGHTNESS_RESOLUTION   100
 

Functions

void color3_cfg_setup (color3_cfg_t *cfg)
 Config Object Initialization function.
 
err_t color3_init (color3_t *ctx, color3_cfg_t *cfg)
 Initialization function.
 
err_t color3_generic_write (color3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Generic write function.
 
err_t color3_generic_read (color3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Generic read function.
 
void color3_normal_wr_byte (color3_t *ctx, uint8_t wr_addr, uint8_t wr_data)
 Generic read function.
 
void color3_special_wr_byte (color3_t *ctx, uint8_t wr_addr, uint8_t wr_data)
 Special write byte function.
 
uint8_t color3_read_byte (color3_t *ctx, uint8_t rd_addr)
 Read byte function.
 
void color3_normal_wr_data (color3_t *ctx, uint8_t wr_addr, uint16_t wr_data)
 Normal write data function.
 
void color3_special_wr_data (color3_t *ctx, uint8_t wr_addr, uint16_t wr_data)
 Special write function.
 
uint16_t color3_read_data (color3_t *ctx, uint8_t rd_addr)
 Read data function.
 
void color3_write_enable_reg (color3_t *ctx, uint8_t wr_data)
 Write Enable Register function.
 
uint8_t color3_read_enable_reg (color3_t *ctx)
 Read Enable Register function.
 
void color3_write_rgbc_timing_reg (color3_t *ctx, uint8_t wr_data)
 Write RGBC Timing Register function.
 
uint8_t color3_read_rgbc_timing_reg (color3_t *ctx)
 Read RGBC Timing Register function.
 
void color3_write_prox_timing_reg (color3_t *ctx)
 Write Proximity Timing Register function.
 
uint8_t color3_read_prox_timing_reg (color3_t *ctx)
 Read Proximity Timing Register function.
 
void color3_write_wait_time_reg (color3_t *ctx, uint8_t wr_data)
 Write Wait Time Register function.
 
uint8_t color3_read_wait_time_reg (color3_t *ctx)
 Read Wait Time Register function.
 
void color3_set_inter_trsh_lo (color3_t *ctx, uint16_t wr_data)
 RGBC interrupt threshold low value function.
 
void color3_set_inter_trsh_hi (color3_t *ctx, uint16_t wr_data)
 RGBC interrupt threshold high value function.
 
void color3_set_prox_inter_trsh_lo (color3_t *ctx, uint16_t wr_data)
 Proximity interrupt threshold low value function.
 
void color3_set_prox_inter_trsh_hi (color3_t *ctx, uint16_t wr_data)
 Proximity interrupt threshold high value function.
 
void color3_set_int_pers (color3_t *ctx, uint8_t int_pers)
 Set Interrupt persistence persistence function.
 
uint8_t color3_read_int_pers (color3_t *ctx)
 Read Interrupt persistence function.
 
void color3_set_prox_int_pers (color3_t *ctx, uint8_t int_pers)
 Set Proximity interrupt persistence function.
 
uint8_t color3_read_prox_int_pers (color3_t *ctx)
 Read Proximity interrupt persistence function.
 
void color3_set_long_wait (color3_t *ctx, uint8_t lon_wait)
 Set long wait function.
 
uint8_t color3_read_long_wait (color3_t *ctx)
 Read long wait function.
 
void color3_write_pulse_cnt (color3_t *ctx, uint8_t pulse_cnt)
 Write Proximity Pulse Count function.
 
uint8_t color3_read_pulse_cnt (color3_t *ctx)
 Read Proximity Pulse Count function.
 
void color3_write_rgbc_gain (color3_t *ctx, uint8_t gain)
 Write RGBC Gain Value function.
 
uint8_t color3_read_rgbc_gain (color3_t *ctx)
 Read RGBC Gain Value function.
 
void color3_set_diode_select (color3_t *ctx, uint8_t dio_sel)
 Set Diode Selection function.
 
uint8_t color3_get_diode_select (color3_t *ctx)
 Get Diode Selection function.
 
void color3_set_led_str (color3_t *ctx, uint8_t led_str)
 Set LED Strength function.
 
uint8_t color3_read_led_str (color3_t *ctx)
 Read LED Strength function.
 
uint8_t color3_read_dev_id (color3_t *ctx)
 Read device ID function.
 
uint8_t color3_read_dev_stat (color3_t *ctx)
 Read device status function.
 
uint16_t color3_read_clear_data (color3_t *ctx)
 Read clear data function.
 
uint16_t color3_read_red_data (color3_t *ctx)
 Read red data function.
 
uint16_t color3_read_green_data (color3_t *ctx)
 Read green data function.
 
uint16_t color3_read_blue_data (color3_t *ctx)
 Read blue data function.
 
uint16_t color3_read_prox_data (color3_t *ctx)
 ead proximity data function.
 
uint8_t color3_get_inter_state (color3_t *ctx)
 Get Interrupt state function.
 
void color3_set_default_settings (color3_t *ctx)
 Default settings function.
 
void color3_get_rgb_data (color3_t *ctx, uint16_t *red_data, uint16_t *green_data, uint16_t *blue_data)
 Get color data function.
 
float color3_get_color_ratio (color3_t *ctx, uint16_t color_data)
 Get color ratio function.
 
err_t color3_get_rgbc_data (color3_t *ctx, color3_channels_t *channels)
 Color 3 get rgbc data function.
 
uint8_t color3_get_color (color3_hsl_t *hsl)
 Color 3 get color function.
 
void color3_rgbc_to_hsl (color3_t *ctx, color3_channels_t *rgbc, color3_hsl_t *hsl)
 Color 3 rgbc to hsl function.
 

Detailed Description

This file contains API for Color 3 Click driver.