Raspberry Pi Cursor

Hi,

I am new here so I apologise if this has already been covered (I couldn’t find the information on these forums so thought I would post it hoping it may help someone else).

Whilst waiting for my Maslow kit to arrive I thought I would setup my Raspberry Pi 3 to run ground control. I am not a fan of using touch screens so ran into the documented problem with the mouse cursor not being displayed.

I tried editing the config.ini to set “touchring = show_cursor=true” but couldn’t get that to work. Setting cursor=1 in the [Modules] section of the config.ini file did work but I had the problem where the cursor would get lost off the edge of the screen. After some messing around I came up with the following solution:

  1. I created a file called trappedcursor.py (2.4 KB) by modifying kivy’s cursor.py module with some code I found on the internet and saved it in /root/.kivy/mods

  2. I edited the [Modules] section of the config.ini file to include “trappedcursor=1”.

Now I when I run ground control a cursor is displayed. If you move the mouse off the screen the cursor image stays at the edge of the screen. I think it is just the location of the image of the pointer which is trapped on the screen and the actual the position of the cursor will keep moving. I have tried to sort this out but I think it will take someone more experienced than me to fix it.

Whilst it is not a perfect solution it does at least mean that it is now useable

4 Likes

I know we have struggled with kivy and rpi in the past and this sounds like one of the most successful solutions that I’ve heard.

Thanks for taking the time to write up what worked and post it so that everyone can benefit

1 Like

@Kingsley

Welcome to our group. This is a great bit of work. I was not able to get good results with kivy Pi so I have spun a version of Ubuntu Mate running with Remote Desktop instead. Have you had any crashes of GC running on the Pi. I couldn’t keep it running for more than 90 seconds. I do have one of the original Pi foundation touch screens and it has always shown a power issue. I’d read that all do though. I find running GC at 720p to be a minimum useful resolution for me. Do I have your permission to redistribute trappedcursor.py? If so I will add it to Community Garden under the wiki.

Thank you

1 Like

@Bee

Yes feel free to redistribute the file.

So far KivyPie hasn’t crashed. However, I haven’t got an Arduino connected yet so it may not be a fair test. I find the performance of the mouse to be acceptable, the only time it is noticeably laggy is when I use ground control to find/open a gcode file, I guess it may be something to do with having multiple popups/windows open.

GC looks good on the old 1280 X 1024 monitor I am using, it is connected via an HDMI-DVI converter and for some reason is giving a much crisper image with kivy/rpi3 than it was with raspbian/rpi2.

1 Like

BTW - It’s far beyond me at this point but I understand there should be a way to tell Kivy the screen boundary. This would limit the courser form ever leaving the screen. I believe this is why I saw so many crashes. In computer terms the courser was flying off into a ridiculously large number in theoretical space off the right side of the screen like 18 football fields in MM. Then GC would close.

Thank you

Thank you - I appreciate all of this. I will test this out when I get a chance. I’m currently working on 4 CNC builds, 4 Linux distos, Documenting 3 projects and trying to trouble shoot a Pi install with a looping Xwindow crash.

B.

Trapped cursor added to Community Garden now.

https://github.com/MaslowCNC/CommunityGarden/wiki/Community-Contributed-Files

Thank you

1 Like

Hi, I am also new to the forums and while waiting for my Maslow kit to go out I have been experimenting with my Raspberry Pi.

I have had some success getting GroundControl to run inside X11 on an Rpi 3 without a touchscreen. This maybe more on the bleeding edge than the cutting edge (pun intended). :slight_smile: In a nutshell:

Instead of using Kivypie, I started with a fresh copy of Raspian Lite ‘Stretch’ and the development version of kivy.
Then in raspi-config, under Advance settings enabled a 256 Mb memory split for the GPU, and also enabled the experimental GL Driver. I then Ran apt-get to get x11 (fluxbox), sdl2 and git requirements.

Inside my home directory I cloned kivy from github:
git clone https://github.com/kivy/kivy.git

I then added these two USE flags when compiling:
USE_SDL2=1 USE_X11=1 make.

After starting the X11 window manger, I open a terminal and run:
cd GroundControl
KIVY_WINDOW=x11 python main.py or
KIVY_WINDOW=sdl2 python main.py.

Now GroundControl runs either fullscreen or in a borderless window and the cursor is bound by the window manager.

This still requires some more tweaking, it may run sluggishly or crash. But I like the idea of having more of an industrial type installation (Fanless SBC and controller), so I will keep hacking at it.

