Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions examples/companion_radio/ui-new/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#define PRESS_LABEL "long press"
#endif

#if defined(JOYSTICK_ROTATION) && (JOYSTICK_ROTATION == 1 || JOYSTICK_ROTATION == 3) \
&& (!defined(JOYSTICK_UP) || !defined(JOYSTICK_DOWN))
#error "JOYSTICK_ROTATION 1/3 requires JOYSTICK_UP and JOYSTICK_DOWN pin definitions"
#endif

#include "icons.h"

class SplashScreen : public UIScreen {
Expand Down Expand Up @@ -711,6 +716,49 @@ void UITask::loop() {
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_ENTER); // REVISIT: could be mapped to different key code
}
#if defined(JOYSTICK_ROTATION) && JOYSTICK_ROTATION == 1
// 90 deg clockwise: physical up/down map to right/left on screen
ev = joystick_down.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_LEFT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_LEFT);
}
ev = joystick_up.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_RIGHT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_RIGHT);
}
#elif defined(JOYSTICK_ROTATION) && JOYSTICK_ROTATION == 2
// 180 deg: physical left/right are swapped
ev = joystick_right.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_LEFT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_LEFT);
}
ev = joystick_left.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_RIGHT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_RIGHT);
}
#elif defined(JOYSTICK_ROTATION) && JOYSTICK_ROTATION == 3
// 270 deg (90 deg counter-clockwise): physical up/down map to left/right on screen
ev = joystick_up.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_LEFT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_LEFT);
}
ev = joystick_down.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_RIGHT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_RIGHT);
}
#else
ev = joystick_left.check();
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_LEFT);
Expand All @@ -723,6 +771,7 @@ void UITask::loop() {
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_RIGHT);
}
#endif
ev = back_btn.check();
if (ev == BUTTON_EVENT_TRIPLE_CLICK) {
c = handleTripleClick(KEY_SELECT);
Expand Down
4 changes: 4 additions & 0 deletions variants/gat562_30s_mesh_kit/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ GAT56230SMeshKitBoard board;
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
MomentaryButton joystick_up(JOYSTICK_UP, 1000, true, false, false);
MomentaryButton joystick_down(JOYSTICK_DOWN, 1000, true, false, false);
#endif
#endif


Expand Down
4 changes: 4 additions & 0 deletions variants/gat562_30s_mesh_kit/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
extern MomentaryButton joystick_left;
extern MomentaryButton joystick_right;
extern MomentaryButton back_btn;
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
extern MomentaryButton joystick_up;
extern MomentaryButton joystick_down;
#endif
#endif

extern GAT56230SMeshKitBoard board;
Expand Down
4 changes: 4 additions & 0 deletions variants/gat562_mesh_tracker_pro/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ GAT562MeshTrackerProBoard board;
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
MomentaryButton joystick_up(JOYSTICK_UP, 1000, true, false, false);
MomentaryButton joystick_down(JOYSTICK_DOWN, 1000, true, false, false);
#endif
#endif


Expand Down
4 changes: 4 additions & 0 deletions variants/gat562_mesh_tracker_pro/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
extern MomentaryButton joystick_left;
extern MomentaryButton joystick_right;
extern MomentaryButton back_btn;
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
extern MomentaryButton joystick_up;
extern MomentaryButton joystick_down;
#endif
#endif

extern GAT562MeshTrackerProBoard board;
Expand Down
1 change: 1 addition & 0 deletions variants/wio-tracker-l1-eink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ build_flags = ${WioTrackerL1Eink.build_flags}
-D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=GxEPDDisplay
-D UI_HAS_JOYSTICK=1
; -D JOYSTICK_ROTATION=1 ; rotate joystick 90 deg CW (display mounted beside joystick)
-D PIN_BUZZER=12
-D QSPIFLASH=1
; -D MESH_PACKET_LOGGING=1
Expand Down
4 changes: 4 additions & 0 deletions variants/wio-tracker-l1/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ EnvironmentSensorManager sensors = EnvironmentSensorManager();
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
MomentaryButton joystick_up(JOYSTICK_UP, 1000, true, false, false);
MomentaryButton joystick_down(JOYSTICK_DOWN, 1000, true, false, false);
#endif
#endif

bool radio_init() {
Expand Down
4 changes: 4 additions & 0 deletions variants/wio-tracker-l1/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ extern EnvironmentSensorManager sensors;
extern MomentaryButton joystick_left;
extern MomentaryButton joystick_right;
extern MomentaryButton back_btn;
#if defined(JOYSTICK_UP) && defined(JOYSTICK_DOWN)
extern MomentaryButton joystick_up;
extern MomentaryButton joystick_down;
#endif
#endif

bool radio_init();
Expand Down