Skip to content

Commit 17eb763

Browse files
authored
Merge pull request #886 from adafruit/revert-865-master
Revert "Blank display when quitting via CTRL-C (Catch SIGINT)"
2 parents 91cf424 + c8fc7a3 commit 17eb763

File tree

4 files changed

+7
-32
lines changed

4 files changed

+7
-32
lines changed

Pi_Hole_Ad_Blocker/fonts/readme.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

Pi_Hole_Ad_Blocker/fonts/slkscr.ttf

-16.7 KB
Binary file not shown.

Pi_Hole_Ad_Blocker/fonts/slkscrb.ttf

-15.6 KB
Binary file not shown.

Pi_Hole_Ad_Blocker/stats.py

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,11 @@
3939
# Import Python Imaging Library
4040
from PIL import Image, ImageDraw, ImageFont
4141

42-
# Signal/sys are used to catch SIGINT.
43-
import signal
44-
import sys
45-
46-
# URL of Pi Hole
4742
api_url = 'http://localhost/admin/api.php'
4843

49-
# Load nice silkscreen font
50-
font = ImageFont.truetype('fonts/slkscr.ttf', 8)
51-
5244
# Create the I2C interface.
5345
i2c = busio.I2C(SCL, SDA)
5446

55-
# Blanks the Pi OLED display.
56-
def blank_screen(display):
57-
display.fill(0)
58-
display.show()
59-
60-
def SIGINT(sig, frame):
61-
print('Ctrl+C detected. Quitting.')
62-
# Clear display.
63-
blank_screen(disp)
64-
sys.exit(0)
65-
66-
# Catch SIGINT (ctrl-c) and blank the screen.
67-
# This ensures that the screen will be blank when we exit.
68-
signal.signal(signal.SIGINT, SIGINT)
69-
7047
# Create the SSD1306 OLED class.
7148
# The first two parameters are the pixel width and pixel height. Change these
7249
# to the right size for your display!
@@ -78,7 +55,8 @@ def SIGINT(sig, frame):
7855
DISPLAY_OFF = 50 # off time in seconds
7956

8057
# Clear display.
81-
blank_screen(disp)
58+
disp.fill(0)
59+
disp.show()
8260

8361
# Create blank image for drawing.
8462
# Make sure to create image with mode '1' for 1-bit color.
@@ -101,6 +79,9 @@ def SIGINT(sig, frame):
10179
# for drawing shapes.
10280
x = 0
10381

82+
# Load nice silkscreen font
83+
font = ImageFont.truetype('/home/pi/slkscr.ttf', 8)
84+
10485
while True:
10586
# Draw a black filled box to clear the image.
10687
draw.rectangle((0, 0, width, height), outline=0, fill=0)
@@ -150,6 +131,6 @@ def SIGINT(sig, frame):
150131
disp.image(image)
151132
disp.show()
152133
time.sleep(DISPLAY_ON)
153-
# Clear display.
154-
blank_screen(disp)
134+
disp.fill(0)
135+
disp.show()
155136
time.sleep(DISPLAY_OFF)

0 commit comments

Comments
 (0)