Peppy player

I'm trying to install Peppy in Debian 10 on a Supermicro X10SBA.
I also ordered this screen: 5 inch Resistive Touch Screen LCD, HDMI interface, supports various systems

It will be a portable NAS. But since it will have a touch screen i thought: way not also install Peppy.

The problem is that i get:
Code:
pygame 1.9.4.post1
Hello from the pygame community. [URL="https://www.pygame.org/contribute.html"]Contribute - pygame wiki[/URL]
Traceback (most recent call last):
  File "peppy.py", line 30, in <module>
    from event.dispatcher import EventDispatcher
  File "/home/haegarthehorrible/Peppy/event/dispatcher.py", line 22, in <module>
    from ui.menu.stationmenu import StationMenu
  File "/home/haegarthehorrible/Peppy/ui/menu/stationmenu.py", line 22, in <module>
    from util.util import IMAGE_SHADOW, IMAGE_SELECTION, FOLDER_ICONS, EXT_PNG, IMAGE_STAR
  File "/home/haegarthehorrible/Peppy/util/util.py", line 32, in <module>
    from util.config import Config, USAGE, USE_VOICE_ASSISTANT, COLORS, COLOR_DARK, FONT_KEY, CURRENT, FILE_LABELS, \
  File "/home/haegarthehorrible/Peppy/util/config.py", line 27, in <module>
    from util.collector import GENRE, ARTIST, ALBUM, TITLE, DATE, TYPE, COMPOSER, FOLDER, FILENAME
  File "/home/haegarthehorrible/Peppy/util/collector.py", line 27, in <module>
    from mutagen import File
ModuleNotFoundError: No module named 'mutagen'
But mutagen is installed:
Code:
~$ pip3 install mutagen
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: mutagen in ./.local/lib/python3.7/site-packages (1.44.0)

Edit:
Now it did all the pip3 installs with sudo and now i get: Unable to open mouse
 
Last edited:
That root and Python thing is killing me.

I did read it is better to install a custom version of Python so id the system Python gets update nothing breaks.

So it did:
Code:
~$ cd ~
~$ mkdir tmp
~$ cd tmp
~$ wget [url]https://www.python.org/ftp/python/3.8.4/Python-3.8.4rc1.tgz[/url]
~$ tar zxvf Python-3.8.4rc1.tgz
~$ cd Python-3.8.4rc1
~$ ./configure --prefix=$HOME/opt/python-3.8.4rc1
~$ make
~$ make install

~$ cd ~
~$ nano .profile

>> Add to .profile:
export PATH=$HOME/opt/python-3.8.4rc1/bin:$PATH

~$ . ~/.profile
~$ which python3
~$ python3 --version

Then rc.local is deprecated so I'm trying to do it with systemd and also you should not run Python as root.

Code:
~$ mkdir -p ~/.local/share/systemd/user
~$ nano ~/.local/share/systemd/user/peppy.service

[Unit]
Description=Start Peppy

[Service]
User=haegarthehorrible
Group=tty
RemainAfterExit=no
Type=simple
ExecStart="/home/haegarthehorrible/Peppy openvt -s -- peppy.py"

[Install]
WantedBy=default.target

~$ systemctl --user daemon-reload
~$ systemctl --user enable peppy.service

