Catch SIGINT and blank the screen. This means that when running via command line and we press CTRL-C the display will always end up getting blanked before the program quits. Helps with the burn in.
This commit is contained in:
parent
3cd02e18ac
commit
ffc94afdbc
1 changed files with 14 additions and 0 deletions
|
|
@ -39,6 +39,10 @@ import adafruit_ssd1306
|
|||
# Import Python Imaging Library
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
# Signal/sys are used to catch SIGINT.
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# URL of Pi Hole
|
||||
api_url = 'http://localhost/admin/api.php'
|
||||
|
||||
|
|
@ -53,6 +57,16 @@ def blank_screen(display):
|
|||
display.fill(0)
|
||||
display.show()
|
||||
|
||||
def SIGINT(sig, frame):
|
||||
print('Ctrl+C detected. Quitting.')
|
||||
# Clear display.
|
||||
blank_screen(disp)
|
||||
sys.exit(0)
|
||||
|
||||
# Catch SIGINT (ctrl-c) and blank the screen.
|
||||
# This ensures that the screen will be blank when we exit.
|
||||
signal.signal(signal.SIGINT, SIGINT)
|
||||
|
||||
# Create the SSD1306 OLED class.
|
||||
# The first two parameters are the pixel width and pixel height. Change these
|
||||
# to the right size for your display!
|
||||
|
|
|
|||
Loading…
Reference in a new issue