Pygame is not longer searching the mouse 🙂
Funny you need to add the users to the 'input' group.
BUT: Touch is not working. I guess normally you can use a mouse in Pygame that is using the framebuffer?
Note: I did add 'root' because at the moment the service is a root service with no 'User=haegarthehorrible' entry.
At the moment I'm using the system Python and did install the pip modules with:
The problem is that python seems to not see them if the service is root and the modules are not.
I need to figure out how i can use my custom Python installation and then start the service as my user.
Code:
~$ sudo usermod -a -G input root
~$ sudo usermod -a -G input haegarthehorrible
BUT: Touch is not working. I guess normally you can use a mouse in Pygame that is using the framebuffer?
Note: I did add 'root' because at the moment the service is a root service with no 'User=haegarthehorrible' entry.
At the moment I'm using the system Python and did install the pip modules with:
Code:
sudo /usr/bin/python3.7 -m pip install -U package
I need to figure out how i can use my custom Python installation and then start the service as my user.
Here is the logic for the mouse device:
Peppy/config.py at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
If the device /dev/input/touchscreen is available it will be used as a mouse device for Pygame/SDL. Otherwise /dev/input/event0 will be used as a mouse device. Please try to find out what is the mouse device in your system and specify it in that code. Probably it's neither touchscreen nor event0 but something else.
The issue with file logging is annoying but it's probably not so critical if you can have console logging.
You are very close, keep going.
Peppy/config.py at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
If the device /dev/input/touchscreen is available it will be used as a mouse device for Pygame/SDL. Otherwise /dev/input/event0 will be used as a mouse device. Please try to find out what is the mouse device in your system and specify it in that code. Probably it's neither touchscreen nor event0 but something else.
The issue with file logging is annoying but it's probably not so critical if you can have console logging.
You are very close, keep going.
If I'm close and you know it - why don't you tell me how 😛
Ok, i can confirm that the user needs to be in the 'input' group.
The moment i remove him the mouse error comes up.
I also have it now that Peppy is using my Python 3.7.8 without sudo.
It looks so simple now. If i think about it what crazy combinations i tried 🙁
Stopping and starting does not work yet and there is no green light that its running. But at least peppy starts on boot now.
Why is it first tty2 and then tty3:
And here it says tty3 is root:
Ok, i can confirm that the user needs to be in the 'input' group.
The moment i remove him the mouse error comes up.
I also have it now that Peppy is using my Python 3.7.8 without sudo.
Code:
[Unit]
Description=Peppy Service
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/home/haegarthehorrible
[Service]
Restart=no
Type=oneshot
User=haegarthehorrible
WorkingDirectory=/home/haegarthehorrible/opt/Peppy
ExecStart=/home/haegarthehorrible/opt/python-3.7.8/bin/python3 peppy.py
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty2
[Install]
WantedBy=multi-user.target
Stopping and starting does not work yet and there is no green light that its running. But at least peppy starts on boot now.
Code:
~$ sudo systemctl status peppy.service
● peppy.service - Peppy Service
Loaded: loaded (/etc/systemd/system/peppy.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2020-07-13 20:39:21 CEST; 6min ago
Main PID: 555 (python3)
Tasks: 11 (limit: 4534)
Memory: 148.3M
CGroup: /system.slice/peppy.service
└─555 /home/haegarthehorrible/opt/python-3.7.8/bin/python3 peppy.py
Jul 13 20:39:21 Cherry systemd[1]: Starting Peppy Service...
Code:
~$ ps aux | grep python
haegart+ 555 7.5 3.1 900984 124196 tty2 Ssl+ 20:39 0:34 /home/haegarthehorrible/opt/python-3.7.8/bin/python3 peppy.py
haegart+ 615 3.7 1.4 592252 55108 tty3 Ssl+ 20:39 0:16 python3 peppy.py
haegart+ 889 0.0 0.0 6072 892 pts/0 S+ 20:46 0:00 grep python
Code:
~$ ls -all /dev/tty2
crw--w---- 1 haegarthehorrible tty 4, 2 Jul 13 20:44 /dev/tty2
~$ ls -all /dev/tty3
crw-rw---- 1 root tty 4, 3 Jul 13 20:39 /dev/tty3
As you know I use rc.local and I was never been able to start the player using systemd. Otherwise I would tell you for sure 😉
In the 'ps' output you have two players running. I'm not sure why. Is it also showing the service start command?
In the 'ps' output you have two players running. I'm not sure why. Is it also showing the service start command?
What do you mean by 'Is it also showing the service start command'?
Where?
I have now
But its not really working. I have to touch a thousand times until something happens and then its just something that opens.
I wonder if it has something to do with that libsdl1.2 you are talking about in your Wiki. But its for ARM.
With Google i cant find anything when it comes to USB touchscreens and framebuffer. It seems more like that people are having problems with Pygame and touchscreens. I also find nothing how you would calibrate without X.
I still don't know if it makes a difference if using X ore framebuffer.
If i doesn't matter i would try systemd with X.
Here is the stuff about input/mouse:
Where?
I have now
Code:
if self.config[USAGE][USE_MOUSE]:
if os.path.exists("/dev/input/touchscreen"):
os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
else:
os.environ["SDL_MOUSEDEV"] = "/dev/input/mouse1"
os.environ["SDL_MOUSEDRV"] = "TSLIB"
I wonder if it has something to do with that libsdl1.2 you are talking about in your Wiki. But its for ARM.
With Google i cant find anything when it comes to USB touchscreens and framebuffer. It seems more like that people are having problems with Pygame and touchscreens. I also find nothing how you would calibrate without X.
I still don't know if it makes a difference if using X ore framebuffer.
If i doesn't matter i would try systemd with X.
Here is the stuff about input/mouse:
Code:
:~$ sudo dmesg | grep WaveShare
[ 6.175664] usb 1-1.4.3: Manufacturer: WaveShare
[ 6.822114] input: WaveShare WS170120 as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/0003:0EEF:0005.0003/input/input7
[ 6.826142] hid-generic 0003:0EEF:0005.0003: input,hidraw2: USB HID v1.10 Device [WaveShare WS170120] on usb-0000:00:1d.0-1.4.3/input0
[ 6.889672] input: WaveShare WS170120 as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/0003:0EEF:0005.0003/input/input8
[ 6.890353] hid-multitouch 0003:0EEF:0005.0003: input,hidraw2: USB HID v1.10 Device [WaveShare WS170120] on usb-0000:00:1d.0-1.4.3/input0
~$ cat /proc/bus/input/devices
I: Bus=0003 Vendor=0eef Product=0005 Version=0110
N: Name="WaveShare WS170120"
P: Phys=usb-0000:00:1d.0-1.4.3/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/0003:0EEF:0005.0003/input/input8
U: Uniq=¦A1823L468
H: Handlers=mouse1 event7
B: PROP=2
B: EV=1b
B: KEY=400 0 0 0 0 0
B: ABS=660800001000003
B: MSC=20
~$ lsusb
Bus 001 Device 007: ID 0eef:0005 D-WAV Scientific Co., Ltd
Bus 001 Device 006: ID 8087:0029 Intel Corp.
Bus 001 Device 005: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 004: ID 0ccd:0028 TerraTec Electronic GmbH Aureon 5.1 MkII
Bus 001 Device 003: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 002: ID 8087:07e6 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Your 'ps' output shows two players running:
Yes you can download the patched libsdl1.2 for ARM. You can also create the patched libsdl1.2 for Debian on your machine by following these instructions:
Solution for Pygame and Touchscreens on Raspbian Buster OS - Raspberry Pi Forums
Though I've never tried to do that for OSs other than Raspberry Pi OSs.
The calibration without X is another challenge. Here are the steps for 5" Waveshare HDMI/SPI touchscreen where touch events go through SPI interface not USB.
Create the file
sudo nano /etc/udev/rules.d/95-ads7846.rules
with content:
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846 Touchscreen", SYMLINK+="input/touchscreen"
Then run:
sudo apt-get install libts-bin
sudo reboot
After completing these steps the device /dev/input/touchscreen will be created. Then calibrate:
sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
Change fb0 if it doesn't exist on your system to fb1.
I've never tried that with USB touch/mouse.
If everything works fine with X just use it. If the only problem is file logging there is a workaround - use console logging: start player from SSH terminal so that UI would show up on touchscreen and you could have console log messages in the SSH terminal. I hope it works for you.
Code:
~$ ps aux | grep python
haegart+ 555 7.5 3.1 900984 124196 tty2 Ssl+ 20:39 0:34 /home/haegarthehorrible/opt/python-3.7.8/bin/python3 peppy.py
haegart+ 615 3.7 1.4 592252 55108 tty3 Ssl+ 20:39 0:16 python3 peppy.py
Solution for Pygame and Touchscreens on Raspbian Buster OS - Raspberry Pi Forums
Though I've never tried to do that for OSs other than Raspberry Pi OSs.
The calibration without X is another challenge. Here are the steps for 5" Waveshare HDMI/SPI touchscreen where touch events go through SPI interface not USB.
Create the file
sudo nano /etc/udev/rules.d/95-ads7846.rules
with content:
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846 Touchscreen", SYMLINK+="input/touchscreen"
Then run:
sudo apt-get install libts-bin
sudo reboot
After completing these steps the device /dev/input/touchscreen will be created. Then calibrate:
sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
Change fb0 if it doesn't exist on your system to fb1.
I've never tried that with USB touch/mouse.
If everything works fine with X just use it. If the only problem is file logging there is a workaround - use console logging: start player from SSH terminal so that UI would show up on touchscreen and you could have console log messages in the SSH terminal. I hope it works for you.
So eine schei..., ich dreh noch durch 😀
The second Peppy was from rc.local. For testing i did create that service on Buster. Then i forgot about it.
I did disable my peppy.service and wondered why Peppy still starts on boot.
Even raspberrypi.org has an example for systemd and Python:
systemd - Raspberry Pi Documentation
Looks simple but start/stop does not work here.
This one looks interesting: GitHub - torfsen/python-systemd-tutorial: A tutorial for writing a systemd service in Python
Especially: GitHub - torfsen/python-systemd-tutorial: A tutorial for writing a systemd service in Python
I will test what you have written and then i give up, use X and concentrate on systemd/service in conjunction with X.
Did somebody stumble over a small 1080p screen?
This seems to be the smallest one: 5.5inch Capacitive Touch Screen AMOLED, HDMI interface
1. I would prefer 4 inch or max 5 inch
2. Its not cheap
Its funny that you can get a whole 5" 1080p smartphone for ~$80 but its hard to find screens.
Do you prefer capacitive or resistive screens for Peppy?
The second Peppy was from rc.local. For testing i did create that service on Buster. Then i forgot about it.
I did disable my peppy.service and wondered why Peppy still starts on boot.
Even raspberrypi.org has an example for systemd and Python:
systemd - Raspberry Pi Documentation
Looks simple but start/stop does not work here.
This one looks interesting: GitHub - torfsen/python-systemd-tutorial: A tutorial for writing a systemd service in Python
Especially: GitHub - torfsen/python-systemd-tutorial: A tutorial for writing a systemd service in Python
I will test what you have written and then i give up, use X and concentrate on systemd/service in conjunction with X.
Did somebody stumble over a small 1080p screen?
This seems to be the smallest one: 5.5inch Capacitive Touch Screen AMOLED, HDMI interface
1. I would prefer 4 inch or max 5 inch
2. Its not cheap
Its funny that you can get a whole 5" 1080p smartphone for ~$80 but its hard to find screens.
Do you prefer capacitive or resistive screens for Peppy?
I give up on the framebuffer.
ts_calibrate did work. Then touch in Peppy did work, did not work, did work...
Then I realized that 'Handlers=mouse0 event7' are changing. If you connect other hardware for example.
And i don't get a /dev/input/touchscreen
I wonder that the 'ts_calibrate' command is working if there is no '/dev/input/touchscreen'
ts_calibrate does not start X - does it? If not that means the USB touch of the screen works in framebuffer.
ts_calibrate did work. Then touch in Peppy did work, did not work, did work...
Then I realized that 'Handlers=mouse0 event7' are changing. If you connect other hardware for example.
And i don't get a /dev/input/touchscreen
Code:
~$ ls /dev/input
by-id by-path event0 event1 event2 event3 event4 event5 event6 event7 event8 event9 mice mouse0
ts_calibrate does not start X - does it? If not that means the USB touch of the screen works in framebuffer.
MrGlasspoole: As the first step I would recommend tuning the udev rule for catching the input device (eventXX) and creating the fixed-name input/touchscreen.
Usually this command helped me with udev issues:
Usually this command helped me with udev issues:
Code:
sudo udevadm trigger --verbose
Ok, after changing it to:
i have a '/dev/input/touchscreen'
I found out about ts_test and drag and draw are working correctly.
So if i understand it right Peppy should now use
But something is still wrong. If i tap 'Audio Files' the radio is starting.
If i tap a second time, Peppy does a shutdown.
Code:
ATTRS{name}=="WaveShare WS170120"
I found out about ts_test and drag and draw are working correctly.
So if i understand it right Peppy should now use
Code:
if os.path.exists("/dev/input/touchscreen"):
os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
If i tap a second time, Peppy does a shutdown.
You described the symptoms of that Pygame+libsdl1.2 issue. You need to build patched version of that library to fix it.
I already did that 🙁
Code:
~$ dpkg -l | grep libsdl1.2
ii libsdl1.2debian:amd64 1.2.15+veloci1-1 amd64 Simple DirectMedia Layer
What exactly is happening? You can enable logging mouse events:
Peppy/config.txt at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
The coordinate origin (0, 0) is the top left corner.
If the X-Ycoordinates are flipped you can try to set this property to True and see if that helps:
Peppy/config.txt at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
Peppy/config.txt at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
The coordinate origin (0, 0) is the top left corner.
If the X-Ycoordinates are flipped you can try to set this property to True and see if that helps:
Peppy/config.txt at 87daa889969de9b0215731785318e903b136219e * project-owner/Peppy * GitHub
Seems like i figured it out and touch is working right.
I had to recompile Pygame after that patched libsdl1.2
I also had to use 'libsdl1.2-dev_1.2.15+veloci1-1_amd64.deb' because when i did force pip to recompile with:
i did get
Wow, that took some doing. Especially since i never did that much fiddling around with Linux stuff like that. Headless servers are easier 🙂
I will now make a fresh installation because there is now a lot of mess.
I had to recompile Pygame after that patched libsdl1.2
I also had to use 'libsdl1.2-dev_1.2.15+veloci1-1_amd64.deb' because when i did force pip to recompile with:
Code:
python3 -m pip install --force-reinstall --ignore-installed --no-binary :all: -U pygame
Code:
WARNING: "sdl-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
I will now make a fresh installation because there is now a lot of mess.
Congratulations! You did a great job. I wish I would have such persistence like you 🙂
You are right, the Pygame+touchscreen is the most complicated part. The headless players with Web UI don't deal with this kind of issues. Hopefully it will be easier with Pygame 2.0 which will use SDL2 library.
It would be very helpful if you could write down all steps required to make the player work on Debian. That could also help to understand if there is anything required to implement on the player side.
Thanks in advance!
You are right, the Pygame+touchscreen is the most complicated part. The headless players with Web UI don't deal with this kind of issues. Hopefully it will be easier with Pygame 2.0 which will use SDL2 library.
It would be very helpful if you could write down all steps required to make the player work on Debian. That could also help to understand if there is anything required to implement on the player side.
Thanks in advance!
I always write installations down. No matter if Windows 95/98/XP/7/8/10 and especially Linux. I started it back then when Windows was like that, that stuff was only working right when drivers where installed in the right order. Today Windows is almost indestructible. But there are still all the settings you make.
And Linux... Who can remember every step he did, what he installed and what package was needed to get something running. Then also the rights on files you did set...
So there is no difference between a SPI and USB touchscreen. Booth use '/dev/input/touchscreen'. That wasn't clear to me at the beginning.
One question:
What is the right way to stop Peppy without systemd? Kill can't be the right one. It sounds like "End task" in Windows where nothing is saved.
And Linux... Who can remember every step he did, what he installed and what package was needed to get something running. Then also the rights on files you did set...
So there is no difference between a SPI and USB touchscreen. Booth use '/dev/input/touchscreen'. That wasn't clear to me at the beginning.
One question:
What is the right way to stop Peppy without systemd? Kill can't be the right one. It sounds like "End task" in Windows where nothing is saved.
The steps are required if you want to make your second system work the same way as the first one. Otherwise you risk to spend the same amount of time. I cannot memorize absolutely all details therefore for example for creating the disk images for each type/size of the touchscreen I have such cheatsheets. That info for udev rules for the touchscreen was taken from there.
You can gracefully stop the player by pressing twice the Shutdown button in UI. The player will save the current settings in the current.txt file and run 'sudo poweroff' command. You can avoid running that command by setting the corresponding property in the config.txt. This is software shutdown. I think I mentioned that already.
I've just finished the implementation of the support for the hardware Shutdown button. It will be available in the next release. After pressing that hardware push-button twice the player will execute the same procedure as during the software shutdown. In the end of that procedure the pin GPIO#4 will go Low. That can be used by additional hardware/relay to switch off the power supply.
The player writes to disk only on demand or when file logging was enabled. Therefore even if you just kill the process it shouldn't hurt/damage anything.
You can gracefully stop the player by pressing twice the Shutdown button in UI. The player will save the current settings in the current.txt file and run 'sudo poweroff' command. You can avoid running that command by setting the corresponding property in the config.txt. This is software shutdown. I think I mentioned that already.
I've just finished the implementation of the support for the hardware Shutdown button. It will be available in the next release. After pressing that hardware push-button twice the player will execute the same procedure as during the software shutdown. In the end of that procedure the pin GPIO#4 will go Low. That can be used by additional hardware/relay to switch off the power supply.
The player writes to disk only on demand or when file logging was enabled. Therefore even if you just kill the process it shouldn't hurt/damage anything.
Yes you mentioned that already. Sorry if it was not clear: I mean from command line.
ctrl + c is not possible because peppy runs in the background. And even then i think its the same as kill?
I can't find what the right way is for Python.
ctrl + c is not possible because peppy runs in the background. And even then i think its the same as kill?
I can't find what the right way is for Python.
There is no graceful way to stop the player from the command line. If you run it from the same terminal you can press Ctrl-C. That's the same as to run 'kill' command for Python PID. The player doesn't handle SIGTERM and SIGKILL signals.
I forgot to answer some of your questions.
The Peppy player UI was developed with small touchscreens in mind. Therefore it looks a little bit shallow on large screens. The one you referenced is really expensive though probably of good quality.
IMHO capacitive screens are more convenient. Instead of pressing on the screen you just slightly touch it. It feels more responsive.
...
Did somebody stumble over a small 1080p screen?
This seems to be the smallest one: 5.5inch Capacitive Touch Screen AMOLED, HDMI interface
1. I would prefer 4 inch or max 5 inch
2. Its not cheap
The Peppy player UI was developed with small touchscreens in mind. Therefore it looks a little bit shallow on large screens. The one you referenced is really expensive though probably of good quality.
Do you prefer capacitive or resistive screens for Peppy?
IMHO capacitive screens are more convenient. Instead of pressing on the screen you just slightly touch it. It feels more responsive.
- Home
- Source & Line
- PC Based
- Peppy player