TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 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 (139560 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47609 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 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: 26 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

PHT click

5

PHT Click is a compact add-on board that contains a PHT combo sensor. This board features the MS8607, a digital combination sensor providing 3 environmental measurements all-in-one: pressure, humidity, and temperature from TE Connectivity Measurement Specialties.

[Learn More]

Brushless 7 Click

0

Brushless 7 Click is, as its name said, a motor driver based expansion board for controlling BLCD motors with any microcontroller.

[Learn More]

Haptic click

2

Haptic click carries a Haptic Driver for ERM and LRA vibration motors. The board carries screw terminals for connecting said motors, as well as an audio interface (3.5mm jack). Haptic click communicates with the target MCU through mikroBUSâ„¢ I2C (SCL, SDA), EN (CS) and PWM pins. The board is designed to use either a 3.3V or 5V power supply.

[Learn More]