We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2024-10-31
Package Version: 2.1.0.13
mikroSDK Library: 2.0.0.0
Category: Capacitive
Downloaded: 157 times
Not followed.
License: MIT license
Button PLAY Click is a very interesting interactive gadget on a Click board™. It is an integrated capacitive touch sensor display in the form of a button. By utilizing an advanced capacitive touch sensing technology, the CTHS15CIC05ARROW sensor can successfully replace the traditional mechanical button, allowing very simplified yet reliable user interfaces to be developed. Besides the touch detection, this sensor also features a green arrow icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.
Do you want to subscribe in order to receive notifications regarding "Button PLAY Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Button PLAY Click" changes.
Do you want to report abuse regarding "Button PLAY Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
4608_button_play_clic.zip [450.55KB] | mikroC AI for ARM GCC for ARM Clang for ARM mikroC AI for PIC mikroC AI for PIC32 XC32 GCC for RISC-V Clang for RISC-V mikroC AI for AVR mikroC AI for dsPIC XC16 |
|
Button PLAY Click is a very interesting interactive gadget on a Click board™. It is an integrated capacitive touch sensor display in the form of a button. By utilizing an advanced capacitive touch sensing technology, the CTHS15CIC05ARROW sensor can successfully replace the traditional mechanical button, allowing very simplified yet reliable user interfaces to be developed. Besides the touch detection, this sensor also features a green arrow icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.
We provide a library for the ButtonPlay 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.
This library contains API for ButtonPlay Click driver.
buttonplay_cfg_setup
Config Object Initialization function.
void buttonplay_cfg_setup ( buttonplay_cfg_t *cfg );
buttonplay_init
Initialization function.
err_t buttonplay_init ( buttonplay_t *ctx, buttonplay_cfg_t *cfg );
buttonplay_pwm_stop
This function stops the PWM moudle output.
err_t buttonplay_pwm_stop ( buttonplay_t *ctx );
- `buttonplay_pwm_start` This function starts the PWM moudle output.
```c
err_t buttonplay_pwm_start ( buttonplay_t *ctx );
buttonplay_get_button_state
This function reads the digital signal from the INT pin which tells us whether the button has been pressed or not.uint8_t buttonplay_get_button_state ( buttonplay_t *ctx );
This example showcases how to initialize and use the whole family of Button clicks. One library is used for every single one of them. They are simple touch detectors which send a pressed/released signal and receive a PWM output which controls the backlight on the button.
The demo application is composed of two sections :
This function initializes and configures the logger and Click modules.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
buttonplay_cfg_t buttonplay_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
buttonplay_cfg_setup( &buttonplay_cfg );
BUTTONPLAY_MAP_MIKROBUS( buttonplay_cfg, MIKROBUS_1 );
err_t init_flag = buttonplay_init( &buttonplay, &buttonplay_cfg );
if ( PWM_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms ( 500 );
buttonplay_set_duty_cycle ( &buttonplay, 0.0 );
buttonplay_pwm_start( &buttonplay );
log_info( &logger, " Application Task " );
}
This example first increases the backlight on the button and then decreases the intensity of the backlight. When the button is touched, reports the event in the console using UART communication.
void application_task ( void )
{
static float duty_cycle;
static uint8_t button_state;
static uint8_t button_state_old;
button_state = buttonplay_get_button_state( &buttonplay );
if ( button_state && ( button_state != button_state_old ) )
{
log_printf( &logger, " <-- Button pressed --> \r\n" );
for ( uint8_t n_cnt = 1; n_cnt <= 100; n_cnt++ )
{
duty_cycle = ( float ) n_cnt ;
duty_cycle /= 100;
buttonplay_set_duty_cycle( &buttonplay, duty_cycle );
Delay_ms ( 10 );
}
button_state_old = button_state;
}
else if ( !button_state && ( button_state != button_state_old ) )
{
for ( uint8_t n_cnt = 100; n_cnt > 0; n_cnt-- )
{
duty_cycle = ( float ) n_cnt ;
duty_cycle /= 100;
buttonplay_set_duty_cycle( &buttonplay, duty_cycle );
Delay_ms ( 10 );
}
button_state_old = button_state;
}
}
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:
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.