mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 02:36:11 +00:00
feat(ui): runtime joystick rotation independent of display rotation
Add NodePrefs::joystick_rotation (0-3 steps CW), persisted in DataStore alongside display_rotation. rotateJoystickKey() now takes a runtime rot parameter instead of compile-time JOYSTICK_ROTATION macro. UITask::loop() reads joystick_rotation from NodePrefs each frame. Settings screen exposes "Joystick" rotation item on any build with UI_HAS_JOYSTICK. JOYSTICK_ROTATION macro still works as compile-time default for legacy/non-prefs builds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
85cfb6f1af
commit
fea1be8e81
@@ -1294,6 +1294,7 @@ static void formatDashVal(uint8_t field, char* val, int val_len, uint16_t batt_m
|
||||
void UITask::loop() {
|
||||
char c = 0;
|
||||
#if UI_HAS_JOYSTICK
|
||||
uint8_t joy_rot = _node_prefs ? _node_prefs->joystick_rotation : JOYSTICK_ROTATION;
|
||||
int ev = user_btn.check();
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
if (back_btn.isPressed()) {
|
||||
@@ -1328,24 +1329,24 @@ void UITask::loop() {
|
||||
#if UI_HAS_JOYSTICK_UPDOWN
|
||||
ev = joystick_up.check();
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
c = checkDisplayOn(KEY_UP);
|
||||
c = checkDisplayOn(rotateJoystickKey(KEY_UP, joy_rot));
|
||||
}
|
||||
ev = joystick_down.check();
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
c = checkDisplayOn(KEY_DOWN);
|
||||
c = checkDisplayOn(rotateJoystickKey(KEY_DOWN, joy_rot));
|
||||
}
|
||||
#endif
|
||||
ev = joystick_left.check();
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
c = checkDisplayOn(KEY_LEFT);
|
||||
c = checkDisplayOn(rotateJoystickKey(KEY_LEFT, joy_rot));
|
||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||
c = handleLongPress(KEY_LEFT);
|
||||
c = handleLongPress(rotateJoystickKey(KEY_LEFT, joy_rot));
|
||||
}
|
||||
ev = joystick_right.check();
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
c = checkDisplayOn(KEY_RIGHT);
|
||||
c = checkDisplayOn(rotateJoystickKey(KEY_RIGHT, joy_rot));
|
||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||
c = handleLongPress(KEY_RIGHT);
|
||||
c = handleLongPress(rotateJoystickKey(KEY_RIGHT, joy_rot));
|
||||
}
|
||||
if (_lock_seq_used && millis() - _lock_seq_ms > 5000) {
|
||||
_lock_seq_used = false; // safety reset if Back release event was missed
|
||||
|
||||
Reference in New Issue
Block a user