Skip to content
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

boards: arm: wio terminal: separate buttons and joystick definition #67458

Conversation

joelguittet
Copy link
Contributor

The purpose of this separation is to avoid conflict initializing gpio-keys because button 0 and joystick up have a shared interrupt source. Joystick is now configured using polling mode option.

Fixes #67049

@maxhbr
Copy link
Contributor

maxhbr commented Jan 14, 2024

at least in #67208 (comment) there was discussion to reverse it and have the joystick with interrupts and the 3 buttons with polling mode:

+1 for having the 3 "normal" buttons use the new polling mode, and leave the 5 joystick buttons as regular interrupt-driven keys

@joelguittet
Copy link
Contributor Author

at least in #67208 (comment) there was discussion to reverse it and have the joystick with interrupts and the 3 buttons with polling mode:

+1 for having the 3 "normal" buttons use the new polling mode, and leave the 5 joystick buttons as regular interrupt-driven keys

True, and this was something I initiated. Will modify.

@joelguittet joelguittet force-pushed the jguittet/fix-gpio-keys-wio-terminal branch 2 times, most recently from 7cbc2c3 to aec0231 Compare January 15, 2024 10:18
@joelguittet
Copy link
Contributor Author

@maxhbr done

@maxhbr
Copy link
Contributor

maxhbr commented Jan 16, 2024

Hey @joelguittet ,

I tried to test the changes by adding support to the lvgl sample similar to #67049 (comment):

diff --git a/samples/subsys/display/lvgl/boards/wio_terminal.conf b/samples/subsys/display/lvgl/boards/wio_terminal.conf
new file mode 100644
index 0000000000..de103d88fe
--- /dev/null
+++ b/samples/subsys/display/lvgl/boards/wio_terminal.conf
@@ -0,0 +1 @@
+CONFIG_INPUT=y
diff --git a/samples/subsys/display/lvgl/boards/wio_terminal.overlay b/samples/subsys/display/lvgl/boards/wio_terminal.overlay
new file mode 100644
index 0000000000..beaa4be71a
--- /dev/null
+++ b/samples/subsys/display/lvgl/boards/wio_terminal.overlay
@@ -0,0 +1,19 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#include <zephyr/dt-bindings/input/input-event-codes.h>
+#include <zephyr/dt-bindings/lvgl/lvgl.h>
+ / {
+
+        lvgl_button_input {
+                compatible = "zephyr,lvgl-button-input";
+                input-codes = <INPUT_KEY_B>;
+                coordinates = <160 120>;
+        };
+
+        lvgl_keypad_input {
+                compatible = "zephyr,lvgl-keypad-input";
+                input-codes = <INPUT_KEY_LEFT INPUT_KEY_RIGHT INPUT_KEY_ENTER>;
+                lvgl-codes = <LV_KEY_LEFT LV_KEY_RIGHT LV_KEY_ENTER>;
+        };
+};

But, with these changes applied, the lvgl sample no longer correctly loads and produces the following output on start:

** Booting Zephyr OS build aec0231c4152 ***
[00:00:00.136,000] <err> app: failed to enable button callback: -16
[00:00:00.162,000] <wrn> lvgl: Ignored input event: 108
[00:00:00.163,000] <wrn> lvgl: Ignored input event: 103

and pressing random buttons generates log similar to:

[00:00:42.274,000] <wrn> lvgl: Ignored input event: 3
[00:00:42.475,000] <wrn> lvgl: Ignored input event: 2
[00:00:42.475,000] <wrn> lvgl: Ignored input event: 3
[00:00:42.675,000] <wrn> lvgl: Ignored input event: 2
[00:00:43.175,000] <wrn> lvgl: Ignored input event: 11
[00:00:43.376,000] <wrn> lvgl: Ignored input event: 11
[00:00:44.224,000] <wrn> lvgl: Ignored input event: 108
[00:00:44.357,000] <wrn> lvgl: Ignored input event: 108

EDIT:
It already behaves like that, if I just add the conf CONFIG_INPUT=y without the overlay.

EDIT:
If I apply the above patch to latest master 982fc41 it works and does not produce that error. But the buttons are not working (as explained in the initial issue)

EDIT:
I tested with logging events, and there all gpio-keys work with your PR 🎉

@joelguittet joelguittet force-pushed the jguittet/fix-gpio-keys-wio-terminal branch from aec0231 to 15eba1c Compare January 20, 2024 21:56
@joelguittet
Copy link
Contributor Author

Hello @maxhbr

I made an overlay a bit different, I added the input entries, but this doesn't help. Then I made a little bit more modifications: I removed the buttons in the dts, so I kept only inputs-codes from the joystick. Seems working (at least the basics left/right/enter events).

=> The lvgl_xxx_input do not work when there are multiple gpio-keys compatible node in the board definition. @faxe1008 maybe this is somethingyou know more than us ?

@joelguittet
Copy link
Contributor Author

@kartben this PR has no automatic reviewers assigned. Maybe you can help here ? Thanks!

The purpose of this separation is to avoid conflict initializing
gpio-keys because button 0 and joystick up have a shared interrupt
source. Joystick is now configured using polling mode option.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
Add Wio Terminal configuration to the LVGL sample with button and
keypad overlay.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
@joelguittet
Copy link
Contributor Author

@maxhbr I have updated this PR:

  • the device tree has now the joystick configured in polling mode. Buttons need toi be set with interrupt to prevent the <err> app: failed to enable button callback: -16 error you have reported in the lvgl sample.
  • I have added wio terminal configuration and overlay for the lvgl sample. Seems to be working according to me, can you check this is suitable ? Thanks!

@kartben kartben requested a review from faxe1008 January 24, 2024 21:50
Copy link
Contributor

@maxhbr maxhbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it and it works perfectly fine. Great! 🎉

@MaureenHelm MaureenHelm merged commit 017b016 into zephyrproject-rtos:main Jan 30, 2024
18 checks passed
@joelguittet joelguittet deleted the jguittet/fix-gpio-keys-wio-terminal branch January 30, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only the first five gpio-keys of wio-terminal seem to work
6 participants