Skip to content

Revert "Blank display when quitting via CTRL-C (Catch SIGINT)" #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Pi_Hole_Ad_Blocker/fonts/readme.txt

This file was deleted.

Binary file removed Pi_Hole_Ad_Blocker/fonts/slkscr.ttf
Binary file not shown.
Binary file removed Pi_Hole_Ad_Blocker/fonts/slkscrb.ttf
Binary file not shown.
33 changes: 7 additions & 26 deletions Pi_Hole_Ad_Blocker/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,11 @@
# 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'

# Load nice silkscreen font
font = ImageFont.truetype('fonts/slkscr.ttf', 8)

# Create the I2C interface.
i2c = busio.I2C(SCL, SDA)

# Blanks the Pi OLED display.
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!
Expand All @@ -78,7 +55,8 @@ def SIGINT(sig, frame):
DISPLAY_OFF = 50 # off time in seconds

# Clear display.
blank_screen(disp)
disp.fill(0)
disp.show()

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

# Load nice silkscreen font
font = ImageFont.truetype('/home/pi/slkscr.ttf', 8)

while True:
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=0)
Expand Down Expand Up @@ -150,6 +131,6 @@ def SIGINT(sig, frame):
disp.image(image)
disp.show()
time.sleep(DISPLAY_ON)
# Clear display.
blank_screen(disp)
disp.fill(0)
disp.show()
time.sleep(DISPLAY_OFF)