4 Likes

After thinking about this, last night I copied KivyPie back onto a spare sd card I had laying around. Then installed the missing X11 window manger per the KivyPie website instructions.

sudo apt-get update
sudo apt-get install fluxbox xinit x11-apps xclip xsel lxterminal xterm xserver-xorg-video-fbturbo

Followed the GroundControl install instructions per the wiki and then ran startx to bring up x11 desktop. While Kivy does not to appear to have been built with X11 Flag in KivyPie, it does work with SDL2 libraries, and I was able to open a terminal on the desktop and start GroundControl with the KIVY_WINDOW environmental variable.

startx and open xterm or lxterminal from the menu.
cd GroundControl
KIVY_WINDOW=sdl2 python main.py

Without even touching the kivy config file the mouse cursor now appears in GroundControl and stays inside the window manager and I am also able to run it remotely from my Windows laptop using the free MobaXterm app that auto forwards X11 over ssh and has a handy sftp file folder for drag and dropping files.

4 Likes

Excellent work. Is it more stable now?

Thank you

Well, I haven’t had a lot of time today to test. I did a little bit of tweaking on the .kivy/config.ini ie, I disabled the touchring, it had defaulted to run both the mouse cursor and touchring together. I also lower framerate and set multisample to 0.

But at first blush it almost seems more stable over the ssh remote connection to my laptop. My RPi was using a logitech K400 bluetooth keyboard with built in touch pad, kivy did not seem to like it. Groundcontrol would crash or lock up if I gestured on the touchpad. I grabbed an old apple aluminum keyboard and plugged it with a wireless mouse and it seems to be an improvement.

After testing some more, and having GroundControl crash or run very slowly, I have since moved onto a different solution, see my post Raspberry Pi with KDE Window Manager, Wayland ver or try the trapped cursor solution Kinglsey uploaded at the beginning of this post or run Ubuntu Mate Headless option Bee created Continued Work on Ubuntu Mate Raspberry Pi3 if you want to run the Raspberry Pi without a touchscreen

2 Likes

Thanks for the links with your summary. Its so helpful as the available information increases here.

2 Likes

Hello everyone, this is my first post here but I’ve been reading for a while, it’s my pleasure to join such great community !

My Maslow kit arrived, before I start working on a frame I want to have electronics up and running. Since I already had Rapsberry Pi3, I wanted to use it. Using Bee’s advice I setup Ubuntu Mate and followed Linux guide, everything worked perfect till I launched Ground Control. It works, but GUI responds strangely: cursor is clearly visible and follows mouse movement, but when I click I have an impression that system “thinks” my cursor is at different location. Pop up windows (GoTo window for example) sometimes lets me press numbers, sometimes it closes after first click.

To have some reference I installed GC on my Ubuntu 18 laptop and it works in a pretty reliable way, no complains so far.

I did some research for rpi/kivy related problems, only hints I found is for invisible cursor problem but that’s not my case. Maybe you have any experience with that or hints what might be the cause ?

I like the idea of using rpi for Maslow since it will be idnustrial-like solution, however I’m not going to sacrifice my main goal which is building things. So I’m pretty close to either using my standard laptop to control maslow, or to get some second hand, ~$100 latpop and use Ubuntu. What do you think ?

On the RPI are you on Ubuntu 16.04 or 18?

Thank you

On RPI I have newest available, Ubuntu MATE 16.04.2 (Xenial).

EDIT: your post made me think and I looked it up: 16.04 is latest downloadable version available for rpi, but it seems it is possible to upgrade it to 18: https://www.raspberrypi.org/forums/viewtopic.php?t=223749. I will do that today and let you know if it helped.

ANOTHER EDIT: I updated Ubuntu Mate on RPI to version 18 (according to guide mentioned above). And now I’m struggling with some kivy dependencies - can’t event start GC. This is error I’m getting: " ImportError: /usr/lib/python2.7/dist-packages/kivy/_event.arm-linux-gnueabihf.so: undefined symbol: PyFPE_jbuf". Google says I’m not first one to encounter that, but I didn’t find a way to resolve it so far.

I will have a look at this problem again tomorrow, but it appears to me that getting cheap laptop might be more efficient.

Reflash it back to 16.04. Run all the updates and upgrades short of going to 18. Try swapping the video driver in the config. One of them will run significantly better.

Thank you

1 Like