But i get:
Code:
peppy.service - Start Peppy
   Loaded: loaded (/home/haegarthehorrible/.local/share/systemd/user/peppy.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-07-03 14:34:18 CEST; 4s ago
  Process: 702 ExecStart=/home/haegarthehorrible/Peppy openvt -s -- peppy.py (code=exited, status=216/GROUP)
 Main PID: 702 (code=exited, status=216/GROUP)

I also tried "sudo" and "haegarthehorrible" as Group
 
Hi,

There are two UI modes in the player.
The first 'headless' mode can be used without any display. To use it you can just set property in the player's configuration file config.txt:
headless = True
After that you can control player from web browser running on any device in your home network.

The second UI mode needs a graphical context. You cannot open it in the same TTY window which you use for SSH. It should be either OS Graphical Desktop (X-Windows) or Virtual Terminal (openvt) which will use framebuffer. The latter case is used in player to connect separate touchscreens.

I'm not sure where player's UI will be running in your case. As far as I understand you don't have OS with Graphical Desktop and you don't have another display attached to the player. I'm not sure if your main display connected to the system can support framebuffer and display player's UI on startup. Try to start player without openvt. Also check that you have framebuffer device(s) - either /dev/fb0 or /dev/fb1.

You can enable debugging in config.txt and see the log messages. Just change the path to the log file accordingly:

[logging]
file.logging = True
log.filename = /home/pi/Peppy/peppy.log

Best regards
 
Last edited:
I'm not sure if your main display connected to the system can support framebuffer and display player's UI on startup. Try to start player without openvt.
Ok, if i now do this in Putty over SSH on my workstation:
Code:
~$ cd /home/haegarthehorrible/Peppy
~/Peppy$ sudo python3 peppy.py
Peppy is showing up on the connected LCD.
So openvt is not needed?

But why do i still need sudo? Without it i get:
Code:
Hello from the pygame community. [url=https://www.pygame.org/contribute.html]Contribute - pygame wiki[/url]
Traceback (most recent call last):
  File "peppy.py", line 2312, in <module>
    main()
  File "peppy.py", line 2308, in main
    peppy = Peppy()
  File "peppy.py", line 93, in __init__
    self.util = Util(connected_to_internet)
  File "/home/haegarthehorrible/Peppy/util/util.py", line 131, in __init__
    self.config_class = Config()
  File "/home/haegarthehorrible/Peppy/util/config.py", line 366, in __init__
    self.pygame_screen = self.get_pygame_screen()
  File "/home/haegarthehorrible/Peppy/util/config.py", line 1242, in get_pygame_screen
    pygame.display.init()
pygame.error: Unable to open a console terminal

Also the GUI is shifted downward about the sizes of Peppys bottom selection bar.

I did set in Peppy/config.txt:
Code:
[screen.info]
width = 800
height = 480
depth = 32
frame.rate = 60
hdmi = True
no.frame = False
flip.touch.xy = False
multi.touch = False

This is the user manual of the LCD:
5inch HDMI LCD (B) - Waveshare Wiki
 
openvt was used to start player without sudo. I'm not sure why in your case it cannot find attached display. Did you complete the steps which I mentioned here:
Expert * project-owner/Peppy.doc Wiki * GitHub
That should allow pi user to access tty created by openvt. Without that you will see the message 'Unable to open console'.

Regarding UI misalignment, do you have the same settings in /boot/config.txt which were mentioned on Waveshare page?
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
hdmi_drive=1

Best regards
 
It's a Supermicro X10SBA:
X10SBA | Motherboards | Products | Super Micro Computer, Inc.

So there is no /boot/config.txt.
But i did open a thread in the Debian forums because GRUP is also not showing right at boot.

I also registered at the Python forum to ask what the right way is to start Python with systemd.

If openvt was used to start player without sudo, then why the "su" in rc.local:
Code:
su pi -c 'cd /home/pi/Peppy; openvt -s -- python3 peppy.py'
That root stuff is confusing...
 
I'm closer now.

It seems like i need some kind of X.
I did install different things but i'm not sure what really is needed.
Code:
sudo apt install xserver-xorg-core
sudo apt install xserver-xorg-input-evdev
sudo apt install x11-xserver-utils
sudo apt install x11-xkb-utils
sudo apt install x11-utils
sudo apt install openbox
sudo apt install xauth
sudo apt install xinit

Then i did:
Code:
nano ~/.profile
#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
. startx
logout
fi

nano ~/.xinitrc
#!/bin/sh
x-terminal-emulator

This starts X and the Terminal and then touch is working.
If i do:
Code:
~$ cd /home/haegarthehorrible/Peppy
~/Peppy$ python3 peppy.py
directly on the machine then Peppy starts, display is right (not shifted) and also touch works in Peppy.

Only thing i still can't figure out is how to start Peppy on boot.
Should also be possible with xinitrc.
But when i do:
Code:
#!/bin/sh
x-terminal-emulator &
exec python3 /home/haegarthehorrible/Peppy/peppy.py
it does not work.
 
Ok this in xinitrc does not work:
Code:
exec python3 /home/haegarthehorrible/Peppy/peppy.py

And this does:
Code:
cd /home/haegarthehorrible/Peppy
exec python3 peppy.py

How can i go out of Peppy to the terminal?
Since i can't figure out how to start for example the calibration from my workstation (Putty) i have to do everything directly on the Peppy machine.
 
Hi MrGlasspoole,

You made a pretty good progress. You can set the property in the config.txt file:
poweroff = False
That allows to exit from the player (after Shutdown) without running 'sudo poweroff' command. I'm not sure though that it will return a control to the terminal. Probably it will as you have X now. You can try.

BTW, what do you mean saying 'portable NAS'? I'm also planning to make a "budget" NAS based on Pi 4 and OpenMediaVault.

Best regards.
 
With "poweroff = False" Peppy stops and starts again.

Peppy stops and i get this before Peppy shows up again:
attachment.php


Also i have to click poweroff two times until something happens.

I will answer the NAS question later ;)
 

Attachments

  • IMG_1396.jpg
    IMG_1396.jpg
    984.1 KB · Views: 315
Ok, i found out how to start stuff from Putty on the screen that is connected to the Peppy machine.

You need to do "export DISPLAY=:0.0" before your other command.
Code:
~$ export DISPLAY=:0.0
~$ xinput_calibrator
And the calibrator will run on the touchscreen.
That also works for videos. They play on top of Peppy.

1. There seems to be a bug with mpv.
If you pause the slider is still running. But i also had it a view times that sound was playing and the slider did not move.
Then you paused playback and the slider started moving.
Also the volume slider does not move sometimes and never moves if you pause.

1. click Radio > Pause > Home > Audio Files
2. click the Disc, browse to folder with audio files and select one
!! slider runs but no sound playing
!! volume silder working
3. click play/pause
!! slider not running but sound playing
!! volume silder not reacting
2. Is it normal that i go from Radio (not paused) to Audio Files and the last file starts playing?

2. Power off and reboot from the web admin does not work with my setup.
If i do that i get a black screen with the mouse pointer being a cross.
I did a fresh install and a attached a txt file with all the steps i did in Buster.

3. I can't figure out how to make the volume slider work. It does not change the volume...

4. config.txt
Do i need to set the frame.rate to the one of my screen (60Hz)?
I'm not sure about multi.touch. Is there a way to test if multi.touch is working on my screen?

Ideas or improvements:
1. It would be nice if you go to radio and it does not play immediately - not before selecting an station.

2. Show bitrate of the radio station

3. Show name of the radio station (not just song)

4. A list view in the Audio Files browser

5. Show sampling and bitrate of the song that is playing

6. Volume percentage beside volume slider

7. Control screen brightness with slider and turn off screen button.
Not really off because it needs to come on again by touching...
 

Attachments

  • Buster Peppy Installation.txt
    9.1 KB · Views: 63
Last edited:
Hi MrGlasspoole,

Thanks a lot for thorough testing of the player! At some point I will probably start Bug Bounty for the player and pay money for each bug found :) Though before that I need to fix most of them ;)

