Open BillMerryman opened 8 months ago
Okay, guess I rubber-duck debugged. I implemented a lock and acquired the lock before each call to 'show_face' and that appears to have resolved it. Is ST7789 not thread-safe? Or is it just the ST7789.image method that isn't thread safe?
Yep, deleted the 'with self.lock:' statements from everywhere and added it just in the line before setting the image:
with self.lock:
disp.image(background)
Problem remains resolved.
I have a simple application that updates a screen (Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout - ST7789 Product ID: 4383) from a Pi Zero W 2, every 1/2 to 1 second, rendering moving 'eyes'. It consists of a main program (face_test.py) and a threaded class (face.py). The updating is done from a thread. The eyes are transparent PNG files that are enumerated from a text file and loaded at startup. In the thread, the code creates a green background, pastes the 'eyes' onto it, and then displays the image to the screen. This part appears to work fine. The main program can call a method on the class that tells it which PNG it should be using. At random times, this part appears to be resetting the screen, as it goes black and doesn't display anything else for the remainder of the run. I've attached all files, with the Python files as txt files.
The main program:
The threaded class:
face.txt images.txt
face_test.txt