I would like to be able to simulate a click/press on the screen.
What MCU/Processor/Board and compiler are you using?
M5Stack running microPython+lvgl bindings
What do you want to achieve?
I would like to simulate a press on a point of the screen whose coordinates are given. Ideally, I would like to be able to use/write a function whose microPython prototype would be:
click_screen(scr: lv.obj, pt: lv.point_t)->None The effect would be the visual efect/event chain that would occur if one acted on that specific point.
What have you tried so far?
Using a Button input device interface. See my other post (https://forum.lvgl.io/t/using-the-button-input-device/2077/2) for the issue I am having with that route.
Hi @fstengel I am also running the same setup as you do, lets see if I can help you in any way.
Have you seen this library before? It simulates an encoder with the 3 m5stack buttons. https://github.com/sci-bots/m5-lvgl
If you don’t want to use a simulation of an encoder but want to really simulate button presses then check Hardware Button multiple points (for 1 button this works 100%). I have also made some changes to the encoder library so it would behave as 3 different on screen buttons. (not complete yet). But when I tried the last solution the first time there was a small problem with the lv_indev_set_button_points as you can see. Since then I believe it has been changed. But I still had not the time to check if it works.
Hope it helps.
Your link (and your post) was my starting point for this post: https://forum.lvgl.io/t/using-the-button-input-device/2077/2. I started withvthat library and your post to try using a button input device. For the time being, I am not able to make the button input device work. The Encoder input device works, but adds that not quite nice focusing ring around the button.
You can disable the focusing ring doing this.
There might be a better way to do it, but this works for me. Try it and let me know if it works. (Based from https://docs.littlevgl.com/en/html/overview/indev.html)
Positive aspect of using an encoder is that you can have more than 3 buttons per page (as if you use the button interface, since we only have 3 buttons, you can only map it for 3 actions or places on screen). With an encoder you can add several and rotate through them… Although I wanted to use the first approach, for now I think I will stick with the encoder. If you succeed making the Button approach fully work please let me know as I might be interested!
I just re-read your first answer. You did say you have been able to make the hardware button work. How? I tried and I cannot get it to work, whereas I can get the encoder method work. I’ll try again with an older firmware, and just
lv.indev_set_button_points(win_drv, point) Still, I am stumped here: it is as if, in my case,
indev_set_button_points were doing nothing… Would it be possible to see a minimal example of working code?
Your idea with the style callbacks works. It had not crossed my mind to want to prevent the forcus ring from appearing.
I found the solution to one of my problems. See https://forum.lvgl.io/t/using-the-button-input-device/2077/3. The documentation was rather unclear on what the various bits do…
Now, still, how to a simulate a click on one or more points on the screen. My aim is to be able to simultaneously press two logical buttons thus emulating somoething of the play/record buttons of an old cassette tape recorder.