Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Clean exit from pygame on PiTFT
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Clean exit from pygame on PiTFT

by bobthechemist on Sat Feb 29, 2020 4:36 pm

I have an old RPi B with a 3.5" PiTFT display on it. The RPi is running the most recent version (as of 2/29/2020) of Raspian lite and I followed https://learn.adafruit.com/adafruit-amg8833-8x8-thermal-camera-sensor/raspberry-pi-thermal-camera to set up thermal imaging.

First, I believe that page needs to be updated to download the python3 versions of scipy and pygame

Code: Select all | TOGGLE FULL SIZE
sudo apt-get install -y python3-scipy python3-pygame


Next, the instructions run very smoothly, but when I try to exit the rpi_thermal_cam.py code with a keyboard interrupt, it does not actually stop. If I SSH into the RPi and kill the process, the screen stops updated but does not return to the console.

If I run rpi_thermal_camp.py from ssh (with a client such as MobaXTerm with tunneling) then I get a screen on my computer with the thermal image, but the PiTFT does not update. I thought setting the environment such as found here https://raspberrypi.stackexchange.com/questions/12448/pygame-from-console-with-pitft would fix that issue but it does not.

Q1. How do I cleanly exit a python program that uses pygame to display on the PiTFT so that the console is returned upon program completion?

Q2. How do I force a python program to display (via pygame) on the PiTFT regardless of being called from the console or via SSH?

bobthechemist
 
Posts: 20
Joined: Sat Aug 24, 2013 9:19 am

Re: Clean exit from pygame on PiTFT

by IOTothemax on Sat Feb 29, 2020 4:38 pm

Could you please post your code? That way, we can see what's missing and what might be a bug.

IOTothemax
 
Posts: 19
Joined: Tue Feb 19, 2019 7:22 pm

Re: Clean exit from pygame on PiTFT

by bobthechemist on Sat Feb 29, 2020 4:46 pm

It is the code directly from Adafruit's website here https://learn.adafruit.com/adafruit-amg8833-8x8-thermal-camera-sensor/raspberry-pi-thermal-camera. It runs as expected; I just cannot exit the program with a keyboard interrupt (CTRL-C) from an attached USB keyboard.

bobthechemist
 
Posts: 20
Joined: Sat Aug 24, 2013 9:19 am

Re: Clean exit from pygame on PiTFT

by tonyromano51 on Fri Sep 11, 2020 12:52 am

Mine would not exit from piTFT display either, so I modified the code to add "from gpiozero import Button" , and "button17 = Button(17, hold_time=3)" , near the top, and at the bottom I added "if button17.is_held:" newline, indent "exit()" . If gpiozero is not found load it with $pip3 install gpiozero . [button 17 is the lower left (landscape) button on the PiTFT 2.8"]
Even though this post is old, I hope this helps anyone else trying it.

tonyromano51
 
Posts: 1
Joined: Fri Sep 11, 2020 12:35 am

Please be positive and constructive with your questions and comments.