pimoroni / st7735-python

Python library to control an ST7735 TFT LCD display. Allows simple drawing on the display without installing a kernel module.
MIT License
63 stars 30 forks source link

Segmentation fault after ~1670000 display updates #6

Closed Gadgetoid closed 4 years ago

Gadgetoid commented 4 years ago

Using this minimal test script on a Pi 4, 4GB results in a segmentation fault after just over 1670000 display updates- or around 18-20 minutes of runtime.

from PIL import Image
import ST7735
import time

# Create LCD instance
disp = ST7735.ST7735(
    port=0,
    cs=1,
    dc=9,
    backlight=12,
    rotation=270,
    spi_speed_hz=1000000000
)

# Initialize display
disp.begin()
WIDTH = disp.width
HEIGHT = disp.height

image = Image.new('RGB', (WIDTH, HEIGHT), color=(255, 0, 255))

count = 0

while True:
    disp.display(image)
    count += 1
    if count % 1000 == 0:
        print(time.time(), count)

Further testing, including the elimination of the PIL image by hard-coding the ST7735 library to send only zero bytes in lieu of actual image data, reveals that the issue appears to be with the use of spidev.

A possible fix may be to use xfer3 to split chunks, and additionally update to spidev==3.4