I hope to fix the bug with mpv for the next release.

Yes, auto-start for each mode was done intentionally when you switch modes. There is the property in the config.txt auto.play = True. If you set it to 'False' the player will always start from Home screen. I'll extend that and disable auto-play when you switch modes as well. The same property will control both.

When you click the 'Reboot' and 'Shutdown' buttons the player runs commands 'sudo reboot' and 'sudo poweroff'. Please make sure that you can run these commands from the terminal.

What do you use for audio output? Do you use any DAC or Amplifier? Here are the default properties for the Volume control in the config.txt:
[volume.control]
type = amixer
amixer.scale = linear
amixer.control = Headphone
Try to run 'alsamixer' command from the terminal and check the name of the mixer control. If it's not 'Headphone' set it to the name which you have. Also make sure that audio doesn't go to HDMI. If nothing helps you can set the volume type to 'player':
Volume Control * project-owner/Peppy.doc Wiki * GitHub

You can try to set framerate to 60. Will it work or not depends on pygame library which should be able to use that frame rate with your display.
There are no multi-touch actions in the player. The property 'multi.touch' was introduced to support the Official 7" touchscreen. It forces player to use special multi-touch driver software.

It's a little bit difficult to get the stream info (bitrate etc) for online radio. Not all stations report that data. And it will need additional implementation for each audio player (mpd, vlc, mpv) to get this info from the stream. I'm not sure if 'mutagen' library could be used for this task. I'll check that out.

