TOP Contributors

  1. MIKROE (2658 codes)
  2. Alcides Ramos (355 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136927 times)
  2. FAT32 Library (70050 times)
  3. Network Ethernet Library (56012 times)
  4. USB Device Library (46313 times)
  5. Network WiFi Library (41935 times)
  6. FT800 Library (41243 times)
  7. GSM click (29030 times)
  8. PID Library (26435 times)
  9. mikroSDK (26422 times)
  10. microSD click (25390 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Button Power click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: Capacitive

Downloaded: 62 times

Not followed.

License: MIT license  

Button Power 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 CTHS15CIC05ONOFF 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 power symbol icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Button Power click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Button Power click" changes.

Do you want to report abuse regarding "Button Power click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


Button Power click

Button Power 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 CTHS15CIC05ONOFF 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 power symbol icon with backlight, which makes the Click board™ very useful for building various stylized and visually appealing interfaces.

button_power_click.png

click Product page


Click library

  • Author : Nikola Peric
  • Date : Jan 2022.
  • Type : GPIO type

Software Support

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

Standard key functions :

  • buttonpower_cfg_setup Config Object Initialization function.

    void buttonpower_cfg_setup ( buttonpower_cfg_t *cfg );
  • buttonpower_init Initialization function.

    err_t buttonpower_init ( buttonpower_t *ctx, buttonpower_cfg_t *cfg );

Example key functions :

  • buttonpower_pwm_stop This function stops the PWM moudle output.

    err_t buttonpower_pwm_stop ( buttonpower_t *ctx );
  • buttonpower_pwm_start This function starts the PWM moudle output.

    err_t buttonpower_pwm_start ( buttonpower_t *ctx );
  • buttonpower_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 buttonpower_get_button_state ( buttonpower_t *ctx );

Example Description

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 :

Application Init

This function initializes and configures the logger and click modules.


void application_init ( void ) 
{
    log_cfg_t log_cfg;                   /**< Logger config object. */
    buttonpower_cfg_t buttonpower_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.

    buttonpower_cfg_setup( &buttonpower_cfg );
    BUTTONPOWER_MAP_MIKROBUS( buttonpower_cfg, MIKROBUS_1 );
    err_t init_flag  = buttonpower_init( &buttonpower, &buttonpower_cfg );
    if ( PWM_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    Delay_ms ( 500 );

    buttonpower_pwm_start( &buttonpower );
    buttonpower_set_duty_cycle ( &buttonpower, 0.1 );

    log_info( &logger, " Application Task " );
}

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 = buttonpower_get_button_state( &buttonpower );

    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;
            buttonpower_set_duty_cycle( &buttonpower, 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;
            buttonpower_set_duty_cycle( &buttonpower, 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:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ButtonPower

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.


ALSO FROM THIS AUTHOR

ADAC 3 click

0

ADAC 3 Click is a compact add-on board representing the ADC/DAC combo solution. This board features the PCF8591, a low-power 8-bit CMOS data acquisition device with four analog inputs, one analog output, and a serial I2C interface from NXP Semiconductors. The PCF8591 includes analog input multiplexing, an on-chip track and hold function and 8-bit analog-to-digital conversion alongside an 8-bit digital-to-analog conversion. In addition, the user is given the option to select the PCF8591 reference voltage value, choosing between 2,048 and 4,096V.

[Learn More]

Button Y click

0

Button Y click is a Click board™ equipped with the tactile switch, sometimes referred to as a pushbutton. A pushbutton is a component that is used very often in various designs, allowing the user to interact with the application. Although it sounds simple, a button needs to comply with a range of application requirements. It needs to have a very good mechanical endurance while retaining its specifications, a predictable bouncing time, a very low ON resistance, very high OFF resistance, and it needs to fulfill aesthetical requirements.

[Learn More]

TempHum 8 click

0

Temp&Hum 8 click is based on a sensor from the popular SHT family, designed to measure temperature and humidity.

[Learn More]