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 COLOR_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.rd = MIKROBUS( mikrobus, MIKROBUS_AN ); \
57 cfg.gr = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.bl = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
59 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
66 #define COLOR_RETVAL uint8_t
69 #define COLOR_INIT_ERROR 0xFF
76 #define COLOR_SLAVE_ADDRESS 0x29
84 #define COLOR_REG_ENABLE 0x00
85 #define COLOR_REG_RGBC_TIME 0x01
86 #define COLOR_REG_WAIT_TIME 0x02
87 #define COLOR_REG_AILTL 0x03
88 #define COLOR_REG_AILTH 0x04
89 #define COLOR_REG_AIHTL 0x05
90 #define COLOR_REG_AIHTH 0x06
91 #define COLOR_REG_PERS 0x0C
92 #define COLOR_REG_CONFIGURATION 0x0D
93 #define COLOR_REG_CONTROL 0x0F
94 #define COLOR_REG_DEVICE_ID 0x12
95 #define COLOR_REG_DEVICE_STATUS 0x13
96 #define COLOR_REG_CLEAR_DATA_LOW 0x14
97 #define COLOR_REG_CLEAR_DATA_HIGH 0x15
98 #define COLOR_REG_RED_DATA_LOW 0x16
99 #define COLOR_REG_RED_DATA_HIGH 0x17
100 #define COLOR_REG_GREEN_DATA_LOW 0x18
101 #define COLOR_REG_GREEN_DATA_HIGH 0x19
102 #define COLOR_REG_BLUE_DATA_LOW 0x1A
103 #define COLOR_REG_BLUE_DATA_HIGH 0x1B
110 #define COLOR_CMD_SELECT 0x80
111 #define COLOR_CMD_REPEATED_BYTE_PROTOCOL 0x00
112 #define COLOR_CMD_AUTO_INCREMENT_PROTOCOL 0x20
119 #define COLOR_ENABLE_RGBC_INTERRUPT 0x10
120 #define COLOR_ENABLE_WAIT 0x08
121 #define COLOR_ENABLE_RGBC 0x02
122 #define COLOR_POWER_ON 0x01
129 #define COLOR_RGBC_TIME_2_4ms 0xFF
130 #define COLOR_RGBC_TIME_24ms 0xF6
131 #define COLOR_RGBC_TIME_101ms 0xD5
132 #define COLOR_RGBC_TIME_154ms 0xC0
133 #define COLOR_RGBC_TIME_700ms 0x00
140 #define COLOR_WAIT_TIME_W0_2_4ms 0xFF
141 #define COLOR_WAIT_TIME_W0_204ms 0xAB
142 #define COLOR_WAIT_TIME_W0_614ms 0xFF
143 #define COLOR_WAIT_TIME_W1_0_029sec 0xFF
144 #define COLOR_WAIT_TIME_W1_2_45sec 0xAB
145 #define COLOR_WAIT_TIME_W1_7_4sec 0xFF
152 #define COLOR_PERS_EVERY_RGBC 0x00
153 #define COLOR_PERS_CLEAR_CH_1 0x01
154 #define COLOR_PERS_CLEAR_CH_2 0x02
155 #define COLOR_PERS_CLEAR_CH_3 0x03
156 #define COLOR_PERS_CLEAR_CH_5 0x04
157 #define COLOR_PERS_CLEAR_CH_10 0x05
158 #define COLOR_PERS_CLEAR_CH_15 0x06
159 #define COLOR_PERS_CLEAR_CH_20 0x07
160 #define COLOR_PERS_CLEAR_CH_25 0x08
161 #define COLOR_PERS_CLEAR_CH_30 0x09
162 #define COLOR_PERS_CLEAR_CH_35 0x0A
163 #define COLOR_PERS_CLEAR_CH_40 0x0B
164 #define COLOR_PERS_CLEAR_CH_45 0x0C
165 #define COLOR_PERS_CLEAR_CH_50 0x0D
166 #define COLOR_PERS_CLEAR_CH_55 0x0E
167 #define COLOR_PERS_CLEAR_CH_60 0x0F
174 #define COLOR_CFG_WAIT_LONG 0x01
181 #define COLOR_CTRL_GAIN_x1 0x00
182 #define COLOR_CTRL_GAIN_x4 0x01
183 #define COLOR_CTRL_GAIN_x16 0x02
184 #define COLOR_CTRL_GAIN_x60 0x03
191 #define COLOR_COLOR_DATA_CLEAR 0x14
192 #define COLOR_COLOR_DATA_RED 0x16
193 #define COLOR_COLOR_DATA_GREEN 0x18
194 #define COLOR_COLOR_DATA_BLUE 0x1A
201 #define COLOR_LED_RED_ENABLE 0x01
202 #define COLOR_LED_GREEN_ENABLE 0x01
203 #define COLOR_LED_BLUE_ENABLE 0x01
204 #define COLOR_LED_RED_DISABLE 0x00
205 #define COLOR_LED_GREEN_DISABLE 0x00
206 #define COLOR_LED_BLUE_DISABLE 0x00
213 #define ORANGE_COLOR_FLAG 1
214 #define RED_COLOR_FLAG 2
215 #define PINK_COLOR_FLAG 3
216 #define PURPLE_COLOR_FLAG 4
217 #define BLUE_COLOR_FLAG 5
218 #define CYAN_COLOR_FLAG 6
219 #define GREEN_COLOR_FLAG 7
220 #define YELLOW_COLOR_FLAG 8
221 #define NON_COLOR_FLAG 0
pin_name_t rd
Definition: color.h:269
pin_name_t int_pin
Definition: color.h:272
pin_name_t sda
Definition: color.h:265
uint8_t color_get_color(float color_value)
Detect color.
uint8_t i2c_address
Definition: color.h:277
digital_out_t rd
Definition: color.h:239
float color_read_color_ratio(color_t *ctx, uint8_t color)
Read color ratio from register.
uint16_t color_read_data(color_t *ctx, uint8_t reg)
Read 16-bit data from register.
void color_generic_read(color_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void color_default_cfg(color_t *ctx)
Click Default Configuration function.
void color_generic_write(color_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
pin_name_t gr
Definition: color.h:270
i2c_master_t i2c
Definition: color.h:249
Click ctx object definition.
Definition: color.h:236
digital_out_t gr
Definition: color.h:240
uint8_t slave_address
Definition: color.h:253
Click configuration structure definition.
Definition: color.h:261
digital_out_t bl
Definition: color.h:241
void color_write_byte(color_t *ctx, uint8_t reg, uint8_t data_to_write)
Write one byte to register.
COLOR_RETVAL color_init(color_t *ctx, color_cfg_t *cfg)
Initialization function.
digital_in_t int_pin
Definition: color.h:245
void color_cfg_setup(color_cfg_t *cfg)
Config Object Initialization function.
uint8_t color_get_interrupt(color_t *ctx)
Get interrupt pin state.
float color_get_color_value(color_t *ctx)
Functions for read color value.
#define COLOR_RETVAL
Definition: color.h:66
uint32_t i2c_speed
Definition: color.h:276
pin_name_t bl
Definition: color.h:271
void color_set_led(color_t *ctx, uint8_t red, uint8_t green, uint8_t blue)
Functions for set Led lights.
pin_name_t scl
Definition: color.h:264