TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139248 times)
  2. FAT32 Library (71743 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47429 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28073 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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

Joystick 4 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: Pushbutton/Switches

Downloaded: 24 times

Not followed.

License: MIT license  

Joystick 4 Click is a compact add-on board that provides precise and reliable input control for various interactive projects. This board features the 2434804-1, a 5-position tactile switch from the ALCOSWITCH series by TE Connectivity. The switch features an extended top actuator for precise input detection, a stainless steel contact base, and silver contact plating, ensuring durability and corrosion resistance with a lifespan of 100,000 cycles. With a low-profile design, it handles a contact current rating of 50mA.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Joystick 4 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Joystick 4 Click" changes.

Do you want to report abuse regarding "Joystick 4 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Joystick 4 Click

Joystick 4 Click is a compact add-on board that provides precise and reliable input control for various interactive projects. This board features the 2434804-1, a 5-position tactile switch from the ALCOSWITCH series by TE Connectivity. The switch features an extended top actuator for precise input detection, a stainless steel contact base, and silver contact plating, ensuring durability and corrosion resistance with a lifespan of 100,000 cycles. With a low-profile design, it handles a contact current rating of 50mA.

joystick4_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

  • joystick4_cfg_setup Config Object Initialization function.

    void joystick4_cfg_setup ( joystick4_cfg_t *cfg );
  • joystick4_init Initialization function.

    err_t joystick4_init ( joystick4_t *ctx, joystick4_cfg_t *cfg );
  • joystick4_default_cfg Click Default Configuration function.

    err_t joystick4_default_cfg ( joystick4_t *ctx );

Example key functions :

  • joystick4_get_int_pin This function returns the INT pin logic state.

    uint8_t joystick4_get_int_pin ( joystick4_t *ctx );
  • joystick4_get_pins This function reads all input pins logic state.

    err_t joystick4_get_pins ( joystick4_t *ctx, uint8_t *pin_mask );
  • joystick4_get_position This function returns the joystick position flag extracted from the input pins state mask.

    uint8_t joystick4_get_position ( uint8_t pin_mask );

Example Description

This example demonstrates the use of the Joystick 4 Click board by reading and displaying the joystick position.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    joystick4_cfg_t joystick4_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.
    joystick4_cfg_setup( &joystick4_cfg );
    JOYSTICK4_MAP_MIKROBUS( joystick4_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == joystick4_init( &joystick4, &joystick4_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( JOYSTICK4_ERROR == joystick4_default_cfg ( &joystick4 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );

    if ( JOYSTICK4_PIN_STATE_HIGH == joystick4_get_int_pin ( &joystick4 ) )
    {
        log_printf ( &logger, " Joystick position: IDLE\r\n\n" );
    }
}

Application Task

Waits for the input change interrupt, reads the input pins mask, extracts the joystick position from those readings, and displays it on the USB UART.

void application_task ( void )
{
    uint8_t pin_mask = 0;
    if ( JOYSTICK4_PIN_STATE_LOW == joystick4_get_int_pin ( &joystick4 ) )
    {
        if ( JOYSTICK4_OK == joystick4_get_pins ( &joystick4, &pin_mask ) )
        {
            log_printf ( &logger, " Joystick position: " );
            switch ( joystick4_get_position ( pin_mask ) )
            {
                case JOYSTICK4_POSITION_IDLE:
                {
                    log_printf ( &logger, "IDLE" );
                    break;
                }
                case JOYSTICK4_POSITION_CENTER:
                {
                    log_printf ( &logger, "CENTER" );
                    break;
                }
                case JOYSTICK4_POSITION_CENTER_UP:
                {
                    log_printf ( &logger, "CENTER-UP" );
                    break;
                }
                case JOYSTICK4_POSITION_CENTER_RIGHT:
                {
                    log_printf ( &logger, "CENTER-RIGHT" );
                    break;
                }
                case JOYSTICK4_POSITION_CENTER_DOWN:
                {
                    log_printf ( &logger, "CENTER-DOWN" );
                    break;
                }
                case JOYSTICK4_POSITION_CENTER_LEFT:
                {
                    log_printf ( &logger, "CENTER-LEFT" );
                    break;
                }
                case JOYSTICK4_POSITION_UP:
                {
                    log_printf ( &logger, "UP" );
                    break;
                }
                case JOYSTICK4_POSITION_UPPER_RIGHT:
                {
                    log_printf ( &logger, "UPPER-RIGHT" );
                    break;
                }
                case JOYSTICK4_POSITION_RIGHT:
                {
                    log_printf ( &logger, "RIGHT" );
                    break;
                }
                case JOYSTICK4_POSITION_LOWER_RIGHT:
                {
                    log_printf ( &logger, "LOWER-RIGHT" );
                    break;
                }
                case JOYSTICK4_POSITION_DOWN:
                {
                    log_printf ( &logger, "DOWN" );
                    break;
                }
                case JOYSTICK4_POSITION_LOWER_LEFT:
                {
                    log_printf ( &logger, "LOWER-LEFT" );
                    break;
                }
                case JOYSTICK4_POSITION_LEFT:
                {
                    log_printf ( &logger, "LEFT" );
                    break;
                }
                case JOYSTICK4_POSITION_UPPER_LEFT:
                {
                    log_printf ( &logger, "UPPER-LEFT" );
                    break;
                }
                default:
                {
                    log_printf ( &logger, "UNKNOWN" );
                    break;
                }
            }
            log_printf ( &logger, "\r\n\n" );
        }
    }
}

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

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

Force Click

0

Force Click is a mikroBUS™ add-on board with circuitry for implementing Interlink Electronics’ Force Sensing Resistors into your projects (with a single zone force sensing resistor included with the Click). The Force Sensing Resistor is a thin sensor made of two membranes that are separated by a spacer around the edges.

[Learn More]

Nano Power 2 click

5

Nano Power 2 click is a very low power voltage comparator, aimed at portable and battery-powered applications. It allows detecting a difference of two voltage potentials, applied on two input pins.

[Learn More]

UT-M 7-SEG R click

0

UT-M 7-SEG R click carries two SMD ultra thin LED 7-SEG displays and the MAX6969 constant-current LED driver from Maxim Integrated. The click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]