Not logged inGosu Forums
Forum www.libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Showcase / Raspberry Pi music touchscreen
- - By leddy231 Date 2017-04-10 12:29
Get a cup of tea or coffee, sit back and enjoy the wall of text.

The goal.
I was tasked by a local gym to build them a music touchscreen. The user was supposed to be able to run pre-mixed mp3 files from it. A raspberry pi with their official touchscreen was the logical choice. But I also needed a graphics api that could run fullscreen, receive touch/mouse input and play mp3 files. It didn’t take many minutes to get a Gosu demo app running using my UI toolkit. And since my last Gosu project went so smooth this could not be that hard, could it? Wrong.

The problems along the way
First up, Gosu just didn’t install. There are probably not many Gosu users running it on a pi so it’s understandable. Got help from Jlnr to solve the installation issues, but even after that Gosu wouldn’t start. At this point I understood that I might need to find another graphics api to use. First on the list was Pygame, comes preloaded on the pi so it was looking promising. But it turns out the fullscreen mode was broken on raspbian. Next up was Kivy, also running on python. After much tinkering, I got it running fullscreen and with multitouch support. I was just about to learn it and develop the app when Jlnr got Gosu running on the pi! This was a relief for me since I didn’t want to spend time learning another language just for this project. I installed Gosu with the new instructions, and my prototype app ran almost without issues, in fullscreen! I figured if I got this far any other issues could be handled, so I gave the green light for the project and they bought the hardware.

Other issues that appeared:
Gosu can’t play mp3 files outside of on macOS. Didn’t know this since most of my development is done on school time on my mac. Jnlr to the rescue again, adding mp3 support with the help of mpg123.

Gosu didn’t do well with the touchscreen. It only updated mouse_x and mouse_y when the user pressed the screen the first time, and not when the finger was moved around. No button_down for MsLeft was registered. Made a quick hack where the mouse was forced to sit at (0,0), and if it moved (the user touched somewere) it was considered a “click”, and the next update the mouse was moved back. You can find this in my UI toolkit, “LUIT.updateTouch”. This however meant no dragging on sliders was possible, but that was a very minor annoyance. Jlnr suggested updating SDL2.0.3 to 2.0.5, but at this point I was so fed up with installing and compiling things on the Pi.

Gosu overheated the Pi. This was a surprise to me, the Pi only survived maybe 15 minutes in fullscreen mode before it flat out died and the screen faded away. Some minor screen flickering could also be seen when it was running. Then it hit me, most of the time nothing is happening on the screen, so I dug out “needs_redraw” and set up the “LUIT.updateTouch” to redraw the screen two times after a click. (to get the hover effects to fade away). And would you look at that, no flickering, no heat, 3% cpu at idle.

Here is a screenshot from the finished app, will post some photos once its installed in the gym.


Big thanks to Jlnr for the help along the way, and Kjarrigan for feedback on my toolkit!
Parent - By jlnr (dev) Date 2017-05-26 10:42
(Took me forever to get back to this post in my reading queue...)

That was really great timing with the MP3 patents expiring just in time for this project ;)

I didn't think it was possible to overheat the Pi though. Is it really the temperature? I've noticed flakiness on my Pi when I use a USB port that doesn't provide enough power. Has it worked OK in the long term?
Up Topic Gosu / Gosu Showcase / Raspberry Pi music touchscreen

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill