Hi Im new to PI Music Box ans wanted to add a touchscreen to it. I have installed the touchscreen and I know it is working. I then installed the extension and added the configuration in the file per https://github.com/9and3r/mopidy-touchscreen.
When I start Mopidy nothing happens on the screen. Mopidy config shows that it loaded the configuration and when I start it verbose it shows it loaded the extension.
I have the same set-up with the same touchscreen, but additionally with an Hifiberry DAC.
I had the same issue as you and was able to resolve at least the issue with the touchscreen and get that one working. I did however do this under Raspbian in the end since I wasn’t able to get it done under musicbox (you might want to try this under musicbox though - probably you can get it done).
If you want to try with musicbox, you might need to enable ssh first or get yourself access to a console.
Here is what I figured out with a lot of support by @9and3r …
First get yourself to be root - keeps you from having to type “sudo …” all the time, and aparently the extension of 9and3r only works with root priviledges anyway. Would therefore start this way:
log in with the normal user
sudo passwd root
<type your pass, hit enter x2>
--> now you're root and can login as root next time
First get the touchscreen working under the console. To do so, follow this tutorial:
In the file /etc/modprobe.d/pitft.conf I changed he line “rotate” to 90.
When this is all done, I would follow the tutorial from Adafruit of this page, but only the part above the “automagic calibration”:
Then do the manual calibration from the same page (after the automagic calibration part). Skip the X Calibration as you won’t need it.
If you want the bootmessages to show on the screen, follow this portion of the howto:
The last hint on the same page you should follow even if you don’t want to see the bootmessages. (set screen blank time to indefinite to not let it turn off automatically)
Now you need to save this and go back to the folder /root/mopidy-touchscreen. There you install this changed version of the plugin - in the folder, type:
python setup.py install develop
When this is done, I would reboot once more - and try to run mopidy as user root. Either by editing the file /etc/init.d/mopidy … and changing the user and group definitions in there, or even better since you can watch the output on the console, directly as root:
If you want to get more debug info to look at things, you can add “-v” (-vv and -vvv also works for even more info).
The first time you run it directly, it will create a new config file under the root folder under /root/.config/mopidy/mopidy.conf and exit. The mopidy version run directly will not know about the file under /etc/mopidy/…, so ensure you got the right config in there.
When you start it up, the console should show on your screen. At least with Raspbian it now always does it for me (reinstalled a couple of times as per method above). With MusicBox I did not get it working.
When I run the touchscreen however, I still run into the issue that GStreamer does not want to play my music any longer:
This is not yet resolved for me - in case anyone could help me fix this, I would greatly appreciate this.
Hope this helped to point you into the right directions.
I have been trying to make it work with musicbox.
I could not make the extension load at boot. I have no idea what is happening. Anyone knows how does boot work in musicbox and where can I see the full log of mopidy?
If I start mopidy from the command line (mopidy -vv) the extension is working correctly, HDMI or TFT display.
Maybe @woutervanwijk can give some advice.
Thank in advance.
ok Actually take that back I got it to load at boot, however I have to see what the consequences are. It seems as though the extension does not like the user musicbox. In etc/rc6.d there is the bash script to run the daemon. This has the user as musicbox. I changed it to root and all is happy. (not shure what else will be broken at the moment though although tune-in works.
Why does your extension have to run as root? Is there file permission issues?
If it interfaces through the raspi GPIO pins it wouldn’t surprise me if this is done via /dev/mem - in which case you need to be root or have CAP_SYS_RAWIO (see man capabilities). Note that this is just a hunch as I have no idea how the setup is interfacing with screen.
Changing the etc/rc6.d makes the extension work properly.
I am working in the next update to make the os.envirom details configurable from mopidy config (you can check preview on github) and I will update the readme.
The extension does not need to run with root for example in ubuntu. As @adamcik said is related with the display being connected to the GPIO.
There is also another reason to use root. (Shutdown and Restart options). But these are totally optional and they will simply not work if we have not permission.
Boot works just like normal Raspbian. I only added the /opt/startup.sh script to /erc/rc.local. Mopidy, upmpdcli and shairport are started by this script. The rest of the services are started normally.
Don’t know much about the touchscreen extension. I don’t have one. Would be a nice idea though. I’ll try to get it to boot without errors.
Mopidy runs as the user mopidy, not musicbox (it did in the old versions). Group is audio.
Did you find a reference to the old musicbox user?
I have reinstaled several times musicbox and I could not find a way to run touchscreen without root or sudo. I found out that it needs mopidy to be video group (/etc/group file). But this is not enough as I am getting other error.
Regarding not working Hifiberry DAC as I do not own one I can test it, but maybe pygame is taking full control of it even it will not use it.
I found that there are some variables related to audio that are set the same way we are doing with video. Check audio variables here
Maybe you can output the pygame sound to a file.
os.environ[“SDL_AUDIODRIVER”] = “disk”
I have no idea if this it will work. It is only something you can try.
The above two lines are not configuration settings for the extension. If you read the posts above they talk about other ways of settings those environment variables.
sdl_mousedrv should be sdl_mousdrv. The other two actually look fine. However, when there is an unknown config key the error message should not include the value the key is set to i.e, it should have just said “touchscreen/sdl_fbdev unknown config key”. This implies it’s the musicbox settings.ini parsing that is getting this wrong and interpreting the whole line as the key, maybe that’s due to the " characters in the os.environ stuff you tried to put in there? So, remove the os.environ lines and set those values some other way. Hopefully the other settings will then be recognised (but you technically don’t need to set any options unless you want a value different to the defaults.