I am working with Raspberry Pi 4 B, 8 gb RAM and Raspbian OS. I am having 7" touch screen attached to PI.
In my project, I want to make touch screen sleep if there is no activity detected for 5 mins from the Python script (just to save some power). Is there any shell command I can use in the Python script?
There is the option in config.txt of "disable_touchscreen=1" which will stop the Pi polling the controller board for touch input. It also doesn't start the firmware side of the touchscreen input driver, which should stop the Linux side loading either. The display side will work exactly as before.
This file is normally accessible as /boot/config.txt from raspbian OS.
You can read config.txt and modify using following python code
import ConfigParser
config_parser = ConfigParser.ConfigParser()
config_parser.read('config.txt')
Related
I'm building a Tkinter GUI in Python 3.7 meant to run on a Raspberry Pi 3, and I want the user to be unable to close it or access the OS (Ubuntu MATE) below it.
I tried using this flag to make the window un-closeable:
root.overrideredirect(boolean=True)
but this creates all top-level widgets underneath the root window. I tried forcing them to be created above the root using a variety of different methods but with no luck.
I then tried to update idle tasks before setting the flag:
root.update_idletasks()
root.overrideredirect(boolean=True)
and this worked on my Intel desktop running Ubuntu, but when running it on a Raspberry Pi 3 running Ubuntu MATE, updating idle tasks before setting the flag just seems to have disabled it completely, meaning the user could still access the OS.
I was wondering how could I prevent the user from accessing the OS on the Raspberry Pi 3. Any help would be nice.
I have an OpenCV/python script running at my Raspberry Pi which reads the camera and shows the stream on the RCA monitor connected to the Pi.
Now I want the script to be loaded on boot. I already tried a cronjob #reboot, the /etc/rc.locale, /etc/profile and ~/.bash_profile.
I see the red light of the camera turning on every time, but the image won't be shown. Is there any solution to run the script? (I have no external input devices connected)
Thank you!
I know its quite an old thread, but I thought you might be still interested in a solution that worked for me. Hopefully, that can help you as well:
Raspberry Pi - Autostart OpenCv-Script - Error with cv::imshow()
In short: You most likely have problems with the DISPLAY / XAUTHORITY environment variable.
I am controlling an LED matrix connected to Raspberry Pi using a code written in nano editor. And i am controlling a camera using opencv in windows. i want to synchronize both the programs. is there any way to do that?
I am using the PiTFT display for the Raspberry Pi, and I want to run my PyGame (Python) program without booting to the Desktop.
The reason I want to do this is because it will mean less RAM usage, and that is pretty important on a Raspberry Pi.
This has been asked before, but none of the answers are up to date, or else never worked in the first place.
I'm not exactly clear what problem you're having, but this should be fairly straightforward.
I add this at the top of my pygame scripts when using the PiTFT screen (none of my Pis use the desktop environment):
import os
# Tell the RPi to use the TFT screen and that it's a touchscreen device
os.putenv('SDL_VIDEODRIVER', 'fbcon')
os.putenv('SDL_FBDEV' , '/dev/fb1')
os.putenv('SDL_MOUSEDRV' , 'TSLIB')
os.putenv('SDL_MOUSEDEV' , '/dev/input/touchscreen')
Then you just need to make sure your pi doesn't boot into the desktop environment. You can do that by running:
sudo raspi-config
and changing the relevant setting.
I am using wand library in my raspberry project running raspbian and python 2.7.
I have a code part as below to display picture from an url:
with Image(file=urllib2.urlopen(r.text)) as imageOBJ:
display(imageOBJ)
These lines display the image correctly. However, I want this window to stay open and my process to continue with other things in my script. Because after 30 seconds I want to repeat the same thing and change the image in the window. Right now, my code is not running until I close the display window.
Please note that this is not the case on my mac but only on raspberry pi B+ , wheezy raspbian.
How can I prevent this behaviour without closing the image display window?
Thanks in advance
This behavior is expected as both Windows & OS X call the OS's run command start & open respectively -- see reference. On the Raspberry Pi, and other like systems, the wand library calls MagickDisplayImage directly on Python's MainThread.
To emulate like behavior on the Raspberry Pi use the xdg-open utility, and Python's subprocess and tmpfile modules.
Create a temporary file to hold the image
Write image to temporary file
Call xdg-open to open temporary file in an isolated process.
import subprocess, tempfile
from wand.image import Image
with Image(filename='wizard:') as imageOBJ:
tempOBJ = tempfile.NamedTemporaryFile(suffix='.jpg',
prefix='/tmp/myProject-',
delete=False)
imageOBJ.save(file=tempOBJ)
subprocess.call('xdg-open {}'.format(tempOBJ.name), shell=True)
Of course mileage will vary across OS distro/version/desktop-environment.