DIY Touch Screen Alarm Control Panel

Can someone find the solution for this problem. I have bought the 3,5 touch on ali but after all installation when i run the main.py this is the output:

pi@alcontpan:~ $ python /srv/main.py
Initting...
Setting Mouse invisible...
Traceback (most recent call last):
  File "/srv/main.py", line 119, in <module>
    ui = UI('images/bg.png')
  File "/srv/alarmpanel/ui.py", line 25, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

Any idea haw to solve this problem?

Please can someone help me with this problem?

im in the same boat. i havent touched the project for afew months now

So guys i finally find the solution!!!

My hardware configuration is Raspberry Pi Zero and this touchscreen (Ali: 3.5 inch 26P SPI TFT LCD Display Screen with Touch Panel 320*480 for RPi1/RPi2/raspberry pi3 Board V3 (Support Raspbian System))

I have installed the last RASPBIAN STRETCH LITE os.

For install the touch screen i follow this video (https://www.youtube.com/watch?v=gVK9MpPzK44) after all this steps i added this three additional command:

sudo apt-get install xserver-xorg-input-evdev
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo reboot

After this step I try to lunch the control panel but with this issue:

pi@alcontpan:~ $ python /srv/main.py
Initting…
Setting Mouse invisible…
Traceback (most recent call last):
File “/srv/main.py”, line 119, in
ui = UI(‘images/bg.png’)
File “/srv/alarmpanel/ui.py”, line 25, in init
pygame.mouse.set_visible(False)
pygame.error: video system not initialized

To solve this we need first change the file /srv/alarmpanel/ui.py in this way:

sudo nano /srv/alarmpanel/ui.py

In this file we need to modify the line 16:
From this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/touchscreen’)
To this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event0’)

If wee try now to lunch the Alarm Control Panel it works, but the touchscreen doesn’t react.

To solve this last issue we need to downgrade the SDL in stis way:
Make sure you do this command in su mode!

sudo su
nano fix.sh

Paste inside this script:

#enable wheezy package sources
echo "deb Index of /raspbian/ wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release "stable";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
#install
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy

Chenge the file permission:

chmod +x fix.sh

And execute the script:

./fix.sh

After this we need to cheat the obsolete installation with:

apt autoremove

Now we can exit from su mode and reinstall the pygame:

exit
sudo apt-get install python-pygame

The last thing to do is calibrate the touchscreen in this way:

sudo su
aptitude install libts-bin
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb1
ts_calibrate

follow the procedure on the screen and finally all is done.

Now we can open the Alarm Control Panel:

python /srv/main.py

and everything should work correctly!

I hope this procedure can help you and solve your problem. :wink:

2 Likes

@mr-varga thank you so much for identifying and sharing this solution!! If you’d like to submit a PR to https://github.com/colinodell/mqtt-control-panel I’d gladly accept it :slight_smile:

2 Likes

Dear All,
can someone help me with one question?

In the mqtt alarm panel, main,py I try to change the background (bg.png) in base on alarm status.
If is armed or armed_home or pending or triggered i like to have alarm_bg.png

If is disarm i like to have disarm_bg.png
I make the two png and i put it in the images folder, but with the code i don’t have success.

No idea for help me??

Hi there,

Thanks for your solution above. I’ve been trying to set this up today and run into the same error as you did before:

pi@raspberrypi:/srv/mqtt-control-panel $ python main.py
Initting...
Setting Mouse invisible...
Traceback (most recent call last):
  File "main.py", line 119, in <module>
    ui = UI('images/bg.png')
  File "/srv/mqtt-control-panel/alarmpanel/ui.py", line 25, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

I’m using a different screen than the one you are (this one) - but has the right SKU - MPI3501 - and the screen works, and displays the text/command line.

I wonder how you worked out what to change and how to initiate video system? Can you help?

This is the result from running cat /proc/bus/input/devices

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="ADS7846 Touchscreen"
P: Phys=spi0.1/input0
S: Sysfs=/devices/platform/soc/20204000.spi/spi_master/spi0/spi0.1/input/input2
U: Uniq=
H: Handlers=mouse1 event2
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

any help would be appreciated!

Try to modify this file:

sudo nano /srv/alarmpanel/ui.py

In this file you need to modify the line 16:
From this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event0’)
To this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event2’)

Let me know.

Hi Mr-Varga,
Thanks for your update as i was stuck on the same point you were for awhile. i have now got it working but would like to get the PIR sensor working also. i have a a PiScreen (http://ozzmaker.com/product/piscreen-3-5-tft-with-touch-for-the-raspberry-pi/) and they give you the code to turn off the backlight here:

Turn off backlight

echo 1 | sudo tee /sys/class/backlight/*/bl_power

Turn on backlight

echo 0 | sudo tee /sys/class/backlight/*/bl_power

I’m not the best coder and looking for assistance :slight_smile:
Cheers

@mr-varga
Sorry for the delay in response - this didn’t work - perhaps I’m running the wrong version of pygame?

When I tried to install 1.9.2a0 I get the error

E: Version ‘1.9.2a0’ for ‘python-pygame’ was not found

It seems that version of PyGame is not available any longer on the latest version of Raspbian. Also, you will get other errors if you install the current version of PyGame.

Not all the dependent modules seem to be readily available for this project in the latest version of Raspbian. If you do manually install PyGame, you then get a dotnet_env error.

I still haven’t worked around it. I have moved to using MQTT Alarm Control Panle on an Android tablet. It seems to work quite well.

I got all the way to the application working, but I can’t get this version of pygame to work with the 3.5in adafruit touchscreen. So close yet so far. Trying to find solutions to this problem so I can just use this. I would build my own solution but I would probably want to use pygame too which doesn’t fix my problem lol.

Any ideas would be appreciated.

I got it working 100%! I put instructions in the readme of my fork that fixes the one line in the program that makes touchscreens work, along with the instructions with the patched deb for SDL 1.2 touchscreen support.