Skip to content

Add JOYSTICK_ROTATION build flag for joystick-equipped boards#2185

Open
sneznaovca wants to merge 1 commit intomeshcore-dev:devfrom
sneznaovca:feature/joystick-rotation
Open

Add JOYSTICK_ROTATION build flag for joystick-equipped boards#2185
sneznaovca wants to merge 1 commit intomeshcore-dev:devfrom
sneznaovca:feature/joystick-rotation

Conversation

@sneznaovca
Copy link
Copy Markdown

Motivation

Some 3D-printed enclosures for the Wio Tracker L1 eInk (e.g.
this one on Printables)
mount the display beside the joystick rather than above it. In this
orientation the physical up/down buttons align with left/right navigation
on screen, making the default joystick mapping unusable.

I tried working around this with DISPLAY_ROTATION but the current UI
does not handle portrait orientation well — that would need more involved
changes. This PR takes the simpler approach of remapping the joystick
input to match the physical orientation, which is sufficient for normal
use. (Happy to also look into proper portrait UI support if that's of
interest to maintainers.)

Changes

Adds a JOYSTICK_ROTATION build flag following the same 03
convention as DISPLAY_ROTATION:

Value Effect
0 (default) no change — left/right navigate left/right
1 90° CW — up/down navigate right/left
2 180° — left/right are swapped
3 270° — up/down navigate left/right

Variants that define JOYSTICK_UP/JOYSTICK_DOWN pins
(wio-tracker-l1, gat562_mesh_tracker_pro, gat562_30s_mesh_kit)
now instantiate joystick_up and joystick_down MomentaryButton
objects so they are available when rotation 1 or 3 is selected.
A compile-time #error catches misconfigured builds (rotation 1/3
without the required pin definitions).

To enable on Wio Tracker L1 eInk, uncomment in platformio.ini:

-D JOYSTICK_ROTATION=1                                                                                                                                                                                                                                               

Testing

Tested on physical Wio Tracker L1 eInk hardware with the enclosure
linked above.

Boards like the Wio Tracker L1 eInk can be mounted with the display beside
the joystick (rotated 90 deg) rather than above it. In this orientation the
physical up/down buttons correspond to right/left navigation on screen.

JOYSTICK_ROTATION follows the same 0-3 convention as DISPLAY_ROTATION:
  0 (default) - no rotation, left/right buttons navigate left/right
  1           - 90 deg CW, up/down buttons navigate right/left
  2           - 180 deg, left/right buttons are swapped
  3           - 270 deg, up/down buttons navigate left/right

Variants that define JOYSTICK_UP/JOYSTICK_DOWN pins (wio-tracker-l1,
gat562_mesh_tracker_pro, gat562_30s_mesh_kit) now instantiate joystick_up
and joystick_down MomentaryButton objects unconditionally so they are
available when JOYSTICK_ROTATION 1 or 3 is selected.

A compile-time #error fires if JOYSTICK_ROTATION 1/3 is requested on a
board that does not define JOYSTICK_UP/JOYSTICK_DOWN pins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant