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

Display Off + Clear At Exit #17

Open Gadgetoid opened 3 years ago

Gadgetoid commented 3 years ago

Add display off (or sleep) functionality (actually send the display off command) and corresponding display on functionality for: https://github.com/pimoroni/grow-python/issues/15

Add an atexit handler to catch library shutdown and clear/turn off the display, for: https://github.com/pimoroni/grow-python/issues/16

KuriGohan-Kamehameha commented 2 years ago

also having this issue, the display blanks but the backlight remains on. pretty useless as a power-saving tool. The backlight is connected to GPIO 12, pin 32. I don't know much Python but I'm assuming that wiringpi is the ideal tool for the job.

tomjn commented 1 year ago

calling set_backlight does not appear to have an effect on the backlight, passing 0 yields no change. Directly sending GPIO.LOW to the backlight pin also had no effect

ziofil commented 4 months ago

did anyone solve this? I can't turn the display off.

EDIT: my bad, I had not passed the right value backlight='12' in the init. Now it works.

benwebbbenwebb commented 3 months ago

I was just playing around with the Pimoroni Enviro+ and was wondering the same about how to get the screen to turn off when the script was interrupted by CONTROL + C, the following seems to work for me...

# Exit cleanly
    except KeyboardInterrupt:
        # blank screen (but backlight still stay on)
        st7735.display_off()
        # turn off backlight
        st7735.set_backlight(False)
        sys.exit(0)

Note: I was using the looping "combined.py" example script (that in theory could run forever), which is why I was calling it in the KeyboardInterrupt, but I'm sure the same could be run at the end of other scripts.