Color 15 click
Color 15 Click is a compact add-on board representing an accurate color sensing solution. This board features the CLS-16D24-44-DF8/TR8, a low power, high sensitivity, color light sensor from Everlight Electronics. This Click boardâ„¢, with an I2C configurable color sensor, senses red, green, blue, white (RGBW), and infrared light and converts them to digital values. The RGBW sensor is designed to reject IR in light sources allowing the device to operate in environments from sunlight to dark rooms. The integrating ADC rejects 50Hz and 60Hz flickers caused by artificial light sources.
click Product page
Click library
- Author : Stefan Filipovic
- Date : Apr 2022.
- Type : I2C type
Software Support
We provide a library for the Color 15 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Color 15 Click driver.
Standard key functions :
color15_cfg_setup
Config Object Initialization function.
void color15_cfg_setup(color15_cfg_t *cfg)
Color 15 configuration object setup function.
Color 15 Click configuration object.
Definition color15.h:312
color15_init
Initialization function.
err_t color15_init(color15_t *ctx, color15_cfg_t *cfg)
Color 15 initialization function.
Color 15 Click context object.
Definition color15.h:293
color15_default_cfg
Click Default Configuration function.
err_t color15_default_cfg(color15_t *ctx)
Color 15 default configuration function.
Example key functions :
color15_get_data
This function reads data from 5 channels (Red, Green, Blue, White, IR).
err_t color15_get_data(color15_t *ctx, color15_channels_t *channels)
Color 15 get data function.
Color 15 RGBWIR channels data object.
Definition color15.h:328
color15_rgbw_to_hsl
This function converts RGBW (red, green, blue, white) to HSL (hue, saturation, lightness) color value.
void color15_rgbw_to_hsl(color15_t *ctx, color15_channels_t *rgbw, color15_hsl_t *hsl)
Color 15 rgbw to hsl function.
Color 15 HSL color data object.
Definition color15.h:342
color15_get_color
This function returns the color name flag from the input HSL color.
uint8_t color15_get_color(color15_hsl_t *hsl)
Color 15 get color function.
Example Description
This example demonstrates the use of Color 15 click board by reading data from 5 channels and converting them to HSL color and displaying those data as
well as the detected color name on the USB UART.
The demo application is composed of two sections :
Application Init
Initializes the driver and performs the click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
color15_init( &color15, &color15_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ COLOR15_ERROR
Definition color15.h:356
#define COLOR15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition color15.h:280
void application_init(void)
Definition main.c:31
Application Task
Waits for the data ready interrupt, then reads the values of all channels and converts them to HSL color and displays those data as well as the detected color name on the USB UART
every 500ms approximately.
{
{
log_printf ( &logger,
"\r\n Hue: %.1f deg\r\n", hsl.
hue );
log_printf ( &logger,
" Saturation: %.1f %%\r\n", hsl.
saturation );
log_printf ( &logger,
" Lightness: %.1f %%\r\n", hsl.
lightness );
{
{
log_printf( &logger, " Color: RED\r\n" );
break;
}
{
log_printf( &logger, " Color: YELLOW\r\n" );
break;
}
{
log_printf( &logger, " Color: GREEN\r\n" );
break;
}
{
log_printf( &logger, " Color: CYAN\r\n" );
break;
}
{
log_printf( &logger, " Color: BLUE\r\n" );
break;
}
{
log_printf( &logger, " Color: MAGENTA\r\n" );
break;
}
{
log_printf( &logger, " Color: WHITE\r\n" );
break;
}
{
log_printf( &logger, " Color: BLACK\r\n" );
break;
}
default:
{
log_printf( &logger, " Color: UNKNOWN\r\n" );
break;
}
}
}
}
@ COLOR15_OK
Definition color15.h:355
#define COLOR15_YELLOW_COLOR
Definition color15.h:221
#define COLOR15_WHITE_COLOR
Definition color15.h:226
#define COLOR15_BLACK_COLOR
Definition color15.h:227
#define COLOR15_RED_COLOR
Definition color15.h:220
#define COLOR15_BLUE_COLOR
Definition color15.h:224
#define COLOR15_MAGENTA_COLOR
Definition color15.h:225
#define COLOR15_GREEN_COLOR
Definition color15.h:222
#define COLOR15_CYAN_COLOR
Definition color15.h:223
err_t color15_clear_interrupt(color15_t *ctx)
Color 15 clear interrupt function.
uint8_t color15_get_int_pin(color15_t *ctx)
Color 15 get int pin function.
void application_task(void)
Definition main.c:67
float hue
Definition color15.h:343
float saturation
Definition color15.h:344
float lightness
Definition color15.h:345
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Color15
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.