Experience the future of navigation with the smart joystick concept, providing users with a seamless and intuitive way to explore digital worlds
A
A
Hardware Overview
How does it work?
Joystick 2 Click is based on the SKRHABE01, a 4-direction joystick switch with Center-push Function from Alps Alpine. It is positioned on the board so it is easily accessible for interacting and the lever could be pressed, activating the microswitch that way. The microswitch is actuated by applying very little physical force, using a tipping-point mechanism which results in fast and reliable snap-in action. It has both NO (Normal open) contacts routed to the mikroBUS™ over the port expander. The switch lines are equipped with the RC filters, which serve as debouncing
elements for the switch and also to pull-up the lines when they are left afloat. This way, the contact bouncing is reduced even further, resulting in an accurate detection of the switching event. As already mentioned above, this click board™ contains the port expander, relatively large number of needed GPIO pins for the joystick switch. Used IC is PCA9538A, Low-voltage 8-bit I2C-bus I/O port with interrupt and reset, from NXP Semiconductors. It uses the I2C communication for interfacing with the main MCU, which simplifies the number of needed pins,
and therefore the design itself. The Active LOW reset input (RESET) and Open-drain active LOW interrupt output (INT) pins helps simplifying the design even further. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand
functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,
which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Joystick 2 Click driver.
Key functions:
joystick2_set_cfg_register
- Functions for configuration joystickjoystick2_get_position
- Functions for get Joystick positionjoystick2_get_interrupt_state
- Functions for read interrupt state
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Joystick2 Click example
*
* # Description
* The demo application shows reading the joistick position ..
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configuring clicks and log objects.
* Reset device and settings the click in the default configuration.
*
* ## Application Task
* It reads the position of the joystick,
* if it detects that the joystick has moved from the zero position,
* it prints a message about the current position.
*
* @note: The I2C peripheral lines external pull up can be required.
*
* \author Katarina Perendic
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "joystick2.h"
// ------------------------------------------------------------------ VARIABLES
static joystick2_t joystick2;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
joystick2_cfg_t cfg;
/**
* 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.
joystick2_cfg_setup( &cfg );
JOYSTICK2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
joystick2_init( &joystick2, &cfg );
joystick2_reset( &joystick2 );
joystick2_default_cfg( &joystick2 );
log_info( &logger, "---- JOYSTICK START ----" );
}
void application_task ( void )
{
uint8_t joystick_pos;
// Task implementation.
joystick_pos = joystick2_get_position( &joystick2 );
switch ( joystick_pos )
{
case JOYSTICK2_BUTTON_ACTIVE:
{
log_info( &logger, "--- Button is pressed!!! ---" );
Delay_ms( 300 );
break;
}
case JOYSTICK2_POSITION_RIGHT:
{
log_info( &logger, "--- Joystick position [RIGHT] ---" );
Delay_ms( 300 );
break;
}
case JOYSTICK2_POSITION_LEFT:
{
log_info( &logger, "--- Joystick position [LEFT] ---" );
Delay_ms( 300 );
break;
}
case JOYSTICK2_POSITION_UP:
{
log_info( &logger, "--- Joystick position [UP] ---" );
Delay_ms( 300 );
break;
}
case JOYSTICK2_POSITION_DOWN:
{
log_info( &logger, "--- Joystick position [DOWN] ---" );
Delay_ms( 300 );
break;
}
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END