JoystickAdapter
-
class JoystickAdapter : public InputInterface
- #include <JoystickAdapter.h>
Adapter class to handle analog joystick input for an LCD menu.
This adapter reads the horizontal and vertical axes of a joystick and converts them into menu commands.
The joystick centre value defaults to
512and can be customised along with the dead-zone margin to accommodate different hardware.Public Functions
-
inline JoystickAdapter(LcdMenu *menu, uint8_t horizontalPin, uint8_t verticalPin, uint16_t center = 512, uint16_t margin = 100, byte leftCmd = BACK, byte rightCmd = RIGHT, byte upCmd = UP, byte downCmd = DOWN)
Construct a new JoystickAdapter.
The adapter can be customised by providing command codes for each direction. By default the horizontal axis maps to
BACKandRIGHTand the vertical axis toUPandDOWN. Pressing the joystick triggersENTER.- Parameters:
menu – Pointer to the LcdMenu instance
horizontalPin – Analog pin connected to the horizontal axis
verticalPin – Analog pin connected to the vertical axis
center – Centre value of the joystick (default
512)margin – Dead zone margin around the centre (default
100)leftCmd – Command for the left direction (default
BACK)rightCmd – Command for the right direction (default
RIGHT)upCmd – Command for the up direction (default
UP)downCmd – Command for the down direction (default
DOWN)
Private Members
-
inline JoystickAdapter(LcdMenu *menu, uint8_t horizontalPin, uint8_t verticalPin, uint16_t center = 512, uint16_t margin = 100, byte leftCmd = BACK, byte rightCmd = RIGHT, byte upCmd = UP, byte downCmd = DOWN)