color17  2.1.0.0
Main Page

Color 17 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Nenad Filipovic
  • Date : Apr 2023.
  • Type : I2C type

Software Support

We provide a library for the Color 17 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 17 Click driver.

Standard key functions :

Example key functions :

Example Description

This library contains API for the Color 17 Click driver. This example displays CCT data, Light intensity level and the light color names.

The demo application is composed of two sections :

Application Init

Initialization of I2C module and log UART. After driver initialization, default settings turn on the device.

void application_init ( void )
{
log_cfg_t log_cfg;
color17_cfg_t color17_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
color17_cfg_setup( &color17_cfg );
COLOR17_MAP_MIKROBUS( color17_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == color17_init( &color17, &color17_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( COLOR17_ERROR == color17_default_cfg ( &color17 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}

Application Task

This example demonstrates the use of the Color 17 Click board™. Reads and displays the calculate the correlated color temperature and Light intensity level. This example also detects and displays the light color names. Results are being sent to the UART Terminal, where you can track their changes.

void application_task ( void )
{
if ( COLOR17_OK == color17_get_cct( &color17, &cct, &light_intensity ) )
{
log_printf( &logger, " CCT: %.2f\r\n", cct );
log_printf( &logger, " LIL: %.2f\r\n", light_intensity );
}
log_printf( &logger, " - - - - - - - - - - - \r\n" );
log_printf( &logger, " ----------------------\r\n" );
Delay_ms( 1000 );
}

Note

Color detection is obtained based on the analysis of calculate the correlated color temperature (CCT) data and the CIE 1931 chromaticity diagram. For more details please refer to the “OPT4048 High Speed High Precision Tristimulus XYZ Color Sensor datasheet” OPT4048 datasheet.

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.Color17

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.


COLOR17_ERROR
@ COLOR17_ERROR
Definition: color17.h:269
color17_cfg_setup
void color17_cfg_setup(color17_cfg_t *cfg)
Color 17 configuration object setup function.
color17_default_cfg
err_t color17_default_cfg(color17_t *ctx)
Color 17 default configuration function.
COLOR17_OK
@ COLOR17_OK
Definition: color17.h:268
application_task
void application_task(void)
Definition: main.c:123
color17_get_measurement
err_t color17_get_measurement(color17_t *ctx, uint32_t *adc_codes)
Color 17 gets light and color measurement data function.
color17_set_config
err_t color17_set_config(color17_t *ctx, color17_config_t config)
Color 17 set the configuration function.
color17_get_cct
err_t color17_get_cct(color17_t *ctx, float *cct, float *light_intensity)
Color 17 gets correlated color temperature data function.
display_color
void display_color(void)
Definition: main.c:50
COLOR17_MAP_MIKROBUS
#define COLOR17_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: color17.h:188
color17_config_t
Color 17 Click configuration data object.
Definition: color17.h:234
application_init
void application_init(void)
Definition: main.c:86
color17_t
Color 17 Click context object.
Definition: color17.h:201
color17_init
err_t color17_init(color17_t *ctx, color17_cfg_t *cfg)
Color 17 initialization function.
color17_cfg_t
Color 17 Click configuration object.
Definition: color17.h:218