Add JOYSTICK_ROTATION build flag for joystick-equipped boards#2185
Open
sneznaovca wants to merge 1 commit intomeshcore-dev:devfrom
Open
Add JOYSTICK_ROTATION build flag for joystick-equipped boards#2185sneznaovca wants to merge 1 commit intomeshcore-dev:devfrom
sneznaovca wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ROTATIONbut the current UIdoes 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_ROTATIONbuild flag following the same0–3convention as
DISPLAY_ROTATION:0(default)123Variants that define
JOYSTICK_UP/JOYSTICK_DOWNpins(
wio-tracker-l1,gat562_mesh_tracker_pro,gat562_30s_mesh_kit)now instantiate
joystick_upandjoystick_downMomentaryButtonobjects so they are available when rotation 1 or 3 is selected.
A compile-time
#errorcatches misconfigured builds (rotation 1/3without the required pin definitions).
To enable on Wio Tracker L1 eInk, uncomment in
platformio.ini:-D JOYSTICK_ROTATION=1Testing
Tested on physical Wio Tracker L1 eInk hardware with the enclosure
linked above.