Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
63 #define COLOR2_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
74 #define COLOR2_ERROR -1
81 #define COLOR2_I2C_ADDR 0x44
82 #define COLOR2_DEVICE_ID 0x00
83 #define COLOR2_CONFIG_1 0x01
84 #define COLOR2_CONFIG_2 0x02
85 #define COLOR2_CONFIG_3 0x03
86 #define COLOR2_THRESHOLD_LL 0x04
87 #define COLOR2_THRESHOLD_LH 0x05
88 #define COLOR2_THRESHOLD_HL 0x06
89 #define COLOR2_THRESHOLD_HH 0x07
90 #define COLOR2_STATUS 0x08
91 #define COLOR2_GREEN_L 0x09
92 #define COLOR2_GREEN_H 0x0A
93 #define COLOR2_RED_L 0x0B
94 #define COLOR2_RED_H 0x0C
95 #define COLOR2_BLUE_L 0x0D
96 #define COLOR2_BLUE_H 0x0E
97 #define COLOR2_CFG_DEFAULT 0x00
98 #define COLOR2_CFG1_MODE_POWERDOWN 0x00
99 #define COLOR2_CFG1_MODE_G 0x01
100 #define COLOR2_CFG1_MODE_R 0x02
101 #define COLOR2_CFG1_MODE_B 0x03
102 #define COLOR2_CFG1_MODE_STANDBY 0x04
103 #define COLOR2_CFG1_MODE_RGB 0x05
104 #define COLOR2_CFG1_MODE_RG 0x06
105 #define COLOR2_CFG1_MODE_GB 0x07
106 #define COLOR2_CFG1_375LUX 0x00
107 #define COLOR2_CFG1_10KLUX 0x08
108 #define COLOR2_CFG1_16BIT 0x00
109 #define COLOR2_CFG1_12BIT 0x10
110 #define COLOR2_CFG1_ADC_SYNC_NORMAL 0x00
111 #define COLOR2_CFG1_ADC_SYNC_TO_INT 0x20
112 #define COLOR2_CFG2_IR_OFFSET_OFF 0x00
113 #define COLOR2_CFG2_IR_OFFSET_ON 0x80
114 #define COLOR2_CFG2_IR_ADJUST_LOW 0x00
115 #define COLOR2_CFG2_IR_ADJUST_MID 0x20
116 #define COLOR2_CFG2_IR_ADJUST_HIGH 0x3F
123 #define COLOR2_CFG3_NO_INT 0x00
124 #define COLOR2_CFG3_G_INT 0x01
125 #define COLOR2_CFG3_R_INT 0x02
126 #define COLOR2_CFG3_B_INT 0x03
127 #define COLOR2_CFG3_INT_PRST1 0x00
128 #define COLOR2_CFG3_INT_PRST2 0x04
129 #define COLOR2_CFG3_INT_PRST4 0x08
130 #define COLOR2_CFG3_INT_PRST8 0x0C
131 #define COLOR2_CFG3_RGB_CONV_TO_INT_DISABLE 0x00
132 #define COLOR2_CFG3_RGB_CONV_TO_INT_ENABLE 0x10
139 #define COLOR2_FLAG_INT 0x01
140 #define COLOR2_FLAG_CONV_DONE 0x02
141 #define COLOR2_FLAG_BROWNOUT 0x04
142 #define COLOR2_FLAG_CONV_G 0x10
143 #define COLOR2_FLAG_CONV_R 0x20
144 #define COLOR2_FLAG_CONV_B 0x30
151 #define COLOR2_UNKNOWN_COLOR 0
152 #define COLOR2_RED_COLOR 1
153 #define COLOR2_YELLOW_COLOR 2
154 #define COLOR2_GREEN_COLOR 3
155 #define COLOR2_CYAN_COLOR 4
156 #define COLOR2_BLUE_COLOR 5
157 #define COLOR2_MAGENTA_COLOR 6
158 #define COLOR2_WHITE_COLOR 7
159 #define COLOR2_BLACK_COLOR 8
165 #define COLOR2_WHITE_COLOR_LIGHTNESS 97
166 #define COLOR2_BLACK_COLOR_LIGHTNESS 3
167 #define COLOR2_YELLOW_COLOR_HUE_ANGLE 30
168 #define COLOR2_GREEN_COLOR_HUE_ANGLE 90
169 #define COLOR2_CYAN_COLOR_HUE_ANGLE 150
170 #define COLOR2_BLUE_COLOR_HUE_ANGLE 210
171 #define COLOR2_MAGENTA_COLOR_HUE_ANGLE 270
172 #define COLOR2_RED_COLOR_HUE_ANGLE 330
178 #define COLOR2_HSL_HUE_RESOLUTION 360
179 #define COLOR2_HSL_SATURATION_RESOLUTION 100
180 #define COLOR2_HSL_LIGHTNESS_RESOLUTION 100
err_t color2_generic_write(color2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Color 2 I2C writing function.
Click configuration structure definition.
Definition: color2.h:209
err_t color2_read_upper_threshold(color2_t *ctx, uint16_t *upper_threshold)
Function read upper threshold register.
uint8_t i2c_address
Definition: color2.h:219
float hue
Definition: color2.h:241
err_t color2_set_lower_hreshold(color2_t *ctx, uint16_t lower_threshold)
Function set lower threshold register.
i2c_master_t i2c
Definition: color2.h:198
uint32_t i2c_speed
Definition: color2.h:218
err_t color2_generic_read(color2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Color 2 I2C reading function.
err_t color2_read_reg(color2_t *ctx, uint8_t reg, uint8_t *data_out)
Generic read data function.
digital_in_t int_pin
Definition: color2.h:195
uint8_t slave_address
Definition: color2.h:201
err_t color2_init_advanced(color2_t *ctx, uint8_t config1, uint8_t config2, uint8_t config3)
Init advanced function.
uint16_t red
Definition: color2.h:229
pin_name_t sda
Definition: color2.h:212
uint16_t green
Definition: color2.h:230
void color2_cfg_setup(color2_cfg_t *cfg)
Config Object Initialization function.
void color2_rgb_to_hsl(color2_t *ctx, color2_rgb_t *rgb, color2_hsl_t *hsl)
Functions for read color value.
Color 2 RGB channels data object.
Definition: color2.h:228
Color 2 HSL color data object.
Definition: color2.h:240
err_t color2_set_upper_threshold(color2_t *ctx, uint16_t upper_threshold)
Function set upper threshold register.
uint8_t color2_get_int_pin(color2_t *ctx)
Get int pin function.
pin_name_t scl
Definition: color2.h:211
uint16_t blue
Definition: color2.h:231
float lightness
Definition: color2.h:243
err_t color2_write_reg(color2_t *ctx, uint8_t reg, uint8_t data_in)
Generic write data function.
uint8_t color2_get_color(color2_hsl_t *hsl)
Functions for detect colors.
float saturation
Definition: color2.h:242
pin_name_t int_pin
Definition: color2.h:215
err_t color2_reset(color2_t *ctx)
Reset default register value function.
Click ctx object definition.
Definition: color2.h:193
err_t color2_read_rgb(color2_t *ctx, color2_rgb_t *rgb)
Function read rgb data.
err_t color2_read_status(color2_t *ctx, uint8_t *status)
Function read status registe value.
err_t color2_default_cfg(color2_t *ctx)
Click Default Configuration function.
err_t color2_read_lower_threshold(color2_t *ctx, uint16_t *lower_threshold)
Function read lower threshold register.
err_t color2_init(color2_t *ctx, color2_cfg_t *cfg)
Initialization function.