Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
53 #define COLOR3_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
64 #define COLOR3_ERROR -1
71 #define COLOR3_COMMAND_TYPE_SPECIAL ( 3 << 5 )
72 #define COLOR3_COMMAND_TYPE_AUTOINC ( 1 << 5 )
73 #define COLOR3_COMMAND_SELECT ( 1 << 7 )
80 #define COLOR3_I2C_SLAVE_ADDR 0x29
87 #define COLOR3_ENABLE 0x00
88 #define COLOR3_ATIME 0x01
89 #define COLOR3_PTIME 0x02
90 #define COLOR3_WTIME 0x03
91 #define COLOR3_AILTL 0x04
92 #define COLOR3_AILTH 0x05
93 #define COLOR3_AIHTL 0x06
94 #define COLOR3_AIHTH 0x07
95 #define COLOR3_PILTL 0x08
96 #define COLOR3_PILTH 0x09
97 #define COLOR3_PIHTL 0x0A
98 #define COLOR3_PIHTH 0x0B
99 #define COLOR3_PERS 0x0C
100 #define COLOR3_CONFIG 0x0D
101 #define COLOR3_PPCOUNT 0x0E
102 #define COLOR3_CONTROL 0x0F
103 #define COLOR3_ID 0x12
104 #define COLOR3_STATUS 0x13
105 #define COLOR3_CDATA 0x14
106 #define COLOR3_CDATAH 0x15
107 #define COLOR3_RDATA 0x16
108 #define COLOR3_RDATAH 0x17
109 #define COLOR3_GDATA 0x18
110 #define COLOR3_GDATAH 0x19
111 #define COLOR3_BDATA 0x1A
112 #define COLOR3_BDATAH 0x1B
113 #define COLOR3_PDATA 0x1C
114 #define COLOR3_PDATAH 0x1D
121 #define COLOR3_ENABLE_REG_DEFAULT 0x00
122 #define COLOR3_ENABLE_REG_PON 0x01
123 #define COLOR3_ENABLE_REG_AEN 0x02
124 #define COLOR3_ENABLE_REG_PEN 0x04
125 #define COLOR3_ENABLE_REG_WEN 0x08
126 #define COLOR3_ENABLE_REG_AIEN 0x10
127 #define COLOR3_ENABLE_REG_PIEN 0x20
134 #define COLOR3_RGBC_TIMING_1_CYC 0xFF
135 #define COLOR3_RGBC_TIMING_4_CYC 0xFC
136 #define COLOR3_RGBC_TIMING_10_CYC 0xF6
137 #define COLOR3_RGBC_TIMING_42_CYC 0xD6
138 #define COLOR3_RGBC_TIMING_64_CYC 0xAD
139 #define COLOR3_RGBC_TIMING_256_CYC 0x00
146 #define COLOR3_PROXY_PULSE_1 0xFF
147 #define COLOR3_PROXY_PULSE_10 0xF6
148 #define COLOR3_PROXY_PULSE_42 0xD6
149 #define COLOR3_PROXY_PULSE_64 0xAD
150 #define COLOR3_PROXY_PULSE_256 0x00
157 #define COLOR3_WAIT_TIME_REG_1_CYC 0xFF
158 #define COLOR3_WAIT_TIME_REG_42_CYC 0xD8
159 #define COLOR3_WAIT_TIME_REG_64_CYC 0xAD
160 #define COLOR3_WAIT_TIME_REG_256_CYC 0x00
167 #define COLOR3_LOW_THRESHOLD_VALUE 0x0130
168 #define COLOR3_HIGH_THRESHOLD_VALUE 0x0170
175 #define COLOR3_EVERY_CYC_INTER 0x00
176 #define COLOR3_1_OR_INTER 0x01
177 #define COLOR3_2_OR_INTER 0x02
178 #define COLOR3_3_OR_INTER 0x03
179 #define COLOR3_5_OR_INTER 0x04
180 #define COLOR3_10_OR_INTER 0x05
181 #define COLOR3_15_OR_INTER 0x06
182 #define COLOR3_20_OR_INTER 0x07
183 #define COLOR3_25_OR_INTER 0x08
184 #define COLOR3_30_OR_INTER 0x09
185 #define COLOR3_35_OR_INTER 0x0A
186 #define COLOR3_40_OR_INTER 0x0B
187 #define COLOR3_45_OR_INTER 0x0C
188 #define COLOR3_50_OR_INTER 0x0D
189 #define COLOR3_55_OR_INTER 0x0E
190 #define COLOR3_60_OR_INTER 0x0F
197 #define COLOR3_LONG_WAIT 0x02
204 #define COLOR3_A_GAIN_1 0x00
205 #define COLOR3_A_GAIN_4 0x01
206 #define COLOR3_A_GAIN_16 0x02
207 #define COLOR3_A_GAIN_60 0x03
214 #define COLOR3_CLEAR_DIODE 0x10
215 #define COLOR3_IR_DIODE 0x20
216 #define COLOR3_BOTH_DIODE 0x30
223 #define COLOR3_LED_STR_100 0x00
224 #define COLOR3_LED_STR_50 0x40
225 #define COLOR3_LED_STR_25 0x80
226 #define COLOR3_LED_STR_12_5 0xC0
233 #define COLOR3_UNKNOWN_COLOR 0
234 #define COLOR3_RED_COLOR 1
235 #define COLOR3_YELLOW_COLOR 2
236 #define COLOR3_GREEN_COLOR 3
237 #define COLOR3_CYAN_COLOR 4
238 #define COLOR3_BLUE_COLOR 5
239 #define COLOR3_MAGENTA_COLOR 6
240 #define COLOR3_WHITE_COLOR 7
241 #define COLOR3_BLACK_COLOR 8
247 #define COLOR3_WHITE_COLOR_LIGHTNESS 97
248 #define COLOR3_BLACK_COLOR_LIGHTNESS 3
249 #define COLOR3_YELLOW_COLOR_HUE_ANGLE 30
250 #define COLOR3_GREEN_COLOR_HUE_ANGLE 90
251 #define COLOR3_CYAN_COLOR_HUE_ANGLE 150
252 #define COLOR3_BLUE_COLOR_HUE_ANGLE 210
253 #define COLOR3_MAGENTA_COLOR_HUE_ANGLE 270
254 #define COLOR3_RED_COLOR_HUE_ANGLE 330
260 #define COLOR3_HSL_HUE_RESOLUTION 360
261 #define COLOR3_HSL_SATURATION_RESOLUTION 100
262 #define COLOR3_HSL_LIGHTNESS_RESOLUTION 100
void color3_write_wait_time_reg(color3_t *ctx, uint8_t wr_data)
Write Wait Time Register function.
err_t color3_get_rgbc_data(color3_t *ctx, color3_channels_t *channels)
Color 3 get rgbc data function.
uint8_t color3_read_pulse_cnt(color3_t *ctx)
Read Proximity Pulse Count function.
uint8_t color3_get_color(color3_hsl_t *hsl)
Color 3 get color function.
void color3_set_diode_select(color3_t *ctx, uint8_t dio_sel)
Set Diode Selection function.
Click configuration structure definition.
Definition: color3.h:291
i2c_master_t i2c
Definition: color3.h:280
uint8_t color3_get_diode_select(color3_t *ctx)
Get Diode Selection function.
pin_name_t scl
Definition: color3.h:293
void color3_normal_wr_data(color3_t *ctx, uint8_t wr_addr, uint16_t wr_data)
Normal write data function.
float saturation
Definition: color3.h:325
void color3_set_prox_inter_trsh_lo(color3_t *ctx, uint16_t wr_data)
Proximity interrupt threshold low value function.
uint8_t color3_read_dev_id(color3_t *ctx)
Read device ID function.
void color3_rgbc_to_hsl(color3_t *ctx, color3_channels_t *rgbc, color3_hsl_t *hsl)
Color 3 rgbc to hsl function.
pin_name_t sda
Definition: color3.h:294
Color 3 RGBC channels data object.
Definition: color3.h:310
uint8_t color3_read_rgbc_timing_reg(color3_t *ctx)
Read RGBC Timing Register function.
uint16_t color3_read_prox_data(color3_t *ctx)
ead proximity data function.
pin_name_t int_pin
Definition: color3.h:297
uint16_t blue
Definition: color3.h:313
uint16_t red
Definition: color3.h:311
uint16_t color3_read_red_data(color3_t *ctx)
Read red data function.
uint8_t color3_read_enable_reg(color3_t *ctx)
Read Enable Register function.
uint8_t i2c_address
Definition: color3.h:301
uint8_t slave_address
Definition: color3.h:283
Color 3 HSL color data object.
Definition: color3.h:323
void color3_write_rgbc_gain(color3_t *ctx, uint8_t gain)
Write RGBC Gain Value function.
digital_in_t int_pin
Definition: color3.h:277
void color3_write_pulse_cnt(color3_t *ctx, uint8_t pulse_cnt)
Write Proximity Pulse Count function.
err_t color3_init(color3_t *ctx, color3_cfg_t *cfg)
Initialization function.
uint8_t color3_get_inter_state(color3_t *ctx)
Get Interrupt state function.
void color3_set_inter_trsh_hi(color3_t *ctx, uint16_t wr_data)
RGBC interrupt threshold high value function.
float hue
Definition: color3.h:324
void color3_special_wr_data(color3_t *ctx, uint8_t wr_addr, uint16_t wr_data)
Special write 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_led_str(color3_t *ctx)
Read LED Strength function.
uint8_t color3_read_prox_timing_reg(color3_t *ctx)
Read Proximity Timing Register function.
err_t color3_generic_read(color3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Generic read function.
void color3_set_prox_inter_trsh_hi(color3_t *ctx, uint16_t wr_data)
Proximity interrupt threshold high value function.
Click ctx object definition.
Definition: color3.h:275
uint8_t color3_read_byte(color3_t *ctx, uint8_t rd_addr)
Read byte function.
void color3_cfg_setup(color3_cfg_t *cfg)
Config Object Initialization function.
uint8_t color3_read_wait_time_reg(color3_t *ctx)
Read Wait Time Register function.
uint8_t color3_read_rgbc_gain(color3_t *ctx)
Read RGBC Gain Value function.
uint16_t color3_read_blue_data(color3_t *ctx)
Read blue data function.
uint8_t color3_read_dev_stat(color3_t *ctx)
Read device status function.
err_t color3_generic_write(color3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Generic write function.
void color3_set_int_pers(color3_t *ctx, uint8_t int_pers)
Set Interrupt persistence persistence function.
void color3_set_inter_trsh_lo(color3_t *ctx, uint16_t wr_data)
RGBC interrupt threshold low value function.
uint16_t color3_read_data(color3_t *ctx, uint8_t rd_addr)
Read data function.
void color3_write_rgbc_timing_reg(color3_t *ctx, uint8_t wr_data)
Write RGBC Timing Register function.
void color3_set_default_settings(color3_t *ctx)
Default settings function.
void color3_write_prox_timing_reg(color3_t *ctx)
Write Proximity Timing Register function.
uint8_t color3_read_int_pers(color3_t *ctx)
Read Interrupt persistence function.
uint32_t i2c_speed
Definition: color3.h:300
uint8_t color3_read_prox_int_pers(color3_t *ctx)
Read Proximity interrupt persistence function.
void color3_write_enable_reg(color3_t *ctx, uint8_t wr_data)
Write Enable Register function.
void color3_set_prox_int_pers(color3_t *ctx, uint8_t int_pers)
Set Proximity interrupt persistence function.
uint16_t green
Definition: color3.h:312
float lightness
Definition: color3.h:326
uint16_t color3_read_clear_data(color3_t *ctx)
Read clear data function.
uint8_t color3_read_long_wait(color3_t *ctx)
Read long wait function.
uint16_t clear
Definition: color3.h:314
void color3_normal_wr_byte(color3_t *ctx, uint8_t wr_addr, uint8_t wr_data)
Generic read function.
void color3_set_led_str(color3_t *ctx, uint8_t led_str)
Set LED Strength 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.
void color3_set_long_wait(color3_t *ctx, uint8_t lon_wait)
Set long wait function.
float color3_get_color_ratio(color3_t *ctx, uint16_t color_data)
Get color ratio function.
uint16_t color3_read_green_data(color3_t *ctx)
Read green data function.