Color 13 click
Color 13 Click is a compact add-on board that measures the subtlest changes in light. This board features the APDS-9999, I2C compatible RGB, proximity detector, and vertical-cavity surface-emitting laser (VCSEL) in one optical module from Broadcom Limited.
click Product page
Click library
- Author : Luka Filipovic
- Date : Jun 2021.
- Type : I2C type
Software Support
We provide a library for the Color13 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 Color13 Click driver.
Standard key functions :
color13_cfg_setup
Config Object Initialization function.
void color13_cfg_setup(color13_cfg_t *cfg)
Color 13 configuration object setup function.
Color 13 Click configuration object.
Definition color13.h:186
color13_init
Initialization function.
err_t color13_init(color13_t *ctx, color13_cfg_t *cfg)
Color 13 initialization function.
Color 13 Click context object.
Definition color13.h:166
Example key functions :
color13_get_rgb_ir
Read color data from device.
err_t color13_get_rgb_ir(color13_t *ctx, color13_color_t *color_data)
Read color data from device.
Color 13 color data object.
Definition color13.h:202
color13_get_als
Read lux data from device.
err_t color13_get_als(color13_t *ctx, float *als_data)
Read lux data from device.
color13_get_proximity
Read proximity data from device.
err_t color13_get_proximity(color13_t *ctx, uint16_t *ps_data)
Read proximity data from device.
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
Initialization of host communication modules (UART, I2C) and additonal pin.
Read and check device ID, selects example and configures device for it.
{
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 == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
log_printf( &logger, " > ID: 0x%.2X\r\n", ( uint16_t )temp_data );
{
log_error( &logger, " ID" );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
{
temp_data |= 0x18;
}
Delay_ms ( 1000 );
log_info( &logger, " Application Task " );
}
@ COLOR13_OK
Definition color13.h:216
#define COLOR13_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition color13.h:153
#define COLOR13_REG_MAIN_CTRL
Color 13 description register.
Definition color13.h:73
#define COLOR13_REG_PART_ID
Definition color13.h:79
#define COLOR13_REG_PS_MEASRATE
Definition color13.h:76
#define COLOR13_ID
Color 13 device ID data.
Definition color13.h:127
err_t color13_generic_read(color13_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Color 13 I2C reading function.
err_t color13_generic_write(color13_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Color 13 I2C writing function.
void application_init(void)
Definition main.c:54
#define COLOR13_EXAMPLE_PS_LS
Definition main.c:32
#define COLOR13_EXAMPLE_RGB
Definition main.c:33
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.
{
switch ( example_type )
{
{
color13_proximity_als_example( );
break;
}
{
color13_rgb_example( );
break;
}
default:
{
log_error( &logger, " Select example!" );
break;
}
}
Delay_ms ( 500 );
}
void application_task(void)
Definition main.c:112
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.Color13
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.