Repository navigation
Adding support for InkHUD joystick navigation for the Seeed Wio Tracker L1 E-ink #8678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HarukiToreda
merged 21 commits into
meshtastic:develop
from
zeropt:seeed-l1-inkhud-with-joystick
Dec 20, 2025
+1,523
−28
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
67fc0c5
TwoButtonExtened mirrors TwoButton but added joystick functionality
scobert969 891a896
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt 4f5ef6c
basic ui navigation with a joystick
zeropt a4ee7ba
handle joystick input in NotificationApplet and TipsApplet
zeropt 1223bf0
MenuApplet controls
scobert969 9ae43d5
add AlignStickApplet for aligning the joystick with the screen
zeropt 3a158c8
update tips applet with joystick controls
zeropt 658d3cf
format InkHUD additions
zeropt 6a4d581
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt ff4057e
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt 9afbb25
fix stroke consistency when resizing joystick graphic
zeropt 8f6d41f
tweak button tips for order consistency
zeropt e4bcf38
increase joystick debounce
zeropt c48b80c
fix comments
zeropt 92ee34e
remove unnecessary '+'
zeropt 1b3d1e3
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt 8a79c10
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt 2e87624
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda ae2c94f
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda 1a762fe
remap joystick controls to match standard inkHUD behavior
zeropt 57e0095
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
205 changes: 205 additions & 0 deletions
205
src/graphics/niche/InkHUD/Applets/System/AlignStick/AlignStickApplet.cpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| #ifdef MESHTASTIC_INCLUDE_INKHUD | ||
|
|
||
| #include "./AlignStickApplet.h" | ||
|
|
||
| using namespace NicheGraphics; | ||
|
|
||
| InkHUD::AlignStickApplet::AlignStickApplet() | ||
| { | ||
| if (!settings->joystick.aligned) | ||
| bringToForeground(); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onRender() | ||
| { | ||
| setFont(fontMedium); | ||
| printAt(0, 0, "Align Joystick:"); | ||
| setFont(fontSmall); | ||
| std::string instructions = "Move joystick in the direction indicated"; | ||
| printWrapped(0, fontMedium.lineHeight() * 1.5, width(), instructions); | ||
|
|
||
| // Size of the region in which the joystick graphic should fit | ||
| uint16_t joyXLimit = X(0.8); | ||
| uint16_t contentH = fontMedium.lineHeight() * 1.5 + fontSmall.lineHeight() * 1; | ||
| if (getTextWidth(instructions) > width()) | ||
| contentH += fontSmall.lineHeight(); | ||
| uint16_t freeY = height() - contentH - fontSmall.lineHeight() * 1.2; | ||
| uint16_t joyYLimit = freeY * 0.8; | ||
|
|
||
| // Use the shorter of the two | ||
| uint16_t joyWidth = joyXLimit < joyYLimit ? joyXLimit : joyYLimit; | ||
|
|
||
| // Center the joystick graphic | ||
| uint16_t centerX = X(0.5); | ||
| uint16_t centerY = contentH + freeY * 0.5; | ||
|
|
||
| // Draw joystick graphic | ||
| drawStick(centerX, centerY, joyWidth); | ||
|
|
||
| setFont(fontSmall); | ||
| printAt(X(0.5), Y(1.0) - fontSmall.lineHeight() * 0.2, "Long press to skip", CENTER, BOTTOM); | ||
| } | ||
|
|
||
| // Draw a scalable joystick graphic | ||
| void InkHUD::AlignStickApplet::drawStick(uint16_t centerX, uint16_t centerY, uint16_t width) | ||
| { | ||
| if (width < 9) // too small to draw | ||
| return; | ||
|
|
||
| else if (width < 40) { // only draw up arrow | ||
| uint16_t chamfer = width < 20 ? 1 : 2; | ||
|
|
||
| // Draw filled up arrow | ||
| drawDirection(centerX, centerY - width / 4, Direction::UP, width, chamfer, BLACK); | ||
|
|
||
| } else { // large enough to draw the full thing | ||
| uint16_t chamfer = width < 80 ? 1 : 2; | ||
| uint16_t stroke = 3; // pixels | ||
| uint16_t arrowW = width * 0.22; | ||
| uint16_t hollowW = arrowW + -stroke * 2; | ||
|
|
||
| // Draw center circle | ||
| fillCircle((int16_t)centerX, (int16_t)centerY, (int16_t)(width * 0.2), BLACK); | ||
| fillCircle((int16_t)centerX, (int16_t)centerY, (int16_t)(width * 0.2) - stroke, WHITE); | ||
|
|
||
| // Draw filled up arrow | ||
| drawDirection(centerX, centerY - width / 2, Direction::UP, arrowW, chamfer, BLACK); | ||
|
|
||
| // Draw down arrow | ||
| drawDirection(centerX, centerY + width / 2, Direction::DOWN, arrowW, chamfer, BLACK); | ||
| drawDirection(centerX, centerY + width / 2 - stroke, Direction::DOWN, hollowW, 0, WHITE); | ||
|
|
||
| // Draw left arrow | ||
| drawDirection(centerX - width / 2, centerY, Direction::LEFT, arrowW, chamfer, BLACK); | ||
| drawDirection(centerX - width / 2 + stroke, centerY, Direction::LEFT, hollowW, 0, WHITE); | ||
|
|
||
| // Draw right arrow | ||
| drawDirection(centerX + width / 2, centerY, Direction::RIGHT, arrowW, chamfer, BLACK); | ||
| drawDirection(centerX + width / 2 - stroke, centerY, Direction::RIGHT, hollowW, 0, WHITE); | ||
| } | ||
| } | ||
|
|
||
| // Draw a scalable joystick direction arrow | ||
| // a right-triangle with blunted tips | ||
| /* | ||
| _ <--point | ||
| ^ / \ | ||
| | / \ | ||
| size / \ | ||
| | / \ | ||
| v |_________| | ||
|
|
||
| */ | ||
| void InkHUD::AlignStickApplet::drawDirection(uint16_t pointX, uint16_t pointY, Direction direction, uint16_t size, | ||
| uint16_t chamfer, Color color) | ||
| { | ||
| uint16_t chamferW = chamfer * 2 + 1; | ||
| uint16_t triangleW = size - chamferW; | ||
|
|
||
| // Draw arrow | ||
| switch (direction) { | ||
| case Direction::UP: | ||
| fillRect(pointX - chamfer, pointY, chamferW, triangleW, color); | ||
| fillRect(pointX - chamfer - triangleW, pointY + triangleW, chamferW + triangleW * 2, chamferW, color); | ||
| fillTriangle(pointX - chamfer, pointY, pointX - chamfer - triangleW, pointY + triangleW, pointX - chamfer, | ||
| pointY + triangleW, color); | ||
| fillTriangle(pointX + chamfer, pointY, pointX + chamfer + triangleW, pointY + triangleW, pointX + chamfer, | ||
| pointY + triangleW, color); | ||
| break; | ||
| case Direction::DOWN: | ||
| fillRect(pointX - chamfer, pointY - triangleW + 1, chamferW, triangleW, color); | ||
| fillRect(pointX - chamfer - triangleW, pointY - size + 1, chamferW + triangleW * 2, chamferW, color); | ||
| fillTriangle(pointX - chamfer, pointY, pointX - chamfer - triangleW, pointY - triangleW, pointX - chamfer, | ||
| pointY - triangleW, color); | ||
| fillTriangle(pointX + chamfer, pointY, pointX + chamfer + triangleW, pointY - triangleW, pointX + chamfer, | ||
| pointY - triangleW, color); | ||
| break; | ||
| case Direction::LEFT: | ||
| fillRect(pointX, pointY - chamfer, triangleW, chamferW, color); | ||
| fillRect(pointX + triangleW, pointY - chamfer - triangleW, chamferW, chamferW + triangleW * 2, color); | ||
| fillTriangle(pointX, pointY - chamfer, pointX + triangleW, pointY - chamfer - triangleW, pointX + triangleW, | ||
| pointY - chamfer, color); | ||
| fillTriangle(pointX, pointY + chamfer, pointX + triangleW, pointY + chamfer + triangleW, pointX + triangleW, | ||
| pointY + chamfer, color); | ||
| break; | ||
| case Direction::RIGHT: | ||
| fillRect(pointX - triangleW + 1, pointY - chamfer, triangleW, chamferW, color); | ||
| fillRect(pointX - size + 1, pointY - chamfer - triangleW, chamferW, chamferW + triangleW * 2, color); | ||
| fillTriangle(pointX, pointY - chamfer, pointX - triangleW, pointY - chamfer - triangleW, pointX - triangleW, | ||
| pointY - chamfer, color); | ||
| fillTriangle(pointX, pointY + chamfer, pointX - triangleW, pointY + chamfer + triangleW, pointX - triangleW, | ||
| pointY + chamfer, color); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onForeground() | ||
| { | ||
| // Prevent most other applets from requesting update, and skip their rendering entirely | ||
| // Another system applet with a higher precedence can potentially ignore this | ||
| SystemApplet::lockRendering = true; | ||
| SystemApplet::lockRequests = true; | ||
|
|
||
| handleInput = true; // Intercept the button input for our applet | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onBackground() | ||
| { | ||
| // Allow normal update behavior to resume | ||
| SystemApplet::lockRendering = false; | ||
| SystemApplet::lockRequests = false; | ||
| SystemApplet::handleInput = false; | ||
|
|
||
| // Need to force an update, as a polite request wouldn't be honored, seeing how we are now in the background | ||
| // Usually, onBackground is followed by another applet's onForeground (which requests update), but not in this case | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onButtonLongPress() | ||
| { | ||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onStickCenterLong() | ||
| { | ||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onStickUp() | ||
| { | ||
| settings->joystick.aligned = true; | ||
|
|
||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onStickDown() | ||
| { | ||
| inkhud->rotateJoystick(2); // 180 deg | ||
| settings->joystick.aligned = true; | ||
|
|
||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onStickLeft() | ||
| { | ||
| inkhud->rotateJoystick(3); // 270 deg | ||
| settings->joystick.aligned = true; | ||
|
|
||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| void InkHUD::AlignStickApplet::onStickRight() | ||
| { | ||
| inkhud->rotateJoystick(1); // 90 deg | ||
| settings->joystick.aligned = true; | ||
|
|
||
| sendToBackground(); | ||
| inkhud->forceUpdate(EInk::UpdateTypes::FULL); | ||
| } | ||
|
|
||
| #endif | ||
50 changes: 50 additions & 0 deletions
50
src/graphics/niche/InkHUD/Applets/System/AlignStick/AlignStickApplet.h
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #ifdef MESHTASTIC_INCLUDE_INKHUD | ||
|
|
||
| /* | ||
|
|
||
| System Applet for manually aligning the joystick with the screen | ||
|
|
||
| should be run on at startup if the joystick is enabled | ||
|
zeropt marked this conversation as resolved.
Resolved
|
||
| and not aligned to the screen | ||
|
|
||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "configuration.h" | ||
|
|
||
| #include "graphics/niche/InkHUD/SystemApplet.h" | ||
|
|
||
| namespace NicheGraphics::InkHUD | ||
| { | ||
|
|
||
| class AlignStickApplet : public SystemApplet | ||
| { | ||
| public: | ||
| AlignStickApplet(); | ||
|
|
||
| void onRender() override; | ||
| void onForeground() override; | ||
| void onBackground() override; | ||
| void onButtonLongPress() override; | ||
| void onStickCenterLong() override; | ||
| void onStickUp() override; | ||
| void onStickDown() override; | ||
| void onStickLeft() override; | ||
| void onStickRight() override; | ||
|
|
||
| protected: | ||
| enum Direction { | ||
| UP, | ||
| DOWN, | ||
| LEFT, | ||
| RIGHT, | ||
| }; | ||
|
|
||
| void drawStick(uint16_t centerX, uint16_t centerY, uint16_t width); | ||
| void drawDirection(uint16_t pointX, uint16_t pointY, Direction direction, uint16_t size, uint16_t chamfer, Color color); | ||
| }; | ||
|
|
||
| } // namespace NicheGraphics::InkHUD | ||
|
|
||
| #endif | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.