rotaryrgb  2.1.0.0
Main Page

Rotary RGB Click

Rotary RGB Click is a compact add-on board for creating visual effects and precise position indications. This board features 16 individual RGB LEDs (WS2812B-2020) from Worldsemi and a high-quality rotary encoder (EC12D1564402) from ALPS. The WS2812B-2020 offers low driving voltage, high brightness, and excellent consistency, while the rotary encoder provides accurate 15-pulse incremental encoding with push-button functionality.

Click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Jan 2024.
  • Type : GPIO type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This library contains the API for the Rotary RGB Click driver to control LEDs states and a rotary encoder position readings.

The demo application is composed of two sections :

Application Init

Initialization of GPIO module and log UART. After the driver init, the app turn off all LEDs.

void application_init ( void )
{
log_cfg_t log_cfg;
rotaryrgb_cfg_t rotaryrgb_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rotaryrgb_cfg_setup( &rotaryrgb_cfg, &rotaryrgb_logic_zero, &rotaryrgb_logic_one );
ROTARYRGB_MAP_MIKROBUS( rotaryrgb_cfg, MIKROBUS_1 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == rotaryrgb_init( &rotaryrgb, &rotaryrgb_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
Delay_ms ( 100 );
}

Application Task

This example demonstrates the use of the Rotary RGB Click board. The demo example shows the functionality of a rotary encoder used to control RGB LEDs. The switch controls the application of the colors, and the encoder mechanism controls the state of the LEDs.

void application_task ( void )
{
rotaryrgb_set_led_pos_color( &rotaryrgb, led_pos % 17, demo_color_table[ led_color_sel ] );
rotaryrgb_switch_detection( );
rotaryrgb_encoder_mechanism( );
}

Note

Make sure the logic delays are defined for your system in the rotaryrgb_delays.h file.

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

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.


rotaryrgb_cfg_t
Rotary RGB Click configuration object.
Definition: rotaryrgb.h:175
rotaryrgb_set_all_led_color
void rotaryrgb_set_all_led_color(rotaryrgb_t *ctx, uint32_t led_color)
Rotary RGB set all LEDs color function.
application_task
void application_task(void)
Definition: main.c:126
rotaryrgb_set_all_leds_data
void rotaryrgb_set_all_leds_data(rotaryrgb_t *ctx, uint32_t *data_in)
Rotary RGB set all LEDs data function.
rotaryrgb_get_state_switch
uint8_t rotaryrgb_get_state_switch(rotaryrgb_t *ctx)
Rotary RGB get switch state function.
rotaryrgb_init
err_t rotaryrgb_init(rotaryrgb_t *ctx, rotaryrgb_cfg_t *cfg)
Rotary RGB initialization function.
rotaryrgb_set_led_pos_color
err_t rotaryrgb_set_led_pos_color(rotaryrgb_t *ctx, uint8_t led_pos, uint32_t led_color)
Rotary RGB set LED position color function.
ROTARYRGB_COLOR_OFF
#define ROTARYRGB_COLOR_OFF
Definition: rotaryrgb.h:100
rotaryrgb_cfg_setup
void rotaryrgb_cfg_setup(rotaryrgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one)
Rotary RGB configuration object setup function.
application_init
void application_init(void)
Definition: main.c:92
rotaryrgb_t
Rotary RGB Click context object.
Definition: rotaryrgb.h:156
ROTARYRGB_MAP_MIKROBUS
#define ROTARYRGB_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rotaryrgb.h:139