The space in the header is pretty limited for showing Station Name, Artist and Song Name. Let me see if using two lines of text will work. For Audio Files you can see the file information using the 'Info' button:
Information * project-owner/Peppy.doc Wiki * GitHub

For the next release I'm making many changes in the File Browser. It will be possible to change alignment, sorting, line wrapping etc. Here is the screenshot showing the list view.

fb-alignment-left.png


I'm not sure that showing volume % is really useful. Maybe just temporarily show it during volume change (?)

The display backlight control works only for displays connected through DSI interface. It doesn't work for any other display (SPI or HDMI). I can simulate that in the software by applying a black filter to the screen but it will not actually switch the display off.

Best regards
 
The display backlight control works only for displays connected through DSI interface. It doesn't work for any other display (SPI or HDMI).
Must be wrong because it seems to be the default behavior :)
PCs have the power saving for monitors on most of the time (no matter if VGA, DVI, HDMI).
I wonder you did not have your screen going blank/off. It happened to me now and that was the reason to look around why it does happen. Its the first time i have a monitor connected to Debian because i always work over SSH with Putty.

If you Google, a lot of people have that also with the Raspberry and ask how to disable that.
There is also this site: Setting the screen saver/screen blanking - Raspberry Pi Documentation

I thought running this commands will disable it and I'm done:
Code:
~$ export DISPLAY=:0.0
~$ xset s off
~$ xset -dpms
~$ xset s noblank
Yes it does disable it but only until you reboot. You need to set it in .xinitrc

The funny thing is that if Peppy runs the screen does not go off. There must be some background stuff running in Peppy that keeps the screen alive?

By running this in Putty:
Code:
~$ export DISPLAY=:0.0
~$ xset dpms force off
I can turn the screen off and by touching it comes on again :)

Its a bit complicated. Because there is xset and DPMS.
DPMS is Display Power Management Signaling.
xset seems to be the screensaver?

Screen Blanking Under X
BlankTime is "fake" screen blanking: it makes the screen black but the backlight and power supply stay on. It doesn't actually do anything to reduce the power usage. Think of it as a really boring screen saver.
This explains why the screen can go on when touching it (small auxiliary circuit): DPMS monitor specification

Other helpful links:
debian - How do I prevent the screen from going blank? - Raspberry Pi Stack Exchange
pts.blog: Screen blanking, DPMS, screen saver control and timeout settings on X11
https://wiki.archlinux.org/index.php/Display_Power_Management_Signaling
https://www.x.org/archive/X11R7.5/doc/man/man1/xset.1.html
https://linuxreviews.org/HOWTO_turn_Screensavers_and_Monitor_Power_Saving_on_and_off

Sometimes "xscreensaver" is recommended:
https://www.jwz.org/xscreensaver/man1.html
https://www.jwz.org/xscreensaver/man2.html

And here somebody is talking about dimming and xscreensaver:
https://unix.stackexchange.com/questions/357973/dim-screen-before-screensaver
But i don't see how you do that.

------------------------
Volume Control
------------------------
Sorry i did miss the wiki entrie about volume control.
I'm using an old USB soundcard.

attachment.php


I did now:
Code:
[volume.control]
type = amixer
amixer.scale = linear
amixer.control = Master
but it still does not work.
 

Attachments

  • AlsaMixer.jpg
    AlsaMixer.jpg
    163.4 KB · Views: 241
Last edited: