Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 Nov 17, 2025
891a896
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt Nov 17, 2025
4f5ef6c
basic ui navigation with a joystick
zeropt Nov 17, 2025
a4ee7ba
handle joystick input in NotificationApplet and TipsApplet
zeropt Nov 17, 2025
1223bf0
MenuApplet controls
scobert969 Nov 17, 2025
9ae43d5
add AlignStickApplet for aligning the joystick with the screen
zeropt Nov 17, 2025
3a158c8
update tips applet with joystick controls
zeropt Nov 17, 2025
658d3cf
format InkHUD additions
zeropt Nov 17, 2025
6a4d581
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt Nov 17, 2025
ff4057e
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt Nov 18, 2025
9afbb25
fix stroke consistency when resizing joystick graphic
zeropt Nov 19, 2025
8f6d41f
tweak button tips for order consistency
zeropt Nov 19, 2025
e4bcf38
increase joystick debounce
zeropt Nov 19, 2025
c48b80c
fix comments
zeropt Nov 19, 2025
92ee34e
remove unnecessary '+'
zeropt Nov 19, 2025
1b3d1e3
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt Nov 20, 2025
8a79c10
Merge branch 'meshtastic:develop' into seeed-l1-inkhud-with-joystick
zeropt Nov 20, 2025
2e87624
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda Dec 5, 2025
ae2c94f
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda Dec 20, 2025
1a762fe
remap joystick controls to match standard inkHUD behavior
zeropt Dec 20, 2025
57e0095
Merge branch 'develop' into seeed-l1-inkhud-with-joystick
HarukiToreda Dec 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/graphics/niche/InkHUD/Applet.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ class Applet : public GFX
virtual void onForeground() {}
virtual void onBackground() {}
virtual void onShutdown() {}
virtual void onButtonShortPress() {} // (System Applets only)
virtual void onButtonLongPress() {} // (System Applets only)
virtual void onButtonShortPress() {}
virtual void onButtonLongPress() {}
virtual void onExitShort() {}
virtual void onExitLong() {}
virtual void onNavUp() {}
virtual void onNavDown() {}
virtual void onNavLeft() {}
virtual void onNavRight() {}

virtual bool approveNotification(Notification &n); // Allow an applet to veto a notification

Expand Down
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::onExitLong()
{
sendToBackground();
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
}

void InkHUD::AlignStickApplet::onNavUp()
{
settings->joystick.aligned = true;

sendToBackground();
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
}

void InkHUD::AlignStickApplet::onNavDown()
{
inkhud->rotateJoystick(2); // 180 deg
settings->joystick.aligned = true;

sendToBackground();
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
}

void InkHUD::AlignStickApplet::onNavLeft()
{
inkhud->rotateJoystick(3); // 270 deg
settings->joystick.aligned = true;

sendToBackground();
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
}

void InkHUD::AlignStickApplet::onNavRight()
{
inkhud->rotateJoystick(1); // 90 deg
settings->joystick.aligned = true;

sendToBackground();
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
}

#endif
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 at startup if the joystick is enabled
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 onExitLong() override;
void onNavUp() override;
void onNavDown() override;
void onNavLeft() override;
void onNavRight() 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
1 change: 1 addition & 0 deletions src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum MenuAction {
TOGGLE_AUTOSHOW_APPLET,
SET_RECENTS,
ROTATE,
ALIGN_JOYSTICK,
LAYOUT,
TOGGLE_BATTERY_ICON,
TOGGLE_NOTIFICATIONS,
Expand Down
Loading