color14  2.0.0.0
Main Page

Color 14 Click

Color 14 Click is a compact add-on board that represents an accurate color sensing solution. This board features the APDS-9151, an integrated RGB, ambient light sensing, IR LED, and a complete proximity detection system from Broadcom Limited.

Click Product page


Click library

  • Author : Luka Filipovic
  • Date : Aug 2021.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This application showcases ability of Click board to read RGB and IR data

from device. Also it can be configured to read proximity data and ALS data in lux units.

The demo application is composed of two sections :

Application Init

Application Init

Initialization of host communication modules (UART, I2C) and additonal pin. Read and check device ID, selects example and configures device for it.

void application_init ( void )
{
log_cfg_t log_cfg;
color14_cfg_t color14_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
color14_cfg_setup( &color14_cfg );
COLOR14_MAP_MIKROBUS( color14_cfg, MIKROBUS_1 );
err_t init_flag = color14_init( &color14, &color14_cfg );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
init_flag = color14_generic_read( &color14, COLOR14_REG_PART_ID, &temp_data, 1 );
log_printf( &logger, " > ID: 0x%.2X\r\n", ( uint16_t )temp_data );
if ( ( COLOR14_OK != init_flag ) && ( COLOR14_ID != temp_data ) )
{
log_error( &logger, " ID" );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
//Select example
example_type = COLOR14_EXAMPLE_RGB;
color14_generic_write( &color14, COLOR14_REG_MAIN_CTRL, &example_type, 1 );
if ( COLOR14_EXAMPLE_PS_LS == example_type )
{
//Configure proximity data to 11 bit
color14_generic_read( &color14, COLOR14_REG_PS_MEASRATE, &temp_data, 1 );
temp_data |= 0x18;
color14_generic_write( &color14, COLOR14_REG_PS_MEASRATE, &temp_data, 1 );
}
Delay_ms ( 1000 );
log_info( &logger, " Application Task " );
}

Application Task

Depending of selected example in task proximity and als data will be read from

device, or it will show ADC value for red, green, blue and ir data from device.

void application_task ( void )
{
switch ( example_type )
{
{
color14_proximity_als_example( );
break;
}
{
color14_rgb_example( );
break;
}
default:
{
log_error( &logger, " Select example!" );
break;
}
}
Delay_ms ( 500 );
}

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

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.


COLOR14_ID
#define COLOR14_ID
Color 14 device ID data.
Definition: color14.h:127
color14_generic_write
err_t color14_generic_write(color14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Color 14 I2C writing function.
color14_get_als
err_t color14_get_als(color14_t *ctx, float *als_data)
Read lux data from device.
color14_get_rgb_ir
err_t color14_get_rgb_ir(color14_t *ctx, color14_color_t *color_data)
Read color data from device.
COLOR14_MAP_MIKROBUS
#define COLOR14_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: color14.h:152
COLOR14_REG_MAIN_CTRL
#define COLOR14_REG_MAIN_CTRL
Color 14 description register.
Definition: color14.h:73
application_task
void application_task(void)
Definition: main.c:112
color14_init
err_t color14_init(color14_t *ctx, color14_cfg_t *cfg)
Color 14 initialization function.
color14_cfg_setup
void color14_cfg_setup(color14_cfg_t *cfg)
Color 14 configuration object setup function.
COLOR14_EXAMPLE_RGB
#define COLOR14_EXAMPLE_RGB
Definition: main.c:33
color14_color_t
Color 14 color data object.
Definition: color14.h:201
COLOR14_REG_PART_ID
#define COLOR14_REG_PART_ID
Definition: color14.h:79
color14_get_proximity
err_t color14_get_proximity(color14_t *ctx, uint16_t *ps_data)
Read proximity data from device.
COLOR14_REG_PS_MEASRATE
#define COLOR14_REG_PS_MEASRATE
Definition: color14.h:76
COLOR14_EXAMPLE_PS_LS
#define COLOR14_EXAMPLE_PS_LS
Definition: main.c:32
application_init
void application_init(void)
Definition: main.c:54
color14_t
Color 14 Click context object.
Definition: color14.h:165
color14_generic_read
err_t color14_generic_read(color14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Color 14 I2C reading function.
color14_cfg_t
Color 14 Click configuration object.
Definition: color14.h:185
COLOR14_OK
@ COLOR14_OK
Definition: color14.h:215